Download presentation

Presentation is loading. Please wait.

Published byBrenna Marlar Modified about 1 year ago

1
Minimum Spanning Tree (MST) form a tree that connects all the vertices (spanning tree). minimize the total edge weight of the spanning tree. Problem Select edges in a connected and undirected graph to 1 f d a b ce g Total weight of tree edges: 14

2
Applications 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

3
A 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? Cheapest edge that maintains the invariant

4
Cut 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. f d a b c e g

5
Respected by a Cut f d a b c e g Ex. S = {a, b, c, d} A = { (a, b), (d, g), (f, b), (a, f) } A = A { (b, d) } The cut (S, V – S) respects A but not A (edge (b, d) crosses the cut). 12

6
Light Edge f d a b c e g Ex. S = {a, b, c, d} Edge {b, e} has weight 3, “lighter” than the other edges {a, d}, {b, d}, and {c, e} that also cross the cut. light edge is the edge that crosses a cut with the minimum weight. 2

7
Light 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. S V – S u v A includes all red edges. 2

8
Why Light Edge Is Safe? S V – S u v 2 A y x A { (u, v) } T ', i.e., (u, v) is safe for A. Proof Suppose T is an MST (consisting of red edges) that includes A. Suppose the light edge (u, v) T. We have T { (u, v) } contains a cycle. There exists an edge (x, y) T that crosses the cut (S, V – S). The new spanning tree T ' = T – { (x, y) } { (u, v) } has total weight the total weight of T. Hence T ' is an MST also.

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 =. If (u, v) is a light edge connecting C to some other component in G, then (u, v) is safe for A. A A u v C 7 4 w 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. A includes the five red edges. 8

10
Finding 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. Kruskal’s algorithm Prim’s algorithm A is a tree. The safe edge is a light edge connecting a vertex in A to one not in A.

11
Kruskal’s Algorithm - an Example f d a b c e g Total weight of the MST: 14

12
Kruskal’s 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

13
Kruskal’s Algorithm - Analysis Sorting takes O(E lg E) time. (V) Make-Set operations (E) Find-Set operations (V) Union operationns Total time O(E lg*V) Running time of the algorithm is O(E lg E) = O(E lg V) (if properly implemented) lg* V = k such that 0 < lg lg … lg V ≤ 1 k

14
Implementation of Disjoint-Set Forest Each member points only to its parent g d b eh c f c he b g d f {b, c, e, h}{f, d, g} Find-Set(b) = c Find-Set(d) = f {b, c, e, h} + {f, d, g} Union(e, g)

15
Running Time of Set Operations c Make-Set(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)

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google