next up previous index
Next: Java implementation Up: Justification Previous: Comment.   Index

Shortest paths

The algorithm just described determines the shortest path length to a reachable node. As it stands, however, nothing has been said about actual paths instantiating these minimum lengths. That is understandable since the minimum path length is unique, whereas actual shortest paths may not be. Consider, for example, a graph whose nodes are the intersections of streets and avenues formed on a rectangular US-style city grid. The arcs connect adjacent intersections. Then there are multiple shortest paths of the same length between any two non-adjacent intersections, since you can go either way round any block.

Despite this, the description of the algorithm allows us to construct a shortest path very simply. Whenever the value of $D(w)$ is changed, either by being defined for the first time in D3(c), or by being reduced in D3(d), it happens when $w$ is adjacent to some node $v$ for which we have just determined the minimum distance. If, at each stage $D(w)$ is changed, we record the $v$ to which it was adjacent at the time, then when $w$ is finally brought into $S$ we shall have recorded a final ``previous'' node for $w$. If we trace these previous nodes back one by one, we shall finally arrive at $s$, and this will provide a path of shortest length. This is not obvious, and the braver of you may like to construct a proper proof along the lines above.

It may seem as though this procedure gives a unique shortest path. It does, to the extent that the order in which nodes are brought into $S$ is unique. But this is not generally unique, because if there are multiple paths of shortest length, at some stage we shall have to make an arbitrary choice in D1.


next up previous index
Next: Java implementation Up: Justification Previous: Comment.   Index
Peter Williams 2005-06-07