im creating a multi-modal journey planner application that finds all possible routes a user can take to get from point A to point B using different/specified public transportation modes (e.g. trains, buses, jeepneys, etc). of course walking edges are permitted. and i’m planning to sort the results based on some criteria (cost). so which would be better for me to use Breadth First or Depth First? ..
im creating a multi-modal journey planner application that finds all possible routes a user
Share
If you’re planning to calculate every single route and its cost, then it doesn’t matter; but depth-first will use slighly less resources (if that matters to you).
However, if you’re planning to calculate the single shortest route to a single destination, then go for breadth-first, as it will stop after finding the destination, and on average will not need to look at every single possible path.