Minimum Spanning Tree
Minimum Spanning Tree
References:
1. Algorithms, Jeff Erickson, Chapter 7
2. Algorithm Design Manual, Skiener, Chapter 6
Intro 2/8
G = (V ; E ); w(e) 2 R
Figure 2. Red edges are in F; dashed lines are useless. Arrows are safe edges.
In more detail, Boruvka's algorithm works like this.
1. It relies on the CountAndLabel() algorithm to count the number
of connected components in a graph, and label each node with its
component number:
2. How do we find all safe edges of F ? Suppose F has more than 1
component. The following subroutine computes an array safe[1::v]
of safe edges, where safe[i] is the minimum weight edge with one
endpoint in the i-th component of F . We brute-force trough all
edges and find the safe edges. For an edge uv, if they belong to
the same component, then it's either useless or already an edge in
F. Otherwise, compare the weight of uv to safe[component(u)] and
safe[component(v)] and update the entries if needed.
What's the time complexity?
Each CountAndLabel() costs O(V + E ), because it's basically
a graph traversal of forest F . Since F is a forest, E < V . Thus
O(V + E ) = O(V )
Each AddAllSafeEdges() costs O(V + E ) (again, it's graph tra-
versal, with constant time work per vertice/edge). Since graph G
is connected, we have V < E . Thus it costs O(V + E ) = O(E ).
How many iterations? Each iteartion reduce the #components
of F by at least 2x (worst case: two components coalesce into
one; best case: every component coalesce into one).
Thus the number of iterations is O(log V ):
In total, the Boruvka algorithm costs O(E log V )
Features of Boruvka algorithm for MST:
It's fast; worst case is O(E log V ) but for a lot of graphs it's
much faster than that.
It allows significant parallelism (each component can be processed
in parallel)
Recent very fast MST algorithms are generalization of Boruvka's.
This should be the choice for implementation of MST.
Jarnik's (Prim's) Algorithm 7/8
The algorithm repeats the following step until T spans the whole
graph: