300 likes | 481 Views
Max flows in O(nm) time, and sometimes less. by James B. Orlin MIT Sloan School. The Maximum Flow Problem. Directed Graph G = (N, A). Source s Sink t Capacities u ij on arc ( i,j ). Let U = max { u sj : j ∈ N}. Maximize the flow out of s, subject to
E N D
Max flows in O(nm) time, and sometimes less.by James B. OrlinMIT Sloan School
The Maximum Flow Problem • Directed Graph G = (N, A). • Source s • Sink t • Capacities uij on arc (i,j). Let U = max {usj : j ∈ N}. • Maximize the flow out of s, subject to • Flow out of i = Flow into i, for i≠ s or t. 1 1 2/2 2 3/4 4 s s 1/1 1 t t 1 1/1 2 2 2/3 3 A maximum Flow A Network with Arc Capacities
Max-Flow Min-Cut 1 • Max-Flow Min-Cut (1956) • The maximum flow value is • the minimum capacity of an • s-t cut. 2/2 3/4 s 1/1 t 1/1 2 2/3 A max flow and minimum cut An s-t cut is a partition of the node set into two parts S and T, with s ∈ S and t ∈ T. The capacity of a cut with respect to capacity vector u is
Running times for max flow algorithms O(nm2) Edmonds and Karp (1972) O(n2m) Dinic (1970) O(n3) Karzanov (1974)Malhotra, Kumar & Maheshwari (1977) O(n2 m½ ) Cherkasky (1977) O(nm log2 n) Galil and Naaman (1980) O(nm log n) Sleator and Tarjan (1983) O(nm log n2/m) Goldberg and Tarjan (1988)
More Improvements in running time O(nm+ n2+ε ) King Rao and Tarjan (1992) O(nm logα n ) King Rao and Tarjan (1994) α = m/(n log n) O(n3 / log n ) Cheriyan, Hagerup, and Mehlhorn (1996) O(nm) O. (2012) O(nm / log n) O. (2012) 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 = Ω(n2) and when m = O(n).
Weakly polynomial running times O(nm log U) Gabow (1985) O(nm + n2 log U) Ahuja and Orlin (1989) O(nm + n2 log½ U) Ahuja, Orlin, and Tarjan (1989) O(m3/2 log n log U) Goldberg and Rao (1998) O(n2/3 m log(n2/m) log U) Goldberg and Rao (1998) O(n2/3m log U) O. (2012) Further improvements if log Umax/Umin = O(n1/3- ε)
On Network Flow Algorithms • Augmenting Path Algorithms: • intermediate solutions are feasible flows • improvements are made by sending flow along a path • Preflow-Push Algorithms • intermediate solutions can violate flow conservation • “improvements” are made by sending flow along a single edge All are improvement algorithms, they start with a non-optimal solution and find an improved solution.
The Goldberg-RaoΔ-scaling phase as a black boxassume that m < n1.06run O( log n) scaling phases of the original GR algorithm Δ-scaling phase INPUT: A flow x and an s-t cut (S, T).Δ = u(S, T) – v(x) Δ is an upper bound on how much more flow can be sent. OUTPUT: A flow x’ and an s-t cut (S’, T’) such that u(S’, T’) – v(x’) ≤ Δ/n. RUNNING TIME: O(m3/2 log2 n). Leads to an (O(m3/2 log n log U) time algorithm for max flows.
1 7/8 8/10 1/1 x /u s t ij ij i j 5/6 6/10 2 u - x ij ij i j x 1 1 2 ij 8 7 1 s t 4 1 2 6 5 The Residual Network We let rij denote the residual capacity of arc (i,j) The Residual Network G(x)
1 7/8 8/10 1/1 s t 5/6 6/10 2 We will ignore arcs directed into s or out of t 1 1 2 8 7 1 s t 4 1 2 6 5 The Residual Network G(x)
Δ-abundant arcs and paths We writei⇒j if there is a Δ-abundant path from i to j. Otherwise, we write i⤃j • We maintain a list of all pairs i, j of nodes such thati⇒j. • O(nm) time over all iterations • Italiano [1986]. Dynamic transitive closure. An arc (i, j) is called Δ-abundant at the Δ scaling phase if rij≥ 2Δ. Lemma.If an arc is Δ-abundant at some scaling phase, it is Δ-abundant at all subsequent phases. Proof. The change in flow in any arc (i, j) in the Δ-scaling phase is at most Δ. If xij≥ 2Δ at the beginning of the phase, then If xij ≥ Δ at the end of the phase, and If xij ≥ nΔ’ at the next phase.
Contraction of arcs • If arcs (i, j) and (j, i) are both Δ-abundant at the Δ scaling phase, then we will contract arcs (i, j) and (j, i) and expand them at the end of the algorithm. (Contraction is well known.) 1 1 2 2 ≥ 2 Δ 5-6 6 5 5 ≥ 2 Δ 4 4 3 3 At time of contraction, flow into 5 (resp., 6) = flow out 5 (resp., 6). After contraction, the flow into (5, 6) changes by at most Δ over all remaining iterations.
More contraction of arcs • If arc (s, j) is Δ-abundant at the Δ scaling phase, then we will contract (s, j). If (j, t) is Δ-abundant, then we will contract (j, t). 2 1 2 ≥ 2 Δ s-1 3-t 1 3 s t ≥ 2 Δ 4 3 4 We also can contract Δ abundant cycles.
Compaction of nodes 1 2 1 2 ≥ 2 Δ ≥ 2 Δ ≥ 2 Δ 6 ≥ 2 Δ 5 ≥ 2 Δ 3 4 4 3 Before compaction After compaction Compaction. New Procedure. Determine nodes that are compactible all arcs incident to compactible nodes are Δ-abundant. Compactible nodes are eliminated. There is an arc (i, j) in the compacted graph if there is an abundant path from i to j in the original graph.
Small, medium, and abundant arcs We partition the arcs of the contracted graph into three groups. We say that arc (i, j) isΔ-small if rij≤ Δ/2n3 We say that arc (i, j) isΔ-medium if Δ/2n3 < rij≤ 2Δ We say that arc (i, j) isΔ-abundant if rij> 2Δ 3 1 6 From here on, we ignore the Δ-small arcs. t 4 s 2 5 7
Δ-Critical Arcs and Nodes We say that arc (i,j) iscritical if it is Δ–medium and j⤃i. We say that node i is critical if is incident to a critical arc. 3 1 6 critical node t 4 s critical arc medium non-critical arc 2 5 7 Each arc is critical for O(1) scaling phases.
Δ-Fertile and Δ-Compactible Nodes Let MNC be the set of medium non-critical arcs. We say that a non-critical node iisΔ-compactibleif We say that a non-critical node iisΔ-Fertileif fertile node 3 1 6 3 2 compactible node 2 t 4 s 5 2 5 7 4
The compacted network. 3 1 3 1 6 3 3 2 t s 2 t 4 s 2 5 2 5 7 4 2 5 7 4 Eliminate all Δ-compactible nodes. The nodes of the compacted network are N* =Δ-critical and Δ-fertile nodes. If i, j ∈ N* and if i⇒j , then there is a Δ-abundant arc in A*. Use flow decomposition for other arcs in MNC.
3 1 3 t s 2 2 5 7 4 Let α = 1 – 1/(4n) G = network before compaction. G* = compacted network. 3 1 6 Lemma 1. Any flow in G* of value v* > Δ/2 can be transformed into a flow in G with value at least v* (1 – α). 3 2 2 t 4 s Lemma 2. Any s-t cut (S*, T*) in G* with capacity C < Δ/2 can be transformed into an s-t cut (S, T) in G with capacity < C(1 + α). 5 2 5 7 4
On the number of nodes in compacted networks Lemma 3. Each arc with finite capacity is critical for O(1) scaling phases. Corollary. The number of critical nodes is O(m’) over all phases. Lemma 4. Each fertile node is contracted within O(1) scaling phases. The number of fertile nodes in all scaling phases is O(n). 3 1 3 t s Proof. Consider the LHS of 2 2 5 7 It is invariant if MNC does not change. After O(1) scaling iterations the left hand side exceeds 4mΔ and so one of the arcs (i, j) must be abundant, and would be contracted. 4
On solving flows on compacted networks. Let G* = (N*, A*) be the compacted network, with c = |N*|. Thus |A*| < c2. If c > m9/16, we will solve the approximate max flow problem on G in O(m3/2 log2 n)time. Ifc ≤ m9/16, we will solve the approximate max flow problem on G in O(c8/3 log n) time. Time to create all compacted networks is O(nm). Total number of nodes in compacted networks is O(n + m’)
Running time for the max flow problem Time for flows in all phases: O(m15/16 m’ log2 n). For ε < 1/16 and for m’ < n1+ε, time is O(nm). Time to create the networks. O(nm). (See note below) Total running time. O(nm). A special approach is needed if c is smaller than nε .
When m’ = O(n), running time is O(nm / log n) That is, the number of arcs with finite capacity is O(n). Time for solving the flow problems Time for flows: O(m15/16 m’ log2 n) = O(n m15/16 log2 n). Time for creating the compacted networks can be sped up to O(nm/log n). Total running time is O(nm / log n). If m = O(n), the running time is O(n2 / log n)
On speeding up the creation of G* • Time for creating a compacted networkG* = (N*, A*) with |N*| = c. • Time for determining all abundant paths between nodes of N* • O(c m) time using search algorithms • O(c m / log n) time using “bit packing” • Time for creating all of the compacted networks • O(nm/log n). • Time for uncompacting the networks • O(nm/log n) • A number of technical details.
Further improvements if Umax/Umin is “small”. Umax = max {uij : uij < ∞}; Umin = min {uij : uij > 0} After 2K phases, there are no small or medium capacity arcs. Running time for flow subroutines: O(nm15/16). Running time for creating compacted networks: O(nm/log n) How large can K be so that the running time is O(nm/log n)? If m is large, can one speed up the time to create compacted network.
How large can K be? Suppose that m = nγ. The running time for the first 2K phases is less O(nm/log n) if m < n4/3 and K < n2– γ/2 – ε or m ≥ n4/3 and K < n1/3 – ε.
A speedup if Umax/Umin is small and m is large. • Suppose that m ≥ n4/3 and K < n1/3 – ε. • Running time for first 2K phases is O(n1-ε/2 m). • One can use fast matrix multiplication for computing the arcs of the compacted graph. • O(n2.376) Coppersmith and Winograd [1990] • O(n2.3727) Williams [2011] • Let ω = 2.3727
Running times if Umax/Umin is small Running time = O(max {nm/ n.1242, n2.5818} )
Improvement in strongly polynomial time max flows Relies on contraction and compaction prior to using GR If log (Umax/Umin) < n1/3- ε , then