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.

Slides:



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

1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
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.
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.
Advanced Algorithms Piyush Kumar (Lecture 2: Max Flows) Welcome to COT5405 Slides based on Kevin Wayne’s slides.
CS138A Network Flows Peter Schröder. CS138A Flow Networks Definitions a flow network G=(V,E) is a directed graph in which each edge (u,v)
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2001 Lecture 4 Tuesday, 2/19/02 Graph Algorithms: Part 2 Network.
1 Maximum flow problems. 2 - Introduction of: network, max-flow problem capacity, flow - Ford-Fulkerson method pseudo code, residual networks, augmenting.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 4 Tuesday, 10/2/01 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.
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.
MAX FLOW CS302, Spring 2013 David Kauchak. Admin.
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)
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.
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.
Maximum Flow Problem Definitions and notations The Ford-Fulkerson method.
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
Richard Anderson Lecture 23 Network Flow
Maximum Flow 9/13/2018 6:12 PM Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.
COMP 382: Reasoning about Algorithms
Network Flow 2016/04/12.
Instructor: Shengyu Zhang
Edmonds-Karp Algorithm
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
Lecture 10 Network flow Max-flow and Min-cut Ford-Fulkerson method
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 21 Network Flow
Max Flow Min Cut, Bipartite Matching Yin Tat Lee
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
Richard Anderson Lecture 22 Network Flow
Lecture 21 Network Flow, Part 1
Richard Anderson Lecture 22 Network Flow
Presentation transcript:

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 bounds

Soviet Rail Network, 1955 Reference: On the history of the transportation and maximum flow problems. Alexander Schrijver in Math Programming, 91: 3, 2002.

Maximum Flow and Minimum Cut Max flow and min cut. n Two very rich algorithmic problems. n Cornerstone problems in combinatorial optimization. n Beautiful mathematical duality. Nontrivial applications / reductions. n Data mining. n Open-pit mining. n Project selection. n Airline scheduling. n Bipartite matching. n Baseball elimination. n Image segmentation. n Network connectivity. n Network reliability. n Distributed computing. n Egalitarian stable matching. n Security of statistical data. n Network intrusion detection. n Multi-camera scene reconstruction. n Many many more...

Flow network. n Abstraction for material flowing through the edges. n G = (V, E) = directed graph, no parallel edges. n Two distinguished nodes: s = source, t = sink. n 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 Cuts 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: Capacity = = 62

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

Min s-t cut problem. Find an s-t cut of minimum capacity. Minimum Cut Problem s t A Capacity = = 28 Suppose the edge capacity represents the cost of removing the edge. What is the least expensive way to disrupt connection from s to t? This is the min-cut problem. Apparently, this is the version that motivated researchers in Rand corporation with a view of breaking down the Russian railway system.

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

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

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

12 Java applet implementation: What is the capacity of the cut ?

13 Java applet implementation: What is the capacity of the cut ? 10 What is the capacity of the cut ?

14 Java applet implementation: What is the capacity of the cut ? 10 What is the capacity of the cut ? 8

15 Java applet implementation: What is the capacity of the min-cut?

16 Java applet implementation: What is the capacity of the min-cut? It is not obvious! Can you find a cut of capacity 6?

17 Java applet implementation: What is the capacity of the min-cut? It is not obvious! Can you find a cut of capacity 6? Answer: Max-flow algorithm will find a cut of minimum capacity.

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 f is at most the capacity of the cut (A, B). 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. n Start with f(e) = 0 for all edge e  E. n Find an s-t path P where each edge has f(e) < c(e). n Augment flow along path P. n Repeat until you get stuck. s 1 2 t Flow value = 0

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

Towards a Max Flow Algorithm Greedy algorithm. n Start with f(e) = 0 for all edge e  E. n Find an s-t path P where each edge has f(e) < c(e). n Augment flow along path P. n 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. n Flow f(e), capacity c(e). Residual edge. n "Undo" flow sent. n e = (u, v) and e R = (v, u). n Residual capacity: Residual graph: G f = (V, E f ). n Residual edges with positive residual capacity. n E f = {e : f(e) 0}. uv 17 6 capacity uv 11 residual capacity 6 flow

Ford-Fulkerson Algorithm s t G: capacity

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. n 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) n Let f be a flow with no augmenting paths. n Let A be set of vertices reachable from s in residual graph. n By definition of A, s  A. n By definition of f, t  A. original network s t A B

The basic Ford Fulkerson algorithm

The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v (residual) network G f

The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v4 0/10 0/13 0/12 0/16 0/4 0/14 0/20 7 0/9 (residual) network G f

The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v (residual) network G f

The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v (residual) network G f temporary variable: c f (p) = 12

The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v (residual) network G f temporary variable: c f (p) = 12 St v1 v2 v3 v /12 12/ / new flow network G

The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v (residual) network G f St v1 v2 v3 v /12 12/ / new flow network G 12

The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v (residual) network G f St v1 v2 v3 v /12 12/ / new flow network G 12

The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v (residual) network G f St v1 v2 v3 v /12 12/ / new flow network G 12

The basic Ford Fulkerson algorithm example of an execution (residual) network G f St v1 v2 v3 v /12 12/ / new flow network G temporary variable: c f (p) = 4 St v1 v2 v3 v

The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v (residual) network G f St v1 v2 v3 v4 10 4/13 12/12 12/16 4 4/4 4/14 12/ new flow network G 12 temporary variable: c f (p) = 4

The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v (residual) network G f St v1 v2 v3 v4 10 4/13 12/12 12/16 4 4/4 4/14 12/ new flow network G

The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v (residual) network G f St v1 v2 v3 v4 10 4/13 12/12 12/16 4 4/4 4/14 12/ new flow network G

The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v (residual) network G f St v1 v2 v3 v4 10 4/13 12/12 12/16 4 4/4 4/14 12/ new flow network G

The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v (residual) network G f St v1 v2 v3 v4 10 4/13 12/12 12/16 4 4/4 4/14 12/ new flow network G temporary variable: c f (p) = 7

The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v (residual) network G f St v1 v2 v3 v /13 12/12 12/16 4 4/4 11/14 19/20 7/7 9 new flow network G temporary variable: c f (p) = 7

The basic Ford Fulkerson algorithm example of an execution (residual) network G f St v1 v2 v3 v /13 12/12 12/16 4 4/4 11/14 19/20 7/7 9 new flow network G St v1 v2 v3 v

The basic Ford Fulkerson algorithm example of an execution (residual) network G f St v1 v2 v3 v /13 12/12 12/16 4 4/4 11/14 19/20 7/7 9 new flow network G St v1 v2 v3 v Finally we have: | f | = f (s, V) = 23

Running Time Assumption. All capacities are integers between 1 and C. 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*)  n C iterations. Pf. Each augmentation increase value by at least 1. ▪ Corollary. If C = 1, Ford-Fulkerson algorithm runs in O(mn) 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. ▪

7.3 Choosing Good Augmenting Paths

Analysis of the Ford Fulkerson algorithm Running time (arbitrary choice of p) O(|E|) O(|E| |f max |) running time: O ( |E| |f max | ) with f max as maximum flow (1) The augmenting path is chosen arbitrarily and all capacities are integers O(|E| )

Analysis of the Ford Fulkerson algorithm Running time (arbitrary choice of p) (1) The augmenting path is chosen arbitrarily and all capacities are integers Consequencies of an arbitrarily choice: Example if |f*| is large: t v2 v1 s 1,000,000 1 running time: O ( |E| |f max | ) with f max as maximum flow

Analysis of the Ford Fulkerson algorithm Running time (arbitrary choice of p) (1) The augmenting path is chosen arbitrarily and all capacities are integers Consequencies of an arbitrarily choice: Example if |f*| is large: t v2 v1 s 1 / 1,000,000 1,000,000 1 / 1,000,000 1 / 1 t v2 v1 s 999,999 1,000, ,999 1 residual network G f 1 1 running time: O ( |E| |f max | ) with f max as maximum flow

Analysis of the Ford Fulkerson algorithm Running time (arbitrary choice of p) (1) The augmenting path is chosen arbitrarily and all capacities are integers Consequencies of an arbitrarily choice: Example if |f*| is large: t v2 v1 s 1 / 1,000,000 1 t v2 v1 s 999,999 1 residual network G f running time: O ( |E| |f max | ) with f max as maximum flow

Analysis of the Ford Fulkerson algorithm Running time with Edmonds-Karp algorithm (2) Edmonds-Karp algorithm augmenting path is found by breath-first search and has to be a shortest path from p to t running time: O ( |V| |E|² ) St u1 u2 v3 v Informal idea of the proof: (1)for all vertices v  V\{s,t}: the shortest path distance  f (s,v) in G f increases monotonically with each flow augmentation  f (s,v) <  f ´ (s,v)