doc

advertisement
Minimum Spanning Tree
We will see how to find MST in linear time using randomization algorithm.
Definitions:
 Cut: A cut in graph is a partition of the vertices into two disjoint sets.
 Crossing edge: is one that connects a vertex in one set with a vertex in the
other.
 Spanning tree: of the graph is a subgraph that contains all of the vertices in
that graph.
 Minimum Spanning Tree: a MST of a weighted graph is a spanning tree
whose weight (the sum of the weights of its edges) is no larger than the
weight of any other spanning tree.
Following figure shows the weighted undirected graph and it’s MST
2
0
6
7
1
3
5
4
0-6
.51
0-1
.32
0-2
.29
4-3
.34
5-3
.18
7-4
.46
5-4
.40
0-5
.60
6-4
.51
7-0
.31
7-6
.25
7-1
.21
Before moving on, we have to understand two basic properties of MST.
1. Cut Rule: given any cut in a graph, every minimal crossing edge belongs to
some MST of the graph, and every MST contains a minimal crossing edge.
Proof: The proof is by contradiction. Suppose that e is a minimal crossing
edge that is not in any MST, and let T be any MST; or suppose that T is an
MST that contains no minimal crossing edge. In either case, T is an MST that
doesn’t contain the minimal crossing edge e. Now consider the graph formed
by adding e to T. this graph has a cycle that contains e, and that cycle must
contain at least one other crossing edge – say, f, which is equal or higher
weight that e (since e is minimal). We can get a spanning tree of equal or
lower weight by deleting f and adding e, contracting either the minimality of T
or the assumption that e is not in T.
2
2
0
6
0
6
7
7
1
1
3
3
5
4
5
4
2
2
0
6
0
6
7
5
7
1
1
3
3
4
5
4
Above four examples represents cut property. Edge connecting two set of
vertices having white and gray color belongs to MST.
2. Cycle Rule: given a graph G, consider the graph G’ defined by adding an
edge e to G. Adding e to an MST of G and deleting a maximal edge on the
resulting cycle gives an MST for G’.
Proof: If e is the longer than all the edges on the cycle, it cannot be on an
MST of G’, because of property #1. Removing e from any such MST would
split the latter into two pieces, and e would not be the shortest path edge
connecting vertices in each of those two pieces, because some other edge on
the cycle must do so. Otherwise, let t be a maximal on the cycle created by
adding e to the MST of G. Removing t would split the original MST into two
pieces, and edges of G connecting those pieces are no shorter than t; so e is
a minimal edge in G’ connecting vertices in those two pieces. The subgraph
induced by the two subsets of vertices are identical for G and G’, so an MST
for G’ consists of e and the MSTs of those two subsets.
2
0
6
7
1
3
5
4
2
2
0
6
0
6
7
5
7
1
1
3
3
4
5
4
Adding the edge 1-3 (shown in gray color in first picture) to the graph
invalidates the MST. To find the MST of new graph, we add the new edge to
the MST of the old graph, which creates a cycle (center). Deleting the
longest edge on the cycle (4-7) yields the MST for new graph. One way to
verify that the spanning tree is minimal is to check that each edge not on
the MST has the largest weight of the cycle that it forms with tree edges.
For example, 4-6 has the largest weight on the cycle 4-6-7-1-3-4.
Note: the process of taking any spanning tree, adding an edge that creates a cycle,
and then deleting a maximal edge on that cycle gives a spanning tree of weight less
than or equal to the original. The new tree weight will be less than the original if and
only if the added edge is shorter than some edge on the cycle.
Before discussing how to find minimum spanning tree forest algorithm, we should
first know the Borůvka’s algorithm and few terms.
Borůvka Step: for each vertex, 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.
Running Time: Running time for Borůvka step is O (m log n)
O (m): finding node adjacent to current node with minimum weight and contact it
O (log n): repetition step in Borůvka algorithm
Note: Borůvka’s step reduces the number of vertices by at least a factor of two.


Let G be a graph with weighted edges.
o w(x, y) : the weight of edge {x, y};
If F is a forest of a subgraph in G,
o F(x, y): the path (if any) connecting x and y in F.
o wF(x, y): the maximum weight of an edge on F(x, y), with the
convention that wF (x, y) = ∞ if x and y are not connected in F.
o F-heavy, if
 w(x, y) > wF(x, y), otherwise, {x, y} is F-light.
Borůvka step + cycle property + randomization = linear time algorithm
Example of F-light and F-heavy edges is shown below:
Not:
G
FH
F-Heavy
F
F-light
GF
Note: the edges of F are all F-light. For any forest F, no F-heavy edge can be in the
minimum spanning forest of G as it is discussed in cycle property.
Let’s now describe the minimum spanning forest algorithm. If the graph is empty,
return an empty forest. Otherwise, proceed as follows:
Step #1:
Apply two successive Borůvka steps to the graph, thereby reducing the
number of vertices by at least a factor of four.
G
G*
Step #2:
In the contracted graph, choose a subgraph H by selecting each edge
independently with probability ½, apply the algorithm recursively to H,
producing a minimum spanning forest F of H. Find all the F-heavy
edges (both those in H and those not in H) and delete them from the
contracted graph.
G
G*
H
H
F
G*
H
F
Step #3:
Apply the algorithm recursively to the remaining graph to compute a
spanning forest F’. Return those edges contracted in step #1 together
with the edges of F’.
G
G*
H
F
G*
Return F
E (G* )  ( F  heavy)
 E (G* )  E ( H )  E ( F )
E (G * )  ( F  heavy)
 E (G*)  E ( H )  E ( F )
F - light
F
Those not in H
V (F )  V (H )
F - heavy
Edges of H
By the cut property, every edge contracted in step #1 is part of minimum spanning
forest. By the cycle property, every edge deleted in step #2 is not a part of minimum
spanning forest. Assuming inductively that step #3 produces minimum spanning
forest shows the correctness of algorithm shown above.
Number of nodes at every step of recursion is shown below with their formula at top
of every node:
ln: leftnode, rn: rightnode
n, m
ln/4, rn/2
ln/4, ln/2
n/4, m/2
n/16, m/4
n/16, n/8
n/4, n/2
n/16, n/4
n/16, n/4
Download