0% found this document useful (0 votes)
28 views

MST BoruvkasAlgorithm

The document summarizes the minimum spanning tree algorithm Boruvka's algorithm. It begins with definitions of minimum spanning tree and spanning tree. It then provides pseudocode for Boruvka's algorithm which works by contracting connected components in each phase until a single component remains, outputting the contracted edges as the MST. An example applying Boruvka's algorithm to a graph is shown step-by-step.

Uploaded by

f20210467
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

MST BoruvkasAlgorithm

The document summarizes the minimum spanning tree algorithm Boruvka's algorithm. It begins with definitions of minimum spanning tree and spanning tree. It then provides pseudocode for Boruvka's algorithm which works by contracting connected components in each phase until a single component remains, outputting the contracted edges as the MST. An example applying Boruvka's algorithm to a graph is shown step-by-step.

Uploaded by

f20210467
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 30

Lecture

Graph Algorithms
Minimum Spanning Tree
A minimum spanning tree is a tree formed
from a subset of the edges in a given
undirected graph, with two properties:
1. It spans the graph, i.e., it includes every

vertex in the graph, and


2. It is a minimum, i.e., the total weight of
all the edges is as low as possible.
Example of Spanning Tree

Source: http://www.cs.nthu.edu.tw/~wkhon/algo09/lectures/lecture26.pdf
Example of Minimum Spanning Tree
Problem Statement

Given a weighted graph G(V,E) with


unique positive edge weights, find the
Minimum Spanning Tree of it.

Itis perhaps one of the best studied


problem in combinatorial optimization.
Algorithms you have done?

Kruskal’s algorithm :
Prim’s algorithm:
History
Boruvka 1926–O(m log n)
Kruskal 1956- O ( m log n)
Prim 1957- O ( m log n)
Yao 1975 – O ( m log log n)
Cheriton and Tarjan 1976 – O ( m log log n)
Fredman and Tarjan 1987 –O (m (m, n))
Gabow 1986 – O(m log  (m, n))
Chazelle 1995 – O ( m ( m, n))
Minimum Spanning Forest
A forest F is an acyclic subgraph of G that
consists of a collection of disjoint trees in G;
treat isolated vertices in F as tree of size 1.
A spanning forest is a forest whose trees are
spanning trees for the connected component
of the graph G.
A spanning forest is a spanning tree if and
only if the graph is connected.
A Minimum Spanning Forest is a forest
with minimum weight.
Boruvka
For each vertex of G(V,E), select the minimum-
weight edge incident to the vertex. Contract all
the selected edges, replacing by a single vertex
each connected component defined by the
selected edges and deleting all resulting isolated
vertices, loops (edges both of whose endpoints
are the same), and all but the lowest-weight edge
among each set of multiple edges. Call this new
graph after contraction as G’.
This is called a Boruvka phase.
Apply recursively Boruvka phase on G’.
Example
A G
3 2.1 3.2 1.5
2.2 5.1
B C H I

1 3.1 5 2.5 2.6


2.3 4
2.4 3.3
D E L J
4.1
1.3 1.2 1.4 2.7
F K
First Phase
A G
3 2.1 3.2 1.5
2.2 5.1
B C H I

1 3.1 5 2.5 2.6


2.3 4
2.4 3.3
D E L J
4.1
1.3 1.2 2.7
F 1.4 K

Edges selected = {AC, BD, EF, GH,


GI, GJ, LK}
After Contraction
A,C G
2.2 5.1 3.2 1.5

B H I

1 3.1 5 2.5 2.6


2.3 4
2.4 3.3
D E L J
4.1
1.3 1.2 2.7
F 1.4 K
After Contraction
A,C G
5.1 3.2 1.5

H I
2.2
2.3 4 5 2.5 2.6
2.4 3.3
B,D E L J
4.1
1.3 1.2 2.7
F 1.4 K
After Contraction
A,C G
5.1 3.2 1.5

H I
2.2
2.3 4 5 2.5 2.6

1.3 3.3
B,D E,F L J
4.1
2.7
1.4 K
After Contraction
A,C G,H
5.1 1.5

I
4
2.2
2.3 2.5 2.6

1.3 3.3
B,D E,F L J
4.1
2.7
1.4 K
After Contraction
A,C G,H,I
5.1

4
2.2
2.3 2.5

1.3 3.3
B,D E,F L J
4.1
2.7
1.4 K
After Contraction
A,C G,H,I,J
5.1

2.2 2.7
2.3 3.3

B,D 1.3 E,F L


4.1
1.4 K
End of Phase I
A,C G,H,I,J
5.1

2.2 2.7
2.3

B,D 1.3 E,F L,K


4.1

Edges selected = {AC, BD, EF, GH,


GI, GJ, LK}
Apply Phase II
A,C G,H,I,J
5.1

2.2 2.7
2.3

B,D 1.3 E,F L,K


4.1

Edges selected = {AC, BD, EF, GH,


GI, GJ, LK}
Apply Phase II
A,C G,H,I,J
5.1

2.2 2.7
2.3
1.3
B,D E,F L,K
4.1

Edges selected = {AC, BD, EF, GH,


GI, GJ, LK}
Apply Phase II
A,C G,H,I,J
5.1

2.2 2.7
2.3
1.3
B,D E,F L,K
4.1

Edges selected = {AC, BD, EF, GH,


GI, GJ, LK, BC, DF, JK}
After Contraction
A,C,B,D G,H,I,J
5.1

2.7
1.3

E,F L,K
4.1

Edges selected = {AC, BD, EF, GH,


GI, GJ, LK, BC, DF, JK}
Last Phase
A,C,B,D,E,F G,H,I,J,L,K
4.1

Edges selected = {AC, BD, EF, GH,


GI, GJ, LK, BC, DF, JK}
After Contraction
A,C,B,D,E,F G,H,I,J,L,K
4.1

Edges selected = {AC, BD, EF, GH,


GI, GJ, LK, BC, DF, JK,EL}
MST
Edges selected = {AC, BD, EF, GH, GI,
GJ, LK, BC, DF, JK,EL}

A G
3 2.1 3.2 1.5
2.2 5.1
B C H I

1 3.1 5 2.5
2.3 4
2.4 3.3
D E L J
4.1
1.3 1.2 1.4 2.7
F K
MST
Edges selected = {AC, BD, EF, GH, GI,
GJ, LK, BC, DF, JK,EL}

A G
2.1 3.2 1.5
2.2 C
B H I

1 2.5

D E L J
4.1
1.3 1.2 1.4 2.7
F K
Boruvka
 Claim: The graph G’ obtained after one Bouruvka
Phase has at most vertices.

 Proof: Note for each vertex we mark an incident


edge. But some of these edges can be marked twice.
So the number of marked edges is larger than . When
a marked edge is collapsed, it eliminates a distinct
vertex. Thus or more than vertices are eliminated.
Hence G’ has at most vertices.

 The number of edges in G’ is no more than since no


new edges are created during the process.
BORUVKA_STEP
Require: Input: Gi = (Vi;Ei)
Ensure: Output: a forest F of MST edges and a contracted graph G’
F  ;
for all {u,v}  Ei do
if w({u,v}) < u.minEdgeWeight then
u.minEdgeWeight  w({u,v})
u.minEdge  {u, v}
end if
if w({u,v}) < v.minEdgeWeight then
v.minEdgeWeight  w({u,v})
v.minEdge  {u, v}
end if
end for
for all v  V do
put v.minEdge in F
end for
Gi+1 = contract (Gi; F)
return Gi+1, F
CONTRACT
Require: Input: G = (V;E), a subgraph H of edges to contract
Ensure: Output: G’, the contracted graph
If not every vertex in V is represented in H, put the missing vertices in
V’  , E’  ;
G’ = (V’;E’)
connectedComponents  find-connected-components(H)
i 0
for all C  connectedComponents do
put i in V’
for all v  C do
v.component  i
end for
i i+1
end for
for all {u, v}  E do
If (u.component != v.component)
put {u.component, v.component} in E’
end for
return G’ = (V’;E’)
Running Time of Boruvka

One can show that a Boruvka phase on a


graph G with n vertices and m edges can
be implemented in time O(n+m).

At most log (n) Boruvka phases will be


required because after each phase the
resultant graph has less than vertices.
So worst case running time O(m log n).

You might also like