Minimum Spanning Trees Definition Two properties of MST’s Prim and Kruskal’s Algorithm –Proofs of correctness Boruvka’s algorithm Verifying an MST Randomized.

Slides:



Advertisements
Similar presentations
Advanced Algorithm Design and Analysis Jiaheng Lu Renmin University of China
Advertisements

Graph Algorithms - 4 Algorithm Design and Analysis Victor AdamchikCS Spring 2014 Lecture 14Feb 14, 2014Carnegie Mellon University.
Greedy Algorithms Greed is good. (Some of the time)
Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm.
A Randomized Linear-Time Algorithm to Find Minimum Spaning Trees 黃則翰 R 蘇承祖 R 張紘睿 R 許智程 D 戴于晉 R David R. Karger.
A Randomized Linear-Time Algorithm to Find Minimum Spanning Trees David R. Karger David R. Karger Philip N. Klein Philip N. Klein Robert E. Tarjan.
1 Greedy 2 Jose Rolim University of Geneva. Algorithmique Greedy 2Jose Rolim2 Examples Greedy  Minimum Spanning Trees  Shortest Paths Dijkstra.
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.
Minimum Spanning Trees Definition Algorithms –Prim –Kruskal Proofs of correctness.
Shortest Paths Definitions Single Source Algorithms –Bellman Ford –DAG shortest path algorithm –Dijkstra All Pairs Algorithms –Using Single Source Algorithms.
1 7-MST Minimal Spanning Trees Fonts: MTExtra:  (comment) Symbol:  Wingdings: Fonts: MTExtra:  (comment) Symbol:  Wingdings:
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Analysis of Algorithms CS 477/677
Dynamic Sets and Data Structures Over the course of an algorithm’s execution, an algorithm may maintain a dynamic set of objects The algorithm will perform.
Shortest Paths Definitions Single Source Algorithms
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.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 11 Instructor: Paul Beame.
Dynamic Sets and Data Structures Over the course of an algorithm’s execution, an algorithm may maintain a dynamic set of objects The algorithm will perform.
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.
Minimal Spanning Trees What is a minimal spanning tree (MST) and how to find one.
Minimum Spanning Trees and Clustering By Swee-Ling Tang April 20, /20/20101.
Design and Analysis of Computer Algorithm September 10, Design and Analysis of Computer Algorithm Lecture 5-2 Pradondet Nilagupta Department of Computer.
9/10/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 8 Greedy Graph.
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.
1 Minimum Spanning Trees. Minimum- Spanning Trees 1. Concrete example: computer connection 2. Definition of a Minimum- Spanning Tree.
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)
F d a b c e g Prim’s Algorithm – an Example edge candidates choosen.
Minimum- Spanning Trees
1 22c:31 Algorithms Minimum-cost Spanning Tree (MST)
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
November 22, Algorithms and Data Structures Lecture XII Simonas Šaltenis Nykredit Center for Database Research Aalborg University
Lecture ? The Algorithms of Kruskal and Prim
Introduction to Algorithms
Minimum Spanning Trees
Minimum Spanning Trees
Lecture 12 Algorithm Analysis
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Data Structures & Algorithms Graphs
Autumn 2016 Lecture 11 Minimum Spanning Trees (Part II)
Minimum-Cost Spanning Tree
Minimum Spanning Tree.
Minimum Spanning Tree.
Algorithms and Data Structures Lecture XII
Minimum-Cost Spanning Tree
Data Structures – LECTURE 13 Minumum spanning trees
CS 583 Analysis of Algorithms
Lecture 12 Algorithm Analysis
Minimum Spanning Tree Algorithms
Minimum Spanning Tree.
Minimum Spanning Trees
CSE 373: Data Structures and Algorithms
Lecture 12 Algorithm Analysis
Winter 2019 Lecture 11 Minimum Spanning Trees (Part II)
CSE 373: Data Structures and Algorithms
Chapter 23: Minimum Spanning Trees: A graph optimization problem
Minimum-Cost Spanning Tree
Minimum Spanning Trees
Autumn 2019 Lecture 11 Minimum Spanning Trees (Part II)
Presentation transcript:

Minimum Spanning Trees Definition Two properties of MST’s Prim and Kruskal’s Algorithm –Proofs of correctness Boruvka’s algorithm Verifying an MST Randomized algorithm in linear time

Problem Definition Input –Weighted, connected undirected graph G=(V,E) Weight (length) function w on each edge e in E Task –Compute a spanning tree of G of minimum total weight Spanning tree –If there are n nodes in G, a spanning tree consists of n-1 edges such that no cycles are formed

Example ABC D EFG Input: ABC D EFG Output:

Two Properties of MST’s Cycle Property: For any cycle C in a graph, the heaviest edge in C does not appear in the minimum spanning tree –Used to rule edges out Cut Property: For any proper non-empty subset X of the vertices, the lightest edge with exactly one endpoint in X belongs to the minimum spanning forest –Used to rule edges in

Cycle Property Illustration/Proof Proof by contradiction: –Suppose T is an MST with such an edge e. –Derive a contradiction showing that T is not an MST ABC D EFG ABC D EFG

Cut Property Illustration/Proof Proof by contradiction: –Suppose T is an MST without such an edge e. –Derive a contradiction showing that T is not an MST ABC D EFG ABC D EFG

Three Classic Greedy Algorithms Kruskal’s approach –Select the minimum weight edge that does not form a cycle Prim’s approach –Choose an arbitrary start node v –At any point in time, we have connected component N containing v and other nodes V-N –Choose the minimum weight edge from N to V-N Boruvka’s approach –Prim “in parallel”

Illustrate the execution of Kruskal and Prim’s algorithms on the following input graph. Let D be the arbitrary start node for Prim’s algorithm. Example ABC D EFG

Prim Implementation Use a priority queue to organize nodes in V-N to facilitate finding closest node. –Extract-Min operation –Decrease-key operation Describe how we could implement Prim using a priority queue. ABC D EFG

Running Time of Prim How many extract-min operations will we perform? How many decrease-key operations will we perform? How much time to build initial priority queue? Given binary heap implementation, what is the running time? Fibonacci heap: –Decrease-key drops to O(1) amortized time

Kruskal Implementation Kruskal’s Algorithm –Adding edge (u,v) to the current set of edges T forms a cycle if and only if u and v are in the same connected component. ABC D EFG

Disjoint Set Data Stucture (Ch 21) Given a universe U of objects –Maintain a collection of sets S i such that Union i S i = U S i intersect S j is empty –Find-set(x): Returns set S i that contains x –Merge(S i, S j ): Returns new set S k = S i union S j Describe how we can implement cycle detection with this data structure. ABC D EFG

Running Time of Kruskal How many merges will we perform? How many Find-set operations will we perform? –Each can be implemented in amortized  (V) time where  is a very slow growing function. What other operations do we need to implement? Overall running time?

Proofs of Correctness Why do we know each edge that is added in Kruskal’s algorithm is part of an MST? Why do we know that each edge added in Prim’s algorithm is part of an MST?

Boruvka’s Algorithm Prim “in parallel” Boruvka Step: –We have a graph of vertices –For each v in V, select the minimum weight edge connected to v –Update Contract all selected edges, replacing each connected component by a single vertex Delete loops, and keep only the lowest weight edge in a multi- edge Run Boruvka steps until we have a single node

Boruvka Step Illustration ABC D EFG ABC D EFG A’B’ 7

Boruvka’s Algorithm Analysis Correctness: –How can we verify that each edge we add is part of an MST? Running time: –What is the running time of a Boruvka Step? –How many Boruvka steps must we implement in the worst case?

Verification Problem Input –Weighted, connected undirected graph G=(V,E) Weight (length) function w on each edge e in E –A spanning tree T of G Task –Answer yes/no if T is a minimum spanning tree for G Two key concepts –Decision problem: problem with yes/no answer –Verification: Is it easier to verify an answer as correct as compared to generating an answer?

Key idea: T(u,v) Suppose we have a tree T For each edge (u,v) not in T, let T(u,v) be the heaviest edge on the (u,v) path in T If w(u,v) > w(T(u,v)), then (u,v) should not be in T. ABC D EFG Consider edge (B,F) with weight 7. T(B,F) = (C,G) which has weight 6. (B,F) is appropriately not in T as w(B,F) > w(C,G).

Verification Algorithm For each edge (u,v) not in T, find T(u,v). Compare w (u,v) to w(T(u,v)) If all are ok, then return yes, else return no. Running time? –O(E) time to perform comparisons –Sophisticated techniques to find all the T(u,v) in O(E) time.

Randomized Algorithm 1.Run Baruvka’s Step 2 times a)If there were originally n nodes, how many in reduced problem 2.Random Sampling a)Make a smaller subgraph by choosing each edge with probability ½ b)Recursively compute minimum spanning tree (or perhaps forest) F on this reduced graph c)Use verification algorithm to eliminate any edges (u,v) not in F whose weight is more than weight of F(u,v). 3.Apply algorithm recursively to the remaining graph to compute a spanning tree T’ a)Knit together tree from step 1 with F’ to form spanning tree

Graph G o Step 1: Run 2 Baruvka Steps: Contracted Graph G 1 List of edges E 1 Step 2: Construct G 2 by sampling ½ edges Step 2: Recursively Construct T 2 for graph G 2 Step 2: Use T 2 to identify edges E 2 that cannot be in MST for G 1 Graph G 3 = G 1 – E 2 Step 3: Recursively Construct T 3 for graph G 3 Step 3: Return T 3 melded with edges E 1 as final tree T 4 Tree T 4 = T 3 union E 1 Visualization

Graph G o Step 1: Run 2 Baruvka Steps: Contracted Graph G 1 List of edges E 1 Step 2: Construct G 2 by sampling ½ edges Step 2: Recursively Construct T 2 for graph G 2 Step 2: Use T 2 to identify edges E 2 that cannot be in MST for G 1 Graph G 3 = G 1 – E 2 Step 3: Recursively Construct T 3 for graph G 3 Step 3: Return T 3 melded with edges E 1 as final tree T 4 Tree T 4 = T 3 union E 1 Analysis Intuition G 2 has at most ½ the edges of G 0 G 3 edges bounded by ½ nodes of G 0