Maximum Flow

Harris and Ross’s map of the Warsaw-Pact railway network.

Background

Here I’ll provide a brief overview of standard definitions related to the maximum flow problem. For a more thorough and gentler introduction, see chapters 10 and 11 in my algorithms textbook.

Pseudoflows, flows, and circulations

Recall that a pseudoflow (or 1-chain, or discrete 1-form) in a graph \(G\) is any function \(\phi \colon D(G) \to \mathbb{R}\) on the darts of \(G\) that is antisymmetric, meaning \(\phi(d) = - \phi(\textsf{rev}(d))\) for every dart \(d\). Intuitively, the value \(\phi(u{\to}v)\) represents the rate of flow of some divisible substance like water, train cars, or network packets from \(u\) to \(v\) along the undirected edge \(uv\). In particular, a negative value indicates that the substance is flowing backward from \(v\) to \(u\).1

The boundary \(\partial\phi\colon V(G)\to \mathbb{R}\) of a pseudoflow \(\phi\) that intuitively describes the total net flow into each vertex \(v\): \[ \partial\phi(v) := \sum_u \phi(u{\to}v). \] A circulation is a pseudoflow \(\phi\) whose boundary \(\partial\phi\) is identically zero. Intuitively, circulations are pseudoflows that respect conservation of mass; any positive flow into \(v\) must be balanced by negative flow into \(v\) (that is, positive flow out of \(v\)).

For two fixed vertices \(s\) and \(t\), an \((s,t)\)-flow is a pseudoflow \(f\) such that \(\partial f(v) = 0\) for all \(v\) except possibly \(s\) and \(t\). The value of an \((s,t)\)-flow \(\phi\) is the total net flow into \(t\) or out of \(s\): \[ |\phi| := \partial \phi(t) = -\partial \phi(s). \] Intuitively, \((s,t)\)-flows model some substance being injected into a network of pipes at \(s\) and being extracted at \(t\), with conservation at every other vertex. Every circulation is an \((s,t)\)-flow with value \(0\).

Lemma: For any two \((s,t)\)-flows \(\phi\) and \(\psi\) in the same graph \(G\) and any two real numbers \(\alpha\) and \(\beta\), the function \(\alpha\phi + \beta\psi\) is an \((s,t)\)-flow in \(G\) with value \(\alpha|\phi| + \beta|\psi|\). In particular, if \(\phi\) and \(\psi\) are circulations, then \(\alpha\phi + \beta\psi\) is also a circulation. Thus, circulations and \((s,t)\)-flows in any graph \(G\) define vector spaces.

We can regard any directed cycle \(\gamma\) as a circulation: \[ \gamma(d) = \begin{cases} 1 & \text{if $d \in \gamma$} \\ -1 & \text{if $\textsf{rev}(d) \in \gamma$} \\ 0 & \text{otherwise} \end{cases} \] Similarly, we can regard any directed path \(\pi\) from \(s\) to \(t\) as an \((s,t)\)-flow: \[ \pi(d) = \begin{cases} 1 & \text{if $d \in \pi$} \\ -1 & \text{if $\textsf{rev}(d) \in \pi$} \\ 0 & \text{otherwise} \end{cases} \]

Lemma: Every circulation is a weighted sum of simple directed cycles. Every \((s,t)\)-flow is a weighted sum of simple directed \((s,t)\)-paths and simple directed cycles.

Capacities and residual graphs

A capacity function for a graph \(G\) is any function \(c\colon D(G)\to\mathbb{R}\) from the darts to the reals. Capacities are not necessary either symmetric, antisymmetric, or non-negative. A flow network is a graph \(G\) together with a capacity function \(c\).

A pseudoflow (or circulation or \((s,t)\)-flow) \(\phi\) is feasible with respect to \(c\) if and only if \(\phi(d) \le c(d)\) for every dart \(d\). In particular, we allow the capacity of a dart to be negative; a negative dart capacity is equivalent to a positive lower bound on the amount of flow through the reversal of the dart. The zero flow \(\phi\equiv 0\) is feasible if and only if every dart has non-negative capacity.

Given a graph \(G\), capacity function \(c\), and two vertices \(s\) and \(t\) as input, the maximum flow problem asks for a feasible \((s,t)\)-flow in \(G\) with the largest possible value.

Fix a graph \(G\) and a capacity function \(c\). Any pseudoflow \(\phi\) in \(G\) induces a residual capacity function \(c_\phi\colon D(G)\to \mathbb{R}\), defined simply as \(c_\phi(d) = c(d) - \phi(d)\). A pseudoflow \(\phi\) is feasible if and only if every dart has non-negative residual capacity. The residual graph \(G_\phi\) is just the original graph \(G\) but with the new capacity function \(c_\phi\). A residual path (respectively, residual cycle) is a directed path (respectively, directed cycle) in \(G_\phi\) in which every dart has positive residual capacity.

The standard textbook algorithm for maximum flows, proposed by Lester Ford and Delbert Fulkerson in 1953, is the augmenting path method. The method starts by finding an initial feasible \((s,t)\)-flow \(\phi\); typically all capacities are non-negative, so we can start with the zero flow \(\phi\equiv 0\). Then we repeatedly augment the flow \(\phi\) by pushing more flow along paths from \(s\) to \(t\). Specifically, at each iteration, we find a residual path \(\pi\) and augment the flow by setting \(\phi’ \gets \phi + \min_{d\in\pi} c_\phi(d) \cdot \pi\); here I’m treating \(\pi\) both as a sequence of darts and as an \((s,t)\)-flow. Straightforward definition-chasing implies that if the original flow \(\phi\) is feasible, then the augmented flow \(\phi’\) is also feasible. When \(G_\phi\) contains no more residual paths, \(\phi\) is a maximum \((s,t)\)-flow. More generally:

Lemma: Let \(\phi\) and \(\phi’\) be any (not necessarily feasible) \((s,t)\)-flows in \(G\).

  1. \(\phi’\) is a feasible \((s,t)\)-flow in \(G\) if and only if \(\phi’-\phi\) is a feasible \((s,t)\)-flow in the residual graph \(G_\phi\).
  2. In particular, if \(|\phi| = |\phi’|\), then \(\phi’\) is a feasible \((s,t)\)-flow in \(G\) if and only if \(\phi’-\phi\) is a feasible circulation in \(G_\phi\).
  3. In particular, \(\phi’\) is a maximum \((s,t)\)-flow in \(G\) if and only if \(\phi’-\phi\) is a maximum \((s,t)\)-flow in \(G_\phi\).

Planar Circulations

Flows and circulations have particularly nice structure in planar graphs, or more accurately, in planar maps.

Fix an arbitrary circulation \(\phi\) in an arbitrary planar map \(\Sigma\), with a distinguished outer face \(o\). The winding number of \(\phi\) around each face \(f\) of \(\Sigma\), denoted \(\textsf{wind}(\phi, f)\) can be defined by extending the definition of the Alexander numbering of a curve:

Conservation at each vertex \(v\) implies that this st of constraints has a unique solution. Equivalently, for any path (in fact, any walk) \(\pi\) in the dual map \(\Sigma^*\) from dual of the outer face \(o^*\) to the dual vertex \(f^*\), we have \[ \textsf{wind}(\phi, f) = \sum_{d^*\in\pi} \phi(d). \] The second definition is independent of the choice of dual path \(\pi\), again by conservation. A third equivalent definition uses the fact that \(\phi\) is a weighted sum of simple cycles: \[ \phi = \sum_i \alpha_i\cdot \gamma_i \implies \textsf{wind}(\phi, f) = \sum_i \alpha_i\cdot \textsf{wind}(\gamma_i, f); \] This definition is independent of the chosen decomposition of \(\phi\) into cycles \(\gamma_1, \gamma_2, \dots\).

Alexander numbering is an example of a face potential (or \(2\)-chain); more generally, a face potential in \(\Sigma\) is any function \(\alpha\colon F(\Sigma)\to\mathbb{R}\) assigning a real number to each face of \(\Sigma\). The boundary of a face potential \(\alpha\) is the circulation \(\partial\alpha\colon D(\Sigma)\to \mathbb{R}\) defined by setting \[ \partial\alpha(d) = \alpha(\textsf{left}(d)) - \alpha(\textsf{right}(d)) \] for every dart \(d\). It should be easy to verify that \(\partial\alpha\) is indeed a circulation. Moreover, the boundary operator \(\partial\) is linear; for all face potentials \(\alpha\) and \(\beta\) and real numbers \(a\) and \(b\), we have \(\partial(a\cdot\alpha + b\cdot\beta) = a\cdot\partial\alpha + b\cdot\partial\beta\).

The following lemma is a natural generalization (and consequence) of the Jordan Curve Theorem.

Lemma: Every circulation in a planar map is a boundary circulation.

Proof:
For any circulation \(\phi\), routine definition-chasing implies \(\phi = \partial (\textsf{wind}(\phi))\). That is, \(\phi = \partial\alpha\), where \(\alpha(f) = \textsf{wind}(\alpha, f)\) for every face \(f\). \(\qquad\square\)

Corollary: The difference between any two \((s,t)\)-flows with the same value in the same planar map \(\Sigma\) is a boundary circulation in \(\Sigma\).

Feasible Planar Circulations and Shortest Paths

Now suppose we endow our planar map \(\Sigma\) with a capacity function \(c\colon D(\Sigma)\to\mathbb{R}\). Every dart \(d^*\) in the dual map \(\Sigma^*\) has a cost or length \(c(d^*)\) equal to the capacity of the corresponding primal dart \(d\); in short, we have \(c(d^*) = c(d)\).

Lemma [Venkatesan]: Let \(\Sigma\) be any planar map, and let \(c\colon D(\Sigma)\to\mathbb{R}\) be any capacity function for \(\Sigma\). There is a feasible circulation in \(\Sigma\) if and only if the dual map \(\Sigma^*\) has no negative cycles.

Proof:
First, consider an arbitrary circulation \(\phi\) in \(\Sigma\) and an arbitrary cycle \(\lambda^*\) in the dual map \(\Sigma^*\) with negative total cost. Without loss of generality, assume \(\lambda^*\) is simple and oriented counterclockwise. Whitney’s duality theorem implies that the set \(\lambda\) of primal darts whose duals lie in \(\lambda^*\) define a directed edge cut. Specifically, let \(A\) denote the vertices of \(\Sigma\) whose corresponding dual faces lie inside \(\lambda^*\). Then \(\lambda\) is the set of all darts in \(\Sigma\) such that \(\textsf{head}(d)\in A\) and \(\textsf{tail}(d) \not\in A\). Straightforward calculation implies \[ \begin{aligned} \sum_{d\in \lambda} \phi(d) &= \sum_{\textsf{head}(d)\in A} \phi(d) & \text{because $\phi(d) = -\phi(\textsf{rev}(d))$} \\ &= \sum_{v\in A\vphantom{[}} ~ \sum_{\textsf{head}(d) = v} \phi(d) \\ &= \sum_{v\in A} \partial\phi(v) & \text{by definition of $\partial$} \\ &= \sum_{v\in A} 0 & \text{because $\phi$ is a circulation} \\ &= 0 \\ & > \sum_{d\in \lambda} c(d). \end{aligned} \] (In the first step, we are adding \(\phi(d)\) for all darts with both endpoints in \(A\).) We conclude that \(\phi(d) > c(d)\) for at least one dart \(d\in\lambda\); in short, \(\phi\) is not feasible.

On the other hand, suppose shortest-path distances are well-defined in \(\Sigma^*\). For any dual vertex \(p\), let \(\textsf{dist}(p)\) denote the shortest-path distance from the outer face \(o\) to \(p\). We can interpret the function \(\textsf{dist}\) as a face potential function for \(\Sigma\). I claim that the boundary circulation \(\partial\textsf{dist}\) is feasible. For any dart \(d\), we have \[ \phi(d) ~=~ \textsf{dist}(\textsf{left}(d)^*) - \textsf{dist}(\textsf{right}(d)^*) \] Now define the slack of every dart \(d\) as \[ \begin{aligned} \textsf{slack}(d) & := c(d) - \phi(d) \\ & = c(d) - \textsf{dist}(\textsf{left}(d)^*) + \textsf{dist}(\textsf{right}(d)^*) \\ & = \textsf{dist}(\textsf{tail}(d^*)) + c(d^*) - \textsf{dist}(\textsf{head}(d^*)) \end{aligned} \] The definition of shortest paths implies that \(\textsf{slack}(d) \ge 0\) for every dart \(d\), and thus \(\phi(d) \le c(d)\) for every dart \(d\). We conclude that \(\phi\) is feasible.

Corollary: Given a planar map \(\Sigma\) with \(n\) vertices and arbitrary dart capacities, we can compute either a feasible circulation in \(\Sigma\) or a negative-cost cycle in \(\Sigma^*\) in \(O(n\log^2 n)\) time.

Proof:
Run the shortest-path algorithm of Klein, Mozes, and Weimann, starting at the vertex \(o^*\) dual to the outer face \(o\). If shortest-path distances in \(\Sigma^*\) are well-defined, set \(\phi(d) = \textsf{dist}(\textsf{left}(d)^*) - \textsf{dist}(\textsf{right}(d)^*)\) for every dart \(d\). Otherwise, the algorithm finds a negative cycle in \(\Sigma^*\). In both cases, the algorithm runs in \(O(n\log^2 n)\) time.

Our First Planar Max-flow Algorithm

The previous lemma can also be used to find feasible \((s,t)\)-flows with particular values. Fix two vertices \(s\) and \(t\) in \(G\).

Corollary: Let \(\phi\) be an arbitrary (not necessarily feasible) \((s,t)\)-flow in \(\Sigma\). There is a feasible \((s,t)\)-flow in \(G\) with value \(|\phi|\) if and only if the dual residual map \(\Sigma^*_\phi\) has no negative cycles.

Corollary: Given a planar map \(\Sigma\) with \(n\) vertices, arbitrary dart capacities, and a real number \(\lambda\), we can either compute a feasible \((s,t)\)-flow in \(\Sigma\) with value \(\lambda\), or correctly report that no such flow exists, in \(O(n\log^2 n)\) time.

Proof:
Let \(\pi\) be any path from \(s\) to \(t\) in \(\Sigma\) with value \(\lambda\), and let \(\phi\) be the flow \(\lambda\cdot\pi\). Then \(\phi’\) is a feasible \((s,t)\)-flow with value \(\lambda\) if and only if \(\phi’-\phi\) is a feasible circulation in the residual map \(\Sigma_\phi\). \(\qquad\square\)

Corollary: Given a planar map \(\Sigma\) with \(n\) vertices, non-negative integer dart capacities \(c(d)\), we can compute a maximum \((s,t)\)-flow in \(\Sigma\) in \(O(n\log^2 n \log (nU))\) time, where \(U = \max_d c(d)\).

Proof:
Suppose every dart in \(\Sigma\) has an integer capacity between \(0\) and \(U\). Because all capacities are non-negative, we know that the zero circulation is a feasible flow with value \(0\), and the upper bound on individual capacities implies that every feasible flow has value at most \(nU\). If there is a feasible flow with any value \(\lambda\), we can scale it down to a feasible flow with any value smaller than \(\lambda\). Finally, Ford and Fulkerson’s augmenting-path algorithm implies by induction that the maximum flow in a network with integer capacities has integer value. Thus, we can compute a maximum flow in \(\Sigma\) by performing a binary search over the \(nU\) possible flow values, running the \(O(n\log^2 n)\)-time decision algorithm at each iteration. \(\qquad\square\)

I find this algorithm deeply unsatisfying, in part because it requires integer capacities, but it does at least serve as a proof of concept. Hassin and Johnson proved that for undirected planar graphs, where every dart has the same capacity as its reversal, we can compute a maximum \((s,t)\)-flow by first running Reif’s minimum-cut algorithm and then running Dijkstra’s algorithm in a modified dual graph. Using Reif’s original algorithm, this approach funds maximum flows in \((n\log^2 n)\) time; this running time can be improved to \(O(n\log n)\) using either the linear-time shortest-path algorithm of Henzinger et al inside Reif’s algorithm, or by replacing Reif’s algorithm with multiple-source shortest paths.

Unfortunately, this approach does not extend to directed planar graphs, because we do not have a similar divide-and-conquer minimum-cut algorithm in that setting. In 1997, Karsten Weihe described an algorithm to compute maximum flows in directed planar graphs in \(O(n\log n)\) time, generalizing his earlier \(O(n)\)-time algorithm for undirected unit-capacity planar graphs. However, his algorithm assumes that every dart in the input graph appears in at leas one simple path from \(s\) to \(t\). Darts that do not satisfy this criterion can be safely removed from the input graph, but an efficient algorithm to find all such “useless” darts was only found in 2017, by Jittat Fakcharoenphol, Bundit Laekhanukit, and Pattara Sukprasert.

Meanwhile, in 2006, Glencora Borradaile and Philip Klein discovered a much cleaner algorithm to compute planar maximum flows in \(O(n\log n)\) time. In the rest of this lecture note I will describe a reformulation of their algorithm that I published in 2010.

Parametric Shortest Paths

We formulate the planar maximum-flow problem as a parametric shortest-path problem, similar to our first multiple-source shortest-path problem. Fix an arbitrary path \(\pi\) from \(s\) to \(t\). We are trying to find the largest value \(\lambda\) such that \(\Sigma\) supports and \((s,t)\)-flow with value \(\lambda\). Equivalently, by the arguments in the last two sections, we are looking for the largest value \(\lambda\) such that the dual residual map \(\Sigma^*_{\lambda\cdot\pi}\) does not contain a negative cycle. The algorithm maintains a shortest-path tree in the dual residual map \(\Sigma^*_{\lambda\cdot\pi}\) as the parameter \(\lambda\) continuously increases from \(0\). At critical values of \(\lambda\), darts \(p{\to}q\) in \(\Sigma^*\) become tense and pivot into the shortest-path tree, replacing earlier darts \(p’{\to}q\). The algorithm halts when a pivot introduces a cycle into the shortest-path tree, which would become negative if we increased \(\lambda\) any further. (That cycle is dual to the minimum cut!)

Again, we fix an arbitrary path \(\pi\) from \(s\) to \(t\); we treat this path as a flow with value \(1\): \[ \pi(d) = \begin{cases} 1 & \text{if $d \in \pi$} \\ -1 & \text{if $\textsf{rev}(d) \in \pi$} \\ 0 & \text{otherwise} \end{cases} \] We also fix a vertex \(o\) in the dual map \(\Sigma^*\). Let’s establish some notation.

Except at critical values of \(\lambda\), subgraph \(L_\lambda\) is a spanning tree of \(\Sigma_\lambda\), and in fact \((L_\lambda, T_\lambda)\) is a tree-cotree decomposition of \(\Sigma\).

Lemma: \(LP_\lambda\) is the unique path from \(s\) to \(t\) in \(L_\lambda\).

Lemma: \(LP_\lambda\) is the set of all active darts in \(\Sigma_\lambda\).

Active Darts

Fast Pivots

Universal Cover Analysis

References

  1. Therese C. Biedl, Bronǎ Brejová, and Tomáš Vinař. Simplifying flow networks. Proc. 25th Symp. Math. Found. Comput. Sci., 192–201, 2000. Lecture Notes Comput. Sci. 1893, Springer-Verlag.

  2. Glencora Borradaile and Anna Harutyunyan. Maximum st-flow in directed planar graphs via shortest paths. Proc. 24th Int. Workshop Combin. Algorithms, 423–427, 2013. Lecture Notes Comput. Sci. 8288, Springer. arXiv:1305.5823.

  3. Glencora Borradaile and Philip Klein. An \(O(n\log n)\) algorithm for maximum st-flow in a directed planar graph. J. ACM 56(2):1–9:1–30, 2009.

  4. David Eppstein and Kevin A. Wortman. Optimal embedding into star metrics. Proc. 11th Algorithms Data Struct. Symp. (WADS), 290–301, 2009. Lecture Notes Comput. Sci. 5664, Springer. Another application of parametric shortest paths.

  5. Jeff Erickson. Parametric shortest paths and maximum flows in planar graphs. Proc. 21st Ann. ACM-SIAM Symp. Discrete Algorithms, 794–804, 2010.

  6. Jittat Fakcharoenphol, Bundit Laekhanukit, and Pattara Sukprasert. Finding all useless arcs in directed planar graphs. Preprint, May 2018. arXiv:1702.04786.

  7. Lester R. Ford and Delbert R. Fulkerson. Maximal flow through a network. Canad. J. Math. 8(399–404), 1956. First published as Research Memorandum RM-1400, The RAND Corporation, Santa Monica, California, November 19, 1954.

  8. Lester R. Ford and Delbert R. Fulkerson. Flows in Networks. Princeton University Press, 1962. First published as Research Memorandum R-375-PR, The RAND Corporation, Santa Monica, California, August 1962.

  9. Theodore E. Harris and Frank S. Ross. Fundamentals of a method for evaluating rail net capacities. Research Memorandum RM-1573, The RAND Corporation, Santa Monica, California, October 24, 1955. Declassified May 13, 1999.

  10. Refael Hassin and Donald B. Johnson. An \(O(n \log^2 n)\) algorithm for maximum flow in undirected planar networks. SIAM J. Comput. 14(3):612–624, 1985.

  11. Samir Khuller, Joseph (Seffi) Naor, and Philip Klein. The lattice structure of flow in planar graphs. SIAM J. Discrete Math. 477–490, 1993. Removing clockwise residual cycles.

  12. Karl Menger. Zur allgemeinen Kurventheorie. Fund. Math. 10:96–115, 1927.

  13. Shankar M. Venkatesan. Algorithms for network flows. Ph.D. thesis, The Pennsylvania State University, 1983.

  14. Karsten Weihe. Edge-disjoint \((s,t)\)-paths in undirected planar graphs in linear time. J. Algorithms 23(1):121–138, 1997.

  15. Karsten Weihe. Maximum \((s,t)\)-flows in planar networks in \(O(|V|\log|V|)\) time. J. Comput. Syst. Sci. 55(3):454–476, 1997.

Aptly Not


  1. A more common textbook definition of (pseudo)flow is any function \(\phi \colon D(G) \to \mathbb{R}\) such that for every dart \(d\), we have \(\phi(d)\ge 0\) and either \(\phi(d) = 0\) or \(\phi(\textsf{rev}(d)) = 0\). That is, for each edge, instead of choosing an arbitrary values for the darts that sum to \(0\), we choose both a direction and a non-negative value for the edge. Converting between the antisymmetric formulation and the non-negative formulation is straightforward.↩︎