Chapter 7 Maximum Flows: Polynomial Algorithms

Slides:



Advertisements
Similar presentations
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.
Advertisements

Min Cost Flow: Polynomial Algorithms. Overview Recap: Min Cost Flow, Residual Network Potential and Reduced Cost Polynomial Algorithms Approach Capacity.
Introduction to Algorithms
15.082J & 6.855J & ESD.78J October 14, 2010 Maximum Flows 2.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Max Flows 2: The Excess Scaling Algorithm and Variants. James Orlin.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
Bioinformatics III1 We will present an algorithm that originated by Ford and Fulkerson (1962). Idea: increase the flow in a network iteratively until it.
Chapter 5 Shortest Paths: Label-Correcting Algorithms
MINIMUM COST FLOWS: NETWORK SIMPLEX ALGORITHM A talk by: Lior Teller 1.
Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm.
15.082J, 6.855J, and ESD.78J Sept 16, 2010 Lecture 3. Graph Search Breadth First Search Depth First Search Intro to program verification Topological Sort.
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.
Chapter 10: Iterative Improvement The Maximum Flow Problem The Design and Analysis of Algorithms.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Lectures on Network Flows
1 Maximum Flow Networks Suppose G = (V, E) is a directed network. Each edge (i,j) in E has an associated ‘capacity’ u ij. Goal: Determine the maximum amount.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
A New Approach to the Maximum-Flow Problem Andrew V. Goldberg, Robert E. Tarjan Presented by Andrew Guillory.
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 Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
15.082J, 6.855J, and ESD.78J September 21, 2010 Eulerian Walks Flow Decomposition and Transformations.
Chapter 4 Shortest Path Label-Setting Algorithms Introduction & Assumptions Applications Dijkstra’s Algorithm.
1 Minimum Cost Flow - Strongly Polynomial Algorithms Introduction Minimum-Mean Cycle Canceling Algorithm Repeated Capacity Scaling Algorithm Enhanced Capacity.
15.082J and 6.855J and ESD.78J October 19, 2010 Max Flows 3 Preflow-Push Algorithms.
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
15.082J & 6.855J & ESD.78J September 23, 2010 Dijkstra’s Algorithm for the Shortest Path Problem.
1 1 © 2003 Thomson  /South-Western Slide Slides Prepared by JOHN S. LOUCKS St. Edward’s University.
Max flows in O(nm) time, and sometimes less. by James B. Orlin MIT Sloan School.
Maximum Flow Problem (Thanks to Jim Orlin & MIT OCW)
Chapter 3 Algorithms Complexity Analysis Search and Flow Decomposition Algorithms.
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.
OR Chapter 8. General LP Problems Converting other forms to general LP problem : min c’x  - max (-c)’x   = by adding a nonnegative slack variable.
Network Flows Chun-Ta, Yu Graduate Institute Information Management Dept. National Taiwan University.
Chapter 8 Maximum Flows: Additional Topics All-Pairs Minimum Value Cut Problem  Given an undirected network G, find minimum value cut for all.
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.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Supplementary: Feasible Labels and Linear Programming  Consider the LP formulation of the shortest s-t path problem: (P) Minimize  (i, j)  A c ij x.
15.082J & 6.855J & ESD.78J September 30, 2010 The Label Correcting Algorithm.
EMIS 8374 The Ford-Fulkerson Algorithm (aka the labeling algorithm) Updated 4 March 2008.
Approximation Algorithms Duality My T. UF.
15.082J and 6.855J and ESD.78J October 21, 2010 Max Flows 4.
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)
Lectures on Network Flows
Chapter 5. Optimal Matchings
EMIS 8374 Dijkstra’s Algorithm Updated 18 February 2008
James B. Orlin Presented by Tal Kaminker
Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
Instructor: Shengyu Zhang
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
Introduction to Maximum Flows
Dijkstra’s Algorithm for the Shortest Path Problem
3.4 Push-Relabel(Preflow-Push) Maximum Flow Alg.
Primal-Dual Algorithm
Algorithms (2IL15) – Lecture 7
EE5900 Advanced Embedded System For Smart Infrastructure
and 6.855J March 6, 2003 Maximum Flows 2
Flow Feasibility Problems
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
The Ford-Fulkerson Algorithm
Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
Max Flows 3 Preflow-Push Algorithms
Class 11 Max Flows Obtain a network, and use the same network to illustrate the shortest path problem for communication networks, the max flow.
Presentation transcript:

Chapter 7 Maximum Flows: Polynomial Algorithms

Max-flow Min-Cut Theorem and LP Duality Consider the LP formulation of the maximum flow problem: (P) Maximize v subject to {j: (i, j)A} xij - {j: (j, i)A} xji = v, for i = s = 0, for i N\{s, t} = -v, for i = t xij  uij for all (i, j)A xij  0 for all (i, j)A As for the shortest path case, multiply (-1) on both sides of the constraints, then get {j: (j, i)A} xji - {j: (i, j)A} xij = -v, for i = s = v, for i = t i.e consider (inflow to i) – (outflow from i) Network Theory and Applications 2010

{j: (j, i)A} xji - {j: (i, j)A} xij = -v, for i = s (P) Maximize v {j: (j, i)A} xji - {j: (i, j)A} xij = -v, for i = s = 0, for i N\{s, t} = v, for i = t xij  uij for all (i, j)A xij  0 for all (i, j)A The dual of (P) is (D) minimize (i, j)A uijwij subject to yj - yi + wij  0 for all (i, j)  A ys – yt  1 wij  0 for all (i, j)  A, yi unrestricted for all iN Network Theory and Applications 2010

(D) minimize (i, j)A uijwij subject to yj - yi + wij  0 for all (i, j)  A ys – yt  1 wij  0 for all (i, j)  A, yi unrestricted for all iN Let [S, S] be a minimum s-t cut, and consider a dual solution yi = 1, if iS = 0, if iS wij = 1, if iS, j S = 0, otherwise This solution is dual feasible and its objective value is equal to the capacity of the cut. From max-flow min-cut theorem, the objective value is equal to the maximum s-t flow. By strong duality of LP, the solution is optimal to (D). The formulation for minimum cut may be used as part of some other formulations if we need to use min cut as part of some solution (possibly with binary restrictions on the variables) Network Theory and Applications 2010

7.1 Introduction Deficiencies of generic augmenting path algorithm: Running time is O(nmU) May converge to a nonoptimal solution for irrational data (no max-flow min-cut proof) Remedies Capacity scaling algorithm Shortest path augmentation Preflow-push algorithm (relax mass balance eq.) Network Theory and Applications 2010

7.2 Distance Labels Distance function d: N → Z+  {0} with respect to the residual capacities rij. A distance function is valid w.r.t a flow x if d(t) = 0 (7.1) d(i)  d(j) + 1 for every arc (i, j) in the residual network G(x). (7.2) d(i): distance label (7.1), (7.2): validity conditions Property 7.1. valid d(i) is a lower bound on the length (number of arcs) of the shortest (directed) i-t path in the residual network. Pf) Let i = i1 – i2 - … - ik – ik+1 = t be any path of length k from node i to node t in the residual network. d(ik)  d(ik+1) + 1 = d(t) + 1 = 1 d(ik-1)  d(ik) + 1  2 …. d(i) = d(i1)  d(i2) + 1 = k. Network Theory and Applications 2010

Property 7.1 implies that if there exists a path P from node i to node t such that d(i) = d(j) + 1, for all (i, j)P, then it is a shortest i-t path. Property 7.2. If d(s)  n, the residual network contains no directed path from s to t. Terminology: We say that the distance labels are exact if for each node i, d(i) equals the length of the shortest path from node i to node t in the residual network. Can determine exact distance labels for all nodes in O(m) by backward breadth-first search (using queue) starting at the sink node. Arc (i, j) in G(x) is called admissible if d(i) = d(j) + 1, otherwise inadmissible. s-t path is called admissible path if all arcs in the path are admissible arcs. Property 7.3. An admissible path is a shortest augmenting path from the source to the sink. Network Theory and Applications 2010

7.3 Capacity Scaling Algorithm Idea: Augment flows using arcs in G(x) with sufficiently large capacities. G(x, ): -residual network. A network containing arcs whose residual capacity is at least . -scaling phase: phase of the algorithm during which  remains constant. (Each augmentation carries at least  units of flow) Network Theory and Applications 2010

Capacity Scaling Algorithm algorithm capacity scaling; begin x := 0;  := 2log U; while   1 do while G(x, ) contains a path from node s to node t do identify a path P in G(x, );  := min{rij : (i, j)P} augment  units of flow along P and update G(x, ); end;  := /2; Network Theory and Applications 2010

Consequently, v* - v’  m. Consider the flow at the end of the -scaling phase. Let x’ be this flow and v’ denote its flow value. Let S be the set of nodes reachable from s in G(x’, ). Then, tS and [S, S] forms an s-t cut. The residual capacity of every arc in [S, S] is strictly less than , so the residual capacity of the cut [S, S] is at most m. Consequently, v* - v’  m. In the next scaling phase, each augmentation carries at least /2 units of flow  number of augmentation is at most 2m. Labeling algorithm takes O(m) to identify an augmenting path, and updating the -residual network takes O(m) Thm 7.4. The capacity scaling algorithm solves the max flow problem within O(m log U) augmentations and runs in O(m2 log U) time. Can be reduced to O(nm log U) using ideas of the shortest augmenting path. Network Theory and Applications 2010

7.4 Shortest Augmenting Path Algorithm If use simple implementation of the shortest augmenting path: Find shortest s-t path in G(x) for each augmentation. (Use breadth first search – O(m)/iteration) It can be shown that total number of augmentation is at most nm  O(nm2) However, use of distance labels can reduce O(m)  O(n) in augmentation and total number of augmentation is at most nm/2.  gives O(n2m) (times for other necessary operations are bounded by the time O(n2m)) Algorithm proceeds by augmenting flows along admissible paths. We start with exact distance labels obtained by performing the backward breadth-first search starting at the sink node. (The labels are valid too) The algorithm maintains a partial admissible path and iteratively performs advance or retreat operations from the last node of the partial path. If sink node t is reached, we augment flow. Network Theory and Applications 2010

algorithm shortest augmenting path; begin x := 0; obtain the exact distance labels d(i); i := s; while d(s) < n do if i has an admissible arc then advance(i); if i = t then augment and set i = s end else retreat(i) end; Network Theory and Applications 2010

procedure advance(i); begin let (i, j) be an admissible arc in A(i); pred(j) := i and i := j; end; procedure retreat(i); (relabel) d(i) := min{d(j) + 1: (i, j)A(i) and rij > 0}; if i  s then i := pred(i); procedure augment; using the predecessor indices identify an augmenting path P from the source to the sink;  := min{rij: (i, j)P}; augment  units of flow along path P; Network Theory and Applications 2010

Illustrating the shortest augmenting path algorithm d(i) d(j) rij 1 1’ 2 1 1 1 4 2 2 3 2 1 2 1 2 s 2 5 t 2 2 2 1 1 3 6 2 1 1 1 4 1 1 1 1 3 2 1 2 1 2 s 2 5 t 2 2 2 1 1 3 6 Illustrating the shortest augmenting path algorithm Network Theory and Applications 2010

Correctness of the algorithm: Lemma 7.5. The shortest path augmenting path algorithm maintains valid distance labels at each step. Moreover, each relabel (or, retreat) operation strictly increases the distance labels of a node. Pf) Induction on the number of augment and relabel operations (advance operation does not change any residual capacity or distance label). Initially, have valid distance labels. Assume, inductively, that the distance labels are valid prior to an operation. Consider (a) augment, and (b) relabel. (a) flow augmentation on arc (i, j) might remove this arc from G(x), but does not affect the validity of the labels. Augmentation on arc (i, j) might create an additional arc (j, i) with rji > 0 and therefore create an additional inequality d(j)  d(i) + 1. This is satisfied since d(i) = d(j) + 1 by the admissibility property of the augmenting path. (b) Show each incoming and outgoing arc satisfy the condition with respect to the new distance label, say d’(i). Network Theory and Applications 2010

(continued) Relabel node i when it has no admissible arc, i.e. no (i, j)A(i) satisfies d(i) = d(j) + 1 and rij > 0. Also labels satisfy validity conditions d(i)  d(j) + 1, hence d(i) < d(j) + 1 for (i, j)A(i) with a positive residual capacity. Therefore, d(i) < min{d(j) + 1: (i, j)A(i) and rij > 0} = d’(i). Hence, d’(i) strictly increases and it satisfies validity conditions for all outgoing arcs in A(i) with a positive residual capacity. Finally, every incoming arc (k, i) satisfies the inequality d(k)  d(i) + 1. Since d(i) < d’(i), validity condition satisfied for incoming arc (k, i).  Algorithm terminates when d(s) > n, indicating that the network contains no augmenting path. Hence, the flow is maximum. Thm 7.6. The shortest augmenting path algorithm correctly computes a maximum flow. Network Theory and Applications 2010

Complexity of the Algorithm: Use current-arc data structure for A(i) Starting from the current arc in A(i), scan the list to find an admissible arc. Note that if an arc (i, j) is inadmissible in previous iterations, it remains inadmissible until d(i) increases. (Exer. 7.13) Therefore, we can start the scan from the current arc. When we reach the end of the arc list, we relabel and set the current arc as the first arc in the list. The relabel operation also examines the list once to compute the new distance label, which is same as the time it spends in identifying admissible arcs at node i in one scan of the arc list. Property 7.7. If the algorithm relabels any node at most k times, the total time spent in finding admissible arcs and relabeling the nodes is O(kiN |A(i)|) = O(km). Network Theory and Applications 2010

Lemma 7.8. If the algorithm relabels any node at most k times, the algorithm saturates arcs (i.e. reduces their residual capacity to zero) at most km/2 times. (Note that relabel strictly increases d(i) values and d(i) < n in any partial admissible path. Hence increase of node label at most n times  saturation of arcs at most nm/2 times  each augmentation saturates at least one arc  number of augmentation is at most nm/2 and each augmentation is O(n) ) Pf) Show that between two consecutive saturations of an arc (i, j), both d(i) and d(j) must increase by at least 2 units. Then, if the algorithm relabels any node at most k times, the algorithm saturates any arc at most k/2 times. Therefore, the total number of arc saturations would be at most km/2. Suppose that an augmentation saturates an arc (i, j). Since (i, j) is admissible, d(i) = d(j) +1. Before the algorithm saturates the arc (i, j) again, it must send flow back from node j to node i. At this time the distance labels d’(i) and d’(j) satisfy d’(j) = d’(i) + 1. In the next saturation, we must have d’’(i) = d’’(j) + 1. Network Theory and Applications 2010

Therefore, d’’(i) = d’’(j) + 1  d’(j) + 1 = d’(i) + 2  d(i) + 2. (continued) Therefore, d’’(i) = d’’(j) + 1  d’(j) + 1 = d’(i) + 2  d(i) + 2. Similarly, for d’’(j)  d(j) + 2. So, between two consecutive saturations of the arc (i, j), both d(i) and d(j) increase by at least 2 units.  Lemma 7.9. (a) In the shortest path algorithm each distance label increases at most n times. Consequently, the number of relabel operations is at most n2. (b) The number of augment operation is at most nm/2 Pf) Each relabel increases d(i) by at least one. If d(i)  n, the algorithm never select node i during an advance operation since for every node k in the partial admissible path, d(k) < d(s) < n. Thus the algorithm relabels a node at most n times and the total number of relabel operations is bounded by n2.  The algorithm saturates at most nm/2 arcs. Since each augmentation saturates at least one arc,the total number of augmentation is at most nm/2.  Network Theory and Applications 2010

Thm 7.10. The shortest augmenting path algorithm runs in O(n2m) time. Pf) From Lemmas 7.9 and 7.7, total effort spent in finding admissible arcs and in relabeling the nodes is O(nm). Total number of augmentation is O(nm) and each augmentation is O(n)  O(n2m) for augmentation Each retreat operation relabels a node, so the total number of retreat operation is O(n2). Advance operations: Each advance operation adds one arc to the partial admissible path, and each retreat operation deletes one arc. Total number of advance operations is O(n2 + n2m). First term comes from retreat operations, and the second term from the number of augmentations.  Network Theory and Applications 2010

A Practical Improvement: Algorithm may take too much time to get the terminating condition d(s)  n, although a maximum flow is obtained. Ex) 4 1 1 1 4 1 1 1 1 3 4 1 1 1 1 s 2 5 t 1 1 1 1 2 1 1 1 1 3 6 Network Theory and Applications 2010

Use an n-dimensional array numb, whose indices vary from 0 to (n-1). numb(k) is the number of nodes whose distance label equals k. Start with initial distance labels. At this point, the positive entries in the array numb are consecutive (starting from numb(0), up to numb(l) for some l). Subsequently, when the algorithm increases the distance label of a node from k1 to k2, we subtract 1 form numb(k1), add 1 to numb(k2) and check whether numb(k1) = 0. If numb(k1) = 0, the algorithm terminates. Correctness: Let S = {iN: d(i) > k1} and S = {iN: d(i) < k1}. Have sS and tS. Consider the s-t cut [S, S]. The definition of S and S imply that d(i) > d(j) + 1 for all (i, j)[S, S]. The validity condition implies that rij = 0 for each arc (i, j) [S, S]. Therefore, [S, S] is a minimum cut and the current flow is a maximum flow. Network Theory and Applications 2010

Application to Capacity Scaling Algorithm: Can improve O(m2 log U) running time of capacity scaling algorithm. (recall algorithm works on G(x, ). O(m) for identifying an augmenting path. At termination for G(x, ), have v* - v’  m, hence 2m augmentations in the next scaling phase.) Use shortest augmenting path algorithm for G(x, ). O(m) augmentations for each scaling phase is guaranteed. (Compare with O(nm) augmentations for general algorithm). Hence the time for augmentation reduces from O(n2m) to O(nm) and all other operations, as before, require at most O(nm) time.  O(nm log U) Further worst-case Improvements: The bound O(nm) on the number of augmenting paths is tight. Using dynamic trees data structure reduces the average time for each augmentation from O(n) to O(log n), hence O(nm log n). Network Theory and Applications 2010

7.5 Distance Labels and Layered Networks (Dinic’s Alg.) Dinic’s algorithm: send flows along shortest paths in layered networks and establish blocking flow. Layered network V with respect to flow x: Determine the exact distance labels d in G(x). The layered network consists of arcs (i, j) in G(x) satisfying the condition d(i) = d(j) + 1 (admissible arcs). Eliminate some arcs not contained in any s-t path in layered network V. Nodes in V are partitioned into layers of nodes V0, V1, V2, … , Vl; layer k contains the nodes whose distance labels equal k. Furthermore, every arc (i, j) in V, iVk and jVk-1 for some k. Let the source node have distance label l. Dinic’s algorithm proceeds by augmenting flows in the layered network. Augmenting flow on arc (i, j) may create arc (j, i) in the residual network, but each arc of the layered network is admissible. So we don’t add (j, i). Network Theory and Applications 2010

(continued) Finding an augmenting path can be done in O(n) on average (continued) Finding an augmenting path can be done in O(n) on average. Each augmentation saturates at least one arc in V, hence at most m augmentations. If no more augmentation possible, current flow is called a blocking flow. Can obtain a blocking flow in O(nm). If blocking flow obtained, Dinic’s algorithm recomputes exact distance labels, forms a new layered network, and repeats these computations. It is possible to show that every time Dinic’s algorithm forms a new layered network, the distance label of the source node strictly increases. So at most n layered networks formed, and running time is O(n2m) Network Theory and Applications 2010

How to view Dinic’s Algorithm as a modified version of the shortest augmenting path algorithm Modification 1: In operation retreat(i), we do not change the distance label of node i, but subsequently term the node i as blocked. A blocked node has no admissible path to the sink node. Modification 2: We define an arc (i, j) to be admissible if d(i) = d(j) + 1, rij > 0, and node j is not blocked. Modification 3: When the source node is blocked, by performing a backward breadth-first search we recompute the distance labels of all nodes exactly. Network Theory and Applications 2010

We term the computations within two successive recomputations of distance labels as occurring within a single phase. Following facts about the modified shortest augmenting path algorithm At the beginning of a phase, when the algorithm recomputes the distance labels d(), the set of admissible arcs defines a layered network. Each arc (i, j) in the admissible path satisfies d(i) = d(j) + 1; therefore, arc (i, j) joins two successive layers of the layered network. As a result, every admissible path is an augmenting path in the layered network. Since we do not update distance labels within a phase, every admissible path has length equal to d(s). The algorithm performs at most m augmentations within a phase because each augmentation causes at least one arc to become inadmissible by reducing its residual capacity to zero, and the algorithm does not create new admissible arcs. A phase ends when the network contains no admissible path from node s to node t. Hence, when the algorithm recomputes distance labels at the beginning of the next phase, d(s) must increase. Network Theory and Applications 2010