Interactive Graph Theory Learning
Interactive Graph Theory Learning
Guest User
Using app without sign in
Parallel minimum spanning tree calculator
Finds MST by parallel component-based approach
Select an algorithm and generate steps to begin visualization
Boruvka's algorithm, published in 1926 and the oldest MST algorithm, finds a minimum spanning tree by letting every component simultaneously pick its cheapest outgoing edge. All selected edges are added at once, merging components in parallel rounds.
Each round scans all edges and records, for every component, the minimum-weight edge leaving it. Those edges are added to the forest, at least halving the number of components, so only O(log V) rounds are needed. Each round costs O(E), for a total of O(E log V). Because each round is a simple parallel scan, Boruvka is the natural basis for parallel and distributed MST computation.
Boruvka's algorithm was originally devised to plan an electrical network in Moravia and today underlies parallel MST implementations on GPUs and clusters, as well as hybrid algorithms that mix Boruvka rounds with Prim or Kruskal phases. It appears in interviews mainly as a discussion point on parallel algorithm design.
Every component picks its own cheapest outgoing edge, and all those picks are applied at once. Rounds rather than steps, which is what makes it parallelisable.
Boruvka(graph):
makeSet(v) for every vertex
mst = []
while more than one component remains:
cheapest = {} // per component
for each edge (u, v, w):
a = find(u); b = find(v)
if a == b: continue // internal edge
if w < cheapest[a]: cheapest[a] = (u,v,w)
if w < cheapest[b]: cheapest[b] = (u,v,w)
for each edge e in cheapest.values():
if find(e.u) != find(e.v): // may already be merged
union(e.u, e.v); mst.append(e)The inner guard on the second loop is essential, not defensive. Two components frequently choose the same edge, one from each end, and applying it twice would add a duplicate. Correctness needs edge weights to be distinct, or a consistent tie-break such as comparing edge ids: without one, several components can each pick a different edge of equal weight and together form a cycle.
Build the minimum spanning tree on the same graph used for Prim and Kruskal, so all three can be compared.
Example graph: Undirected edges A-B (2), A-C (3), B-C (1), C-D (4) and B-D (7).
The minimum spanning tree is A-B, B-C and C-D with total weight 2 + 1 + 4 = 7, the same tree Prim and Kruskal produced. Boruvka got there in one round rather than three sequential steps, which is the point: each round at least halves the number of components, since every component merges with at least one other, so only O(log V) rounds are ever needed.
Time: O(E log V) · Space: O(V + E)
Each round scans every edge once at O(E) to find the cheapest outgoing edge per component. Every component merges with at least one other during a round, so the component count at least halves, meaning at most log base 2 of V rounds occur. Multiplying gives O(E log V), matching Prim and Kruskal. The distinguishing property is that within a round every component works independently, so the scan parallelises directly, which is why Boruvka underlies GPU and distributed MST implementations while Prim and Kruskal, both inherently sequential, do not. Hybrid algorithms run a few Boruvka rounds to shrink the graph and then switch to Prim.
All three classical MST algorithms cost O(E log V). The difference is structural.
| Alternative | Prefer it when | Cost |
|---|---|---|
| Prim's algorithm | Sequential code on a dense graph. One tree, one priority queue, simple to implement. | O(E log V) or O(V^2) |
| Kruskal's algorithm | Sparse graphs or pre-sorted edges, and disconnected graphs where a forest is acceptable. | O(E log E) |
| Boruvka | Parallel or distributed execution, since each round is an independent scan per component. | O(E log V) |
| Boruvka plus Prim hybrid | Very large graphs. A few Boruvka rounds contract the graph, then Prim finishes on the smaller one. | O(E log log V) in practice |
Related algorithms: Prim's MST Algorithm, Kruskal's MST Algorithm