# week 3: minimum spanning trees

of 66/66
1 Week 3: Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm

Post on 23-Feb-2016

34 views

Category:

## Documents

Tags:

• #### edge d

Embed Size (px)

DESCRIPTION

Week 3: Minimum Spanning Trees. Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm. Problem: Laying Telephone Wire. Central office. Wiring: Naïve Approach. Central office. Expensive!. Wiring: Better Approach. Central office. - PowerPoint PPT Presentation

TRANSCRIPT

PowerPoint Presentation

1Week 3: Minimum Spanning TreesDefinition of MSTGeneric MST algorithmKruskal's algorithmPrim's algorithm2Problem: Laying Telephone WireCentral office3Wiring: Nave ApproachCentral officeExpensive!4Wiring: Better ApproachCentral officeMinimize the total length of wire connecting the customers5Definition of MSTInput: connected, and undirected Graph G=(V,E)Each edge (u,v) in E carries a weight w(u,v)Also referred to as cost (length of edge) to connect u and v.Output: A subset T of E that connects all of the vertices in V and whose total weight is minimized.Since the total weight is minimized, the subset T must be acyclic (no circuit). Thus, T is a tree. We call it a spanning tree.The problem of determining the tree T is called the minimum-spanning-tree problem.What is a Minimum-Cost Spanning TreeExample: The graph

Has 16 spanning trees. Some are:

The graph has two minimum-cost spanning trees, each with a cost of 6:

6All 16 of its Spanning TreesComplete GraphMinimum Spanning TreesThe Minimum Spanning Tree for a given graph is the Spanning Tree of minimum cost for that graph.572134213Complete GraphMinimum Spanning Tree9Application of MST: an exampleIn the design of electronic circuitry, it is often necessary to make a set of pins electrically equivalent by wiring them together.To interconnect n pins, we can use n-1 wires, each connecting two pins.We want to minimize the total length of the wires.Minimum Spanning Trees can be used to model this problem.

10Electronic Circuits:

11Electronic Circuits:

12Here is an example of a connected graph and its minimum spanning tree:abhcdefgi48791014422617118Notice that the tree is not unique: replacing (b,c) with (a,h) yields another spanning tree with the same minimum weight.13Growing a MST(Generic Algorithm)Set A is always a subset of some minimum spanning tree. This property is called the invariant Property.An edge (u, v) is a safe edge for A if adding the edge to A does not destroy the invariant.A safe edge is just the CORRECT edge to choose to add to T. GENERIC_MST(G,w)1A:={}2while A does not form a spanning tree do3find an edge (u,v) that is safe for A4A:=A{(u,v)}5return A14V-Sabhcdefgi48791014422617118S S V-S This figure shows a cut (S,V-S) of the graph. The edge (d,c) is the unique light edge crossing the cut.15Safe edgeWe need some definitions and a theorem.A cut (S,V-S) of an undirected graph G=(V,E) is a partition of V.An edge crosses the cut (S,V-S) if one of its endpoints is in S and the other is in V-S.An edge is a light edge crossing a cut if its weight is the minimum of any edge crossing the cut.16Theorem 1Given: G=(V, E) be a connected, undirected graph with a real-valued weight function w defined on E.A be a subset of E that is included in some minimum spanning tree for G.Let (S,V-S) be any cut of G such that for any edge e=(u, v) in A, {u, v} S or {u, v} (V-S). Let (x, y) be a light edge crossing (S,V-S).Then, edge (x, y) is safe for A.Proof: Let Topt be a minimum spanning tree. (Blue) A --a subset of Topt and (x, y)-- a light edge crossing (S, V-S)If (x, y) is NOT safe, then (x, y) is not in T. (See the red edge in Figure)There MUST be another edge (x, y) in Topt crossing (S, V-S).(Green)We can replace (x, y) in Topt with (x, y) and get another tree Topt Since (x, y) is light , Topt is also optimal. 1211111117CorollaryGiven: Let G=(V, E) be a connected, undirected graph with a real-valued weight function w defined on E.Let A be a subset of E that is included in some minimum spanning tree for G.Let C be a connected component (tree) in the forest GA=(V, A).Let (u, v) be a light edge (shortest among all edges connecting C with others components) connecting C to some other component in GA.Then, edge (u,v) is safe for A. (For Kruskals algorithm)