Borůvka's algorithm
   HOME

TheInfoList



OR:

Borůvka's algorithm is a greedy algorithm for finding a
minimum spanning tree A minimum spanning tree (MST) or minimum weight spanning tree is a subset of the edges of a connected, edge-weighted undirected graph that connects all the vertices together, without any cycles and with the minimum possible total edge weight. ...
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 An electrical grid is an interconnected network for electricity delivery from producers to consumers. Electrical grids vary in size and can cover whole countries or continents. It consists of:Kaplan, S. M. (2009). Smart Grid. Electrical Power ...
for
Moravia Moravia ( , also , ; cs, Morava ; german: link=yes, Mähren ; pl, Morawy ; szl, Morawa; la, Moravia) is a historical region in the east of the Czech Republic and one of three historical Czech lands, with Bohemia and Czech Silesia. The ...
. The algorithm was rediscovered by Choquet in 1938; again by Florek, Łukasiewicz, Perkal,
Steinhaus Steinhaus may refer to: *Bibiana Steinhaus, German football referee * Edward Arthur Steinhaus (1914–1969), American insect pathologist * Hugo Steinhaus, mathematician * Steinhaus, Austria, a municipality in Upper Austria, Austria * 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 Parallel computing is a type of computation in which many calculations or processes are carried out simultaneously. Large problems can often be divided into smaller ones, which can then be solved at the same time. There are several different f ...
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 In mathematics, a total or linear order is a partial order in which any two elements are comparable. That is, a total order is a binary relation \leq on some set X, which satisfies the following for all a, b and c in X: # a \leq a ( reflexive ...
on vertices or edges. This can be achieved by representing vertices as integers and comparing them directly; comparing their
memory address In computing, a memory address is a reference to a specific memory location used at various levels by software and hardware. Memory addresses are fixed-length sequences of digits conventionally displayed and manipulated as unsigned integers. ...
es; 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'', ''E''') where ''E''' = . ''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 graph In graph theory, a planar graph is a graph that can be embedded in the plane, i.e., it can be drawn on the plane in such a way that its edges intersect only at their endpoints. In other words, it can be drawn in such a way that no edges cro ...
s, and more generally in families of graphs closed under
graph minor In graph theory, an undirected graph is called a minor of the graph if can be formed from by deleting edges and vertices and by contracting edges. The theory of graph minors began with Wagner's theorem that a graph is planar if and only if ...
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


Other algorithms

Other algorithms for this problem include Prim's algorithm and
Kruskal's algorithm Kruskal's algorithm finds a minimum spanning forest of an undirected edge-weighted graph. If the graph is connected, it finds a minimum spanning tree. (A minimum spanning tree of a connected graph is a subset of the edges that forms a tree that ...
. 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 (deterministic) minimum spanning tree algorithm by
Bernard Chazelle Bernard Chazelle (born November 5, 1955) is a French-American computer scientist. He is currently the Eugene Higgins Professor of Computer Science at Princeton University. Much of his work is in computational geometry, where he is known for hi ...
is also based in part on Borůvka's and runs in time, where α is the inverse of the
Ackermann function In computability theory, the Ackermann function, named after Wilhelm Ackermann, is one of the simplest and earliest-discovered examples of a total computable function that is not primitive recursive. All primitive recursive functions are total ...
. 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

{{DEFAULTSORT:Boruvka's Algorithm Graph algorithms Spanning tree Articles with example pseudocode