Answer
Showing that the length of the shortest path between vertices v and u in a connected simple graph equals the level number of u in the breadth-first spanning tree of G with root v.
Work Step by Step
--Proof by induction on the length of the path:
- If the path has length 0, then the result is trivial. If the length is 1, then u is adjacent to v, so u is at level 1 in the breadth-first spanning tree.
- Assume that the result is true for paths of length l. If the length of a
path is l + 1,
-- let u be the next-to-last vertex in a shortest
path from v to u. By the inductive hypothesis, u is at level
l in the breadth-first spanning tree.
-If u were at a level not exceeding l, then clearly the length of the shortest path from v to u would also not exceed l.
- So u has not been added to the breadth-first spanning tree yet after the vertices of level l have been added. Because u is adjacent to u, it will be added at level l + 1 (although the edge connecting u and u is not necessarily added).