Minimum Spanning Tree
1.
2.
3.
Properties of MST
Second-best MST
Bottleneck Spanning Tree
Property 1 of MST
Let (u, v) be a minimum-weight edge in a graph G = (V, E).
Then (u, v) belongs to some MST of G.
Proof: Let A be the empty set of edges. Then
(1) A is a subset of some MST, and A does not include (u, v).
(2) The cut (u, V\u) respects A.
(3) Edge (u, v) is a light edge crossing cut (u, V\u).
By theorem 23.1, (u, v) is a safe edge for A. Hence, (u, v)
belongs to some MST.
Another proof: Suppose T is an arbitrary MST, and (u, v) is
not in T. Then T {(u, v)} contains a cycle. Let f be any
edge other than (u, v) on the cycle, then T {(u, v)} – {f} is
a MST containing (u, v).
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
2
Property 2 of MST
(1) Let T be a MST of a graph G, and
(2) let T’ be an arbitrary spanning tree of G,
(3) suppose the edges of each tree are sorted in non-decreasing
weight order, that is,
w(e1) w(e2) … w(en - 1) and
w(e1’) w(e2’) … w(en - 1’).
Then for 1 i n -1, w(ei) w(ei’).
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
3
Proof of Property 2
Proof. Prove by contradiction.
Suppose w.l.o.g. that there exists an index i1 such that w(e1)
w(e1’), w(e2) w(e2’), …, w(ei-1) w(ei-1’), but w(ei) > w(ei’).
This indicates that
w(en-1) w(en-2) … w(ei) > w(ei’) w(ei-1’) …
w(e1’).
So, if we add any ex’{ e1’, e2’, …, ei’} onto T, then either ex’
is an edge of {e1, e2,…, ei-1}, or a cycle is formed which
includes only edges in {ex’, e1, e2, …, ei-1}.
Thus each ex’{ e1’, e2’, …, ei’} is included in a connected
component of {e1, e2, …, ei-1}.
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
4
Proof of Property 2
Thus the graph (V, {e1’, e2’, …, ei’, e1, e2, ..., ei-1}) has the same
number of connected components as graph (V, {e1, e2, ..., ei-1})
have, i.e., n-i+1.
But the graph (V, {e1’, e2’, …, ei’}) has n-i connected
components, since e1’, e2’, …, ei’ are tree edges from T’. A
contradiction.
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
5
Gi-1 = (V, {e1, …, ei-1}) has n-i+1 (=3) connected components.
By assumption, {e1’, …, ei’} are all included in the connected components of Gi-1.
So, (V, {e1’, …, ei’, e1, …, ei-1}) has also n-i+1 (=3) connected components.
Impossible, since Gi-1’ = (V, {e1’, …, ei’}) has n-i (=2) connected components.
edges in {e1, …, ei-1}
©2005, 2009, 2011, SDU
edges in {e1’, …, ei’}
http://www.sciencenet.cn/u/algzhang/
6
Property 3 of MST
Let T be a MST of a graph G, and
let L be the sorted list of the edge weights of T.
Then for any other MST T’ of G, the list L is also the sorted list of
edge weights of T’.
Proof. By Property 2.
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
7
MST Property (Prob. 23-1(a))
Property 4. Let G = (V, E) be an undirected, connected graph
with weight function w: E R+, and suppose that
(1) | E | | V | and
(2) all edge weights are distinct.
Then the MST of G is unique.
Proof. By Property 3.
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
8
Second-best MST
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
9
Definition of Second-best MST
Let G = (V, E) be an undirected, connected graph with weight
function w: E R+, and suppose that
(1) | E | | V | and
(2) all edge weights are distinct.
A second-best MST is a spanning tree T such that
w(T) = minT’’-{T’}{w(T’’)},
where is the set of all spanning trees of G, and T’ is a MST of
G.
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
10
Examples of Second-best MST
The second-best MST need not be unique.
2
1
3
2
4
1
4
MST
5
2
1
3
4
1
2BMST
2BMST
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
5
11
Property of Second-best MST
Property 5. A second-best MST can be obtained from the MST
by replacing a single edge from the tree with another edge not in
the tree.
Proof. By contradiction. Suppose T1 is the MST and T2 is a
second-best MST, and they differ by at least two edges, we will
get another spanning tree T3 such that (1) T3 T1 and (2) w(T3)
< w(T2), thus contradicts that T2 is second-best.
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
12
Proof (Cont.)
Suppose e1 is the minimum edge in T1\ T2.
Then T2 {e1} contains a cycle C on which there must be some
edge e T2 such that e T1, since otherwise C would be
entirely in T1 (and this is impossible since C is a cycle and T1 is
a tree).
Let T3 = T2 {e1} \ {e}. Then T3 is a spanning tree.
Since T3 differs from T2 by only one edge, while T1 differs from T2 by at least
two edges, T3 is not equal to T1. (1) is satisfied.
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
13
Proof (Cont.)
We claim that w(e) > w(e1). Then we have (2) w(T3) < w(T2)
since T3 = T2 \ {e} {e1}.
Prove the claim by contradiction. Assume w(e) < w(e1).
If we add e to T1, we get a cycle C’, which contains some edge
e' in T1 but e' is not in T2. (otherwise, T2 would contain the
entire cycle C’).
Therefore, T4 = T1 \ {e'} {e} is a spanning tree, and we must
have w(e') < w(e), since otherwise w(T4) would be less than
w(T1).
Thus, w(e') < w(e) < w(e1), which contradicts our choice of e1
as the edge in T1 \ T2 of minimum weight.
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
14
Compute the Second-best MST
Idea: use Property 5.
(u, v) T, try the spanning tree T’ = T \ {e} (u, v), where e is
the edge with maximum weight in cycle C, which is formed by
adding (u, v) onto T.
Pick the tree T’ such that w(T’) = w(T) – w(e) + w(u, v) is
minimized among all possible trees.
Let T be a spanning tree of G and for any two vertices u, v V,
let max[u, v] be the maximum weight among all edges on the
unique path between u and v in T.
Thus we need to compute max[u, v]. How?
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
15
Compute the Second-best MST
Second-Best-MST(G)
1 Compute a MST T for G.
2 Compute max[u, v] for each pair (u, v) in T.
3 For each edge (u, v) not in T, compute the difference w(u, v) –
max[u, v].
4 Find the smallest positive difference and replace the
max_edge[u, v] with corresponding edge (u, v).
Note: max_edge[u, v] means the edge with maximum weight in
the path connecting u and v in T. It can be easily computed.
Compute-max(T): O(V2)
Second-Best-MST(G): O(ElogV + V2)
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
16
Compute the Second-best MST
Compute-max(T)
1 for each pair of vertices
u, v V do
2
max[u, v] 0
3 endfor
4 for each vertex s V do
5
BFS (T, s)
//E(T)=O(V)
6 endfor
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
17
Compute the Second-best MST
BFS(T, s)
1 for each vertex u V do
2
color[u] WHITE
3 endfor
4 color[s] GRAY
5 Q
6 Enqueue(Q, s)
©2005, 2009, 2011, SDU
7 while Q do
8 u Dequeue(Q)
9 for each v Adj[u] do
10
if color[v] = WHITE then
11
color[v] GRAY
12
max[s, v]
max{w(u, v), max[s, u]}
13
Enqueue(Q, v)
14
endif
15 endfor
16 color[u] BLACK
17 endwhile
http://www.sciencenet.cn/u/algzhang/
18
Bottleneck Spanning Tree
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
19
Bottleneck Spanning Tree
A bottleneck spanning tree T of a connected, weighted and
undirected graph G is a spanning tree of G whose largest edge
weight is minimum over all spanning trees of G.
Let T1, T2, …, Tm are all the spanning trees G, and the largest edge
of each tree is et1, et2, …, etm. If w(eti) w(etj) for 1 j m and j i,
then Ti is a bottleneck spanning tree.
The value of a BST T is the weight of the maximum-weight edge in
T.
The bottleneck spanning tree may not be unique.
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
20
BST vs MST
Property 6. Every minimum spanning tree is a bottleneck spanning tree.
Proof. Property 2 implies it.
Another proof. Let T be a MST and T’ be a BST, let the maximum-weight edge in T
and T’ be e and e’, respectively.
Suppose for the contrary that the MST T is not a BST, then we have w(e) > w(e’),
which also implies that f T’, w(e) > w(f).
Removing e from T disconnects T into two subtrees T1 and T2. There must exist an
edge f in T’ connecting T1 and T2, otherwise, T’ is not connected.
T1T2 {f} forms a new tree T’’ with w(T’’) = w(T) - w(e) + w(f) < w(T), a
contradiction to the fact that T is MST, thus, A MST is also a BST.
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
21
The BST Problem
The BST Problem:
I: A weighted, connected and undirected graph G.
Q: A BST T of G.
A solution:
Kruskal’s and Prim’s Algorithm works for the BST problem.
More efficient algorithm exist for the problem?
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
22
A Decision Problem
Decision version of the BST problem:
I: A graph G = (V, E) with weight function w on E, and an integer b.
Q: TRUE if the value of the BST(G) is at most b and FALSE
otherwise.
How to solve this problem in linear time?
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
23
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
CHECK-BOTTLENECK(G, b)
for each vertex u V[G] do
color[u] WHITE
endfor
u randomly chosen vertex in G
DFS(u, b)
//O(V+E)
for each vertex u V[G] do
if color[u] = WHITE then
return FALSE
endif
endfor
return TRUE
©2005, 2009, 2011, SDU
1.
2.
3.
4.
5.
6.
7.
DFS(u, b)
color[u] GRAY
for each v Adj[u] do
if color[v] = WHITE and
w(u, v) b then
DFS(v, b)
endif
endfor
color[u] BLACK
http://www.sciencenet.cn/u/algzhang/
24
Solve the BST Problem
BOTTLENECK(G)
1 Sort the weights of edges of G in non-decreasing order:
e[1] e[2] … e[ | E | ]
2 start 1, end | E |
4 while start < end do
5 middle (start + end)/2
6 if CHECK-BOTTLENECK(G, e[middle]) = FALSE then
7
start middle
8 else
9
end middle //in the end there is a BST with value e[end]
10 endif
11 endwhile
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
25
Solve the BST Problem
12 u randomly chosen a vertex of G
13 call DFS(u, e[start]) to build a spanning tree
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
26
Solve the Problem in Linear Time
Time complexity:
Sorting:O(E log E)
Finding the value of BST: O((V+E) log E)=O(E log E)
Total:O(E log E)
Can the problem be solved in linear time?
Please think it carefully, anyone who finds the solution will be given an extra
bonus.
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
27
A Linear Time Algorithm for BST
BST(G)
1 T (V, )
2 while there exist 2 types of edge costs in G do
3 Find the median of all types of edge costs, say b
4 if G|{e: w(e) b} is connected then
5
Remove all edges with cost > b from G
6 else
7
Contract-Merge(G, b, T)
8 endif
9 endwhile
10 Contract-Merge(G, any edge cost in G, T)
11 return T
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
28
A Linear Time Algorithm for BST
Contract-Merge(G, b, T)
1 while there exists an edge e with w(e) b in G do
2 T T {e}
3 Contract e. Denote by e1, e2, ..., ek the edges merged
because of the contraction.
4 Keep only the edge with minimum cost in e1, e2, ..., ek,
and remove all the other edges.
5 endwhile
6 return
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
29
An Example
b
4
a
c
8
4
i
7
8
h
1 2 4 6 7 8 9 10 11 14
9
2
11
d
7
14
6
1
10
g
2
f
•There is no BST with value
e 7.
•Thus all edges with cost 7
are contracted.
•We begin from (a, b).
b
4
a
7
4
i
11
7
h
d
9
2
8
©2005, 2009, 2011, SDU
c
8
14
6
1
http://www.sciencenet.cn/u/algzhang/
e
10
g
2
f
30
An Example
a
c
8
4
i
7
h
1 2 4 6 7 8 9 10 11 14
9
2
8
d
7
14
6
1
•Next contract (i, c).
e
10
g
2
f
b
4
a
7
4
i
11
7
h
d
9
2
8
©2005, 2009, 2011, SDU
c
8
14
6
1
http://www.sciencenet.cn/u/algzhang/
e
10
g
2
f
31
An Example
a
c
8
d
7
1 2 4 6 7 8 9 10 11 14
9
4
7
8
•Next contract (h, c).
14
6
e
10
h
1
g
2
f
b
4
a
7
4
i
11
7
h
d
9
2
8
©2005, 2009, 2011, SDU
c
8
14
6
1
http://www.sciencenet.cn/u/algzhang/
e
10
g
2
f
32
An Example
a
c
8
d
7
1 2 4 6 7 8 9 10 11 14
9
4
•Next contract (c, g).
14
1
e
10
g
2
f
b
4
a
7
4
i
11
7
h
d
9
2
8
©2005, 2009, 2011, SDU
c
8
14
6
1
http://www.sciencenet.cn/u/algzhang/
e
10
g
2
f
33
An Example
a
8
c
d
7
1 2 4 6 7 8 9 10 11 14
9
2
•Next contract (c, f).
14
e
10
f
b
4
a
7
4
i
11
7
h
d
9
2
8
©2005, 2009, 2011, SDU
c
8
14
6
1
http://www.sciencenet.cn/u/algzhang/
e
10
g
2
f
34
An Example
a
8
c
d
7
1 2 4 6 7 8 9 10 11 14
9
10
•Next contract (c, d).
e
f
b
4
a
7
4
i
11
7
h
d
9
2
8
©2005, 2009, 2011, SDU
c
8
14
6
1
http://www.sciencenet.cn/u/algzhang/
e
10
g
2
f
35
An Example
a
8
c
8 9
•There is no BST with value
e 8.
•We contract (a, c).
9
b
4
a
7
4
i
11
7
h
d
9
2
8
©2005, 2009, 2011, SDU
c
8
14
6
1
http://www.sciencenet.cn/u/algzhang/
e
10
g
2
f
36
An Example
a
9
9
•There is only one type of edge
e costs.
•We contract (a, e).
b
4
a
7
4
i
11
7
h
d
9
2
8
©2005, 2009, 2011, SDU
c
8
14
6
1
http://www.sciencenet.cn/u/algzhang/
e
10
g
2
f
37
An Example
a
•This is our BST.
b
4
a
7
4
i
11
7
h
d
9
2
8
©2005, 2009, 2011, SDU
c
8
14
6
1
http://www.sciencenet.cn/u/algzhang/
e
10
g
2
f
38
Exercises
Page 43-44
23.1-2
23.1-3
23.1-4
23.1-5
Page 50-51
23.2-1
23.2-4
23.2-8
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
39
Steiner Tree and Steiner Forest
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
40
The Steiner Tree Problem
Instance: An undirected graph G = (V, E) with nonnegative costs
{c(e)} defined on edges, a required vertex set D V.
Query: a minimum cost subgraph T of G such that T spans D.
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
41
Approximating Steiner Tree
The Steiner Tree problem is NP-hard.
A MST-based algorithm achieves approximation ratio 2.
A 1.55-approximation algorithm is known for a long time.
The current best known approximation ratio for Steiner is 1.39,
due to
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
42
The Steiner Forest Problem
Instance: An undirected graph G = (V, E) with nonnegative costs
defined on edges, a source-sink terminal pair set D = {(s1, t1), (s2,
t2), ..., (sk, tk)}.
Query: A minimum cost subgraph F of G such that every pair (s,
t) D is connected in F.
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
43
Approximating Steiner Forest
A factor 2 approximation algorithm was due to
The algorithm in [AKR95] was simplified and generalized by
The factor 2 is currently the best for Steiner Forest.
R. Ravi
©2005, 2009, 2011, SDU
Michel Goemans
http://www.sciencenet.cn/u/algzhang/
44
k-MST
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
45
The k-MST Problem
Instance: An undirected graph G = (V, E), a positive integer k.
Query: find a MST spanning at least k vertices of G.
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
46
Approximating k-MST
The k-MST problem is NP-hard.
Factor of 3k1/2:
O(log2 k):
O(log k):
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
47
Approximating k-MST
35:
3:
2 + :
2:
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
48
Two Men
Naveen Garg
©2005, 2009, 2011, SDU
Sanjeev Arora
http://www.sciencenet.cn/u/algzhang/
49
Thanks for attention!
©2005, 2009, 2011, SDU
http://www.sciencenet.cn/u/algzhang/
50
© Copyright 2026 Paperzz