# 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.

## Presentation on theme: "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."— Presentation transcript:

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 2 7 5 7 4 1 3 4 4 5 2 Total weight of tree edges: 14

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

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

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 2 7 5 7 1 4 1 3 4 4 5 2

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

Light Edge f d a b c e g 2 7 5 7 1 4 1 3 4 4 5 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

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 4 2 6 u v A includes all red edges. 2

Why Light Edge Is Safe? S V – S 4 2 6 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.

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

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.

Kruskal’s Algorithm - an Example f d a b c e g 2 7 5 7 1 4 1 3 4 4 5 2 Total weight of the MST: 14

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

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

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)

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)

Download ppt "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."

Similar presentations