Borůvka's algorithm


Borůvka's algorithm is a greedy algorithm for finding a minimum spanning tree in a graph,
or a minimum spanning forest in the case of a graph that is not connected.
It was first published in 1926 by Otakar Borůvka as a method of constructing an efficient electricity network for Moravia.
The algorithm was rediscovered by Choquet in 1938; again by Florek, Łukasiewicz, Perkal, Steinhaus, and Zubrzycki in 1951; and again by Georges Sollin in 1965. This algorithm is frequently called Sollin's algorithm, especially in the parallel computing literature.
The algorithm begins by finding the minimum-weight edge incident to each vertex of the graph, and adding all of those edges to the forest.
Then, it repeats a similar process of finding the minimum-weight edge from each tree constructed so far to a different tree, and adding all of those edges to the forest.
Each repetition of this process reduces the number of trees, within each connected component of the graph, to at most half of this former value,
so after logarithmically many repetitions the process finishes. When it does, the set of edges it has added forms the minimum spanning forest.

Pseudocode

Designating each vertex or set of connected vertices a "component", pseudocode for Borůvka's algorithm is:
algorithm Borůvka is
input: A graph G whose edges have distinct weights.
output: F is the minimum spanning forest of G.
Initialize a forest F to be a set of one-vertex trees, one for each vertex of the graph.
while F has more than one component do
Find the connected components of F and label each vertex of G by its component
Initialize the cheapest edge for each component to "None"
for each edge uv of G do
if u and v have different component labels:
if uv is cheaper than the cheapest edge for the component of u then
Set uv as the cheapest edge for the component of u
if uv is cheaper than the cheapest edge for the component of v then
Set uv as the cheapest edge for the component of v
for each component whose cheapest edge is not "None" do
Add its cheapest edge to F
If edges do not have distinct weights, then a consistent tie-breaking rule can be used.
An optimization is to remove from G each edge that is found to connect two vertices in the same component as each other.

Complexity

Borůvka's algorithm can be shown to take O iterations of the outer loop until it terminates, and therefore to run in time O, where E is the number of edges, and V is the number of vertices in G. In planar graphs, and more generally in families of graphs closed under graph minor operations, it can be made to run in linear time, by removing all but the cheapest edge between each pair of components after each stage of the algorithm.

Example

ImagecomponentsDescription






This is our original weighted graph. The numbers near the edges indicate their weight. Initially, every vertex by itself is a component.

In the first iteration of the outer loop, the minimum weight edge out of every component is added. Some edges are selected twice. Two components remain.
In the second and final iteration, the minimum weight edge out of each of the two remaining components is added. These happen to be the same edge. One component remains and we are done. The edge BD is not considered because both endpoints are in the same component.

Other algorithms

Other algorithms for this problem include Prim's algorithm and Kruskal's algorithm. Fast parallel algorithms can be obtained by combining Prim's algorithm with Borůvka's.
A faster randomized minimum spanning tree algorithm based in part on Borůvka's algorithm due to Karger, Klein, and Tarjan runs in expected time. The best known minimum spanning tree algorithm by Bernard Chazelle is also based in part on Borůvka's and runs in time, where α is the inverse of the Ackermann function. These randomized and deterministic algorithms combine steps of Borůvka's algorithm, reducing the number of components that remain to be connected, with steps of a different type that reduce the number of edges between pairs of components.