Breadth-first search
Finds the fewest roads from one place to every place it can reach. Visit every place one road away first, then every place two roads away, and so on, keeping the places still to visit in a queue so the nearest always go first.
the map
the queue
- roads looked along
- 0
step 1 of 1
Examples