CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 11.

Slides:



Advertisements
Similar presentations
Great Theoretical Ideas in Computer Science for Some.
Advertisements

Combinatorial Algorithms
Great Theoretical Ideas in Computer Science.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 13 Minumum spanning trees Motivation Properties of minimum spanning trees Kruskal’s.
CSE 421 Algorithms Richard Anderson Dijkstra’s algorithm.
CPSC 411, Fall 2008: Set 4 1 CPSC 411 Design and Analysis of Algorithms Set 4: Greedy Algorithms Prof. Jennifer Welch Fall 2008.
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.
Minimal Spanning Trees. Spanning Tree Assume you have an undirected graph G = (V,E) Spanning tree of graph G is tree T = (V,E T E, R) –Tree has same set.
1 Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
CSE 421 Algorithms Richard Anderson Lecture 10 Minimum Spanning Trees.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 10 Instructor: Paul Beame.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 11 Instructor: Paul Beame.
Tirgul 13 Today we’ll solve two questions from last year’s exams.
CPSC 411, Fall 2008: Set 4 1 CPSC 411 Design and Analysis of Algorithms Set 4: Greedy Algorithms Prof. Jennifer Welch Fall 2008.
Lecture 27 CSE 331 Nov 6, Homework related stuff Solutions to HW 7 and HW 8 at the END of the lecture Turn in HW 7.
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.
TECH Computer Science Graph Optimization Problems and Greedy Algorithms Greedy Algorithms  // Make the best choice now! Optimization Problems  Minimizing.
Minimum Spanning Tree Algorithms. What is A Spanning Tree? u v b a c d e f Given a connected, undirected graph G=(V,E), a spanning tree of that graph.
Data Structure & Algorithm 11 – Minimal Spanning Tree JJCAO Steal some from Prof. Yoram Moses & Princeton COS 226.
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.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum.
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.
COSC 2007 Data Structures II Chapter 14 Graphs III.
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.
Dijkstra’s Algorithm. Announcements Assignment #2 Due Tonight Exams Graded Assignment #3 Posted.
1 Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Google News and the theory behind it Sections 4.5, 4.6, 4.7 of [KT]
Introduction to Graph Theory
Minimum Spanning Trees CS 146 Prof. Sin-Min Lee Regina Wang.
Overview of Graph Theory. Some applications of Graph Theory Models for communications and electrical networks Models for computer architectures Network.
1 Chapter 4 Minimum Spanning Trees Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Chapter 9 Finding the Optimum 9.1 Finding the Best Tree.
1 Chapter 5-3 Greedy Algorithms Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
CSEP 521 Applied Algorithms Richard Anderson Winter 2013 Lecture 4.
Minimum- Spanning Trees
1 Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
1 22c:31 Algorithms Minimum-cost Spanning Tree (MST)
CSCI 256 Data Structures and Algorithm Analysis Lecture 10 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
Minimum Spanning Trees Problem Description Why Compute MST? MST in Unweighted Graphs MST in Weighted Graphs –Kruskal’s Algorithm –Prim’s Algorithm 1.
::Network Optimization:: Minimum Spanning Trees and Clustering Taufik Djatna, Dr.Eng. 1.
Minimum Spanning Trees
Great Theoretical Ideas in Computer Science
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Minimal Spanning Trees
Data Structures & Algorithms Graphs
Autumn 2016 Lecture 11 Minimum Spanning Trees (Part II)
Graph Algorithm.
Minimum-Cost Spanning Tree
Minimum Spanning Trees
Autumn 2015 Lecture 11 Minimum Spanning Trees (Part II)
Minimum-Cost Spanning Tree
Data Structures – LECTURE 13 Minumum spanning trees
Minimum-Cost Spanning Tree
CS 583 Analysis of Algorithms
Richard Anderson Lecture 11 Minimum Spanning Trees
Hannah Tang and Brian Tjaden Summer Quarter 2002
Autumn 2015 Lecture 10 Minimum Spanning Trees
Richard Anderson Lecture 10 Minimum Spanning Trees
CSE 373: Data Structures and Algorithms
Autumn 2016 Lecture 10 Minimum Spanning Trees
Winter 2019 Lecture 11 Minimum Spanning Trees (Part II)
Winter 2019 Lecture 10 Minimum Spanning Trees
Minimum-Cost Spanning Tree
Minimum Spanning Trees
Autumn 2019 Lecture 11 Minimum Spanning Trees (Part II)
Presentation transcript:

CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 11

Shortest Path Problem Negative Cost Edges –Dijkstra’s algorithm assumes positive cost edges –For some applications, negative cost edges make sense –Shortest path not well defined if a graph has a negative cost cycle –Bellman-Ford algorithm finds shortest paths in a graph with negative cost edges (or reports the existence of a negative cost cycle). a b c s e g f

Minimum Spanning Tree Minimum spanning tree: Given a connected graph G = (V, E) with real-valued edge weights c e, a MST is a subset of the edges T  E such that T is a spanning tree whose sum of edge weights is minimized G = (V, E) T,  e  T c e = 50

Applications MST is a fundamental problem with diverse applications –Network design telephone, electrical, hydraulic, TV cable, computer, road –Approximation algorithms for NP-hard problems traveling salesperson problem, Steiner tree –Indirect applications max bottleneck paths LDPC codes for error correction image registration with Renyi entropy learning salient features for real-time face verification reducing data storage in sequencing amino acids in a protein model locality of particle interactions in turbulent fluid flows autoconfig protocol for Ethernet bridging to avoid cycles in a network –Cluster analysis

Greedy Algorithms Kruskal's algorithm –Start with T = . Consider edges in ascending order of cost. Insert edge e in T unless doing so would create a cycle Reverse-Delete algorithm –Start with T = E. Consider edges in descending order of cost. Delete edge e from T unless doing so would disconnect T Prim's algorithm –Start with some root node s and greedily grow a tree T from s outward. At each step, add the cheapest edge e to T that has exactly one endpoint in T Remark: All three algorithms produce a MST

Greedy Algorithm 1: Kruskal’s Algorithm Add the cheapest edge that joins disjoint components t a e c g f b s u v Construct the MST with Kruskal’s algorithm Label the edges in order of insertion

Greedy Algorithm 2: Reverse-Delete Algorithm Delete the most expensive edge that does not disconnect the graph t a e c g f b s u v Construct the MST with the reverse- delete algorithm Label the edges in order of removal

Greedy Algorithm 3: Prim’s Algorithm Extend a tree by including the cheapest out going edge t a e c g f b s u v Construct the MST with Prim’s algorithm starting from vertex a Label the edges in order of insertion

Why do the greedy algorithms work? All these algorithms work by repeatedly inserting or deleting edges from a partial solution –Thus to analyze these algorithms, it would be useful to have in hand some basic facts saying when it is “safe” to include an edge in the MST or when it is “safe” to eliminate and edge on the grounds that it couldn’t possible be in the MST For simplicity, assume all edge costs are distinct. Thus, we can refer to “the MST”

When is it safe to include an edge in the MST? Edge inclusion lemma –Let S be a subset of V, and suppose e = (u, v) is the minimum cost edge of E, with u in S and v in V-S –e is in every MST of G. Or equivalently, if e is not in T, then T is not a MST SV - S e

Proof Suppose T is a spanning tree that does not contain e Add e to T, this creates a cycle The cycle must have some edge e 1 = (u 1, v 1 ) with u 1 in S and v 1 in V-S T 1 = T – {e 1 } + {e} is a spanning tree with lower cost Hence, T is not a minimum spanning tree SV - S e e1e1 e is the minimum cost edge between S and V-S

Optimality Proofs Prim’s Algorithm computes a MST Kruskal’s Algorithm computes a MST Show that when an edge is added to the MST by Prim or Kruskal, the edge is the minimum cost edge between S and V-S for some set S

Prim’s Algorithm S = { }; T = { }; while S != V choose the minimum cost edge e = (u,v), with u in S, and v in V-S add e to T add v to S

Prove Prim’s algorithm computes an MST Show an edge e is in the MST when it is added to T

Kruskal’s Algorithm Let C = {{v 1 }, {v 2 },..., {v n }}; T = { } while |C| > 1 Let e = (u, v) with u in C i and v in C j be the minimum cost edge joining distinct sets in C Replace C i and C j by C i U C j Add e to T

Prove Kruskal’s algorithm computes an MST Show an edge e is in the MST when it is added to T

When can we guarantee an edge is not in the MST? Cycle lemma –The most expensive edge on a cycle is never in a MST –Optimality of Reverse-Delete algorithm follows from this SV - S e e1e1 e is the most expensive edge on a cycle involving S and V-S

Dealing with the assumption of no equal weight edges Force the edge weights to be distinct –Add small quantities to the weights –Give a tie breaking rule for equal weight edges