Download Minimum Spanning Trees: Construction and Properties - Prof. Mark K. Goldberg and more Study notes Computer Science in PDF only on Docsity!
1 Minimum Spanning Trees (MST)
14
a
b
c
d e g f h (^) i
j k
l (^) m
1
2 3
4
8 6
12
15
19
16
17
9
10
5
7 11
13
18
A graph H(U, F ) is a subgraph of G(V, E) if U ⊆ V and F ⊆ E.
A subgraph H(U, F ) is called spanning if U = V.
Let G be a graph with weights assigned to the edges. Then the
weight of a subgraph H of the G is the sum of the weights of the
edges of H.
A minimum spanning tree, MST, is a spanning tree of the
minimum weight.
A cut (V 1 , V −V 1 ) of a graph G(V, E) is a partitioning of its vertices
into two subsets; [V 1 , V − V 1 ] denotes the set of edges (u, v) of the
form
u ∈ V 1 & v ∈ V − V 1.
Machinery for constructing MST’s
1. All algorithms use the Greedy Algorithmic Strategy: a tree is
constructed as a sequence of steps; each step is locally opti-
mal; no step is ever reversed.
2. Main step of every algorithm:
an edge is colored either BLUE (≡ accepted) or RED (≡ rejected)
every step is done so that the color invariant holds true:
∃ MST containing all blue edges and none of the red ones.
3. The coloring rules
blue rule:
• construct a cut of the graph without blue edges (if it ex-
ists);
• select a shortest uncolored edge from the cut and color
it blue.
red rule:
• construct a simple cycle without red edges (if it exists);
• select the longest uncolored edge in the cycle and color
it red.
Greedy Method: Initialize by coloring all edges white. At every moment,
apply either rule until all edges are colored red or blue.
Comment: For the method to succeed, it is necessary that the
color invariant holds after every coloring step.
Problem 5
Let T be an MST of a graph G(V, E) and let V
⊆ V. Let T
be
the subgraph of T induced by V
and let G
be the subgraph of G
induced by V
. Show that if T
is connected, then T
is an MST of
G′.
Theorem 1
At every step of the red-blue coloring, the color invariant holds true.
Proof: We want to prove that, at every step of the coloring there
is a minimum spanning tree which uses all blue edges and does not
use any of the red ones.
Initially, no edge is colored either blue or red, so the statement is
correct and any minimum spanning tree would do. Let T be a min-
imum spanning tree satisfying the color invariant and let e be the
next colored edge.
Case 1: e was colored blue. If e is in T already, we are done.
Otherwise, T contains a path, P , connecting the end-points of e. If
(X, X) is the cut used to select e, then P contains edges from the
cut. Because of the color invariant and the condition of the blue rule,
every edge which belongs to P and to [X, X] is uncolored. Let e′^ be
such an edge. We build a new tree T ∗^ by removing e′^ and adding
e to P. Obviously, the resulting spanning tree can only be shorter
than T.
Case 2: e was colored red. If e is not in T , we are done. Let e
be an edge of T and let C be the cycle using which e was selected.
Obviously, at least one edge of the cycle, e′, does not belong to T.
Since T contains all blue edges, e′^ is not blue; furthermore, because
of the color invariant, it is not red. By the red rule, the weight of
e is not less than that of e
. This proves that T − {e} ∪ {e
} is a
minimum spanning tree satisfying the required conditions.
[X,X ]
e
e
is a cut without blue edges
Remove
Add e
X (^) e X
e
e
C is a cycle Remove
Add e
e
without red edges
2 Ideas for min-span algorithms
A blue tree is a tree in the forest defined by blue edges.
All three algorithms below are mainly blue-rule algorithms; every
coloring step selects a blue tree, finds a minimum-cost edge incident
to the tree and colors it blue.
Kruskal’s algorithm builds blue trees according to the edge costs;
Prim’s algorithm builds only one non-trivial tree; Boruvka’s algo-
rithm builds blue trees uniformly througout the graph.
30
16
a
b c
d
e (^) f
g
8 10
2
30
(^4 )
(^18 ) 14
5
3
a
b c
d
e (^) f
g
8 5 10 2 3
30 16
(^4 )
(^18 ) 14
a
b c
d
e (^) f
g
a
b c
d
e (^) f
g
2
(^4 )
(^18 ) 14
Prim’s Algoritm (example) After 3 steps
After 4 steps (^) After 6 steps
4
12
2
10
8 5
16
3 30 14
26
18
10
8 5
16
3
3 Algorithms for Minimum Spanning Trees
MST-Kruskal(G, w); //At every moment, the algorithm maintains a collection of trees(components) //containing all vertices of G. When an edge (u, v) is examined, it is checked //if the endponts of the edge belong to the same component. It is done with //the help of the procedure FIND SET(), which outputs the representative of //the component containing the input. If the edge (u, v) passes the test, the //algorithm converges the two components containing u and v, respectively; //the latter is done by procedure Union(u, v)
1. A = ∅;
- for each vertex v ∈ V [G]
- Make Set(v);
- sort the edges of E by nondecreasing weight w;
- for each edge (u, v) ∈ E, in order by nondecreasing weight
- if Find Set(u) 6 =Find Set(v)
- {A = A ∪ (u, v);
- Union(u, v)};
- return A.
Complexity of MST-Kruskal()
The first three lines initialize the components; at that moment, every component is an one- vertex tree. The initialization is a linear procedure; done in O(|V |) time.
The time to sort the edges in line 4 is O(|E| lg |E|).
There are O(|E|) operations (lines (6), (7), and (8)) on the disjoint set, which in total takes O(|E| log |E|) time.
Usual algorithms for set manipulation execute FIND SET() and UNION in O(|E| lg |E|) time in total, but there are even faster algorithms.
The total running time of MST-Kruscal is O(|E| lg |E|).
Theorem 2
Let U ⊆ V and e be of the minimum length among the edges with one endpoint in U and the other in V − U. Then there exists a minimum spanning tree T such that e is in T.
Proof: Let T 0 be a minimum spanning tree. If e is not in T , add e to T. There is a path comprised of T -edges that connects the endpoints of e. Together with e the path forms a cycle.
This cycle must have at least one more edge connecting U and V − U. Let e′^ be the edge; add e to T and remove e′.
The resulting graph T ′^ is connected and is a tree; the length of the new tree does not exceed that of T , thus T ′^ is minimal.
Problem 6
Let G be a weighted undirected graph with all weights distinct; is it true that G has a unique minimum spanning tree?
a
b c d
e (^) f
g
8 5
18
10
16 12 30
4
(^2 )
14 26
c d
e (^) f
g
a
b
c d
e (^) f
g
a
b c d
e (^) f
g
a
b (^) c d
e (^) f
g
a
b
a
b c d
e (^) f
g
8 5
18
10
16 12 30
4
(^2 )
14 26
c d
e (^) f
g
a
b
c d
e (^) f
g
a
b c d
e (^) f
g
a
b (^) c d
e (^) f
g
a
b
Application to the TSP on the plane
For this case of the general TSP, the triangle inequality holds true: for any three points x, y, and z, w(x, y) + w(y, z) ≥ w(x, z).
Approximate-TSP(G, w)
- select a vertex r ∈ V [G] to be the root vertex;
- construct a minimum spanning tree T for G from r using MST-Prim(G, w, r);
- let L be the list of vertices visited in a preorder tree walk of T ;
- use shortcuts to eliminate revisits; let H be the resulting tour;
- return the cycle H;
Problem 7
Let L be a curcular tour of n points on the plane which intersects itself (the intersection point is not one of the n). Is it true that the tour is not optimal? How to construct a shorter tour which goes through all n points?