Skip to content

Breadth-first search

networks

Level 2 of 3

Also called BFS.

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

Tap a spot to put your pen down there, then tap a spot next to it to draw a road. Keep tapping to draw on.

Places stand in two rows, A to D above and E to H below. A road joins two places side by side, one above the other, or corner to corner (one road across each square), with a dash: A-B. Separate roads with commas, then a semicolon and where to start: A-B, A-E, B-F; A.