Max Flow: Shortest Augmenting Path

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.
Min Cost Flow: Polynomial Algorithms. Overview Recap: Min Cost Flow, Residual Network Potential and Reduced Cost Polynomial Algorithms Approach Capacity.
1 Chapter 6 Dynamic Programming Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2012 Lecture 19.
Chapter 10: Iterative Improvement The Maximum Flow Problem The Design and Analysis of Algorithms.
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.
Chapter 7 Maximum Flows: Polynomial Algorithms
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
1 Efficient implementation of Dinic’s algorithm for maximum flow.
Advanced Algorithms Piyush Kumar (Lecture 2: Max Flows) Welcome to COT5405 Slides based on Kevin Wayne’s slides.
The max flow problem
Maximum Flow Applications
1 Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
1 Efficient implementation of Dinic’s algorithm for maximum flow.
Assignment 4. (Due on Dec 2. 2:30 p.m.) This time, Prof. Yao and I can explain the questions, but we will NOT tell you how to solve the problems. Question.
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.
Lecture 5: Network Flow Algorithms Single-Source Shortest-Path (SSSP) (Dijkstra's Algorithm) Max Flow - Min Cut (Ford-Fulkerson) Job Sequencing.
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
Algorithm Design by Éva Tardos and Jon Kleinberg Copyright © 2005 Addison Wesley Slides by Kevin Wayne 7. Edmonds-karp Demo.
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Finding Max Flow.
1 WEEK 11 Graphs III Network Flow Problems A Simple Maximum-Flow Algorithm Izmir University of Economics.
Chapter 7 April 28 Network Flow.
15.082J and 6.855J and ESD.78J The Successive Shortest Path Algorithm and the Capacity Scaling Algorithm for the Minimum Cost Flow Problem.
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.
CS38 Introduction to Algorithms Lecture 10 May 1, 2014.
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.
15.082J & 6.855J & ESD.78J September 30, 2010 The Label Correcting Algorithm.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 23.
EMIS 8374 The Ford-Fulkerson Algorithm (aka the labeling algorithm) Updated 4 March 2008.
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.
CSE 421 Algorithms Richard Anderson Lecture 21 Shortest Paths and Network Flow.
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Ford-Fulkerson Recap.
Submodularity Reading Group Minimum Cut, Dinic’s Algorithm
Lectures on Network Flows
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
James B. Orlin Presented by Tal Kaminker
Network Flow 2016/04/12.
Instructor: Shengyu Zhang
Edmonds-Karp Algorithm
Efficient implementation of Dinic’s algorithm for maximum flow
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Network Flow and Connectivity in Wireless Sensor Networks
Chapter 6 Dynamic Programming
Chapter 6 Dynamic Programming
Max Flow Min Cut, Bipartite Matching Yin Tat Lee
Complexity of Ford-Fulkerson
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
and 6.855J March 6, 2003 Maximum Flows 2
Lecture 21 Network Flow, Part 1
The Ford-Fulkerson Algorithm
Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
Class 11 Max Flows Obtain a network, and use the same network to illustrate the shortest path problem for communication networks, the max flow.
Data Structures and Algorithm Analysis Lecture 8
Presentation transcript:

Max Flow: Shortest Augmenting Path

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) Max bottleneck capacity. Sufficiently large capacity. Fewest number of edges.

Shortest Augmenting Path Find augmenting path with fewest number of edges. BFS is an efficient implementation. may implement by accident! Shortest-Augmenting-Path(G, s, t, c) { foreach e  E f(e)  0 Gf  residual graph while (there exists an augmenting path) { find such a shortest such path P using BFS f  Augment(f, c, P) update Gf } return f

Shortest Augmenting Path: Overview of Analysis Proof outline. L1. Throughout the algorithm, the length of the shortest path never decreases. L2. After at most m shortest path augmentations, the length of the shortest augmenting path strictly increases. Theorem. The shortest augmenting path algorithm performs at most O(mn) augmentations. It can be implemented in O(m2n) time. O(m) time to find shortest augmenting path via BFS. O(m) augmentations for paths of exactly k edges. If there is an augmenting path, there is a simple one.  1  k < n  O(mn) augmentations. ▪ proof ahead proof ahead

Shortest Augmenting Path: Analysis number of edges Level graph. G = (V, E), s For each vertex v, define  (u) to be the length of shortest s-u path. L = (V, F) is subgraph of G that contains only those edges (u, v)  E with  (v) =  (u) + 1. Compute in O(m+n) time using BFS, deleting back and side edges. P is a shortest s-u path in G iff it is an s-u path LG. 2 5 L: s 3 6 t  = 0  = 1  = 2  = 3

Shortest Augmenting Path: Analysis L1. Throughout the algorithm, the length of the shortest path never decreases. Let f and f' be flow before and after a shortest path augmentation. Let L and L' be level graphs of Gf and Gf ' Only back edges added to Gf ' Path with back edge has length greater than previous length. 2 5 L s 3 6 t  = 0  = 1  = 2  = 3 2 5 L' s 3 6 t

Shortest Augmenting Path: Analysis L2. After at most m shortest path augmentations, the length of the shortest augmenting path strictly increases. At least one edge (the bottleneck edge) is deleted from L after each augmentation. No new edges added to L until length of shortest path strictly increases. 2 5 L s 3 6 t  = 0  = 1  = 2  = 3 2 5 L' s 3 6 t

Shortest Augmenting Path: Review of Analysis L1. Throughout the algorithm, the length of the shortest path never decreases. L2. After at most m shortest path augmentations, the length of the shortest augmenting path strictly increases. Theorem. The shortest augmenting path algorithm performs at most O(mn) augmentations. It can be implemented in O(m2n) time. Note: (mn) augmentations necessary on some networks. Try to decrease time per augmentation instead. Dynamic trees  O(mn log n) Sleator-Tarjan, 1983 Simple idea  O(mn2)

Shortest Augmenting Path: Improved Version Two types of augmentations. Normal augmentation: length of shortest path doesn't change. Special augmentation: length of shortest path strictly increases. L3. Group of normal augmentations takes O(mn) time. Explicitly maintain level graph - it changes by at most 2n edges after each normal augmentation. Start at s, advance along an edge in L until reach t or get stuck. if reach t, augment and delete at least one edge if get stuck, delete node 2 5 L s 3 6 t  = 0  = 1  = 2  = 3

Shortest Augmenting Path: Improved Version 2 5 L augment bottleneck edge s 3 6 t 2 5 L delete 3 got stuck, delete node s 3 6 t 2 5 augment L s 6 t bottleneck edge

Shortest Augmenting Path: Improved Version 2 5 L augment bottleneck edge s 6 t 2 5 L s 6 t Stop: length of shortest path must have strictly increased.

Shortest Augmenting Path: Improved Version Advance-Retreat(V, E, f, s, t) { array pred[u  V] L  level graph of Gf u  s, pred[v]  nil repeat { while (there exists (u, v)  L) { pred[v]  u, u  v if (u = t) { P  path defined by pred[] f  Augment(f, P) update L u  s, pred[u]  nil } delete u from L } until (u = s) return f advance nonrecursive DFS in acyclic graph, deleting nodes when you get stuck retreat

Shortest Augmenting Path: Improved Version Two types of augmentations. Normal augmentation: length of shortest path doesn't change. Special augmentation: length of shortest path strictly increases. L3. Group of normal augmentations takes O(mn) time. At most n advance steps before you either get stuck: delete a node from level graph reach t: augment and delete an edge from level graph Theorem. Algorithm runs in O(mn2) time. O(mn) time between special augmentations. At most n special augmentations.

Choosing Good Augmenting Paths: Summary Method Augmentations Asymptotic time Augmenting path nU mnC † Max capacity m log C m log C (m + n log n) † Capacity scaling m log C m2 log C † Improved capacity scaling m log C mn log C † Shortest path mn m2n Improved shortest path mn mn2 † Edge capacities are between 1 and C.

History of Worst-Case Running Times Year Discoverer Method Asymptotic Time 1951 Dantzig Simplex m n2 C † 1955 Ford, Fulkerson Augmenting path m n C † 1970 Edmonds-Karp Shortest path m2 n 1970 Edmonds-Karp Fattest path m log U (m log n) † 1970 Dinitz Improved shortest path m n2 1972 Edmonds-Karp, Dinitz Capacity scaling m2 log C † top half are augmenting path algorithms Could speed up Fattest path in theory using Fibonacci heap 1973 Dinitz-Gabow Improved capacity scaling m n log C † 1974 Karzanov Preflow-push n3 1983 Sleator-Tarjan Dynamic trees m n log n 1986 Goldberg-Tarjan FIFO preflow-push m n log (n2 / m) . . . . . . . . . . . . 1997 Goldberg-Rao Length function m3/2 log (n2 / m) log C † mn2/3 log (n2 / m) log C † † Edge capacities are between 1 and C.

Unit Capacity Simple Networks 1 Unit capacity simple network. Every edge capacity is one. Every node has either: (i) at most one incoming edge, or (ii) at most one outgoing edge. If G is simple unit capacity, then so is Gf, assuming f is 0-1 flow. Shortest augmenting path algorithm. Normal augmentation: length of shortest path doesn't change. Special augmentation: length of shortest path strictly increases. Theorem. Shortest augmenting path algorithm runs in O(m n1/2) time. L1. Each phase of normal augmentations takes O(m) time. L2. After at most n1/2 phases, | f |  | f *| - n1/2. L3. After at most n1/2 additional augmentations, flow is optimal. 1 1

Unit Capacity Simple Networks Lemma 1. Phase of normal augmentations takes O(m) time. Start at s, advance along an arc in LG until reach t or get stuck. if reach t, augment and delete ALL arcs on path if get stuck, delete node and go to previous node Augment Level graph

Unit Capacity Simple Networks Lemma 1. Phase of normal augmentations takes O(m) time. Start at s, advance along an arc in LG until reach t or get stuck. if reach t, augment and delete ALL arcs on path if get stuck, delete node and go to previous node Delete node and retreat Level graph

Unit Capacity Simple Networks Lemma 1. Phase of normal augmentations takes O(m) time. Start at s, advance along an arc in LG until reach t or get stuck. if reach t, augment and delete ALL arcs on path if get stuck, delete node and go to previous node Augment Level graph

Unit Capacity Simple Networks Lemma 1. Phase of normal augmentations takes O(m) time. Start at s, advance along an arc in LG until reach t or get stuck. if reach t, augment and delete ALL arcs on path if get stuck, delete node and go to previous node STOP Length of shortest path has increased. Level graph

Unit Capacity Simple Networks Lemma 1. Phase of normal augmentations takes O(m) time. Start at s, advance along an arc in LG until reach t or get stuck. if reach t, augment and delete ALL arcs on path if get stuck, delete node and go to previous node O(m) running time. O(m) to create level graph O(1) per arc, since each arc traversed at most once O(1) per node deletion

Unit Capacity Simple Networks ARRAY pred[v  V] LG  level graph of Gf v  s, pred[v]  nil REPEAT WHILE (there exists (v,w)  LG) pred[w]  v, v  w IF (v = t) P  path defined by pred[] f  augment(f, P) update LG delete v from LG UNTIL (v = s) RETURN f AdvanceRetreat(V, E, f, s, t) advance augment retreat

Unit Capacity Simple Networks Lemma 2. After at most n1/2 phases, | f |  | f *| - n1/2. After n1/2 phases, length of shortest augmenting path is > n1/2. Level graph has more than n1/2 levels. Let 1  h  n1/2 be layer with min number of nodes: |Vh|  n1/2. Level graph V0 V1 Vh Vn1/2

Unit Capacity Simple Networks Lemma 2. After at most n1/2 phases, | f |  | f *| - n1/2. After n1/2 phases, length of shortest augmenting path is > n1/2. Level graph has more than n1/2 levels. Let 1  h  n1/2 be layer with min number of nodes: |Vh|  n1/2. S := {v : (v) < h}  {v : (v) = h and v has  1 outgoing residual arc}. capf (S, T)  |Vh|  n1/2  | f |  | f *| - n1/2. note: only level graph shown, there can be residual arcs that are back or sideways arcs in level graph. The former can't participate in given s-t cut, the latter don't either because only nodes in V_h that have one outgoing residual arc are included Residual arcs Level graph V0 V1 Vh Vn1/2