Spreading Out One Ring at a Time
Last timeWriting a Graph Down
Visiting a graph in rings of increasing distance finds the fewest-link route to everything reachable, and the proof of that is one sentence about the order points are met in.
The order you meet things in
Start at one point. Visit everything one link away. Then everything two links
away that has not been seen. Then three. Keep going until nothing new appears.
That is the whole method, and it needs no arithmetic at all to carry out. The
machinery is a waiting line. Put the start in it. Repeatedly take the point at
the front, look at its neighbours, and put any neighbour not seen before at
the back. Because the line is served front to back, everything one link away
is taken out before anything two links away, which is taken out before
anything three links away. Nobody counts distances to make this happen. It is
a property of serving the line in the order it was joined.
| step | step | taken from the front | its neighbours | newly added | the line now |
|---|---|---|---|---|---|
| 1 | 1 | a | b, c | b, c | b, c |
| 2 | 2 | b | a, d | d | c, d |
| 3 | 3 | c | a, d | nothing | d |
| 4 | 4 | d | b, c, e | e | e |
| 5 | 5 | e | d, f | f | f |
| 6 | 6 | f | e | nothing | empty, done |
Why the first arrival is the shortest
Walking everything is easy. The reason this particular order matters is that
it answers a question, and the question is how few links away is each point.
The claim is that when a point is first reached, it is reached by a route with
the fewest possible links. The argument is short. Suppose a point is first
reached at distance , and suppose there were a better route of length
. That better route arrives at from some point at distance
. But every point at distance was taken out of the line before
any point at distance , and when was taken out, all of its
neighbours were added, including . So would have been reached at
distance , not , which contradicts where we started.
- the fewest links from the start to the point v
- any point u with a link to v
So the method is not merely a tour that happens to be tidy. Recording, for
each point, how far it was when first reached, gives the shortest distance
from the start to every reachable point, all in one pass. Recording which
point it was reached from gives the route itself, read backwards.
That is a great deal of answer for one walk, and it is exactly and only
correct when every link counts the same. The fifth lesson is about what
happens when they do not.
The lesson stops here
4 more paragraphs to go
You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.
The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.
See the planThe contentsThis is the reading half
Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.
The contents