| You have a bunch of “places” and “paths”, and need to find the shortest path between two places. |
Make a list of all the places. Beginning at your ending place, put a “1” next to each place that’s connected to the ending place by a path. Then, for each of those places, do the same, but this time put a “2”. Continue looking at each place and all the places it can get to, putting the number that indicates how far it is from the ending place by adding 1 to the connected place’s distance. If a place already has a number, you replace it if the new number would be smaller. When you’ve looked at all the places, the path from the starting place to the ending place will follow the smallest numbers. |