Graph Algorithms - 4 Algorithm Design and Analysis Victor AdamchikCS 15-451 Spring 2014 Lecture 14Feb 14, 2014Carnegie Mellon University.

Slides:



Advertisements
Similar presentations
Graph Algorithms - 3 Algorithm Design and Analysis Victor AdamchikCS Spring 2014 Lecture 13Feb 12, 2014Carnegie Mellon University.
Advertisements

Graph Algorithms Algorithm Design and Analysis Victor AdamchikCS Spring 2014 Lecture 11Feb 07, 2014Carnegie Mellon University.
Lecture 15. Graph Algorithms
Graphs - II Algorithms G. Miller V. Adamchik CS Spring 2014 Carnegie Mellon University.
Comp 122, Spring 2004 Greedy Algorithms. greedy - 2 Lin / Devi Comp 122, Fall 2003 Overview  Like dynamic programming, used to solve optimization problems.
10.4 Spanning Trees. Def Def: Let G be a simple graph. A spanning tree of G is a subgraph of G that is a tree containing every vertex of G See handout.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
Minimum Spanning Trees Definition Two properties of MST’s Prim and Kruskal’s Algorithm –Proofs of correctness Boruvka’s algorithm Verifying an MST Randomized.
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
MIN-COST ABORESCENCES YQ Lu. Aborescence Definition: Given a directed graph G=(V,E) and a root r, an aborescence rooted at r is a subgraph T that each.
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 13 Minumum spanning trees Motivation Properties of minimum spanning trees Kruskal’s.
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 Spanning Trees Definition Algorithms –Prim –Kruskal Proofs of correctness.
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
Spanning Trees.
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)
Lecture 12 Minimum Spanning Tree. Motivating Example: Point to Multipoint Communication Single source, Multiple Destinations Broadcast – All nodes in.
CSE 421 Algorithms Richard Anderson Lecture 10 Minimum Spanning Trees.
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.
Minimum Spanning Trees
Tirgul 13 Today we’ll solve two questions from last year’s exams.
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.
Minimal Spanning Trees What is a minimal spanning tree (MST) and how to find one.
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.
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
MST Many of the slides are from Prof. Plaisted’s resources at University of North Carolina at Chapel Hill.
SPANNING TREES Lecture 21 CS2110 – Spring
2IL05 Data Structures Fall 2007 Lecture 13: Minimum Spanning Trees.
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.
Spanning Trees CSIT 402 Data Structures II 1. 2 Two Algorithms Prim: (build tree incrementally) – Pick lower cost edge connected to known (incomplete)
Minimum Spanning Trees CSE 373 Data Structures Lecture 21.
Spanning tree Lecture 4.
Minimum- Spanning Trees
1 22c:31 Algorithms Minimum-cost Spanning Tree (MST)
CS38 Introduction to Algorithms Lecture 3 April 8, 2014.
Lecture 12 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Data Structures & Algorithms Graphs Richard Newman based on book by R. Sedgewick and slides by S. Sahni.
Minimum Spanning Trees
Chapter 9 : Graphs Part II (Minimum Spanning Trees)
Introduction to Algorithms
Minimum Spanning Trees and Shortest Paths
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
CSCE350 Algorithms and Data Structure
Spanning Trees.
Minimum Spanning Trees
Minimum Spanning Tree.
Autumn 2015 Lecture 11 Minimum Spanning Trees (Part II)
Minimum-Cost Spanning Tree
Data Structures – LECTURE 13 Minumum spanning trees
Minimum-Cost Spanning Tree
Autumn 2015 Lecture 10 Minimum Spanning Trees
Lecture 12 Algorithm Analysis
Autumn 2016 Lecture 10 Minimum Spanning Trees
Lecture 12 Algorithm Analysis
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:

Graph Algorithms - 4 Algorithm Design and Analysis Victor AdamchikCS Spring 2014 Lecture 14Feb 14, 2014Carnegie Mellon University

Plan: Min-cost Spanning Tree Algorithms: - Prim’s (review) - Arborescence problem Kleinberg-Tardos, Ch. 4

Page’s Rank BillionairesNevanlinna Prize, 10k euro Jon KleinbergPage and Brin

The Minimum Spanning Tree for Undirected Graphs Find a spanning tree of minimum total weight. The weight of a spanning tree is the sum of the weights on all the edges which comprise the spanning tree.

Boruvka’s Algorithm (1926) Kruskal’s Algorithm (1956) Prim's Algorithm (1957) The Minimum Spanning Tree

First described by Jarnık in a 1929 letter to Boruvka. Rediscovered by Kruskal in 1956, by Prim in 1957, by Loberman and Weinberger in 1957, and finally by Dijkstra in Prim's Algorithm Greedy algorithm that builds a tree one VERTEX at a time.

- Start with an arbitrary vertex as component C -Expand C by adding a new vertex having the minimum weight edge with exactly one end point in C. - Continue to grow the tree until C gets all vertices. Prim's Algorithm algorithm builds a tree one VERTEX at a time.

Prim's Algorithm BC EF D A C={a} d-1 c-1 b-4 e-oo f-oo heap decleteMin

Prim's Algorithm BC EF D A C={a,d} c-1 b-4 e-oo f-oo heap

Prim's Algorithm BC EF D A C={a,d} c-1 b-4 e-5 f-7 heap decreaseKey

Prim's Algorithm bc ef d a C={a,d,c,b,e,f} Weight = = 9

Lemma: Let X be any subset of the vertices of G, and let edge e be the smallest edge connecting X to G-X. Then e is part of the minimum spanning tree. Property of the MST

What is the worst-case runtime complexity of Prim's Algorithm? We run deleteMin V times We update the queue E times O(V*log V + E*log V) deleteMindecreaseKey O(1) – Fibonacci heap

The Minimum Spanning Tree for Directed Graphs x y z Start at X and follow the greedy approach We will get a tree of size 5, though the min is 4. However there is even a smaller subset of edges - 3

The Minimum Spanning Tree for Directed Graphs x y z This example exhibits two problems What is the meaning of MST for directed graphs? How would you find it? Clearly, we want to have a rooted tree, in which we can reach any vertex staring at the root Clearly, the greedy approach of Prim’s does not work

Arborescences Def. Given a digraph G = (V, E) and a vertex r ∈ V, an arborescence (rooted at r) is a treeT s.t. ・ T is a spanning tree of G if we ignore the direction of edges. ・ There is a directed unique path in T from r to each other node v ∈ V. r

Given a digraph G, find an arborescence rooted at r (if one exists) Run DFS or BFS

Arborescences Theorem. A subgraph T of G is an arborescence rooted at r iff T has no directed cycles and each node v ≠ r has exactly one entering edge. Proof. ⇒ ) Trivial. ⇐ ) Start a vertex v and follow edges in backward direction. Since no cycles you eventually reach r.

Min-cost Arborescences Given a digraph G with a root node r and with a nonnegative cost on each edge, compute an arborescence rooted at r of minimum cost. r We assume that all vertices are reachable from r.

Min-cost Arborescences Observation 1. This is not a min-cost spanning tree. It does not necessarily include the cheapest edge. Running Prim’s on undirected graph won’t help. Running an analogue of Prim’s for directed graph won’t help either r

Min-cost Arborescences Observation 2. This is not a shortest-path tree r Edges rb and rc won’t be in the min-cost arborescence tree a b c

Edge reweighting For each v ≠ r, let δ(v) denote the min cost of any edge entering v. r x The reduced cost w * (u, v) = w(u, v) – δ(v) ≥ 0 In the picture, δ(x) is y δ(y) is 5. 0 a δ(a) is b δ(b) is

w * (u, v) = w(u, v) – δ(v) Lemma. An arborescence in a digraph has the min-cost with respect to w iff it has the min- cost with respect to w*. Proof. Let T be an arborescence in G(V,E). Compute w(T) – w*(T) The last term does not depend on T.QED δ(v) - min cost of any edge entering v

Algorithm: intuition Let G* denote a new graph after reweighting. If B is an arborescence, we are done. For every v≠r in G* pick 0-weight edge entering v. Let B denote the set of such edges. Note B is the min-cost since all edges have 0 cost. If B is NOT an arborescence… When B is not an arborescence?

How can it happen B is not an arborescence? when it has a directed cycle or several cycles… r Note, only a single edge can enter a vertex

How can it happen B is not an arborescence? a directed cycle… It must be a cycle

Vertex contraction We contract every cycle into a supernode Dashed edges and nodes are from the original graph G. Recursively solve the problem in contracted graph z y x z y x

The Algorithm For each v≠r compute δ(v) – the mincost of edges entering v. For each v≠r compute w * (u, v) = w(u, v) – δ(v). For each v≠r choose 0-cost edge entering v. Let us call this subset of edges – B. If B forms an arborescence, we are done. else Contract every cycle C to a supernode Repeat the algorithm Extend an arborescence by adding all but one edge of C. Return

Complexity At most V contractions (since each one reduces the number of nodes). Finding and contracting the cycle C takes O(E). Transforming T' into T takes O(E) time. Total - O(V E). Faster for Fibonacci heaps.

r r x 1 0 y 0 a 0 4 b x yab c c Cycle AXY Take 0-weight edge for each vertex reweight δ(a) is 3 r x 1 0 y 0 a 0 4 b c

r x 1 4 b c Contract AXY r x 0 3 b c r x 1 0 y 0 a 0 4 b c reweight δ(x) is 1 Take 0-weight edges. break ties arbitrarily 0 0

r 2 6 x b c Extend an arborescence 2 a y r 2 6 x b c 2 a y By removing an edge from a cycle 3 5

Correctness Lemma. Let C be a cycle in G consisting of 0-cost edges. There exists a mincost arborescence rooted at r that has exactly one edge entering C. r x 0 y 0 a 0 4 b c 1

Correctness Lemma. Let C be a cycle in G consisting of 0-cost edges. There exists a mincost arborescence rooted at r that has exactly one edge entering C. Proof. Let T be a min-cost arborescence that has more than one edge enters C r x b a Let (a,x) lies on a shortest path from r. We delete all edges in T that enters C except (a,b) We add all edges in C except the one that enters x.

Correctness Lemma. Let C be a cycle in G consisting of 0-cost edges. There exists a mincost arborescence rooted at r that has exactly one edge entering C. Claim: that new tree T* is a mincost arborescence r x b 0 1. cost(T*) ≤ cost(T) since we add 0-cost edges a T* has exactly one edge entering each vertex 3. T* has no cycles.