fullscreen
timer
qrcode
plickers
selector
edit
reset

network flow (7)

capacity-scaling algorithm

analysis ford-fulkerson alg (with integral capacities)

Assumption: Every edge capacity \(c(e)\) is an integer in \([1,C]\)

Integrality invariant: Throughout Ford-Fulkerson, every edge flow \(f(e)\) and residual capacity \(c_f(e)\) is an integer

Pf: By induction on the number of augmenting paths \(\quad\qed\)


Theorem: Ford-Fulkerson terminates after at most \(\mathit{val}(f^*) \leq nC\) augmenting paths, where \(f^*\) is a max flow (consider cut \(A = \{s\}\); assumes no parallel edges)

Pf: Each augmentation increases value of flow by at least \(1\) \(\qed\)


Corollary: The running time of Ford-Fulkerson is \(O(mnC)\)

Pf: Can use either BFS or DFS to find an augmenting path in \(O(m)\) time \(\qed\)

analysis ford-fulkerson alg (with integral capacities)

Assumption: Every edge capacity \(c(e)\) is an integer in \([1,C]\)

Integrality theorem: There exists an integral max flow \(f^*\) (\(f(e)\) is an integer for every \(e\))

Pf: Since Ford-Fulkerson terminates, theorem follows from integrality invariant (and augmenting path theorem) \(\quad\qed\)

Ford-Fulkerson: exponential example

Q: Is generic Ford-Fulkerson algorithm poly-time in input size (\(m\), \(n\), and \(\log C\))?

A: No. If max capacity is \(C\), then algorithm can take \(\geq C\) iterations

  • \(s \rightarrow a \rightarrow b \rightarrow t\)
  • \(s \rightarrow b \rightarrow a \rightarrow t\)
  • \(s \rightarrow a \rightarrow b \rightarrow t\)
  • \(s \rightarrow b \rightarrow a \rightarrow t\)
  • \(s \rightarrow a \rightarrow b \rightarrow t\)
  • \(s \rightarrow b \rightarrow a \rightarrow t\)
  • ...

each augmenting path sends only 1 unit of flow (number of augmenting paths is \(2C\))

fork-fulkerson algorithm: exponential-time example

Bad news: Number of augmenting paths can be exponential in input size

quiz: network flow

live view ]

The Ford-Fulkerson algorithm is guaranteed to terminate if the edge capacities are ...

  1. Rational numbers
  2. Real numbers
  3. Both A and B
  4. Neither A nor B

choosing good augmenting paths

Use care when selecting augmenting paths


Pathology: When edge capacities can be irrational, no guarantee that Ford-Fulkerson terminates (or converges to a maximum flow)!

Zwick 1995
Zwick 1995

ford-fulkerson algorithm: pathological example

Intuition: Let \(r > 0\) satisfy \(r^2 = 1 - r\)

\[\begin{eqnarray} r = \frac{\sqrt{5} - 1}{2} & \quad\Rightarrow\quad & r^2 = 1 - r \\ r \approx 0.618 & \quad\Rightarrow\quad & r^4 < r^3 < r^2 < r < 1 \end{eqnarray}\]

ford-fulkerson algorithm: pathological example

ford-fulkerson algorithm: pathological example

flow after augmenting path:

ford-fulkerson algorithm: pathological example

Theorem: the Ford-Fulkerson algorithm may not terminate; moreover, it may converge to a value not equal to the value of the maximum flow

Pf:

choosing good augmenting paths

Use care when selecting augmenting paths


Pathology: When edge capacities can be irrational, no guarantee that Ford-Fulkerson terminates (or converges to a maximum flow)!


Goal: Choose augmenting paths so that

choosing good augmenting paths

Choosing augmenting paths with

Edmonds-Karp 1972 (USA);
Edmonds-Karp 1972 (USA);
Dinitz 1970 (Soviet Union)
Dinitz 1970 (Soviet Union)

Dinitz invented algorithm in response to a pre-class exercise by Adelson-Velsky

capacity-scaling algorithm

Overview: Choosing augmenting paths with "large" (though not necessarily largest) bottleneck capacity

capacity-scaling algorithm

Capacity-Scaling(G)
    Foreach edge e in E: f(e) <- 0
    Delta <- largest power of 2 <= C
    While(Delta >= 1)
        // body of this loop is Delta-scaling phase
        Gf(Delta) <- Delta-residual network of G with respect to flow f
        While(there exists an s-t path P in Gf(Delta))
            f <- Augment(f, c, P)
            Update Gf(Delta)
        Delta <- Delta / 2
    Return f

capacity-scaling alg: proof of correctness

Assumption: All edge capacities are integers between \(1\) and \(C\)

Invariant: The scaling parameter \(\Delta\) is a power of 2

Pf: Initially a power of 2; each phase divides \(\Delta\) by exactly 2 \(\qed\)


Integrality invariant: Throughout the algorithm, every edge flow \(f(e)\) and residual capacity \(c_f(e)\) is an integer.

Pf: Same as for generic Ford-Fulkerson \(\qed\)

capacity-scaling alg: proof of correctness

Assumption: All edge capacities are integers between \(1\) and \(C\)

Theorem: If capacity-scaling algorithm terminates, then \(f\) is a max flow

Pf:

capacity-scaling alg: analysis of running time

Lemma 1: There are \(1 + \lfloor\log_2 C\rfloor\) scaling phases

Lemma 2: Let \(f\) be the flow at the end of a \(\Delta\)-scaling phase. Then, the max-flow value \(\leq \mathit{val}(f) + m\Delta\)

Lemma 3: There are \(\leq 2m\) augmentations per scaling phase

capacity-scaling alg: analysis of running time

Lemma 1: There are \(1 + \lfloor\log_2 C\rfloor\) scaling phases

Pf: Initially \(C / 2 < \Delta \leq C\); \(\Delta\) decreases by a factor of \(2\) in each iteration \(\qed\)

capacity-scaling alg: analysis of running time

Lemma 2: Let \(f\) be the flow at the end of a \(\Delta\)-scaling phase. Then, the max-flow value \(\leq \mathit{val}(f) + m\Delta\)

Pf:

\[ \begin{eqnarray} \mathit{val}(f) & =^\dagger & \sum_{e\text{ out of }A} f(e) - \sum_{e\text{ in to }A} f(e) \\ & \geq & \sum_{e\text{ out of }A} (c(e) - \Delta) - \sum_{e\text{ in to }A}\Delta \\ & \geq & \sum_{e\text{ out of }A} c(e) - \sum_{e\text{ out of }A}\Delta - \sum_{e\text{ in to }A}\Delta \\ & \geq & \mathit{cap}(A,B) - m\Delta \quad\qed \end{eqnarray} \] \(\dagger\): flow value lemma

capacity-scaling alg: analysis of running time

Lemma 3: There are \(\leq 2m\) augmentations per scaling phase

Pf:

capacity-scaling alg: analysis of running time

Lemma 1: There are \(1 + \lfloor\log_2 C\rfloor\) scaling phases

Lemma 2: Let \(f\) be the flow at the end of a \(\Delta\)-scaling phase. Then, the max-flow value \(\leq \mathit{val}(f) + m\Delta\)

Lemma 3: There are \(\leq 2m\) augmentations per scaling phase

Theorem: the capacity-scaling algorithm takes \(O(m^2 \log C)\) time

Pf:

network flow (7)

shortest augmenting paths

shortest augmenting path

Q: How to choose next augmenting path in Ford-Fulkerson?

A: Pick one that uses the fewest edges (can find via BFS)



Shortest-Augmenting-Path(G)
    Foreach e in E: f(e) <- 0
    Gf <- residual network of G with respect to flow f
    While(there exists an s-t path P in Gf)
        P <- Breadth-First-Search(Gf)
        f <- Augment(f, c, P)
        Update Gf
    Return f

shortest augmenting path: overview of analysis

Lemma 1: The length (number of edges) of a shortest augmenting path never decreases. (Pf later)

Lemma 2: After at most \(m\) shortest-path augmentations, the length of a shortest augmenting path strictly increases (Pf later)

Theorem: The shortest-augmenting-path algorithm take \(O(m^2n)\) time

Pf:

shortest augmenting path: analysis

Defn: Given a digraph \(G = (V,E)\) with source \(s\), its level graph is defined by:

quiz: network flow

live view ]

Which edges are in the level graph of the following digraph?

  1. \(c \rightarrow t\)
  2. \(d \rightarrow t\)
  3. Both A and B
  4. Neither A nor B

shortest augmenting path: analysis

Defn: Given a digraph \(G = (V,E)\) with source \(s\), its level graph is defined by:

Key property: \(P\) is a shortest \(s \leadsto v\) path in \(G\) iff \(P\) is an \(s \leadsto v\) path in \(L_G\)

shortest augmenting path: analysis

Lemma 1: The length (number of edges) of a shortest augmenting path never decreases

Pf:

shortest augmenting path: analysis

Lemma 2: After at most \(m\) shortest-path augmentations, the length of a shortest augmenting path strictly increases

Pf:

shortest augmenting path: analysis review

Lemma 1: The length (number of edges) of a shortest augmenting path never decreases. (Pf later)

Lemma 2: After at most \(m\) shortest-path augmentations, the length of a shortest augmenting path strictly increases (Pf later)

Theorem: The shortest-augmenting-path algorithm take \(O(m^2n)\) time

shortest augmenting path: improving the running time

Note: \(\Theta(mn)\) augmentations necessary for some flow networks

network flow (7)

dinitz' algorithm

Dinitz' algorithm

Start by constructing level graph \(L_G\) of original graph \(G\)

Two phases of augmentations

Normal Augmentation Phase:

Special Augmentation Phase:

Dinitz' algorithm

Phase of normal augmentations (within a phase, length of shortest augmenting path does not change)

dinitz' algorithm (as refined by even and itai)

Dinitz(G)
    Foreach e in E: f(e) <- 0
    Gf <- residual network of G with respect to flow f
    Initialize(Gf)

Initialize(Gf)
    LG <- level-graph of Gf  // residual network, not G!
    If(t not reached)
        // found max-flow
        Stop
    P <- empty set
    Goto Advance(s)

// assuming LG,P,s,t,Gf,f are accessible in following functions

Advance(v)
    If(v=t)
        Augment(P)
        Update Gf
        Remove saturated edges from LG
        P <- empty set
        Goto Advance(s)
    If(there exists edge (v,w) in LG)
        Add edge (v,w) to P
        Goto Advance(w)
    Else
        Goto Retreat(v)

Retreat(v)
    If(v=s)
        // switch to special phase
        Goto Initialize(Gf)
    Else
        Delete v (and all incident edges) from LG
        Remove last edge (u,v) from P
        Goto Advance(u)

quiz: network flow

live view ]

How to compute the level graph \(L_G\) efficiently?

  1. Depth-first search
  2. Breadth-first search
  3. Both A and B
  4. Neither A nor B

dinitz' algorithm: analysis

Lemma: A phase can be implemented to run in \(O(mn)\) time

Pf:

dinitz' algorithm: analysis

Lemma: A phase can be implemented to run in \(O(mn)\) time

Theorem: Dinitz' algorithm runs in \(O(mn^2)\) time

Pf:

augmenting-path algorithms: summary

year method # augmentations running time
1955 augmenting path \(nC\) \(O(mnC)\)
1972 fattest path \(m \log(mC)\) \(O(m^2\log n \log(mC))\) \(*\)
1972 capacity scaling \(m \log C\) \(O(m^2 \log C)\) \(*\)
1985 improved capacity scaling \(m \log C\) \(O(mn \log C)\) \(*\)
1970 shortest augmenting path \(mn\) \(O(m^2n)\) \(\dagger\)
1970 level graph \(mn\) \(O(mn^2)\) \(\dagger\)
1983 dynamic trees \(mn\) \(O(mn\log n)\) \(\dagger\)

\(m\) edges, \(n\) nodes, integer capacites in \([1,C]\)

\(*\): fat paths; \(\dagger\): shortest paths

maximum-flow algorithms: theory highlights

year method worst case discovered by
1951 simplex \(O(mn^2C)\) Dantzig
1955 augmenting paths \(O(mnC)\) Ford-Fulkerson
1970 shortest augmenting paths \(O(mn^2)\) Edmonds-Karp, Dinitz
1974 blocking flows \(O(n^3)\) Karzanov
1983 dynamic trees \(O(mn\log n)\) Sleator-Tarjan
1985 improved capacity scaling \(O(mn\log C)\) Gabow
1988 push-relabel \(O(mn\log(n^2/m))\) Goldberg-Tarjan
1998 binary blocking flows \(O(m^a\log(n^2/m)\log C)\) Goldberg-Rao
2013 compact networks \(O(mn)\) Orlin
2014 interior-point methods \(\tilde O (mm^b\log C)\) Lee-Sidford
2016 electrical flows \(\tilde O (m^c C^d)\) Mądry
20xx ??? ??? ???

\(m\) edges, \(n\) nodes, integer capacities in \([1,C]\)
\(a=3/2\), \(b=1/2\), \(c=10/7\), \(d=1/7\)

maximum-flow algorithms: practice

Push-relabel algorithm (section 7.4) increases flow one edge at a time instead of one augmenting path at a time.

[ Goldberg-Tarjan 1988 ]

maximum-flow algorithms: practice

Caveat: Worst-case running time is generally not useful for predicting or comparing max-flow algorithm performance in practice

Best in practice: Push-relabel method with gap relabeling: \(O(m^{3/2})\) in practice

[ Cherkassky and Goldberg 1994; Ahuja et al. 1996 ]

maximum-flow algorithms: practice

Computer vision: different algorithms work better for some dense problems that arise in applications to computer vision

[ Boykov and Kolmogorov 2004; Verma and Batra 2012 ]

maximum-flow algorithms: matlab

maximum-flow algorithms: google

network flow (7)

simple unit-capacity networks

×