Network flow
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.
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)$.
$$ \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$.
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.
$$ \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.
$$ \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*} $$
Every minimum cost flow problem with finite capacities or non-negative capacities can be recast as an equivalent transport problem.
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.
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$.
The transport tableau is as follow:
To construct an initial basic feasible solution, we use the northwest corner rule:
-
Start with any edge variable, and increase it until the supply or demand is satisfied.
-
If supply is satisfied, move to the next supplier and repeat step 1.
-
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:
-
If $c_{ij} \geq \lambda_i + \mu_j$ for all $i,j$, then the current solution is optimal and the algorithm is terminated.
-
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.
-
Along this cycle, increase the flow $x_{ij}$ until some flow in the cycle decreases to zero.
-
Update the dual variables.
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.
$$ \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*} $$
A cut of a graph $G = (V,E)$ is a partition of $V$ into $(S, V\setminus S)$.
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)$.
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$.
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*} $$
-
Start with a feasible flow, say the zero flow $x=0$.
-
While there exists an augmenting path from $1$ to $n$:
-
Push as much as possible through the path.
-
-
$x$ is now optimal. We can find a cut with capacity equal to the amount of flow.
If the capacity is an integer, the algorithm is guaranteed to terminate. Otherwise it may have infinite steps.