10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 21 Network.

Slides:



Advertisements
Similar presentations
COMP 482: Design and Analysis of Algorithms
Advertisements

Lecture 7. Network Flows We consider a network with directed edges. Every edge has a capacity. If there is an edge from i to j, there is an edge from.
15.082J & 6.855J & ESD.78J October 14, 2010 Maximum Flows 2.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
EMIS 8374 Vertex Connectivity Updated 20 March 2008.
Piyush Kumar (Lecture 6: MaxFlow MinCut Applications)
Max Flow: Shortest Augmenting Path
MAXIMUM FLOW Max-Flow Min-Cut Theorem (Ford Fukerson’s Algorithm)
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2012 Lecture 19.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Lectures on Network Flows
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
Advanced Algorithms Piyush Kumar (Lecture 2: Max Flows) Welcome to COT5405 Slides based on Kevin Wayne’s slides.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2001 Lecture 4 Tuesday, 2/19/02 Graph Algorithms: Part 2 Network.
The max flow problem
Maximum Flows Lecture 4: Jan 19. Network transmission Given a directed graph G A source node s A sink node t Goal: To send as much information from s.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2004 Lecture 5 Wednesday, 10/6/04 Graph Algorithms: Part 2.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
9/3/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Guest lecturer: Martin Furer Algorithm Design and Analysis L ECTURE.
Advanced Algorithms Piyush Kumar (Lecture 5: Weighted Matching) Welcome to COT5405 Based on Kevin Wayne’s slides.
Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.
1 Chapter 10 Extending the Limits of Tractability Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Finding Max Flow.
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
1 WEEK 11 Graphs III Network Flow Problems A Simple Maximum-Flow Algorithm Izmir University of Economics.
Maximum Flow Problem (Thanks to Jim Orlin & MIT OCW)
Chapter 7 April 28 Network Flow.
15.082J & 6.855J & ESD.78J October 7, 2010 Introduction to Maximum Flows.
15.082J and 6.855J March 4, 2003 Introduction to Maximum Flows.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 25.
and 6.855J March 6, 2003 Maximum Flows 2. 2 Network Reliability u Communication Network u What is the maximum number of arc disjoint paths from.
Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow.
Algorithm Design and Analysis (ADA)
Chapter 7 May 3 Ford-Fulkerson algorithm Step-by-step walk through of an example Worst-case number of augmentations Edmunds-Karp modification Time complexity.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Exercise 6.1 Find the number of different shortest paths from point A to point B in a city with perfectly horizontal streets and vertical avenues as shown.
CSCI 256 Data Structures and Algorithm Analysis Lecture 20 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
EMIS 8374 The Ford-Fulkerson Algorithm (aka the labeling algorithm) Updated 4 March 2008.
Prof. Swarat Chaudhuri COMP 382: Reasoning about Algorithms Fall 2015.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Maximum Flow Problem Definitions and notations The Ford-Fulkerson method.
1 Maximum Flows CONTENTS Introduction to Maximum Flows (Section 6.1) Introduction to Minimum Cuts (Section 6.1) Applications of Maximum Flows (Section.
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Algorithm Design and Analysis
Lectures on Network Flows
Richard Anderson Lecture 23 Network Flow
Chapter 5. Optimal Matchings
Edmunds-Karp Algorithm: Choosing Good Augmenting Paths
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
COMP 382: Reasoning about Algorithms
Network Flow 2016/04/12.
Instructor: Shengyu Zhang
Edmonds-Karp Algorithm
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Network Flow and Connectivity in Wireless Sensor Networks
Richard Anderson Lecture 21 Network Flow
Problem Solving 4.
Max Flow Min Cut, Bipartite Matching Yin Tat Lee
Piyush Kumar (Lecture 6: MaxFlow MinCut Applications)
Algorithms (2IL15) – Lecture 7
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
EE5900 Advanced Embedded System For Smart Infrastructure
Lecture 22 Network Flow, Part 2
Presentation transcript:

10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 21 Network Flow Finish bipartite matching Capacity-scaling algorithm

Marriage Theorem. [Frobenius 1917, Hall 1935] Let G = (L  R, E) be a bipartite graph with |L| = |R|. Then, G has a perfect matching iff |N(S)|  |S| for all subsets S  L. Pf.  This was the previous observation. Marriage Theorem ' 3' 5' 2 4 2' 4' L R No perfect matching: S = { 2, 4, 5 } N(S) = { 2', 5' }.

Pf.  Suppose G does not have a perfect matching. n Formulate as a max flow problem with 1 constraints on edges from L to R and let (A, B) be min cut in G'. n Key property #1 of this graph: min-cut cannot use  edges.  So cap(A, B) = | L  B | + | R  A | n Key property #2: integral flow is still a matching – By max-flow min-cut, cap(A, B) < | L |. n Choose S = L  A. – Since min cut can't use  edges: N(S)  R  A. n |N(S )|  | R  A | = cap(A, B) - | L  B | < | L | - | L  B | = | S|. ▪ Proof of Marriage Theorem S = {2, 4, 5} L  B = {1, 3} R  A = {2', 5'} N(S) = {2', 5'} s ' 3' 5' t 2 4 4' 1  2' A  G' 

Which max flow algorithm to use for bipartite matching? n Generic augmenting path: O(m val(f*) ) = O(mn). n Capacity scaling: O(m 2 log C ) = O(m 2 ). n Shortest augmenting path (not covered in class): O(m n 1/2 ). Non-bipartite matching. n Structure of non-bipartite graphs is more complicated, but well-understood. [Tutte-Berge, Edmonds-Galai] n Blossom algorithm: O(n 4 ). [Edmonds 1965] n Best known: O(m n 1/2 ). [Micali-Vazirani 1980] n Recently: better algorithms for dense graphs, e.g. O(n 2.38 ) [Harvey, 2006] Bipartite Matching: Running Time

Exercise A bipartite graph is k-regular if |L|=|R| and every vertex (regardless of which side it is on) has exactly k neighbors Prove or disprove: every k-regular bipartite graph has a perfect matching

Faster algorithms when capacities are large

1 X X X Ford-Fulkerson: Exponential Number of Augmentations Q. Is generic Ford-Fulkerson algorithm polynomial in input size? A. No. If max capacity is C, then algorithm can take C iterations. Intuition: we’re choosing the wrong paths! s 1 2 t C C C C 1 s 1 2 t C C X C C X X X X X 1 1 m, n, and log C

Choosing Good Augmenting Paths Use care when selecting augmenting paths. n Some choices lead to exponential algorithms. n Clever choices lead to polynomial algorithms. n If capacities are irrational, algorithm not guaranteed to terminate! Goal: choose augmenting paths so that: n Can find augmenting paths efficiently. n Few iterations. Choose augmenting paths with: [Edmonds-Karp 1972, Dinitz 1970] n Max bottleneck capacity. n Sufficiently large bottleneck capacity. n Fewest number of edges.

Capacity Scaling Intuition. Choosing path with highest bottleneck capacity increases flow by max possible amount. n Don't worry about finding exact highest bottleneck path. n Maintain scaling parameter . n G f (  ) = subgraph of the residual graph with only arcs ofcapacity at least . 110 s 4 2 t GfGf 110 s 4 2 t G f (100)

Capacity Scaling Scaling-Max-Flow(G, s, t, c) { foreach e  E f(e)  0   smallest power of 2 greater than or equal to C G f  residual graph while (   1) { G f (  )   -residual graph while (there exists augmenting path P in G f (  )) { f  augment(f, c, P) // augment flow by   update G f (  ) }    / 2 } return f } Scaling-Max-Flow(G, s, t, c) { foreach e  E f(e)  0   smallest power of 2 greater than or equal to C G f  residual graph while (   1) { G f (  )   -residual graph while (there exists augmenting path P in G f (  )) { f  augment(f, c, P) // augment flow by   update G f (  ) }    / 2 } return f }

Capacity Scaling: Correctness Assumption. All edge capacities are integers between 1 and C. Integrality invariant. All flow and residual capacity values are integral. Correctness. If the algorithm terminates, then f is a max flow. Pf. n By integrality invariant, when  = 1  G f (  ) = G f. n Upon termination of  = 1 phase, there are no augmenting paths. ▪

Capacity Scaling: Running Time Lemma 1. The outer while loop repeats 1 +  log 2 C  times. Pf. Initially C   < 2C.  decreases by a factor of 2 each iteration. ▪ Lemma 2. Let f be the flow at the end of a  -scaling phase. Then the value of the maximum flow f* is at most v(f) + m . (Sanity check: |v(f*) – v(f)|  m , and  shrinks, so v(f) converges towards v(f*) ) Lemma 3. There are at most 2m augmentations per scaling phase. n Let f be the flow at the end of the previous scaling phase. n Lemma 2  v(f*)  v(f) + m (2  ). n Each augmentation in a  -phase increases v(f) by at least . ▪ Theorem. The scaling max-flow algorithm finds a max flow in O(m log C) augmentations. It can be implemented to run in O(m 2 log C) time. ▪ proof on next slide (Why?)

Capacity Scaling: Running Time Lemma 2. Let f be the flow at the end of a  -scaling phase. Then value of the maximum flow is at most v(f) + m . Pf. (almost identical to proof of max-flow min-cut theorem) n We show that at the end of a  -phase, there exists a cut (A, B) such that cap(A, B)  v(f) + m . n Choose A to be the set of nodes reachable from s in G f (  ). n By definition of A, s  A. n By definition of f, t  A. So v(f*)-v(f) ≤ cap(A,B) – v(f) ≤ m  original network s t A B

Best Known Algorithms For Max Flow Reminder: The scaling max-flow algorithm runs in O(m 2 log C) time. Currently there are algorithms that run in time O(mn log n) O(n 3 ) O(min(n 2/3, m 1/2 ) m log n log C) Active topic of research: Flow algorithms for specific types of graphs Special cases (bipartite matching, etc) Multi-commodity flow …

What you should know about max flow How Ford-Fulkerson works How to use it to find min cuts How to use it to solve other problems (more examples coming) max matching project selection edge-disjoint paths vertex-disjoint paths … To study: Review lecture notes/ textbook Solved exercises in book Homework problems Homework exercises Solve lots of problems!