Network flow

Definition (graph) open_in_new

A directed graph is a tuple $G=(V,E)$ where $V$ is the set of vertices and $E\subseteq V\times V$ is a set of ordered edges.

$G$ is called an undirected graph if $E$ is symmetric, i.e. for all $(v,v')\in E$, we have $(v',v)\in E$ as well.

Minimum cost flow problem open_in_new

Let a graph $G = (V, E)$ where $V=\set{1,2,\ldots,n}$.

For each edge $(i,j)\in E$, an amount $x_{ij}$ flows from vertex $i$ to vertex $j$. We impose the following constraints:

  • Flow is conserved at each vertex. We fix a vector $\v b\in\R^n$ which indicates the amount of flow $b_i$ that enters a vertex $i$. A vertex with $b_i>0$ is called a source and a vertex with $b_i<0$ is called a sink.

  • $n\times n$ matrices $\underline{M} = (\underline{m}_{ij})$ and $\overline{M} = (\overline{m}_{ij})$ give the lower and upper bounds for the flow $x_{ij}$.

  • $n\times n$ matrices $C = (c_{ij})$ gives the cost per unit flow on the edge $(i,j)$.

Minimal cost flow problem

$$ \begin{align*} \text{Minimise } & \sum_{(i,j)\in E} c_{ij} x_{ij} \\ \text{subject to } & b_i + \sum_{(j,i)\in E} x_{ji} = \sum_{(i,j)\in E} x_{ij} \quad \forall i\in V, \\ & \underline{m}_{ij} \leq x_{ij} \leq \overline{m}_{ij}. \end{align*} $$

For the problem to be feasible, we require $\sum_{i\in V} b_i = 0$.

Transport problem open_in_new

We have $n$ suppliers labelled $i=1,2,\ldots,n$, each supplying $s_i$ units of products. There are also $m$ consumers labelled $j=1,2,\ldots,m$, each demanding $d_i$ units of products. Transporting one unit of product from $i$ to $j$ costs $c_{ij}$.

This is a special case of the minimum cost flow problem, with $G$ being a bipartite graph and $E$ only consists of edges from a supplier to a consumer.

Transport problem

$$ \begin{align*} \text{Minimise } &\sum_{(i,j)\in E} c_{ij} x_{ij} \\ \text{subject to } &\sum_{j=1}^{m} x_{ij} = s_i && \forall i=1,2,\ldots,n, \\ &\sum_{i=1}^{n} x_{ij} = d_j && \forall j=1,2,\ldots,m, \\ &x_{ij} \geq 0 &&\forall (i,j)\in E. \end{align*} $$

We can let $E = V\times V$ and set the cost of the non-existent edges to be infinity.

Transport problem

$$ \begin{align*} \text{Minimise } &\sum_{i=1}^{n} \sum_{j=1}^{m} c_{ij} x_{ij} \\ \text{subject to } &\sum_{j=1}^{m} x_{ij} = s_i && \forall i=1,2,\ldots,n, \\ &\sum_{i=1}^{n} x_{ij} = d_j && \forall j=1,2,\ldots,m, \\ &x_{ij} \geq 0 &&\forall (i,j)\in E. \end{align*} $$

Theorem (equivalence of minimum cost flow and transport problem) open_in_new

Every minimum cost flow problem with finite capacities or non-negative capacities can be recast as an equivalent transport problem.

Proof

Theorem (optimality in the transport problem) open_in_new

Consider the transport problem. If for some feasible $x$, we have dual variables $\v \lambda\in\R^n$ (for suppliers) and $\v\mu\in\R^m$ (for consumers) such that the following holds:

  • dual feasibility: $c_{ij}\geq \lambda_i + \mu_j$ for all $i,j$; and

  • complementary slackness: $(c_{ij} - \lambda_i - \mu_j)x_{ij} = 0$,

then $x$ is optimal.

Proof

Note that optimality only depends on $\lambda_i + \mu_j$, so WLOG we can assume $\lambda_1 = 0$ by subtracting all $\lambda$ and adding all $\mu$ by $\lambda_1$.

Transport algorithm open_in_new

The transport tableau is as follow:

To construct an initial basic feasible solution, we use the northwest corner rule:

  1. Start with any edge variable, and increase it until the supply or demand is satisfied.

  2. If supply is satisfied, move to the next supplier and repeat step 1.

  3. If demand is satisfied, move to the next consumer and repeat step 1.

In a non-degenerate problem, we assume we arrive at a spanning tree $T$, i.e. a connected graph with no cycles. So there are exactly $n+m-1$ edges with positive flow.

We keep updating the current solution:

  1. If $c_{ij} \geq \lambda_i + \mu_j$ for all $i,j$, then the current solution is optimal and the algorithm is terminated.

  2. Otherwise let $(i,j)$ be such that $c_{ij} < \lambda_i + \mu_j$. By complementary slackness, $x_{ij} = 0$, so $(i,j)\not\in T$. Then $(i,j)$ and those edges in $T$ form a cycle.

  3. Along this cycle, increase the flow $x_{ij}$ until some flow in the cycle decreases to zero.

  4. Update the dual variables.

Example (transport algorithm)

Maximum flow problem open_in_new

Given a graph with a single source (vertex 1) and a single sink (vertex $n$), find the maximum possible flow $\delta$ between the source and the sink subject to capacity constraints.

Maximum flow problem

$$ \begin{align*} \text{Maximise } &\delta \\ \text{subject to } & \sum_{j:\ (i,j)\in E} x_{ij} - \sum_{j:\ (j,i)\in E} x_{ji} = 0 &&\forall i\neq 1,n, \\ & \sum_{j:\ (1,j)\in E} x_{1j} - \sum_{j:\ (j,1)\in E} x_{j1} = \delta, \\ & \sum_{j:\ (n,j)\in E} x_{nj} - \sum_{j:\ (j,n)\in E} x_{jn} = -\delta, \\ & 0 \leq x_{ij} \leq c_{ij} &&\forall (i,j)\in E. \end{align*} $$

Definition (cut of a graph) open_in_new

A cut of a graph $G = (V,E)$ is a partition of $V$ into $(S, V\setminus S)$.

Definition (capacity of a cut) open_in_new

The capacity of a cut $(S,V\setminus S)$ of a graph $G=(V,E)$ is $$ \begin{align*} c(S) = \sum_{(i,j)\in E: \ i\in S, \ j\in V\setminus S} c_{ij} \end{align*} $$ where $c_{ij}$ is the capacity of edge $(i,j)$.

Theorem (total flow does not exceed cut capacity) open_in_new

Let $x$ be a feasible flow of the maximum flow problem with flow $\delta$.

Then for any cut $(S,V\setminus S)$ such that $1\in S$ and $n\in V\setminus S$, we have $\delta\leq c(S)$.

Proof

Definition (augmenting path) open_in_new

In a graph $G=(V,E)$, a path is defined as a sequence of vertices $(v_1,v_2, \ldots, v_k)$ where each pair of adjacent vertices is connected, i.e. $(v_i, v_{i+1})$ or $(v_{i+1}, v_i) \in E$ for all $i=1,2,\ldots,k-1$.

Let $c_{ij}$ be the capacity of edge $(i,j)\in E$. For a flow $x$, a path is called an augmenting path if a forward edge is not full yet and a backward edge is not zero, i.e. $x_{v_i v_{i+1}} < c_{v_iv_{i+1}}$ when $(v_i, v_{i+1})\in E$ and $x_{v_{i+1} v_i} > 0$ when $(v_{i+1}, v_i)\in E$.

Observe that we can "push" a sufficiently small value $\epsilon$ along an augmenting path by adding a flow of $\epsilon$ along forward edges and subtracting $\epsilon$ along backward edges. So if there is an augmenting path from $1$ to $n$, then the flow is not optimal. (Example)

Theorem (max-flow min-cut) open_in_new

In a maximum flow problem, let $\delta^\ast$ be the optimal value. Then $$ \begin{align*} \delta^\ast = \min\sb{c(S)}{S\subset V,\ 1\in S,\ n\in V\setminus S}. \end{align*} $$

Proof

Ford-Fulkerson algorithm open_in_new
  1. Start with a feasible flow, say the zero flow $x=0$.

  2. While there exists an augmenting path from $1$ to $n$:

    1. Push as much as possible through the path.

  3. $x$ is now optimal. We can find a cut with capacity equal to the amount of flow.

Example

If the capacity is an integer, the algorithm is guaranteed to terminate. Otherwise it may have infinite steps.