# Max-flow min-cut theorem

(Redirected from Max flow in networks)

In optimization theory, the max-flow min-cut theorem states that in a flow network, the maximum amount of flow passing from the source to the sink is equal to the total weight of the edges in the minimum cut, i.e. the smallest total weight of the edges which if removed would disconnect the source from the sink.

The max-flow min-cut theorem is a special case of the duality theorem for linear programs and can be used to derive Menger's theorem and the König–Egerváry theorem.

## Definitions and statement

Let N = (V, E) be a network (directed graph), where V denotes the set of vertices and E is the set of edges. Let sV and tV be the source and the sink of N, respectively.

Definition. The capacity of an edge is a mapping c : ER+, denoted by cuv or c(u, v). It represents the maximum amount of flow that can pass through an edge.

### Maximum flow

Definition. A flow is a mapping f : ER+, denoted by  fuv or f (u, v), subject to the following two constraints:

1. Capacity Constraint:
${\displaystyle \forall (u,v)\in E:\qquad f_{uv}\leq c_{uv}}$
2. Conservation of Flows:
${\displaystyle \forall v\in V\setminus \{s,t\}:\qquad \sum \nolimits _{\{u:(u,v)\in E\}}f_{uv}=\sum \nolimits _{\{u:(v,u)\in E\}}f_{vu}.}$

Definition. The value of flow is defined by

${\displaystyle |f|=\sum \nolimits _{\{v:(s,v)\in E\}}f_{sv}-\sum \nolimits _{\{v:(v,s)\in E\}}f_{vs},}$

where s is the source of N. It represents the amount of flow leaving the source, minus the amount of flow entering the source. Therefore it represents the amount of the flow passing from the source to the sink.

Maximum Flow Problem. Maximize | f |, that is, to route as much flow as possible from s to t.

### Minimum cut

Definition. An s-t cut C = (S, T) is a partition of V such that sS and tT. The cut-set ${\displaystyle X_{C}}$ of C is the set

${\displaystyle X_{C}:=\{(u,v)\in E\ :\ u\in S,v\in T\}=(S\times T)\cap E.}$

Note that if the edges in the cut-set of C are removed, then | f | = 0.

Definition. The capacity of an s-t cut is defined by

${\displaystyle c(S,T)=\sum \nolimits _{(u,v)\in X_{C}}c_{uv}=\sum \nolimits _{(i,j)\in E}c_{ij}d_{ij},}$

where ${\displaystyle d_{ij}=1}$ if ${\displaystyle i\in S}$ and ${\displaystyle j\in T}$, 0 otherwise.

Minimum s-t Cut Problem. Minimize c(S, T), that is, to determine S and T such that the capacity of the S-T cut is minimal.

### Statement

Max-flow min-cut theorem. The maximum value of an s-t flow is equal to the minimum capacity over all s-t cuts.

## Linear program formulation

The max-flow problem and min-cut problem can be formulated as two primal-dual linear programs.

Max-flow (Primal)

Min-cut (Dual)

variables: ${\displaystyle |f|,\{f_{uv}\mid (u,v)\in E\}}$

variables: ${\displaystyle \{d_{uv}\mid (u,v)\in E\},\{p_{u}\mid u\in V\}}$

maximize ${\displaystyle |f|}$

minimize ${\displaystyle \sum _{(u,v)\in E}c_{uv}d_{uv}}$

subject to

${\displaystyle {\begin{array}{rclr}f_{uv}&\leq &c_{uv}&(u,v)\in E\\\sum _{v:(v,u)\in E}f_{vu}-\sum _{v:(u,v)\in E}f_{uv}&\leq &0&u\in V,u\neq s,t\\|f|+\sum _{v:(v,s)\in E}f_{vs}-\sum _{v:(s,v)\in E}f_{sv}&\leq &0&\\-|f|+\sum _{v:(v,t)\in E}f_{vt}-\sum _{v:(t,v)\in E}f_{tv}&\leq &0&\\f_{uv}&\geq &0&(u,v)\in E\\\end{array}}}$

subject to

${\displaystyle {\begin{array}{rclr}d_{uv}-p_{u}+p_{v}&\geq &0&(u,v)\in E\\p_{s}-p_{t}&\geq &1&\\p_{u}&\geq &0&u\in V\\d_{uv}&\geq &0&(u,v)\in E\end{array}}}$

Note that for the given s-t cut ${\displaystyle C=(S,T)}$ if ${\displaystyle u\in S}$ then ${\displaystyle p_{u}=1}$ and 0 otherwise. Therefore, ${\displaystyle p_{s}}$ should be 1 and ${\displaystyle p_{t}}$ should be zero. The equality in the max-flow min-cut theorem follows from the strong duality theorem in linear programming, which states that if the primal program has an optimal solution, x*, then the dual program also has an optimal solution, y*, such that the optimal values formed by the two solutions are equal.

## Example

A network with the value of flow equal to the capacity of an s-t cut

The figure on the right is a network having a value of flow of 7. The vertex in white and the vertices in grey form the subsets S and T of an s-t cut, whose cut-set contains the dashed edges. Since the capacity of the s-t cut is 7, which equals to the value of flow, the max-flow min-cut theorem tells us that the value of flow and the capacity of the s-t cut are both optimal in this network.

## Application

### Generalized max-flow min-cut theorem

In addition to edge capacity, consider there is capacity at each vertex, that is, a mapping c : VR+, denoted by c(v), such that the flow f has to satisfy not only the capacity constraint and the conservation of flows, but also the vertex capacity constraint

${\displaystyle \forall v\in V\setminus \{s,t\}:\qquad \sum \nolimits _{\{u\in V\mid (u,v)\in E\}}f_{uv}\leq c(v).}$

In other words, the amount of flow passing through a vertex cannot exceed its capacity. Define an s-t cut to be the set of vertices and edges such that for any path from s to t, the path contains a member of the cut. In this case, the capacity of the cut is the sum the capacity of each edge and vertex in it.

In this new definition, the generalized max-flow min-cut theorem states that the maximum value of an s-t flow is equal to the minimum capacity of an s-t cut in the new sense.

### Menger's theorem

In the undirected edge-disjoint paths problem, we are given an undirected graph G = (V, E) and two vertices s and t, and we have to find the maximum number of edge-disjoint s-t paths in G.

The Menger's theorem states that the maximum number of edge-disjoint s-t paths in an undirected graph is equal to the minimum number of edges in an s-t cut-set.

### Project selection problem

A network formulation of the project selection problem with the optimal solution

In the project selection problem, there are n projects and m machines. Each project pi yields revenue r(pi) and each machine qj costs c(qj) to purchase. Each project requires a number of machines and each machine can be shared by several projects. The problem is to determine which projects and machines should be selected and purchased respectively, so that the profit is maximized.

Let P be the set of projects not selected and Q be the set of machines purchased, then the problem can be formulated as,

${\displaystyle \max\{g\}=\sum _{i}r(p_{i})-\sum _{p_{i}\in P}r(p_{i})-\sum _{q_{j}\in Q}c(q_{j}).}$

Since the first term does not depend on the choice of P and Q, this maximization problem can be formulated as a minimization problem instead, that is,

${\displaystyle \min\{g'\}=\sum _{p_{i}\in P}r(p_{i})+\sum _{q_{j}\in Q}c(q_{j}).}$

The above minimization problem can then be formulated as a minimum-cut problem by constructing a network, where the source is connected to the projects with capacity r(pi), and the sink is connected by the machines with capacity c(qj). An edge (pi, qj) with infinite capacity is added if project pi requires machine qj. The s-t cut-set represents the projects and machines in P and Q respectively. By the max-flow min-cut theorem, one can solve the problem as a maximum flow problem.

The figure on the right gives a network formulation of the following project selection problem:

Project r(pi)

Machine c(qj)

1 100 200

Project 1 requires machines 1 and 2.

2 200 100

Project 2 requires machine 2.

3 150 50

Project 3 requires machine 3.

The minimum capacity of a s-t cut is 250 and the sum of the revenue of each project is 450; therefore the maximum profit g is 450 − 250 = 200, by selecting projects p2 and p3.

The idea here is to 'flow' the project profits through the 'pipes' of the machine. If we cannot fill the pipe, the machine's return is less than its cost, and the min cut algorithm will find it cheaper to cut the project's profit edge instead of the machine's cost edge.

### Image segmentation problem

Each black node denotes a pixel.

In the image segmentation problem, there are n pixels. Each pixel i can be assigned a foreground value  fi or a background value bi. There is a penalty of pij if pixels i, j are adjacent and have different assignments. The problem is to assign pixels to foreground or background such that the sum of their values minus the penalties is maximum.

Let P be the set of pixels assigned to foreground and Q be the set of points assigned to background, then the problem can be formulated as,

${\displaystyle \max\{g\}=\sum _{i\in P}f_{i}+\sum _{i\in Q}b_{i}-\sum _{i\in P,j\in Q\lor j\in P,i\in Q}p_{ij}.}$

This maximization problem can be formulated as a minimization problem instead, that is,

${\displaystyle \min\{g'\}=\sum _{i\in P,j\in Q\lor j\in P,i\in Q}p_{ij}.}$

The above minimization problem can be formulated as a minimum-cut problem by constructing a network where the source (orange node) is connected to all the pixels with capacity  fi, and the sink (purple node) is connected by all the pixels with capacity bi. Two edges (i, j) and (j, i) with pij capacity are added between two adjacent pixels. The s-t cut-set then represents the pixels assigned to the foreground in P and pixels assigned to background in Q.

## History

The max-flow min-cut theorem was proven by P. Elias, A. Feinstein, and C.E. Shannon in 1956[1], and independently also by L.R. Ford, Jr. and D.R. Fulkerson in the same year[2].

## Proof

Let G = (V, E) be a network (directed graph) with s and t being the source and the sink of G respectively.

Consider the flow f computed for G by Ford–Fulkerson algorithm. In the residual graph (Gf ) obtained for G (after the final flow assignment by Ford–Fulkerson algorithm), define two subsets of vertices as follows:

1. A: the set of vertices reachable from s in Gf
2. Ac: the set of remaining vertices i.e. V − A

Claim. value( f ) = c(A, Ac), where the capacity of an s-t cut is defined by

${\displaystyle c(S,T)=\sum \nolimits _{(u,v)\in S\times T}c_{uv}}$.

Now, we know, ${\displaystyle value(f)=f_{out}(A)-f_{in}(A)}$ for any subset of vertices, A. Therefore, for value( f ) = c(A, Ac) we need:

• All outgoing edges from the cut must be fully saturated.
• All incoming edges to the cut must have zero flow.

To prove the above claim we consider two cases:

• In G, there exists an outgoing edge ${\displaystyle (x,y),x\in A,y\in A^{c}}$ such that it is not saturated, i.e., f (x, y) < cxy. This implies, that there exists a forward edge from x to y in Gf, therefore there exists a path from s to y in Gf, which is a contradiction. Hence, any outgoing edge (x, y) is fully saturated.
• In G, there exists an incoming edge ${\displaystyle (y,x),x\in A,y\in A^{c}}$ such that it carries some non-zero flow, i.e., f (x, y) > 0. This implies, that there exists a backward edge from x to y in Gf, therefore there exists a path from s to y in Gf, which is again a contradiction. Hence, any incoming edge (x, y) must have zero flow.

Both of the above statements prove that the capacity of cut obtained in the above described manner is equal to the flow obtained in the network. Also, the flow was obtained by Ford-Fulkerson algorithm, so it is the max-flow of the network as well.

Also, since any flow in the network is always less than or equal to capacity of every cut possible in a network, the above described cut is also the min-cut which obtains the max-flow.