All pages 8 of 8
The graph
A map of stations and lines, where a ripple from one station finds the shortest way to all the others.
Counted: 8 steps
The steps
- Start at A and light it.
- B is 1 hop from A.
- C is 1 hop from A.
- D is 1 hop from A.
- E is 2 hops from A, reached from B.
- F is 2 hops from A, reached from C.
- G is 2 hops from A, reached from D.
- H is 3 hops from A, reached from F.
- Follow the way back: H from F, F from C, C from A.
- The way from A to H is A C F H: 3 hops, found in 8 steps.
What it is
Picture a metro map. Stations are joined by lines, and a station can have many lines. There is no top and no bottom, and there may be more than one way between two stations.
This is called a graph. The stations are called nodes and the lines are called edges.
How a move works
Here eight stations, A to H, are joined by nine lines. To ripple out from A, light A first. Then light each station one line away: B, C and D. Then each station one line from those: E, F and G. Then H.
Each station is lit once, so the ripple from A takes 8 steps. It also finds the shortest way to each station. To get from A to H, follow the ripple back: H was reached from F, F from C, and C from A. The way is A, C, F, H, which is 3 hops.
Drawing a new line takes 1 step, and so does rubbing one out.
Where you meet it
Maps, flights, friends on a social app and links between web pages are all graphs. A sat nav ripples out over the roads to find your way home.
Watch out for
A map is not a tree. Two routes can reach the same station, and a loop can lead you back to where you started. So a ripple must keep track of where it has been, or it goes round in circles for ever.