Advanced Algorithms Piyush Kumar (Lecture 2: Max Flows) Welcome to COT5405 Slides based on Kevin Wayne’s slides.

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.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
Network Flow CS494/594 – Graph Theory Alexander Sayers.
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.
CSCI 256 Data Structures and Algorithm Analysis Lecture 18 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
The Maximum Network Flow Problem. CSE Network Flows.
1 Maximum Flow w s v u t z 3/33/3 1/91/9 1/11/1 3/33/3 4/74/7 4/64/6 3/53/5 1/11/1 3/53/5 2/22/2 
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.
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.
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.
Chapter 26 Maximum Flow How do we transport the maximum amount data from source to sink? Some of these slides are adapted from Lecture Notes of Kevin.
Advanced Algorithms Piyush Kumar (Lecture 5: Weighted Matching) Welcome to COT5405 Based on Kevin Wayne’s slides.
MAX FLOW CS302, Spring 2013 David Kauchak. Admin.
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.
Advanced Algorithms Piyush Kumar (Lecture 5: Preflow Push) Welcome to COT5405.
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
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)
CS223 Advanced Data Structures and Algorithms 1 Maximum Flow Neil Tang 3/30/2010.
Chapter 7 April 28 Network Flow.
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.
Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow.
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.
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.
CSCI 256 Data Structures and Algorithm Analysis Lecture 20 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 23.
CSEP 521 Applied Algorithms Richard Anderson Lecture 8 Network Flow.
1 Network Flow CSC401 – Analysis of Algorithms Chapter 8 Network Flow Objectives: Flow networks –Flow –Cut Maximum flow –Augmenting path –Maximum flow.
Fall 2003Maximum Flow1 w s v u t z 3/33/3 1/91/9 1/11/1 3/33/3 4/74/7 4/64/6 3/53/5 1/11/1 3/53/5 2/22/2 
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
Prof. Swarat Chaudhuri COMP 382: Reasoning about Algorithms Fall 2015.
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.
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)
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
CS4234 Optimiz(s)ation Algorithms
Algorithm Design and Analysis
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
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
Network Flow and applications
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
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
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
Lecture 21 Network Flow, Part 1
Piyush Kumar (Lecture 3: Preflow Push)
Richard Anderson Lecture 22 Network Flow
Presentation transcript:

Advanced Algorithms Piyush Kumar (Lecture 2: Max Flows) Welcome to COT5405 Slides based on Kevin Wayne’s slides

Announcements Preliminary Homework 1 is out Scribing is worth 5% extra credit. My compgeom.com web pages might not be accessible from inside campus(for now you can use cs.fsu.edu/~piyush pages.

Today More about the programming assignment. On Max Flow Algorithms

Soviet Rail Network, 1955 Reference: On the history of the transportation and maximum flow problems. Alexander Schrijver in Math Programming, 91: 3, “The Soviet rail system also roused the interest of the Americans, and again it inspired fundamental research in optimization.” -- SchrijverSchrijver G. Danzig* 1951…First soln… Again formulted by Harris in 1955 for the US Airforce (“unclassified in 1999”) What were they looking for?

Maximum Flow and Minimum Cut Max flow and min cut. –Two very rich algorithmic problems. –Cornerstone problems in combinatorial optimization. –Beautiful mathematical duality.

Applications –Network reliability. –Distributed computing. –Egalitarian stable matching. –Security of statistical data. –Network intrusion detection. –Multi-camera scene reconstruction. –Many many more... - Nontrivial applications / reductions. - Data mining. - Open-pit mining. - Project selection. - Airline scheduling. - Bipartite matching. - Baseball elimination. - Image segmentation. - Network connectivity.

Some more history

Flow network. –Abstraction for material flowing through the edges. –G = (V, E) = directed graph, no parallel edges. –Two distinguished nodes: s = source, t = sink. –c(e) = capacity of edge e. Minimum Cut Problem s t capacity source sink

Def. An s-t cut is a partition (A, B) of V with s  A and t  B. Def. The capacity of a cut (A, B) is : Cuts s t Capacity = = 30 A

s t A Def. An s-t cut is a partition (A, B) of V with s  A and t  B. Def. The capacity of a cut (A, B) is: Cuts Capacity = = 62

Min s-t cut problem. Find an s-t cut of minimum capacity. Minimum Cut Problem s t A Capacity = = 28

Def. An s-t flow is a function that satisfies: –For each e  E: (capacity) –For each v  V – {s, t}: (conservation) Def. The value of a flow f is: Flows Value = 4 0 capacity flow s t

Flows as Linear Programs Maximize: Subject to:

Flows capacity flow s t Value = 24 4 Def. An s-t flow is a function that satisfies: –For each e  E: (capacity) –For each v  V – {s, t}: (conservation) Def. The value of a flow f is:

Max flow problem. Find s-t flow of maximum value. Maximum Flow Problem capacity flow s t Value = 28

Flow value lemma. Let f be any flow, and let (A, B) be any s-t cut. Then, the net flow sent across the cut is equal to the amount leaving s. Flows and Cuts s t Value = 24 4 A

Flow value lemma. Let f be any flow, and let (A, B) be any s- t cut. Then, the net flow sent across the cut is equal to the amount leaving s. Flows and Cuts s t Value = = A

Flow value lemma. Let f be any flow, and let (A, B) be any s- t cut. Then, the net flow sent across the cut is equal to the amount leaving s. Flows and Cuts s t Value = = 24 4 A

Flows and Cuts Flow value lemma. Let f be any flow, and let (A, B) be any s-t cut. Then Pf. by flow conservation, all terms except v = s are 0

Flows and Cuts Weak duality. Let f be any flow, and let (A, B) be any s-t cut. Then the value of the flow is at most the capacity of the cut. Cut capacity = 30  Flow value  30 s t Capacity = 30 A

Weak duality. Let f be any flow. Then, for any s-t cut (A, B) we have v(f)  cap(A, B). Pf. Flows and Cuts s t A B

Certificate of Optimality Corollary. Let f be any flow, and let (A, B) be any cut. If v(f) = cap(A, B), then f is a max flow and (A, B) is a min cut. Value of flow = 28 Cut capacity = 28  Flow value  s t A

Towards a Max Flow Algorithm Greedy algorithm. –Start with f(e) = 0 for all edge e  E. –Find an s-t path P where each edge has f(e) < c(e). –Augment flow along path P. –Repeat until you get stuck. s 1 2 t Flow value = 0

Towards a Max Flow Algorithm Greedy algorithm. –Start with f(e) = 0 for all edge e  E. –Find an s-t path P where each edge has f(e) < c(e). –Augment flow along path P. –Repeat until you get stuck. s 1 2 t 20 Flow value = X X X 20

Towards a Max Flow Algorithm Greedy algorithm. –Start with f(e) = 0 for all edge e  E. –Find an s-t path P where each edge has f(e) < c(e). –Augment flow along path P. –Repeat until you get stuck. greedy = 20 s 1 2 t opt = 30 s 1 2 t locally optimality  global optimality

Residual Graph Original edge: e = (u, v)  E. –Flow f(e), capacity c(e). Residual edge. –"Undo" flow sent. –e = (u, v) and e R = (v, u). –Residual capacity: Residual graph: G f = (V, E f ). –Residual edges with positive residual capacity. –E f = {e : f(e) 0}. uv 17 6 capacity uv 11 residual capacity 6 flow

DemoDemo

Augmenting Path Algorithm Augment(f, c, P) { b  bottleneck(P) foreach e  P { if (e  E) f(e)  f(e) + b else f(e R )  f(e) - b } return f } Ford-Fulkerson(G, s, t, c) { foreach e  E f(e)  0 G f  residual graph while (there exists augmenting path P) { f  Augment(f, c, P) update G f } return f } forward edge reverse edge

Max-Flow Min-Cut Theorem Augmenting path theorem. Flow f is a max flow iff there are no augmenting paths. Max-flow min-cut theorem. [Ford-Fulkerson 1956] The value of the max flow is equal to the value of the min cut. Proof strategy. We prove both simultaneously by showing the TFAE: (i)There exists a cut (A, B) such that v(f) = cap(A, B). (ii)Flow f is a max flow. (iii)There is no augmenting path relative to f. (i)  (ii) This was the corollary to weak duality lemma. (ii)  (iii) We show contrapositive. –Let f be a flow. If there exists an augmenting path, then we can improve f by sending flow along path.

Proof of Max-Flow Min-Cut Theorem (iii)  (i) –Let f be a flow with no augmenting paths. –Let A be set of vertices reachable from s in residual graph. –By definition of A, s  A. –By definition of f, t  A. original network s t A B

Running Time Assumption. All capacities are integers between 1 and U. The cut containing s and rest of the nodes has C capacity. Invariant. Every flow value f(e) and every residual capacities c f (e) remains an integer throughout the algorithm. Theorem. The algorithm terminates in at most v(f*)  C iterations. Pf. Each augmentation increase value by at least 1. ▪ Corollary. If C = 1, Ford-Fulkerson runs in O(m) time. Integrality theorem. If all capacities are integers, then there exists a max flow f for which every flow value f(e) is an integer. Pf. Since algorithm terminates, theorem follows from invariant. ▪ Total running time?

Choosing Good Augmenting Paths

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. s 1 2 t C C C C 1 s 1 2 t C C X 1 C C X X X X X 1 1 X X X m, n, and log C

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

Capacity Scaling Intuition. Choosing path with highest bottleneck capacity increases flow by max possible amount. –Don't worry about finding exact highest bottleneck path. –Maintain scaling parameter . –Let G f (  ) be the subgraph of the residual graph consisting of only arcs with capacity 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 max 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) 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. –By integrality invariant, when  = 1  G f (  ) = G f. –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.  drops by a factor of 2 each iteration and never gets below 1. Lemma 2. Let f be the flow at the end of a  -scaling phase. Then the value of the maximum flow is at most v(f) + m . Lemma 3. There are at most 2m augmentations per scaling phase. –Let f be the flow at the end of the previous scaling phase. –L2  v(f*)  v(f) + m (2  ). –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

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) –We show that at the end of a  -phase, there exists a cut (A, B) such that cap(A, B)  v(f) + m . –Choose A to be the set of nodes reachable from s in G f (  ). –By definition of A, s  A. –By definition of f, t  A. original network s t A B

Bipartite matching. Can solve via reduction to max flow. Flow. During Ford-Fulkerson, all capacities and flows are 0/1. Flow corresponds to edges in a matching M. Residual graph G M simplifies to: –If (x, y)  M, then (x, y) is in G M. –If (x, y)  M, the (y, x) is in G M. Augmenting path simplifies to: –Edge from s to an unmatched node x  X. –Alternating sequence of unmatched and matched edges. –Edge from unmatched node y  Y to t. Bipartite Matching st YX

References R.K. Ahuja, T.L. Magnanti, and J.B. Orlin. Network Flows. Prentice Hall, (Reserved in Dirac) R.K. Ahuja and J.B. Orlin. A fast and simple algorithm for the maximum flow problem. Operation Research, 37: , K. Mehlhorn and S. Naeher. The LEDA Platform for Combinatorial and Geometric Computing. Cambridge University Press, pages.The LEDA Platform for Combinatorial and Geometric Computing On the history of the transportation and maximum flow problems, Alexander Schrijver.On the history of the transportation and maximum flow problems