Presentation is loading. Please wait.

Presentation is loading. Please wait.

2015-10-20  2004 SDU Lecture 7- Minimum Spanning Tree-- Extension 1.Properties of Minimum Spanning Tree 2.Secondary Minimum Spanning Tree 3.Bottleneck.

Similar presentations


Presentation on theme: "2015-10-20  2004 SDU Lecture 7- Minimum Spanning Tree-- Extension 1.Properties of Minimum Spanning Tree 2.Secondary Minimum Spanning Tree 3.Bottleneck."— Presentation transcript:

1 2015-10-20  2004 SDU Lecture 7- Minimum Spanning Tree-- Extension 1.Properties of Minimum Spanning Tree 2.Secondary Minimum Spanning Tree 3.Bottleneck Spanning Tree Problem 4.Other MST algorithms

2  2004 SDU 2 Properties of MST Property 1:  Let (u, v) be a minimum-weight edge in a graph G = (V, E), then (u, v) belongs to some minimum spanning tree of G.  Proof: Let A be the empty set of edges. Then A is a subset of some minimum spanning tree, and A does not include (u, v). Then cut (u, V\u) respects A. Edge (u, v) is a light edge crossing cut (u, V\u). According to theorem 23.1, (u, v) is a safe edge for A. Hence, (u, v) belongs to some minimum spanning tree.  Another method: 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 e on the cycle, then T + (u, v) - f is another MST and it contains (u, v).

3  2004 SDU 3 Properties of MST Property 2  Let T be a minimum spanning tree of a graph G, and let L be the sorted list of the edge weights of T, then for any other minimum spanning tree T’ of G, the list L is also the sorted list of edge weights of T’. –A corollary of Property 3. –If all the edge weights are distinct, then MST is unique. Property 3  Let T be a minimum spanning tree of a graph G, and let T’ be an arbitrary spanning tree of G, suppose the edges of each tree are sorted in non-decreasing weight order, that is, w(e 1 )  w(e 2 )  …  w(e n-1 ) and w(e 1 ’)  w(e 2 ’)  …  w(e n-1 ’), then for 1  i  n-1, w(e i )  w(e i ’).

4  2004 SDU 4 Proof of Property 3  (Prove by contradiction) Suppose without loss of generality that there exists an index i  1 such that w(e 1 )  w(e 1 ’), w(e 2 )  w(e 2 ’), …, w(e i-1 )  w(e i-1 ’), but w(e i ) >w(e i ’). This indicates that w(e n-1 )  w(e n-2 )  …  w(e i )>w(e i ’)  w(e i-1 ’)  …  w(e 1 ’). So, if we add any e x ’  { e 1 ’, e 2 ’, …, e i ’} onto T, then either e x ’ is an edge of {e 1, e 2,…, e i-1 }, or a cycle is formed which includes only edges from {e x ’, e 1, e 2,…, e i-1 }. Thus if we add all the edges { e 1 ’, e 2 ’, …, e i ’} onto T and delete {e i, …, e n-1 }, the connected components of { e 1 ’, e 2 ’, …, e i ’, e 1, e 2, …, e i-1 } are just the same as those of {e 1, e 2,.., e i-1 }. Thus {e 1 ’, e 2 ’, …, e i ’ e 1, e 2,.., e i-1 } have the same number of connected components as {e 1, e 2,.., e i-1 } have, i.e., n-i+1. A contradiction, since {e 1 ’, e 2 ’, …, e i ’} are tree edges, they can have at most n-i connected components.

5  2004 SDU 5 edges in {e 1, …, e i-1 } edges in {e 1 ’, …, e i ’} {e 1 ’, …, e i ’} are all included in the components of G i-1, So, red edges cannot have less components.

6  2004 SDU 6 Second-best MST Let G = (V, E) be an undirected, connected graph with weight function w: E  R, and suppose that | E |  | V | and all edge weights are distinct, a second-best minimum spanning tree is a spanning tree T such that w(T) = min T’’  -{T’} {w(T’’)}, where  is the set of all spanning trees of G, and T’ is a minimum spanning tree of G.

7  2004 SDU 7 MST Property Let G = (V, E) be an undirected, connected graph with weight function w: E  R, and suppose that | E |  | V | and all edge weights are distinct. Then the minimum spanning tree of G is unique.  According to Property 2.

8  2004 SDU 8 Second-best MST Properties The second-best minimum spanning tree may not be unique. 1 2 4 5 3 1 2 4 1 4 3 1 2 5 MST

9  2004 SDU 9 Second-best MST Properties A second-best minimum spanning tree can be obtained from the minimum spanning tree by replacing a single edge from the tree with another edge not in the tree.  By contradiction. Suppose T 1 is the MST and T 2 is a second-best MST, and they differ by at least two edges, we will get another spanning tree T 3 which is not equal to T 1 but better than T 2, thus contradicts that T 2 is second-best.

10  2004 SDU 10  Suppose e 1 is the minimum edge in T 1 \ T 2.  Then T 2  {e 1 } contains a cycle on which there must be some edge f which belongs to T 2 but not belongs to T 1, since otherwise T 1 would have a cycle.  Let T 3 =T 2  {e 1 } \f. Then T 3 is a spanning tree. We claim that 1.T 3 is better than T 2. 2.T 3 is not equal to T 1. Thus, contradicts to that T 2 is a second-best MST.

11  2004 SDU 11 Proof of 1: We claim that w(f) > w(e 1 ). Proof by contradiction: Assume that w(f) < w(e 1 ). If we add f to T 1, we get a cycle C, which contains some edge e' in T 1 but e' is not in T 2 (otherwise, T 2 would contain a cycle). Therefore, the set of edges T 4 = T 1 - {e'}  {f} form a spanning tree, and we must have w(e') < w(f), since otherwise T 4 would be a spanning tree with weight less than w(T 1 ). Thus, w(e') < w(f) < w(e 1 ), which contradicts our choice of e 1 as the edge in T 1 - T 2 of minimum weight. Since T 3 =T 2  {e 1 } \f, T 3 is better than T 2. Proof of 2: T 3 differs from T 2 by only one edge, while T 1 differs from T 2 by at least two edges, so, T 3 is not equal to T 1. Thus, we have formed a spanning tree T 3 whose weight is less than w(T 2 ) but is not T 1. Hence, contradicts that T 2 is a second-best minimum spanning tree. Another Method: Let e 1 be the edge with minimum weight in T 2 \ T 1. We aim to find an edge f in T 1 \ T 2, add f into T 2, and delete another edge g in the cycle just formed such that f < g. Note: e 1  T 1 contains a cycle, in which there must be an edge f  T 1 \ T 2 and f < e 1. Then f  T 2 contains a cycle in which there must be an edge g  T 2 \ T 1. Then f < e 1  g. Then T 3 = T 2  f \ g is better than T 2 and is distinct with T 1.

12  2004 SDU 12 Compute the Second-best MST Idea: use the property in previous page:  (u, v): An edge of MST T, (x, y): an edge in G but not in T  w (T’) = w (T) + (w (x, y) – w (u, v)) 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. How to compute max [u, v]?

13  2004 SDU 13 Compute_max(T) 1. for each pair of vertices u, v  V 2. do max[u, v]  0 3. for each vertex s  V 4. do BFS (T, s) BFS(T, s) 1. for each vertex u  V 2. do color[u]  WHITE 3. color[s]  GRAY 4. Q  5. ENQUEUE(Q, s) 6. while Q   7. do u  DEQUEUE(Q) 8. for each v  Adj[u] 9. do if color[v] = WHITE 10. then color[v]  GRAY 11. max[s, v]  max{w(u, v), max[s, u]} 12. ENQUEUE(Q, v) 13. color[u]  BLACK //  (V 2 )

14  2004 SDU 14 Compute the Second-best MST Second-Best-MST(G) 1.Compute a MST T for G 2.Compute max[u, v] for each pair of vertices in T 3.For each edge (u, v) in G but not 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.

15  2004 SDU 15 Time Complexity Analysis Compute-max(T):  (V 2 ) Second-Best-MST(G):  (V 2 ) by using Fibonacci Heap.

16  2004 SDU 16 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 T 1, T 2, …, T m are all the spanning trees G, and the largest edge of each tree is e t1, e t2, …, e tm. If w(e ti )  w(e tj ) for 1  j  m and j  i, then T i is a bottleneck spanning tree.  The value of a BST T is the maximum edge weight among all the edges in T.  The bottleneck spanning tree may not be unique.

17  2004 SDU 17 BST vs. MST Every minimum spanning tree is a bottleneck spanning tree.  Property 3 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 indicates that the weight of e is greater than that of any edges in T’. Removing e from T disconnects T into two subtrees T 1 and T 2, suppose the two end vertices of e are x and y, in T 1 and T 2 respectively. Then there must exist a path in T’ that connects x and y. Then there must be an edge f=(u, v) on this path such that u  T 1 and v  T 2. Thus T 1  T 2  {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, an MST is also a BST.

18  2004 SDU 18 The BST Problem The Problem:  Input: A weighted, connected and undirected graph G.  Output: 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?

19  2004 SDU 19 A Verification Problem A verification problem:  Input: A graph G = (V, E; W) and b  Output: TRUE if the value of the bottleneck spanning tree of G is at most b and FALSE otherwise How to solve this problem in linear time? an integer

20  2004 SDU 20 CHECKBOTTLENECK(G, b) 1. for each vertex u  V[G] 2. do color[u]  WHITE 3. u  randomly chosen vertex in G 4. DFS(u, b) //O(V+E) 5. for each vertex u  V[G] 6. do if color[u] = WHITE 7. then return FALSE 8. return TRUE DFS(u, b) 1. color[u]  GRAY 2. for each v  Adj[u] 3. do if color[v] = WHITE and w(u, v)  b 4. then DFS(v, b) 5. color[u]  BLACK

21  2004 SDU 21 Solve the BST Problem BOTTLENECK(G) 1. sort the weights of edges of G in non-decreasing order: w[1], w[2], …, w[| E |] 2. start  1 3. end  | E | 4. while start < end 5. do middle   (start + end)/2  6. if CHECKBOTTLENECK(G, w[middle]) = FALSE 7. then start  middle+1 8. else end  middle //in the end there is a BST with value =w[start], 9.u  randomly chosen a vertex of G 10.call DFS(u, w[start]) to build a spanning tree

22  2004 SDU 22 Solve the Problem in Linear Time Can the problem be solved in linear time? Time complexity: Sorting: O(E lgV) Finding the value of BST: O((V+E) lgE)=O(E lgV) Total: O(E lgV)

23  2004 SDU 23 MAYBE-MST-A 1.sort the edges into non-increasing order of edge weights w 2.T  E 3.for each edge e, taken in non-increasing order by weight 4. do if T-{e} is a connected graph 5. then T  T-e 6.return T Does this algorithm correctly output a MST? Yes. According to exercise 23.1-5, each time we delete an edge that is of maximum-weight in a cycle, in the last, T contains a MST, and since T itself does not contain cycles, T itself is a MST. Time complexity? O(E 2 ). If e=(u, v), call DFS(T, u), if v is found, return True; return False.

24  2004 SDU 24 MAYBE-MST-B 1.T   2.for each edge e, taken in arbitrary order 3. do if T  {e} has no cycles 4. then T  T  {e} 5.return T Correct? No. Example: Algorithm will return 22 if 221 is the edge order. Time complexity? O(E+VlgV) using weighted lists. 2 2 1

25  2004 SDU 25 MAYBE-MST-C 1.T   2.for each edge e, taken in arbitrary order 3. do T  T  {e} 4. if T has a cycle C 5. then let e’ be the maximum-weight edge on C 6. T  T-{e’} 7.return T Correct? Yes. T=G-{e’| e’ is deleted in the process}. Since each deleted edge e’ is the edge of maximum weight on a cycle, so, after deleting these edges, T still contains a MST according to exercise 23.1-5. And since T does not contain cycles, T itself is a MST. Time complexity? O(VE).


Download ppt "2015-10-20  2004 SDU Lecture 7- Minimum Spanning Tree-- Extension 1.Properties of Minimum Spanning Tree 2.Secondary Minimum Spanning Tree 3.Bottleneck."

Similar presentations


Ads by Google