1. Given a connected, undirected graph with edge weights and a vertex S, a shortest path tree rooted at S is a spanning tree T such that for each vertex v in the graph, the length (sum of edge weights) of the shortest path from S to v in T is the same as the length of the shortest path from S to v in the original graph.
Disprove the following claim: given any undirected graph where all the edge weights are distinct and any start vertex S, there is at most one shortest path tree rooted at S. (That is, the shortest path tree rooted at S is unique.)
1 A---B | | 0| |2 | | C---D 3
This graph has two shortest path trees rooted at A. You get one by removing the edge (C,D) and the other by removing (B,D).
2A: Give an example of a graph with 5 vertices (two of which are S and T) with three S,T-cut vertices.
S--a--b--c--T
2B: prove or disprove the following claim: In a DFS of the graph starting at S, every S,T-cut vertex must lie on the path from S to T in the resulting dfs tree.
Claim is true. Suppose a vertex v does not lie on the path. Then even if v is removed, there remains a path from S to T. Thus v is not an S,T-cut vertex.
2C: prove or disprove the following claim: In a DFS of the graph starting at S, every vertex on the path from S to T in the resulting DFS tree is an S,T-cut vertex.
Claim is false. Consider for example a cycle or a complete graph on at least 3 vertices. These graphs have no S,T-cut vertices.
2D: use low[] numbers (from CutVerticesByDFS) to give a necessary and sufficient condition for a vertex W on the path from S to T in the DFS tree to be an S,T-cut vertex.
A vertex v (other than S or T) on the S,T-path in the DFS tree is an S,T-vertex iff it has a child w in the DFS tree that is on the path from S to T and has low[w] ≥ dfs-num[v].
Note that this includes the case when v is the lowest common ancestor of S and T (when neither S, nor T is the root of the DFS tree).
3. Consider the following two rules. Starting with a connected graph G=(V,E) with edge weights:
Prove or disprove the following claim: If you start with an undirected connected graph with edge weights, and apply the above rules repeatedly in any order, then the following property holds: There is a minimum spanning tree T containing all the red edges and none of the blue edges.
Hint: review MinimumSpanningTreesByKruskals
We adapt the proofs from /MSTExerciseSolutions .
Prove the claim by induction.
Consider a sequence of applications of the rules.
The property initially holds, since no edges are colored red or blue.
If the edge (u,w) is contained in T, then take T'=T. Otherwise, some path p in T connects u to w. The path p must leave S at some point as it goes from u to w. Let e' be the first edge on the path leaving S, so e' is in L. (Recall that S is the set of vertices in the application of the red rule, so that e is a minimum-weight edge leaving S and no other edges in S are red.)
Since e is a minimum-weight edge in L, e' costs at least what e costs. Thus, cost(T') = cost(T) + cost(e) - cost(e') ≤ cost(T) . Thus, T' is also a minimum spanning tree. To finish we need to argue that T' contains all the red edges and e, and none of the blue edges.
Since no edge in L is red, and e' is in L, e' is not red. Since T'=T-{e'}+{e}, and e' is not red, and T contains all of the red edges other than e, T' contains all of the red edges.
Since T contains none of the blue edges, and e is not blue (since we just colored it red), T' contains no blue edges either.
Thus, after applying the red rule, there is still a minimum spanning tree containing all of the red edges and none of the blue edges.
We need to convince ourselves that, after coloring e blue, there is still a minimum spanning tree T' containing all of the red edges and none of the blue edges.
If e is not in T, then taking T'=T we are done.
Otherwise e is in T. Let e=(u,w). Consider removing e from T. This breaks T into two connected components, say S1 and S2. Because we are applying the blue rule, e must be a maximum-weight edge on some cycle C with no blue edges.
This cycle consists of e together with a path p from u to w. Since u is in one of the two components S1,S2, and w is in the other, the path p must cross from S1 to S2 at some point. Let e' be an edge on p connecting S1 to S2.
Let T' = T - {e} + {e'}.
Since e is a maximum-weight edge on C, and e' is on C, cost(e) ≥ cost(e'). Thus, cost(T') ≤ cost(T). Thus T' is a minimum-weight spanning tree.
To finish, we need to convince ourselves that T' contains all the red edges and none of the blue ones after e is colored blue.
Recall that T' = T - {e} + {e'}, and that T contains all of the red edges and none of the blue edges (before e is colored blue).
Since T' does not contain e, and e' is not blue (since it is on the cycle C that has no blue edges), T' contains no blue edges.
Since e is colored blue, it can't be red, so T' contains all of the red edges.