Title: Minimum Spanning Tree MST
1Minimum Spanning Tree (MST)
Problem Select edges in a connected and
undirected graph to
form a tree that connects all the vertices
(spanning tree). minimize the total edge
weight of the spanning tree.
Total weight of tree edges 14
2Applications of MST
Telephone wiring (use as little wire as possible)
Electronic circuit board design
Cancer imaging (MSTs describe arrangements of
nuclei in skin
cells)
Biomedical image analysis (detect actin fibers in
cell images)
Astronomy (find clusters of quasars and Seyfert
galaxies)
Finding road networks in satellite and aerial
imagery
3A Greedy Strategy
Generic-MST(G, w) A //
Invariant A is a subset of some MST
while A does not form a spanning tree
do find an edge (u, v) that is safe for A
A A ?(u, v)
// A remains a subset of some MST return
A
How to find a safe edge?
4Cut
A cut of G (V, E) is a partition (S, V S) of
V.
Ex. S a, b, c, f, V S e, d, g
Edges b, d, a, d, b, e, c, e all cross
the cut. The remaining edges do not cross the
cut.
5Respected by a Cut
A (a, b), (d, g), (f, b), (a, f) A A ?
(b, d)
Ex. S a, b, c, d
1
2
1
a
7
d
2
2
5
4
5
b
f
g
1
1
4
3
7
4
c
e
6Light Edge
is the edge that crosses a cut with the minimum
weight.
Ex. S a, b, c, d
7
a
d
2
2
5
4
5
b
f
g
1
3
1
4
light edge
7
4
c
e
Edge b, e has weight 3, lighter than the
other edges a, d, b, d, and c, e that also
cross the cut.
7Light Edge Is Safe!
Theorem Let (S, V S) be any cut of G(V, E)
that respects a subset A of E, which is
included in some MST for G. Let (u, v) be a
light edge crossing (S, V S). Then (u, v)
is safe for A that is, A ? (u, v) is also
included in some MST.
4
v
2
S
2
V S
6
u
A includes all red edges.
8Why Light Edge Is Safe?
Proof Suppose T is an MST (consisting of red
edges) that includes A.
Suppose the light edge (u, v) ? T. We have
9 Corollary Let A be a subset of E that is
included in some MST of G, and C be a
connected component in the forest G ltV, Agt.
If (u, v) is a light edge connecting C to
some other component in G , then (u, v) is safe
for A.
A
A
Proof The edge (u, v) is a light edge for the
cut (C, V C) which respects A. By
the previous theorem (u, v) is safe for A.
v
4
8
w
7
u
A includes the five red edges.
C
10Finding a Safe Edge
Let A be a subset of edges included in some MST.
A is a forest. The safe edge added to A has least
weight among all edges connecting its two
components.
A is a tree. The safe edge is a light edge
connecting a vertex in A to one not in A.
11Kruskals Algorithm - an Example
7
a
d
2
2
5
4
5
b
f
g
1
4
3
1
7
c
e
4
Total weight of the MST 14
12Kruskals Algorithm - Description
MST-Kruskal(G, w) A for each
vertex v in V do Make-Set(v) sort the
edges of E by nondecreasing weight w // O(E lg
E) for each edge (u, v) in E, in order of
nondecreasing weight do if Find-Set(u) ?
Find-Set(v) then A A (u, v)
Union(u, v) return A
13Kruskals Algorithm - Analysis
Sorting takes O(E lg E) time.
?(V) Make-Set operations ?(E) Find-Set
operations ?(V) Union operationns
Total time O(E lgV)
(if properly implemented)
14Implementation of Disjoint-Set Forest
Each member points only to its parent
Find-Set(d) f
Find-Set(b) c
15Running Time of Set Operations
Make-Set(c)
c
Claim A sequence of m Make-Set, Union, and
Find-Set operations, n of which are
Make-Set, can be performed in worst-case
time O(m lg n).
(See Sections 22.3 22.4 for more on
Disjoint-Set operations)