Borůvka's algorithm explained

Class:Minimum spanning tree algorithm
Data:Graph
Time:

O(

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.[1] [2] [3] The algorithm was rediscovered by Choquet in 1938;[4] again by Florek, Łukasiewicz, Perkal, Steinhaus, and Zubrzycki in 1951;[5] and again by Georges Sollin in 1965.[6] 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

The following pseudocode illustrates a basic implementation of Borůvka's algorithm.In the conditional clauses, every edge uv is considered cheaper than "None". The purpose of the completed variable is to determine whether the forest F is yet a spanning forest.

If edges do not have distinct weights, then a consistent tie-breaking rule must be used, e.g. based on some total order on vertices or edges.This can be achieved by representing vertices as integers and comparing them directly; comparing their memory addresses; etc.A tie-breaking rule is necessary to ensure that the created graph is indeed a forest, that is, it does not contain cycles. For example, consider a triangle graph with nodes and all edges of weight 1. Then a cycle could be created if we select ab as the minimal weight edge for, bc for, and ca for .A tie-breaking rule which orders edges first by source, then by destination, will prevent creation of a cycle, resulting in the minimal spanning tree .

algorithm Borůvka is input: A weighted undirected graph G = (V, E). output: F, a minimum spanning forest of G. Initialize a forest F to (V, ) where = . completed := false while not completed do Find the connected components of F and assign to each vertex its component Initialize the cheapest edge for each component to "None" for each edge uv in E, where u and v are in different components of F: let wx be the cheapest edge for the component of u if is-preferred-over(uv, wx) then Set uv as the cheapest edge for the component of u let yz be the cheapest edge for the component of v if is-preferred-over(uv, yz) then Set uv as the cheapest edge for the component of v if all components have cheapest edge set to "None" then // no more trees can be merged -- we are finished completed := true else completed := false for each component whose cheapest edge is not "None" do Add its cheapest edge to E function is-preferred-over(edge1, edge2) is return (edge2 is "None") or (weight(edge1) < weight(edge2)) or (weight(edge1) = weight(edge2) and tie-breaking-rule(edge1, edge2)) function tie-breaking-rule(edge1, edge2) is The tie-breaking rule; returns true if and only if edge1 is preferred over edge2 in the case of a tie.

As an optimization, one could remove from G each edge that is found to connect two vertices in the same component, so that it does not contribute to the time for searching for cheapest edges in later components.

Complexity

Borůvka's algorithm can be shown to take iterations of the outer loop until it terminates, and therefore to run in time, where is the number of edges, and is the number of vertices in (assuming). 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.[7]

Example

ImagecomponentsDescription






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

In the first iteration of the outer loop, the minimum weight edge out of every component is added. Some edges are selected twice (AD, CE). 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.[8]

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.[9] The best known (deterministic) minimum spanning tree algorithm by Bernard Chazelle is also based in part on Borůvka's and runs in time, where α is the inverse Ackermann function.[10] 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.

Notes

  1. Borůvka . Otakar . Otakar Borůvka . 1926 . O jistém problému minimálním . About a certain minimal problem . Práce Mor. Přírodověd. Spol. V Brně III . 3 . 37–58 . cs, de.
  2. Borůvka . Otakar . Otakar Borůvka . 1926 . Příspěvek k řešení otázky ekonomické stavby elektrovodních sítí (Contribution to the solution of a problem of economical construction of electrical networks) . Elektronický Obzor . 15 . 153 - 154 . cs .
  3. Nešetřil . Jaroslav . Jaroslav Nešetřil . Milková . Eva . Nešetřilová . Helena . 10.1016/S0012-365X(00)00224-7 . 1–3 . . 1825599 . 3–36 . Otakar Borůvka on minimum spanning tree problem: translation of both the 1926 papers, comments, history . 233 . 2001. 10338.dmlcz/500413 . free .
  4. Choquet . Gustave . Gustave Choquet . 1938 . Étude de certains réseaux de routes . Comptes Rendus de l'Académie des Sciences . 206 . 310 - 313 . fr .
  5. Florek . K. . Łukaszewicz . J. . Jan Łukasiewicz . Perkal . J. . Steinhaus . Hugo . Hugo Steinhaus . Zubrzycki . S. . Colloquium Mathematicum . fr . 0048832 . 282–285 . Sur la liaison et la division des points d'un ensemble fini . 2 . 1951. 3–4 . 10.4064/cm-2-3-4-282-285 .
  6. Sollin . Georges . 1965 . Le tracé de canalisation . Programming, Games, and Transportation Networks . fr .
  7. Book: Eppstein, David. David Eppstein. Spanning trees and spanners. Handbook of Computational Geometry. J.-R.. Sack. Jörg-Rüdiger Sack. J.. Urrutia. Jorge Urrutia Galicia. Elsevier. 1999. 425–461.
    Mareš. Martin. Two linear time algorithms for MST on minor closed graph classes. Archivum Mathematicum. 40. 2004. 3. 315–320. .
  8. Bader. David A.. Cong. Guojing. Fast shared-memory algorithms for computing the minimum spanning forest of sparse graphs. Journal of Parallel and Distributed Computing. 2006. 66. 11. 1366–1378. 10.1016/j.jpdc.2006.06.001. 10.1.1.129.8991. 2004627.
  9. Karger. David R.. Klein. Philip N.. Tarjan. Robert E.. A randomized linear-time algorithm to find minimum spanning trees. Journal of the ACM. 1995. 42. 2. 321–328. 10.1145/201019.201022. 10.1.1.39.9012. 832583.
  10. Chazelle. Bernard. A minimum spanning tree algorithm with inverse-Ackermann type complexity. J. ACM. 47. 2000. 6. 1028–1047. 10.1145/355541.355562. 10.1.1.115.2318. 6276962.