Hint on CLRS 24-1

For part b, consider any path that is part of a shortest path; we want to show and upper bound on how many passes it takes to make all the vertices in that path "correct." That means, if the d of the first vertex in that path is equal to the real distance from s, then how many passes does it take to make the last vertex in the path have a correct d?

When we relax an edge whose first vertex is correct, we make its second vertex correct. I'm going to refer to that as the "final relaxation" of that edge.

Notice that all edges are either forward edges or back edges in the ordering. The number of passes it takes for the path that we're looking at depends on the pattern of forward edges and back edges. For example, if the path has five edges, the first of which is a back edge and the rest are forward edges, it has pattern bffff. It requires two passes: Since forward edges are relaxed before back edges, on the first pass we will finally relax the first edge, but the other edges won't benefit. However, on the next pass, we know that those forward edges will all be relaxed in the order they appear in the path, so we will finally relax all of them.

So, to do this proof, think about what are the worst case pattern or patterns would be, and show that in those cases what the greatest number of required passes is.

Finally, apply that result to the longest possible path in the whole graph to show the bound of the total number of passes.


Thomas VanDrunen
Last modified: Thu Nov 11 16:43:17 CST 2010