# Max Flows 2: The Excess Scaling Algorithm and Variants. James Orlin.

## Presentation on theme: "Max Flows 2: The Excess Scaling Algorithm and Variants. James Orlin."— Presentation transcript:

Max Flows 2: The Excess Scaling Algorithm and Variants. James Orlin

Algorithmic ideas from the previous lecture Augmenting path algorithm an improvement algorithm that is guaranteed to be optimal Max-Flow Min-Cut: using a variation of LP duality to establish optimality and distance from optimality. Scaling Solving a sequence of problems that converges to the original problem. Efficient when reoptimizing can be done quickly. Simple data structures keeping track of distance labels and current arcs sped up the algorithm 2

Algorithmic Ideas in this lecture Preflows: A relaxation of flows that leads to improved algorithms. A new scaling algorithm Potential function analysis a method of establishing a faster running time by using “global” information about the algorithm. 3

Running times for max flow algorithms O(nm 2 )Edmonds and Karp (1972) O(n 2 m)Dinic (1970) O(n 3 )Karzanov (1974) Malhotra, Kumar & Maheshwari (1977) O(n 2 m ½ )Cherkasky (1977) O(nm log 2 n)Galil and Naaman (1980) O(nm log n)Sleator and Tarjan (1983) O(nm log n 2 /m)Goldberg and Tarjan (1988) 4

More Improvements in running time O(nm+ n 2+ε )King Rao and Tarjan (1992) O(nm log α n )King Rao and Tarjan (1994) α = m/(n log n) O(n 3 / log n )Cheriyan, Hagerup, and Mehlhorn (1996) O(nm)O. (2011) O(nm / log n)O. (2011) if m = O(n) and under some other conditions. Remark 1: The max flow problem is solvable in O(nm / log n) steps when m = Ω(n 2 ) and when m = O(n). Remark 2: The improvements by O. (2011) are very involved. 5

Weakly polynomial running times O(nm log U)Gabow (1985) O(nm + n 2 log U)Ahuja and Orlin (1989) O(nm + n 2 log ½ U)Ahuja, Orlin, and Tarjan (1989) O(m 3/2 log n log U) Goldberg and Rao (1998) O(n 2/3 m log(n 2 /m) log U)Goldberg and Rao (1998) O(n 2/3 m log U)O. (2011) Further improvements if log U max /U min = O(n 1/3 ) Remark: The improvement by O. (2011) is very simple 6

7 Preflows At each intermediate stages we permit more flow arriving at nodes than leaving (except for s) A preflow is a function x: A → R s.t. 0  x  u and such that e(i) = ∑ j ∈ N x ji - ∑ j ∈ N x ij ≥ 0, for all i ∈ N – {s, t}. i.e., e(i) = excess at i = net excess flow into node i. The excess is required to be nonnegative.

8 A Feasible Preflow The excess e(j) at each node j ≠ s, t is the flow in minus the flow out. s 3 4 25 t 3 3 3 2 2 2 2 1 2 1 0 0 Note: total excess = flow out of s minus flow into t. In preflow push algorithms, we typically send flow in only one arc at a time.

9 Converting a preflow into a flow Any preflow can be converted into a flow that preserves the flow into t. s 5 t 3 2 2 1 3 3 2 1 4 32 0 0 Run flow decomposition and then keep only the paths from s to t. PathFlow s-3-t2 s-31 s-4-t2 s-4-21 PathFlow s-21 s-2-5-t2 1 2 2 2 2 1 2

Distances We will maintain distance labels. Next: how to maintain distance labels efficiently. 10

11 Exact Distance Labels Distance labels d( ) are exact for G(x) if for all j with a path to t, d(j) is the length of the shortest path from j to t. it P = the shortest path from i to t in G(x) d( ) 0123434 Lemma. Suppose all distance labels are exact. Then, an arc (i, j) is admissible if and only if it is on a shortest path from i to t. An arc is (i, j) is admissible if d(i) = d(j) + 1.

Maintaining Exact Distance Labels At each iteration, CurrentArc(i) is the first admissible arc in A(i). The current arcs form a tree (or forest), whose arcs are directed into node t. 12 1 23 4 5 6 7 8 t 7654321076543210 Suppose CurrentArc(i) = (i, j). Arc (i, j) may become inadmissible if 1. (i, j) is saturated or 2. the distance label of j is increased. We will update CurrentArc(i) if it is inadmissible. We will update d(i) if there is no admissible arc out of i.

An update of CurrentArc Example 1. Suppose that flow is sent in (7, 2) and the arc is saturated. 13 1 23 4 5 6 7 8 t 7654321076543210 7 8 4 6 23 TailHeadRes. Cap 720 731 744 762 780 Then (7, 3) becomes admissible.

Example 2: there is a cascading effect Example 2. Suppose now that (3, 8) is saturated. 14 1 2 4 5 6 7 8 t 7654321076543210 TailHeadRes. Cap 3 5 6 3 7 2 3 8 0 Node 3 increases its distance label to 4. (3, 5) is admissible. (7, 3) is inadmissible and node 7 is updated next. 3

Example 3: a gap is created Example 3. Suppose now that (5, 2) is saturated. 15 1 2 4 5 67 8 t 7654321076543210 TailHeadRes. Cap 5 2 0 5 3 3 5 4 6 Node 5 increases its distance label to 5. But now there is no node with distance label 3. 3

Example 3: continued 16 1 2 4567 8 t 3 7654321076543210 ∞ When a gap is created, all nodes with distance level above the gap have their distance level set to ∞.

17 Time for updating distance labels Lemma. 1. The arc list of each node i is scanned at most once between updates of d(i). 2. The arc list is scanned once if d(i) needs to be updated. 3. d(i) is updated at most n-1 times for each i. Conclusion. Each arc is scanned O(n) times. The total running time for updating CurrentArc and d( ) is O(nm).

On the order in which things are done Typically, the generic preflow push algorithm is presented before the excess scaling algorithm. But not here. 18

Scaling Algorithms 19 Generic Scaling Algorithm Δ := 2 K for some selected value K determine a Δ-optimal solution x while Δ > 1 do y := ImproveApprox(x, Δ) x := y Δ := Δ/2 1. Define a concept called Δ- optimal, where Δ is some positive integer, and where a 1-optimal solution is optimal for the original problem. 2. Develop a subroutine that efficiently determines Δ 0 - optimum solution where Δ 0 is some (possibly large) power of 2 3. Develop a subroutine Improve-Approx that transforms a Δ-optimal solution into a Δ/2-optimal solution.

Initialize 20 s 5 7 d(s) := ∞ e(5) = u s5 e(7) = u s7 1. Determine exact distance labels for each node. 2. For each arc (s, j), send u sj units of flow from s to j. This results in an excess e(j) = u sj. 3. d(s) := ∞; 4. Choose Δ 0 to be the minimum power of 2 that is greater than max (u sj : j ∈ N}.

21 Excess- Scaling Preliminaries u A preflow x is called Δ-optimal if 1. 0 ≤ e(i) < Δ for all i with 1 ≤ d(i) < ∞. 2. the distance labels are exact 3. d(s) = ∞; that is, there is no path from s to t in G(x).  Subroutine ImproveApprox(x,Δ): takes a flow that is Δ-maximum and outputs a flow that is Δ/2-maximum. ImproveApprox terminates when e(i) < Δ/2 for all i with 1 ≤ d(i) < ∞. After initialization, the flow is Δ 0 -optimal.

Push-Relabel(i) 22 INPUT: a node i with e(i) ≥ Δ/2. Push-Relabel(i) begin while e(i) > 0 do if there is an admissible arc (i, j) then send min {e(i), Δ - e(j) – 1, r ij ) units of flow in (i, j) else replace d(i) by 1 + min{d(j) : r ij > 0} update r, e, CurrentArc, and d( ); end

Examples of Push-Relabel 23 7 4 6 3 Δ = 64 level k+2 k+1 k k-1 Case 1. e(7) = 62 r 73 = 40 e(3) = 10 62 10 40 22 52 0 Case 2. e(7) = 62 r 73 = 40 e(3) = 30 62 30 40 29 63 7 62 30 0 Case 3. e(7) = 62 r 73 = 0

24 Excess Scaling Algorithm Procedure Improve-Approx(r, Δ) begin while there is a Δ/2-active node do begin let i = argmin (d(i) : i is Δ/2-active} Push-Relabel(i) end end;

25 Pushing in the 64-scaling phase 0 5 4 3 2 1 t 4 5 s 2 s s 5 7 9 8 7 6 9 6 3 8 5 j 32 ≤ e(j) < 64 “large excess” i e(i) < 32 4 7 5 62 025 240 For each admissible arc (i,j), j is not large excess. Choose a large excess node i at minimum distance level.

26 Pushing in the 64-scaling phase. 4 7 5 62 028 2 40 Rule: push as before, except that no node excess can exceed Δ-1. Push 2 units in (7,4). Then push 35 units in (7,5) 4 7 5 25 2 63 2 5 35 Send min{e(i), r ij, Δ-e(j)-1} units of flow in (i,j) Any non-saturating push has at least Δ/2 units of flow j 32 ≤ e(j) < 64 “large excess” i e(i) < 32

Bounding the number of pushes Each arc (i, j) has at most one saturating push in between relabels of i. It may have several non- saturating pushes. We will show that the number of non-saturating pushes per scaling phase is O(n 2 ). We will use a potential function argument. We will define a potential function Φ. Each non-saturating push will decrease Φ by.5. We will bound this number by bounding the total increase in Φ over all iterations. 27

Elevators movements 28 10 9 8 7 6 5 4 3 2 1 0 An elevator is in a building that is n stories high. It can go up multiple floors at a time, but it can only go down one floor at a time. In m movements of the elevator, how many floors can it travel upwards? Note: it can travel n floors in a single move.

UP ≤ DOWN + n. 29 10 9 8 7 6 5 4 3 2 1 0 It can go up at most n floors more than it goes down. It can go down at most m floors in m moves. In m moves, it can travel at most 2m + n floors. If m > n, it travels at most 3m floors, or fewer than 3 floors per move on average.

Finding a min-distance Δ/2-active node. 30 10 9 8 7 6 5 4 3 2 1 0 For each distance level store a doubly linked list of Δ/2-active nodes. After pushing flow from a node i, the next push is from a node with d(j) ≥ d(i) – 1. Start with distance level d(i) – 1 and seek the first distance level with a Δ/2-active node. Number of steps in m pushes is at most 2m + n. ∅ ∅ ∅ ∅ {i} {j, j’} Δ/2-active nodes at level k ∅

Next: Bounding the number of pushes We will create a potential function Φ. We will use the up and down argument to bound the amount of decrease in Φ over all iterations. This will bound the number of pushes. 31

32 A potential function for excess-scaling 0 5 4 3 2 1 t 4 5 s 2 s s 5 7 9 8 7 6 9 6 3 8 5 Φ = ∑ j ∈ N e(j) d(j) / Δ node23456789 e(j)40105355540 e(j)d(j)80102070165120 Φ = 384 / 64 = 6 The potential is the “gravitational potential” measured in units of Δ

33 Increases in the potential function 0 5 4 3 2 1 t 4 5 s 2 s s 5 7 9 8 7 6 9 6 3 8 5 Relabels: Φ increases by at most k if d(j) increases by k. Φ increases by O(n 2 ) over all relabels. Φ = ∑ j ∈ N e(j) d(j) / Δ Start of scaling phase. Φ doubles when Δ is replaced by Δ/2. Φ increases by O(n 2 log U) over all scaling phases.

34 Decreases in the potential function 0 5 4 3 2 1 t 4 5 s 2 s s 5 7 9 8 7 6 9 6 3 8 5 Push: Φ decreases by δ/Δ if δ units of flow are sent in (i, j) Φ decreases by at least ½ in any large push Φ = ∑ j ∈ N e(j) d(j) / Δ Conclusion: number of large pushes is at most 2n 2 plus the total increase in Φ. This is O(n 2 log U) large pushes.

Summary of Excess Scaling Algorithm Converts Δ-optimal flows into Δ/2-optimal flows O(nm) running time (excluding time for large pushes) O(n 2 ) time for large pushes per scaling phase. O(nm + n 2 log U) time overall. 35

On the analysis of the potential function Note: the potential function Φ increased O(n 2 ) because of relabels, and increased O(n 2 log U) when Δ was replaced by Δ/2. Speeding up the algorithm: If we can reduce the total flow at the end of the algorithm to O(nΔ/K) for some K, then the potential increase would be O( (n 2 log U)/K). We will show how to do this for K = log ½ U. Another bottleneck appears; so one cannot make K any larger. 36

General Algorithmic Rule 37 Single bottleneck rule If the bottleneck in an algorithm is caused by one “thing”, then try to speed up the “thing.”

Excess Scaling with Waves Carry out a sequence of “waves” during a scaling phase. Rules for the wave. 1. Select the lowest level Δ/2-active node, if one exists. Else, select the highest level node i with 1 < e(i) < Δ/2. Push flow from the selected node. 2. If a node has no admissible arcs, then delete it from G(x) for the rest of the wave (and add it back after the wave). 3. The wave ends when there are no nodes with positive excess remaining. 4. After the wave, update the distance labels and the CurrentArc( ). 38

Excess Scaling with Waves 39 Procedure Improve-Approx(r, Δ) begin while the total excess is greater than nΔ / log ½ U do perform a wave update distance labels and current arcs end;

Examples of Pushes During a Wave 40 Δ = 64 level k k-1 There are no Δ/2-active nodes. Node 7 is the highest level node with excess. Arcs (7, 3) and (7, 4) are admissible. 30 20 7 34 5 15 30 8 20 7 34 5 15 30 10 6 7 34 5 4 40 0 7 3 4 5 15 0 28 0 7 34 15 5 20 16 0 7 34 9 0 Case 1. Send 20 units in arc (7, 3). Node 3 becomes Δ/2-active. Case 2. Send 20 units in arc (7, 3). Send 10 units in arc (7, 4). Delete node 7 from LIST. Case 3. Send 6 units in arc (7, 3). Send 4 units in arc (7, 4). Delete node 7 from LIST. Example 1 Example 2Example 3

4 5 5 t Waves during the Δ-scaling Phase 1. No node is ever Δ-active during the Δ-scaling phase. 2. At the end of the wave, each active node j (that is, e(j) > 0) will increase its distance label. (There is no path from j to t of admissible arcs). 41 0 4 3 2 1 2 6 37 1 An arc may become inadmissible when it is saturated. This can cause a “cascading effect of deletions. e.g., suppose (1, 5) is saturated. suppose (2, 4) is saturated.

Waves during the Δ-scaling Phase 3. There is at most one non-saturating push from a node with e(i) < Δ/2. 42 4 5 5 t 0 4 3 2 1 2 6 37 1 If no nodes are Δ/2 active, then the highest level active node will never receive any more flow during the wave. 4. If the Δ-scaling phase does not end after a wave, there were at least n/log ½ U distance increases. If e(6) := 0, then e(6) = 0 for the rest of the wave. At the end of the wave, each node with excess will be relabeled. If the Δ-scaling phase didn’t end, then the total excess is at least nΔ/log ½ U.

Putting it all together 1. There are O(log U + n log ½ U ) waves. Each wave leads to O(n) small non-saturating pushes. 2. Total run time because of the waves is O(n 2 log ½ U ), if log U < n 2 43 3. Each non-saturating push from a Δ/2-active node decreases Φ by at least.5 4. Φ increases by O(n 2 / log ½ U ) following a scaling phase. It increases by O(n 2 log ½ U ) in total. 5. Conclusion: Number of non-saturating pushes is O(n 2 log ½ U ).

summary of techniques Preflows: A relaxation of flows that leads to improved algorithms. It is quite common to solve problems by solving relaxations. Potential function analysis a method of establishing a faster running time by using “global” information about the algorithm. surprisingly useful in analyzing data structures and algorithms Excess scaling Excess scaling with waves. (If there is a single bottleneck operation or a single cause of the bottleneck, sometimes the running time can be improved by combining two approaches.) 44

45 Research notes on preflow push u Pushing from the active node with the largest distance label leads to O(n 2 m.5 ) nonsaturating pushes. u A very efficient data structure called dynamic trees reduces the running time to O(nm log n 2 /m). Goldberg- Tarjan (1986) u The “excess scaling technique” of Ahuja and Orlin (1989) reduced the running time to O(nm + n 2 log U). u Ahuja, Orlin, and Tarjan (1989): further very small improvements. u Goldberg and Rao (1998). An even more efficient algorithm for max flows. u Orlin [2011] max flows in O(nm) time and sometimes less.

Download ppt "Max Flows 2: The Excess Scaling Algorithm and Variants. James Orlin."

Similar presentations