© 2007 Seth James Nielson Minimum Spanning Trees … or how to bring the world together on a budget.

Slides:



Advertisements
Similar presentations
Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm.
Advertisements

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.
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.
1 Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm.
Analysis of Algorithms CS 477/677
Lecture 12 Minimum Spanning Tree. Motivating Example: Point to Multipoint Communication Single source, Multiple Destinations Broadcast – All nodes in.
CSE Algorithms Minimum Spanning Trees Union-Find Algorithm
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
Minimum Spanning Trees. a b d f g e c a b d f g e c.
David Luebke 1 9/10/2015 CS 332: Algorithms Single-Source Shortest Path.
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.
Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm Binary Search Trees1.
Algorithms: Design and Analysis Summer School 2013 at VIASM: Random Structures and Algorithms Lecture 3: Greedy algorithms Phan Th ị Hà D ươ ng 1.
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.
1 Minimum Spanning Trees. Minimum- Spanning Trees 1. Concrete example: computer connection 2. Definition of a Minimum- Spanning Tree.
1 Greedy Algorithms and MST Dr. Ying Lu RAIK 283 Data Structures & Algorithms.
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.
Greedy Algorithms Z. GuoUNC Chapel Hill CLRS CH. 16, 23, & 24.
© 2007 Seth James Nielson Minimum Spanning Trees … or how to bring the world together on a budget.
1 2/23/2016 ITCS 6114 Topological Sort Minimum Spanning Trees.
1 Week 3: Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm.
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.
Algorithm Design and Analysis June 11, Algorithm Design and Analysis Pradondet Nilagupta Department of Computer Engineering This lecture note.
Minimum Spanning Tree. p2. Minimum Spanning Tree G=(V,E): connected and undirected w: E  R, weight function a b g h i c f d e
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
Tirgul 12 Solving T4 Q. 3,4 Rehearsal about MST and Union-Find
Greedy Algorithms General principle of greedy algorithm
Lecture ? The Algorithms of Kruskal and Prim
Introduction to Algorithms
Topological Sort Minimum Spanning Tree
Spanning Trees Kruskel’s Algorithm Prim’s Algorithm
CS 3343: Analysis of Algorithms
Minimum Spanning Trees
Minimum Spanning Tree Shortest Paths
CSC 413/513: Intro to Algorithms
Minimum Spanning Trees
Lecture 12 Algorithm Analysis
CISC 235: Topic 10 Graph Algorithms.
CS6045: Advanced Algorithms
Algorithms and Data Structures Lecture XII
CS200: Algorithm Analysis
Data Structures – LECTURE 13 Minumum spanning trees
Chapter 23 Minimum Spanning Tree
CS 583 Analysis of Algorithms
Lecture 12 Algorithm Analysis
Minimum Spanning Trees
Algorithms Searching in a Graph.
Minimum spanning tree Shortest path algorithms
Greedy Algorithms Comp 122, Spring 2004.
Lecture 12 Algorithm Analysis
Total running time is O(E lg E).
Advanced Algorithms Analysis and Design
Finding Minimum Spanning Trees
Chapter 23: Minimum Spanning Trees: A graph optimization problem
Minimum Spanning Trees
Presentation transcript:

© 2007 Seth James Nielson Minimum Spanning Trees … or how to bring the world together on a budget

© 2007 Seth James Nielson Remembering Graphs Relationships between entities Weighted edges quantify relationships

© 2007 Seth James Nielson Carving Trees from Graphs BFS creates tree (or forest) –BF-tree contains shortest paths DFS creates tree (or forest)

© 2007 Seth James Nielson Spanning Tree Derived from connected graph Contains all vertices Is a tree (no cycles) Obviously, there could be many

© 2007 Seth James Nielson The Math View G=(V,E) is a connected graph T=(V,E) is a spanning tree on G iff –V T = V G, E T  E G –T contains no cycles

© 2007 Seth James Nielson RETURN OF THE SEARCH! BF tree is a spanning tree DF tree is a spanning tree

© 2007 Seth James Nielson Philosophical View A tree on a graph is –filter on the set of relationships –enable discovery of new relationships –or meta-relationships For example, BF and DF trees

© 2007 Seth James Nielson Spanning Trees and Weights Tree in weighted graph has an associated weight Weight is just sum of weights of edges in the tree

© 2007 Seth James Nielson Minimum Spanning Tree An MST on G –is a spanning tree –weight <= every other ST on G NOTE: any connected subgraph with min weight must be a tree –Removing a cyclic edge Preserves connectedness Reduces weight

© 2007 Seth James Nielson Obvious application Running electrical wires or water pipes –Assuming shorter wires/pipes are cheaper Car / airplane repair –Vertices = states, edges = repairs (open hood, remove air filter, remove carburator…) –Eliminating edges simplifies the design

© 2007 Seth James Nielson A “Cut” of G A cut partitions vertices (S,V-S) Edge (u,v) crosses the cut if –u in S –v in V-S A cut respects A  E if none of the edges in A cross the cut

© 2007 Seth James Nielson “Light” Edges A light edge satisfying a property –Has min weight for all edges that satisfy the property

© 2007 Seth James Nielson Generic MST Algorithm (setup) Let A be a subset of E A is a subset of some MST (u,v) is a safe edge for A iff –A U {(u,v)}  MST

© 2007 Seth James Nielson Generic-MST(G, w) 1.A <- 0 2.while A is not a spanning tree 3. do find edge (u,v) that is safe for A 4. A <- A U {(u,v)} 5.return A

© 2007 Seth James Nielson Generic MST Loop Invariant Initialization: –Line 1 –Trivially satisfies Maintenance: –Lines 2-4 –Only add safe edges Termination: –All edges are in MST –Therefore, A (line 5) must be an MST

© 2007 Seth James Nielson Theorem 1 (recognizing safe edges) Let G=(V,E) is connected, undirected, and weighted Let A be a subset of E (in some MST) Let (S,V-S) be a cut of G that respects A Let (u,v) be a light edge crossing (S, V- S) (u,v) is safe for A

© 2007 Seth James Nielson Proof of Theorem 1 See CLRS 23.1 (p )

© 2007 Seth James Nielson Generic Uselessness Of course, the generic algorithm isn’t very useful The hard part if finding a safe edge. Two greedy algorithms –Kruskal’s algorithm –Prim’s algorithm

© 2007 Seth James Nielson MST-Kruskal(G,W) 1.A = {} 2.for each v in V 3. MAKE-SET(v) 4.sort E in nondecreasing order by weight 5.for (u,v) in sorted-E 6. if FIND-SET(u) != FIND-SET(v) 7. A = A + {(u,v)} 8. UNION(u,v) 9.return A

© 2007 Seth James Nielson Kruskal: Intuition Create disjoint sets for each v In the loop –Find light edge (using sort) –The disjoint sets represent the cut (partition) –The cut (A,V-A) respects A –(u,v) is light edge crossing cut –(u,v) is safe for A

© 2007 Seth James Nielson Kruskal’s Running Time MAKE-SET takes O(v) time Sorting edges takes O(E log E) Find set for each e O(E a(V)) Union is O(1) Total time is O(E log E) (or O(E log V) )

© 2007 Seth James Nielson Prim’s Algorithm Starts with arbitrary root In loop –Adds a light edge (u,v) u in the tree v out of the tree –Uses a min priority queue for v MST-PRIM(G,W,r) on next slide

© 2007 Seth James Nielson 1. for each u in V 2. key[u] = INFINITY 3. p[u] = NULL 4. key[r] = 0 5. Q = CREATE-MIN-QUEUE(V) 6. while Q != {} 7. u = EXTRACT-MIN(Q) 8. for each v adjacent to u 9. if v is in Q and w(u,v) < key[v] 10. p[v] = u 11. key[v] = w(u,v) 12. A = { (v,p[v]): v is in V - {r}} 13. return A

© 2007 Seth James Nielson Prim’s Running Time If we use a binary heap –O(E lg V) Fibonacci heap –O(E + V lg V) –(See CLRS 20 and end of 23.2)