Lecture 12 Minimum Spanning Tree. Motivating Example: Point to Multipoint Communication Single source, Multiple Destinations Broadcast – All nodes in.

Slides:



Advertisements
Similar presentations
Lecture 15. Graph Algorithms
Advertisements

Minimum Spanning Tree CSE 331 Section 2 James Daly.
UNC Chapel Hill Lin/Foskey/Manocha Minimum Spanning Trees Problem: Connect a set of nodes by a network of minimal total length Some applications: –Communication.
1 Greedy 2 Jose Rolim University of Geneva. Algorithmique Greedy 2Jose Rolim2 Examples Greedy  Minimum Spanning Trees  Shortest Paths Dijkstra.
Chapter 23 Minimum Spanning Trees
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 13 Minumum spanning trees Motivation Properties of minimum spanning trees Kruskal’s.
CSE 780 Algorithms Advanced Algorithms Minimum spanning tree Generic algorithm Kruskal’s algorithm Prim’s algorithm.
Lecture 18: Minimum Spanning Trees Shang-Hua Teng.
Lecture 5 Group Communication. Point to Multipoint Communication Single source, Multiple Destinations Broadcast – All nodes in the network are destinations.
Analysis of Algorithms CS 477/677
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 11 Instructor: Paul Beame.
Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.
Minimum Spanning Trees What is a MST (Minimum Spanning Tree) and how to find it with Prim’s algorithm and Kruskal’s algorithm.
Midwestern State University Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm 1.
1.1 Data Structure and Algorithm Lecture 13 Minimum Spanning Trees Topics Reference: Introduction to Algorithm by Cormen Chapter 13: Minimum Spanning Trees.
Design and Analysis of Computer Algorithm September 10, Design and Analysis of Computer Algorithm Lecture 5-2 Pradondet Nilagupta Department of Computer.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
MST Many of the slides are from Prof. Plaisted’s resources at University of North Carolina at Chapel Hill.
2IL05 Data Structures Fall 2007 Lecture 13: Minimum Spanning Trees.
Spring 2015 Lecture 11: Minimum Spanning Trees
UNC Chapel Hill Lin/Foskey/Manocha Minimum Spanning Trees Problem: Connect a set of nodes by a network of minimal total length Some applications: –Communication.
Minimum Spanning Trees and Kruskal’s Algorithm CLRS 23.
 2004 SDU Lecture 7- Minimum Spanning Tree-- Extension 1.Properties of Minimum Spanning Tree 2.Secondary Minimum Spanning Tree 3.Bottleneck.
1 Minimum Spanning Trees. Minimum- Spanning Trees 1. Concrete example: computer connection 2. Definition of a Minimum- Spanning Tree.
Lecture 19 Greedy Algorithms Minimum Spanning Tree Problem.
November 13, Algorithms and Data Structures Lecture XII Simonas Šaltenis Aalborg University
Chapter 23: Minimum Spanning Trees: A graph optimization problem Given undirected graph G(V,E) and a weight function w(u,v) defined on all edges (u,v)
Finding Minimum Spanning Trees Algorithm Design and Analysis Week 4 Bibliography: [CLRS]- Chap 23 – Minimum.
© 2007 Seth James Nielson Minimum Spanning Trees … or how to bring the world together on a budget.
1 22c:31 Algorithms Minimum-cost Spanning Tree (MST)
© 2007 Seth James Nielson Minimum Spanning Trees … or how to bring the world together on a budget.
MST Lemma Let G = (V, E) be a connected, undirected graph with real-value weights on the edges. Let A be a viable subset of E (i.e. a subset of some MST),
Lecture 12 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Minimum Spanning Trees Problem Description Why Compute MST? MST in Unweighted Graphs MST in Weighted Graphs –Kruskal’s Algorithm –Prim’s Algorithm 1.
Algorithm Design and Analysis June 11, Algorithm Design and Analysis Pradondet Nilagupta Department of Computer Engineering This lecture note.
Midwestern State University Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm 1.
November 22, Algorithms and Data Structures Lecture XII Simonas Šaltenis Nykredit Center for Database Research Aalborg University
Greedy Algorithms General principle of greedy algorithm
Lecture ? The Algorithms of Kruskal and Prim
Introduction to Algorithms
Minimum Spanning Trees
Lecture 22 Minimum Spanning Tree
Spanning Trees Kruskel’s Algorithm Prim’s Algorithm
CS 3343: Analysis of Algorithms
Minimum Spanning Trees
Lecture 12 Algorithm Analysis
CISC 235: Topic 10 Graph Algorithms.
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Minimum Spanning Trees
Minimum-Cost Spanning Tree
Minimum Spanning Tree Neil Tang 3/25/2010
Minimum Spanning Tree.
Algorithms and Data Structures Lecture XII
Minimum-Cost Spanning Tree
Data Structures – LECTURE 13 Minumum spanning trees
Chapter 23 Minimum Spanning Tree
Minimum-Cost Spanning Tree
CS 583 Analysis of Algorithms
Kruskal’s Minimum Spanning Tree Algorithm
Analysis of Algorithms CS 477/677
Lecture 12 Algorithm Analysis
Minimum Spanning Trees
Greedy Algorithms Comp 122, Spring 2004.
Lecture 12 Algorithm Analysis
Total running time is O(E lg E).
Advanced Algorithms Analysis and Design
Lecture 14 Minimum Spanning Tree (cont’d)
Chapter 23: Minimum Spanning Trees: A graph optimization problem
Minimum-Cost Spanning Tree
Minimum Spanning Trees
Presentation transcript:

Lecture 12 Minimum Spanning Tree

Motivating Example: Point to Multipoint Communication Single source, Multiple Destinations Broadcast – All nodes in the network are destinations Multicast –Some nodes in the network are destinations Only one copy of the information travels along common edges Message replication along forking points only. 1 2

Spanning Tree We consider undirected graphs here. A tree is a connected graph without a cycle A spanning tree is a tree which has all vertices of the graph There may be multiple spanning trees We need to choose the minimum weight tree for broadcast.

Blue edge spanning tree is the minimum weight spanning tree

Properties of a Tree A tree of V vertices has V-1 edges There exists a unique path between any two vertices of a tree. Adding any edge to a tree creates a unique cycle. Breaking any edge on this cycle restores a tree.

Minimum Spanning Tree Construction We maintain a set of edges A, which is initially empty. Edges are added to A one at a time such that finally A becomes a minimum spanning tree. Edges are never removed from A. So ``safe’’ edges must be added to A, i.e., at any stage A must be a part of a spanning tree.

Safe Edge Addition Consider a cut in a graph (a cut consists of 2 sets which partition the vertex set). A cut respects set A if no edge in A crosses the cut. A minimum weight edge crossing a cut is denoted a light weight edge in the cut.

Let A be a subset of a MST (minimum weight spanning tree). Let (S, V – S) be any cut that respects A Let edge (u, v) be a light edge crossing the cut Then A  (u, v) is subset of a MST

Assume that all the edge weights are distinct. Let no MST containing A contain edge (u, v). Add the edge (u, v) to T Consider a MST T containing A Since (u, v) is not in T, T  (u, v) contains a cycle, and (u, v) is in the cycle. Edge (u, v) are in the opposite sides of the cut. Since any cycle must cross the cut even number of times, there exists at least one other edge (x, y) crossing the cut. Clearly, w(x, y) > w(u, v).

The edge (x, y) is not in A because (x, y) crosses the cut, and the cut respects A. Removing (x, y) from the cycle, breaks the cycle and hence creates a spanning tree, T’, s.t. T’ = T  (u, v) – (x, y) w(T’) = w(T) + w(u, v) – w(x, y)  w(T) (as w(u, v) < w(x, y)) This contradicts the fact that T is a MST.

So we always find a cut that respects A, And add a light edge across the cut to A. Kruskals and Prims algorithms find the cut differently.

Kruskals Algorithm A =  1.For each vertex u in V, Create_Set(u) 2.Sort E in increasing order by weight w 3.For each edge (u,v) in the sorted list –If Set(u)  = Set(v) Add (u,v) to E Union Set(u) and Set(v) Return A;

Complexity Analysis The operations create set, testing whether set(u) == set(v), union operations can be done in log V operations, using Union find data structure. Step 1 can be done in Vlog V Step 2 can be done in Elog E Step 3 can be done in Elog V Overall complexity is O(Vlog V + Elog E + Elog V) or O((V + E)log V)

Prims Algorithm Maintains a set of vertices S already in the spanning tree. Initially, S consists of one vertex r, selected arbitrarily. For every vertex u in V – S, maintain the weight of the lightest edge between u and any vertex in S. If there is no edge between u and S, then this weight associated with u is infinity.

Add the vertex with the least weight to S. This is in effect adding the light weight edge crossing the cut S and V-S. Whenever a vertex is added to S, the weights of all its neighbors are reduced, if necessary.

Pseudo-Code For each u in V, key[u] =  S =  Pred[r] = NULL Key[r] = 0 While V  = S u = Extract_Min(V-S) For each (v in Adj(u)) if (v not in S) key(v) = min(w(u, v), key(v)) and pred(v) = u Add u in S

For each v in Adj[u]…. can be done in E complexity Rest of the loop can be done in V 2 complexity So, overall O(V 2 ) Using heaps we can solve in O((V + E)logV)

Example 0 s s s s s s