Homework problem R on Minimum Spanning Trees

Due Nov 20.

Let G be an undirected graph. Let us say that u is reachable from v if there is a path from v to u. It is easy to see that reachable is an equivalence relation: reflexivity - u is reachable from u (by an empty path); symmetry - if u is reachable from v then v is reachable from u (same path, it's an undirected graph); transitivity - u Rfrom v, v Rfrom w implies u Rfrom w (concatenate the paths).

The equivalence classes under the reachability relation constitute the vertex sets of the components of G. Every edge is within one component, so the comonents partitition both vertices and edges of G consistently. We say simply that the components partition G. Each component is a connected subgraph of G, and it is a maximal subgraph with respect to being connected.

Let G be an undirected weighted graph, not necessarily connected. A minimum spanning forest, MSF, for G is a set F of n - k edges, where k is the number of components of G, such that F contains a minimum spanning tree of each component of G.

  1. (1 pt) Argue that Kruskal's algorithm works even when G is unconnected and produces a MSF for G.

  2. (4 pts) Modify Kruskal's algorithm, without changing it's asymptotic complexity (it's worst case runtime up to big-O), to return the number, k, of components.

  3. (1 pt) What does Prim's algorithm do on an unconnected graph?

  4. (4 pts) Modify Prim's algorithm, without changing it's asymptotic complexity, to correctly set parent pointers to represent the trees of a MSF (and no false parent pointers) and to return the number, k, of components.