Minimum Spanning Trees

Slides:



Advertisements
Similar presentations
Minimum Spanning Tree CSE 331 Section 2 James Daly.
Advertisements

Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
CSE 780 Algorithms Advanced Algorithms Minimum spanning tree Generic algorithm Kruskal’s algorithm Prim’s algorithm.
Minimum-Cost Spanning Tree weighted connected undirected graph spanning tree cost of spanning tree is sum of edge costs find spanning tree that has minimum.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
CSE 326: Data Structures Spanning Trees Ben Lerner Summer 2007.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 10 Instructor: Paul Beame.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
1 Chapter 8 The Disjoint Set ADT Concerns with equivalence problems Find and Union.
CSE 373, Copyright S. Tanimoto, 2002 Up-trees - 1 Up-Trees Review of the UNION-FIND ADT Straight implementation with Up-Trees Path compression Worst-case.
Prim’s Algorithm and an MST Speed-Up
Lecture 25 CSE 331 Nov 2, Adding teeth to group talk Form groups of size at most six (6) Pick a group leader I will ask group leader(s) to come.
Minimum Spanning Tree Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Midwestern State University Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm 1.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
2IL05 Data Structures Fall 2007 Lecture 13: 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.
Minimum spanning trees (MST) Def: A spanning tree of a graph G is an acyclic subset of edges of G connecting all vertices in G. A sub-forest of G is an.
Nattee Niparnan. Greedy If solving problem is a series of steps Simply pick the one that “maximize” the immediate outcome Instead of looking for the long.
Union-Find  Application in Kruskal’s Algorithm  Optimizing Union and Find Methods.
Minimum Spanning Trees CSE 373 Data Structures Lecture 21.
1 22c:31 Algorithms Minimum-cost Spanning Tree (MST)
1 Equivalence relations Binary relations: –Let S1 and S2 be two sets, and R be a (binary relation) from S1 to S2 –Not every x in S1 and y in S2 have such.
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),
CSE 373, Copyright S. Tanimoto, 2001 Up-trees - 1 Up-Trees Review of the UNION-FIND ADT Straight implementation with Up-Trees Path compression Worst-case.
Minimum Spanning Trees
Data Structures and Algorithms I Day 19, 11/3/11 Edge-Weighted Graphs
Introduction to Algorithms
May 12th – Minimum Spanning Trees
Shortest Paths and Minimum Spanning Trees
Minimum Spanning Tree Chapter 13.6.
Minimum Spanning Trees
CSE373: Data Structures & Algorithms
CSE 373, Copyright S. Tanimoto, 2001 Up-trees -
CSE373: Data Structures & Algorithms Lecture 19: Spanning Trees
Lecture 22 Minimum Spanning Tree
Lecture 12 Algorithm Analysis
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Autumn 2016 Lecture 11 Minimum Spanning Trees (Part II)
Minimum-Cost Spanning Tree
Minimum Spanning Tree.
Minimum Spanning Trees
Connected Components Minimum Spanning Tree
Minimum Spanning Tree.
Autumn 2015 Lecture 11 Minimum Spanning Trees (Part II)
CSE373: Data Structures & Algorithms Lecture 12: Minimum Spanning Trees Catie Baker Spring 2015.
Minimum Spanning Trees
CSE373: Data Structures & Algorithms Lecture 20: Minimum Spanning Trees Linda Shapiro Spring 2016.
Minimum-Cost Spanning Tree
Chapter 23 Minimum Spanning Tree
Minimum-Cost Spanning Tree
Lecture 12 Algorithm Analysis
CSE373: Data Structures & Algorithms Lecture 19: Spanning Trees
Shortest Paths and Minimum Spanning Trees
CSE332: Data Abstractions Lecture 18: Minimum Spanning Trees
Minimum Spanning Trees
The UNION-FIND Abstract Data Type
Minimum Spanning Tree.
Minimum Spanning Trees
CSE 373: Data Structures and Algorithms
Weighted Graphs & Shortest Paths
Equivalence relations
Lecture 12 Algorithm Analysis
CSE 373: Data Structures and Algorithms
CSE 332: Minimum Spanning Trees
Minimum-Cost Spanning Tree
Minimum Spanning Trees
Disjoint Set Operations: “UNION-FIND” Method
Presentation transcript:

Minimum Spanning Trees Given an undirected graph G=(V,E), find a graph G’=(V,E’) such that E’ is a subset of E |E’| = |V| - 1 G’ is connected is minimal G’ is a minimal spanning tree. Applications: wiring a house, power grids, Internet connections Nov 26, 2001 CSE 373, Autumn 2001

Prim’s algorithm Idea: Grow a tree by adding an edge from the “known” vertices to the “unknown” vertices. Pick the edge with the smallest weight. G v known Nov 26, 2001 CSE 373, Autumn 2001

Example 5 5 v1 v0 5 8 2 2 v3 10 1 v2 v4 10 6 5 3 v5 Nov 26, 2001 CSE 373, Autumn 2001

Analysis Running time. Same as Dijkstra’s: O(|E| log |V|) Correctness: Suppose we have a partially built tree that we know is contained in some minimum spanning tree T. Let (u,v)E, where u is “known” and v is “unknown” and has minimal cost. Then there is a MST T’ that contains the partially built tree and (u,v) that has as low a cost as T. Nov 26, 2001 CSE 373, Autumn 2001

Union/Find Algorithms Equivalence Relations Suppose R is a relation defined on a set S. R is an equivalence relation if: aRa for all aS (reflexive) aRb iff bRa for all a,bS (symmetric) aRb and bRc implies aRc for all a,b,cS (transitive) Examples: Yes No = over the integers  over the integers path from u to v in undirected graphs path from u to v in directed graphs Nov 26, 2001 CSE 373, Autumn 2001

Dynamic Equivalence An equivalence relation defines a partition of S. b a An equivalence relation defines a partition of S. operations: find(a): return the name of the equivalence class of a. union(a,b): merge the equivalence classes of a and b. Dynamic: the classes change because of the union operation. Nov 26, 2001 CSE 373, Autumn 2001

Simple Strategy find(i): return A[i]. O(1) union(a,b): Let i = A[a] 1 2 3 … N-1 i find(i): return A[i]. O(1) union(a,b): Let i = A[a] Let j = A[b] Scan the array and change all the i’s to j’s. O(N) Is there a better way? Yes! Nov 26, 2001 CSE 373, Autumn 2001

Better Strategy Make unions “easy” but finds “hard”. Idea: Keep a tree for each equivalence class. find(x) returns the root of the tree x is in. union(x,y): merge the two trees by making one a subtree of the other. 1 2 3 4 5 6 7 after union(1, 2): 1 3 4 5 6 7 2 Nov 26, 2001 CSE 373, Autumn 2001

Example, continued after union(3, 4): 1 3 5 6 7 2 4 after union(2, 4): 1 3 5 6 7 2 4 after union(2, 4): 1 5 6 7 3 2 4 implicit (array) implementation: A[i] -1 1 3 i 2 4 5 6 7 Nov 26, 2001 CSE 373, Autumn 2001