# 组合数学 (Spring 2014)/Flow and matching

## Flow and Cut

### Flows

An instance of the maximum flow problem consists of:

• a directed graph ${\displaystyle G(V,E)}$;
• two distinguished vertices ${\displaystyle s}$ (the source) and ${\displaystyle t}$ (the sink), where the in-degree of ${\displaystyle s}$ and the out-degree of ${\displaystyle t}$ are both 0;
• the capacity function ${\displaystyle c:E\rightarrow \mathbb {R} ^{+}}$ which associates each directed edge ${\displaystyle (u,v)\in E}$ a nonnegative real number ${\displaystyle c_{uv}}$ called the capacity of the edge.

The quadruple ${\displaystyle (G,c,s,t)}$ is called a flow network.

A function ${\displaystyle f:E\rightarrow \mathbb {R} ^{+}}$ is called a flow (to be specific an ${\displaystyle s}$-${\displaystyle t}$ flow) in the network ${\displaystyle G(V,E)}$ if it satisfies:

• Capacity constraint: ${\displaystyle f_{uv}\leq c_{uv}}$ for all ${\displaystyle (u,v)\in E}$.
• Conservation constraint: ${\displaystyle \sum _{u:(u,v)\in E}f_{uv}=\sum _{w:(v,w)\in E}f_{vw}}$ for all ${\displaystyle v\in V\setminus \{s,t\}}$.

The value of the flow ${\displaystyle f}$ is ${\displaystyle \sum _{v:(s,v)\in E}f_{sv}}$.

Given a flow network, the maximum flow problem asks to find the flow of the maximum value.

The maximum flow problem can be described as the following linear program.

{\displaystyle {\begin{aligned}{\text{maximize}}\quad &\sum _{v:(s,v)\in E}f_{sv}\\{\begin{aligned}{\text{subject to}}\\\\\\\\\end{aligned}}\quad &{\begin{aligned}f_{uv}&\leq c_{uv}&\quad &\forall (u,v)\in E\\\sum _{u:(u,v)\in E}f_{uv}-\sum _{w:(v,w)\in E}f_{vw}&=0&\quad &\forall v\in V\setminus \{s,t\}\\f_{uv}&\geq 0&\quad &\forall (u,v)\in E\end{aligned}}\end{aligned}}}

### Cuts

 Definition Let ${\displaystyle (G(V,E),c,s,t)}$ be a flow network. Let ${\displaystyle S\subset V}$. We call ${\displaystyle (S,{\bar {S}})}$ an ${\displaystyle s}$-${\displaystyle t}$ cut if ${\displaystyle s\in S}$ and ${\displaystyle t\not \in S}$. The value of the cut (also called the capacity of the cut) is defined as ${\displaystyle \sum _{u\in S,v\not \in S \atop (u,v)\in E}c_{uv}}$.

A fundamental fact in flow theory is that cuts always upper bound flows.

 Lemma Let ${\displaystyle (G(V,E),c,s,t)}$ be a flow network. Let ${\displaystyle f}$ be an arbitrary flow in ${\displaystyle G}$, and let ${\displaystyle (S,{\bar {S}})}$ be an arbitrary ${\displaystyle s}$-${\displaystyle t}$ cut. Then ${\displaystyle \sum _{v:(s,v)}f_{sv}\leq \sum _{u\in S,v\not \in S \atop (u,v)\in E}c_{uv}}$, that is, the value of any flow is no greater than the value of any cut.
Proof.
 By the definition of ${\displaystyle s}$-${\displaystyle t}$ cut, ${\displaystyle s\in S}$ and ${\displaystyle t\not \in S}$. Due to the conservation of flow, ${\displaystyle \sum _{u\in S}\left(\sum _{v:(u,v)\in E}f_{uv}-\sum _{v:(v,u)\in E}f_{vu}\right)=\sum _{v:(s,v)\in E}f_{sv}+\sum _{u\in S\setminus \{s\}}\left(\sum _{v:(u,v)\in E}f_{uv}-\sum _{v:(v,u)\in E}f_{vu}\right)=\sum _{v:(s,v)\in E}f_{sv}\,.}$ On the other hand, summing flow over edges, ${\displaystyle \sum _{v\in S}\left(\sum _{u:(u,v)\in E}f_{uv}-\sum _{u:(v,u)\in E}f_{vu}\right)=\sum _{u\in S,v\in S \atop (u,v)\in E}\left(f_{uv}-f_{uv}\right)+\sum _{u\in S,v\not \in S \atop (u,v)\in E}f_{uv}-\sum _{u\in S,v\not \in S \atop (v,u)\in E}f_{vu}=\sum _{u\in S,v\not \in S \atop (u,v)\in E}f_{uv}-\sum _{u\in S,v\not \in S \atop (v,u)\in E}f_{vu}\,.}$ Therefore, ${\displaystyle \sum _{v:(s,v)\in E}f_{sv}=\sum _{u\in S,v\not \in S \atop (u,v)\in E}f_{uv}-\sum _{u\in S,v\not \in S \atop (v,u)\in E}f_{vu}\leq \sum _{u\in S,v\not \in S \atop (u,v)\in E}f_{uv}\leq \sum _{u\in S,v\not \in S \atop (u,v)\in E}c_{uv}\,,}$
${\displaystyle \square }$

### Augmenting paths

 Definition (Augmenting path) Let ${\displaystyle f}$ be a flow in ${\displaystyle G}$. An augmenting path to ${\displaystyle u_{k}}$ is a sequence of distinct vertices ${\displaystyle P=(u_{0},u_{1},\cdots ,u_{k})}$, such that ${\displaystyle u_{0}=s\,}$; and each pair of consecutive vertices ${\displaystyle u_{i}u_{i+1}\,}$ in ${\displaystyle P}$ corresponds to either a forward edge ${\displaystyle (u_{i},u_{i+1})\in E}$ or a reverse edge ${\displaystyle (u_{i+1},u_{i})\in E}$, and ${\displaystyle f(u_{i},u_{i+1}) when ${\displaystyle u_{i}u_{i+1}\,}$ corresponds to a forward edge ${\displaystyle (u_{i},u_{i+1})\in E}$, and ${\displaystyle f(u_{i+1},u_{i})>0\,}$ when ${\displaystyle u_{i}u_{i+1}\,}$ corresponds to a reverse edge ${\displaystyle (u_{i+1},u_{i})\in E}$. If ${\displaystyle u_{k}=t\,}$, we simply call ${\displaystyle P}$ an augmenting path.

Let ${\displaystyle f}$ be a flow in ${\displaystyle G}$. Suppose there is an augmenting path ${\displaystyle P=u_{0}u_{1}\cdots u_{k}}$, where ${\displaystyle u_{0}=s}$ and ${\displaystyle u_{k}=t}$. Let ${\displaystyle \epsilon >0}$ be a positive constant satisfying

• ${\displaystyle \epsilon \leq c(u_{i},u_{i+1})-f(u_{i},u_{i+1})}$ for all forward edges ${\displaystyle (u_{i},u_{i+1})\in E}$ in ${\displaystyle P}$;
• ${\displaystyle \epsilon \leq f(u_{i+1},u_{i})}$ for all reverse edges ${\displaystyle (u_{i+1},u_{i})\in E}$ in ${\displaystyle P}$.

Due to the definition of augmenting path, we can always find such a positive ${\displaystyle \epsilon }$.

Increase ${\displaystyle f(u_{i},u_{i+1})}$ by ${\displaystyle \epsilon }$ for all forward edges ${\displaystyle (u_{i},u_{i+1})\in E}$ in ${\displaystyle P}$ and decrease ${\displaystyle f(u_{i+1},u_{i})}$ by ${\displaystyle \epsilon }$ for all reverse edges ${\displaystyle (u_{i+1},u_{i})\in E}$ in ${\displaystyle P}$. Denote the modified flow by ${\displaystyle f'}$. It can be verified that ${\displaystyle f'}$ satisfies the capacity constraint and conservation constraint thus is still a valid flow. On the other hand, the value of the new flow ${\displaystyle f'}$

${\displaystyle \sum _{v:(s,v)\in E}f_{sv}'=\epsilon +\sum _{v:(s,v)\in E}f_{sv}>\sum _{v:(s,v)\in E}f_{sv}}$.

Therefore, the value of the flow can be "augmented" by adjusting the flow on the augmenting path. This immediately implies that if a flow is maximum, then there is no augmenting path. Surprisingly, the converse is also true, thus maximum flows are "characterized" by augmenting paths.

 Lemma A flow ${\displaystyle f}$ is maximum if and only if there are no augmenting paths.
Proof.
 We have already proved the "only if" direction above. Now we prove the "if" direction. Let ${\displaystyle S=\{u\in V\mid \exists {\text{an augmenting path to }}u\}}$. Clearly ${\displaystyle s\in S}$, and since there is no augmenting path ${\displaystyle t\not \in S}$. Therefore, ${\displaystyle (S,{\bar {S}})}$ defines an ${\displaystyle s}$-${\displaystyle t}$ cut. We claim that ${\displaystyle \sum _{v:(s,v)}f_{sv}=\sum _{u\in S,v\not \in S \atop (u,v)\in E}c_{uv}}$, that is, the value of flow ${\displaystyle f}$ approach the value of the cut ${\displaystyle (S,{\bar {S}})}$ defined above. By the above lemma, this will imply that the current flow ${\displaystyle f}$ is maximum. To prove this claim, we first observe that ${\displaystyle \sum _{v:(s,v)}f_{sv}=\sum _{u\in S,v\not \in S \atop (u,v)\in E}f_{uv}-\sum _{u\in S,v\not \in S \atop (v,u)\in E}f_{vu}}$. This identity is implied by the flow conservation constraint, and holds for any ${\displaystyle s}$-${\displaystyle t}$ cut ${\displaystyle (S,{\bar {S}})}$. We then claim that ${\displaystyle f_{uv}=c_{uv}}$ for all ${\displaystyle u\in S,v\not \in S,(u,v)\in E}$; and ${\displaystyle f_{vu}=0}$ for all ${\displaystyle u\in S,v\not \in S,(v,u)\in E}$. If otherwise, then the augmenting path to ${\displaystyle u}$ apending ${\displaystyle uv}$ becomes a new augmenting path to ${\displaystyle v}$, which contradicts that ${\displaystyle S}$ includes all vertices to which there exist augmenting paths. Therefore, ${\displaystyle \sum _{v:(s,v)}f_{sv}=\sum _{u\in S,v\not \in S \atop (u,v)\in E}f_{uv}-\sum _{u\in S,v\not \in S \atop (v,u)\in E}f_{vu}=\sum _{u\in S,v\not \in S \atop (u,v)\in E}c_{uv}}$. As discussed above, this proves the theorem.
${\displaystyle \square }$

## Max-Flow Min-Cut

### The max-flow min-cut theorem

 Max-Flow Min-Cut Theorem In a flow network, the maximum value of any ${\displaystyle s}$-${\displaystyle t}$ flow equals the minimum value of any ${\displaystyle s}$-${\displaystyle t}$ cut.
Proof.
 Let ${\displaystyle f}$ be a flow with maximum value, so there is no augmenting path. Again, let ${\displaystyle S=\{u\in V\mid \exists {\text{an augmenting path to }}u\}}$. As proved above, ${\displaystyle (S,{\bar {S}})}$ forms an ${\displaystyle s}$-${\displaystyle t}$ cut, and ${\displaystyle \sum _{v:(s,v)}f_{sv}=\sum _{u\in S,v\not \in S \atop (u,v)\in E}c_{uv}}$, that is, the value of flow ${\displaystyle f}$ equals the value of cut ${\displaystyle (S,{\bar {S}})}$. Since we know that all ${\displaystyle s}$-${\displaystyle t}$ flows are not greater than any ${\displaystyle s}$-${\displaystyle t}$ cut, the value of flow ${\displaystyle f}$ equals the minimum value of any ${\displaystyle s}$-${\displaystyle t}$ cut.
${\displaystyle \square }$

### Flow Integrality Theorem

 Flow Integrality Theorem Let ${\displaystyle (G,c,s,t)}$ be a flow network with integral capacity ${\displaystyle c}$. There exists an integral flow which is maximum.
Proof.
 Let ${\displaystyle f}$ be an integral flow of maximum value. If there is an augmenting path, since both ${\displaystyle c}$ and ${\displaystyle f}$ are integral, a new flow can be constructed of value 1+the value of ${\displaystyle f}$, contradicting that ${\displaystyle f}$ is maximum over all integral flows. Therefore, there is no augmenting path, which means that ${\displaystyle f}$ is maximum over all flows, integral or not.
${\displaystyle \square }$

### Applications: Menger's theorem

Given an undirected graph ${\displaystyle G(V,E)}$ and two distinct vertices ${\displaystyle s,t\in V}$, a set of edges ${\displaystyle C\subseteq E}$ is called an ${\displaystyle s}$-${\displaystyle t}$ cut, if deleting edges in ${\displaystyle C}$ disconnects ${\displaystyle s}$ and ${\displaystyle t}$.

A simple path from ${\displaystyle s}$ to ${\displaystyle t}$ is called an ${\displaystyle s}$-${\displaystyle t}$ path. Two paths are said to be edge-disjoint if they do not share any edge.

 Theorem (Menger 1927) Let ${\displaystyle G(V,E)}$ be an arbitrary undirected graph and ${\displaystyle s,t\in V}$ be two distinct vertices. The minimum size of any ${\displaystyle s}$-${\displaystyle t}$ cut equals the maximum number of edge-disjoint ${\displaystyle s}$-${\displaystyle t}$ paths.
Proof.
 Construct a directed graph ${\displaystyle G'(V,E')}$ from ${\displaystyle G(V,E)}$ as follows: replace every undirected edge ${\displaystyle uv\in E}$ that ${\displaystyle s,t\not \in \{u,v\}}$ by two directed edges ${\displaystyle (u,v)}$ and ${\displaystyle (v,u)}$; replace every undirected edge ${\displaystyle sv\in E}$ by ${\displaystyle (s,v)}$, and very undirected edge ${\displaystyle vt\in E}$ by ${\displaystyle (v,t)}$. Then assign every directed edge with capacity 1. It is easy to verify that in the flow network constructed as above, the followings hold: An integral ${\displaystyle s}$-${\displaystyle t}$ flow corresponds to a set of ${\displaystyle s}$-${\displaystyle t}$ paths in the undirected graph ${\displaystyle G}$, where the value of the flow is the number of ${\displaystyle s}$-${\displaystyle t}$ paths. An ${\displaystyle s}$-${\displaystyle t}$ cut in the flow network corresponds to an ${\displaystyle s}$-${\displaystyle t}$ cut in the undirected graph ${\displaystyle G}$ with the same value. The Menger's theorem follows as a direct consequence of the max-flow min-cut theorem.
${\displaystyle \square }$

### Applications: König-Egerváry theorem

Let ${\displaystyle G(V,E)}$ be a graph. An edge set ${\displaystyle M\subseteq E}$ is called a matching if no edge in ${\displaystyle M}$ shares any vertex. A vertex set ${\displaystyle C\subseteq V}$ is called a vertex cover if for any edge ${\displaystyle uv\in E}$, either ${\displaystyle u\in C}$ or ${\displaystyle v\in C}$.

 Theorem (König 1936) In any bipartite graph ${\displaystyle G(V_{1},V_{2},E)}$, the size of a maximum matching equals the size of a minimum vertex cover.

We now show how a reduction of bipartite matchings to flows.

Construct a flow network ${\displaystyle (G'(V,E'),c,s,t)}$ as follows:

• ${\displaystyle V=V_{1}\cup V_{2}\cup \{s,t\}}$ where ${\displaystyle s}$ and ${\displaystyle t}$ are two new vertices.
• For ever ${\displaystyle uv\in E}$, add ${\displaystyle (u,v)}$ to ${\displaystyle E'}$; for every ${\displaystyle u\in V_{1}}$, add ${\displaystyle (s,u)}$ to ${\displaystyle E'}$; and for every ${\displaystyle v\in V_{2}}$, add ${\displaystyle (v,t)}$ to ${\displaystyle E'}$.
• Let ${\displaystyle c_{su}=1}$ for every ${\displaystyle u\in V_{1}}$ and ${\displaystyle c_{vt}=1}$ for every ${\displaystyle v\in V_{2}}$. Let ${\displaystyle c_{uv}=\infty }$ for every bipartite edges ${\displaystyle (u,v)}$.
 Lemma The size of a maximum matching in ${\displaystyle G}$ is equal to the value of a maximum ${\displaystyle s}$-${\displaystyle t}$ flow in ${\displaystyle G'}$.
Proof.
 Given an integral ${\displaystyle s}$-${\displaystyle t}$ flow ${\displaystyle f}$ in ${\displaystyle G'}$, let ${\displaystyle M=\{uv\in E\mid f_{uv}=1\}}$. Then ${\displaystyle M}$ must be a matching since for every ${\displaystyle u\in V_{1}}$. To see this, observe that there is at most one ${\displaystyle v\in V_{2}}$ that ${\displaystyle f_{uv}=1}$, because of that ${\displaystyle f_{su}\leq c_{su}=1}$ and conservation of flows. The same holds for vertices in ${\displaystyle V_{2}}$ by the same argument. Therefore, each flow corresponds to a matching. Given a matching ${\displaystyle M}$ in bipartite graph ${\displaystyle G}$, define an integral flow ${\displaystyle f}$ as such: for ${\displaystyle uv\in E}$, ${\displaystyle f_{uv}=1}$ if ${\displaystyle uv\in M}$ and ${\displaystyle f_{uv}=0}$ if otherwise; for ${\displaystyle u\in V_{1}}$, ${\displaystyle f_{su}=1}$ if ${\displaystyle uv\in M}$ for some ${\displaystyle v}$ and ${\displaystyle f_{su}=0}$ if otherwise; for ${\displaystyle v\in V_{2}}$, ${\displaystyle f_{vt}=1}$ if ${\displaystyle uv\in M}$ for some ${\displaystyle u}$ and ${\displaystyle f_{vt}=0}$ if otherwise. It is easy to check that ${\displaystyle f}$ is valid ${\displaystyle s}$-${\displaystyle t}$ flow in ${\displaystyle G'}$. Therefore, there is an one-one correspondence between flows in ${\displaystyle G'}$ and matchings in ${\displaystyle G}$. The lemma follows naturally.
${\displaystyle \square }$

We then establish a correspondence between ${\displaystyle s}$-${\displaystyle t}$ cuts in ${\displaystyle G'}$ and vertex covers in ${\displaystyle G}$.

Suppose ${\displaystyle (S,{\bar {S}})}$ is an ${\displaystyle s}$-${\displaystyle t}$ cut in ${\displaystyle G'}$.

 Lemma The size of a minimum vertex cover in ${\displaystyle G}$ is equal to the value of a minimum ${\displaystyle s}$-${\displaystyle t}$ cut in ${\displaystyle G'}$.
Proof.
 Let ${\displaystyle (S,{\bar {S}})}$ be an ${\displaystyle s}$-${\displaystyle t}$ cut of minimum capacity in ${\displaystyle G'}$. Then ${\displaystyle \sum _{u\in S,v\not \in S \atop (u,v)\in E'}c_{uv}}$ must be finite since ${\displaystyle S=\{s\}}$ gives us an ${\displaystyle s}$-${\displaystyle t}$ cut whose capacity is ${\displaystyle |V_{1}|}$ which is finite. Therefore, no edge ${\displaystyle uv\in E}$ has ${\displaystyle u\in V_{1}\cap S}$ and ${\displaystyle v\in V_{2}\setminus S}$, i.e., for all ${\displaystyle uv\in E}$, either ${\displaystyle u\in V_{1}\setminus S}$ or ${\displaystyle v\in V_{2}\cap S}$. Therefore, ${\displaystyle (V_{1}\setminus S)\cup (V_{2}\cap S)}$ is a vertex cover in ${\displaystyle G}$, whose size is ${\displaystyle |(V_{1}\setminus S)\cup (V_{2}\cap S)|=|V_{1}\setminus S|+|V_{2}\cap S|=\sum _{u\in V_{1}\setminus S}c_{su}+\sum _{v\in V_{2}\cap S}c_{ut}=\sum _{u\in S,v\not \in S \atop (u,v)\in E'}c_{uv}}$. The last term is the capacity of the minimum ${\displaystyle s}$-${\displaystyle t}$ cut ${\displaystyle (S,{\bar {S}})}$.
${\displaystyle \square }$

The König-Egerváry theorem then holds as a consequence of the max-flow min-cut theorem.

## Linear Programming

Consider the following LP:

{\displaystyle {\begin{aligned}{\text{minimize}}&&7x_{1}+x_{2}+5x_{3}\\{\text{subject to}}&&x_{1}-x_{2}+3x_{3}&\geq 10\\&&5x_{1}-2x_{2}-x_{3}&\geq 6\\&&x_{1},x_{2},x_{3}&\geq 0\end{aligned}}}

Let ${\displaystyle OPT}$ be the value of the optimal solution. We want to estimate the upper and lower bound of ${\displaystyle OPT}$.

Since ${\displaystyle OPT}$ is the minimum over the feasible set, every feasible solution forms an upper bound for ${\displaystyle OPT}$. For example ${\displaystyle {\boldsymbol {x}}=(2,1,3)}$ is a feasible solution, thus ${\displaystyle OPT\leq 7\cdot 2+1+5\cdot 3=30}$.

For the lower bound, the optimal solution must satisfy the two constraints:

{\displaystyle {\begin{aligned}x_{1}-x_{2}+3x_{3}&\geq 10,\\5x_{1}-2x_{2}-x_{3}&\geq 6.\\\end{aligned}}}

Since the ${\displaystyle x_{i}}$'s are restricted to be nonnegative, term-by-term comparison of coefficients shows that

${\displaystyle 7x_{1}+x_{2}+5x_{3}\geq (x_{1}-x_{2}+3x_{3})+(5x_{1}-2x_{2}-x_{3})\geq 16.}$

The idea behind this lower bound process is that we are finding suitable nonnegative multipliers (in the above case the multipliers are all 1s) for the constraints so that when we take their sum, the coefficient of each ${\displaystyle x_{i}}$ in the sum is dominated by the coefficient in the objective function. It is important to ensure that the multipliers are nonnegative, so they do not reverse the direction of the constraint inequality.

To find the best lower bound, we need to choose the multipliers in such a way that the sum is as large as possible. Interestingly, the problem of finding the best lower bound can be formulated as another LP:

{\displaystyle {\begin{aligned}{\text{maximize}}&&10y_{1}+6y_{2}\\{\text{subject to}}&&y_{1}+5y_{2}&\leq 7\\&&-y_{1}+2y_{2}&\leq 1\\&&3y_{1}-y_{2}&\leq 5\\&&y_{1},y_{2}&\geq 0\end{aligned}}}

Here ${\displaystyle y_{1}}$ and ${\displaystyle y_{2}}$ were chosen to be nonnegative multipliers for the first and the second constraint, respectively. We call the first LP the primal program and the second LP the dual program. By definition, every feasible solution to the dual program gives a lower bound for the primal program.

### Duality

Given an LP in canonical form, called the primal LP:

{\displaystyle {\begin{aligned}{\text{minimize}}&&{\boldsymbol {c}}^{T}{\boldsymbol {x}}\\{\text{subject to}}&&A{\boldsymbol {x}}&\geq {\boldsymbol {b}}\\&&{\boldsymbol {x}}&\geq {\boldsymbol {0}}\end{aligned}}}

the dual LP is defined as follows:

{\displaystyle {\begin{aligned}{\text{maximum}}&&{\boldsymbol {b}}^{T}{\boldsymbol {y}}\\{\text{subject to}}&&A^{T}{\boldsymbol {y}}&\leq {\boldsymbol {c}}\\&&{\boldsymbol {y}}&\geq {\boldsymbol {0}}\end{aligned}}}

#### LP for maximum flow

In the last lecture, we defined the maximum flow problem, whose LP is

{\displaystyle {\begin{aligned}{\text{maximize}}\quad &\sum _{v:(s,v)\in E}f_{sv}\\{\begin{aligned}{\text{subject to}}\\\\\\\\\end{aligned}}\quad &{\begin{aligned}f_{uv}&\leq c_{uv}&\quad &\forall (u,v)\in E\\\sum _{u:(u,v)\in E}f_{uv}-\sum _{w:(v,w)\in E}f_{vw}&=0&\quad &\forall v\in V\setminus \{s,t\}\\f_{uv}&\geq 0&\quad &\forall (u,v)\in E\end{aligned}}\end{aligned}}}

where directed graph ${\displaystyle G(V,E)}$ is the flow network, ${\displaystyle s\in V}$ is the source, ${\displaystyle t\in V}$ is the sink, and ${\displaystyle c_{uv}}$ is the capacity of directed edge ${\displaystyle (u,v)\in E}$.

We add a new edge from ${\displaystyle t}$ to ${\displaystyle s}$ to ${\displaystyle E}$, and let the capacity be ${\displaystyle c_{ts}=\infty }$. Let ${\displaystyle E'}$ be the new edge set. The LP for the max-flow problem can be rewritten as:

{\displaystyle {\begin{aligned}{\text{maximize}}\quad &f_{ts}\\{\begin{aligned}{\text{subject to}}\\\\\\\\\end{aligned}}\quad &{\begin{aligned}f_{uv}&\leq c_{uv}&\quad &\forall (u,v)\in E\\\sum _{u:(u,v)\in E'}f_{uv}-\sum _{w:(v,w)\in E'}f_{vw}&\leq 0&\quad &\forall v\in V\\f_{uv}&\geq 0&\quad &\forall (u,v)\in E'\end{aligned}}\end{aligned}}}

The second set of inequalities seem weaker than the original conservation constraint of flows, however, if this inequality holds at every node, then in fact it must be satisfied with equality at every node, thereby implying the flow conservation.

To obtain the dual program we introduce variables ${\displaystyle d_{uv}}$ and ${\displaystyle p_{v}}$ corresponding to the two types of inequalities in the primal. The dual LP is:

{\displaystyle {\begin{aligned}{\text{minimize}}\quad &\sum _{(u,v)\in E}c_{uv}d_{uv}\\{\begin{aligned}{\text{subject to}}\\\\\\\\\end{aligned}}\quad &{\begin{aligned}d_{uv}-p_{u}+p_{v}&\geq 0&\quad &\forall (u,v)\in E\\p_{s}-p_{t}&\geq 1\\d_{uv}&\geq 0&\quad &\forall (u,v)\in E\\p_{v}&\geq 0&\quad &\forall v\in V\end{aligned}}\end{aligned}}}

It is more helpful to consider its integer version:

{\displaystyle {\begin{aligned}{\text{minimize}}\quad &\sum _{(u,v)\in E}c_{uv}d_{uv}\\{\begin{aligned}{\text{subject to}}\\\\\\\\\end{aligned}}\quad &{\begin{aligned}d_{uv}-p_{u}+p_{v}&\geq 0&\quad &\forall (u,v)\in E\\p_{s}-p_{t}&\geq 1\\d_{uv}&\in \{0,1\}&\quad &\forall (u,v)\in E\\p_{v}&\in \{0,1\}&\quad &\forall v\in V\end{aligned}}\end{aligned}}}

Suppose that for the flow LP, the integral optimal solution always equals the fractional optimal solution (we will show this later). The variables ${\displaystyle p_{v}}$ defines a bipartition of vertex set ${\displaystyle V}$. Let ${\displaystyle S=\{v\in V\mid p_{v}=1\}}$. The complement ${\displaystyle {\bar {S}}=\{v\in V\mid p_{v}=1\}}$.

For 0/1-valued variables, the only way to satisfy ${\displaystyle p_{s}-p_{t}\geq 1}$ is to have ${\displaystyle p_{s}=1}$ and ${\displaystyle p_{t}=0}$. Therefore, ${\displaystyle (S,{\bar {S}})}$ is an ${\displaystyle s}$-${\displaystyle t}$ cut.

In an optimal solution, ${\displaystyle d_{uv}=1}$ if and only if ${\displaystyle u\in S,v\in {\bar {S}}}$ and ${\displaystyle (u,v)\in E}$. Therefore, the objective function of an optimal solution ${\displaystyle \sum _{u\in S,v\not \in S \atop (u,v)\in E}c_{uv}}$ is the capacity of the minimum ${\displaystyle s}$-${\displaystyle t}$ cut ${\displaystyle (S,{\bar {S}})}$.

#### LP duality theorem

Consider the primal LP:

{\displaystyle {\begin{aligned}{\text{minimize}}&&{\boldsymbol {c}}^{T}{\boldsymbol {x}}\\{\text{subject to}}&&A{\boldsymbol {x}}&\geq {\boldsymbol {b}}\\&&{\boldsymbol {x}}&\geq {\boldsymbol {0}}\end{aligned}}}

Its dual LP is:

{\displaystyle {\begin{aligned}{\text{maximum}}&&{\boldsymbol {b}}^{T}{\boldsymbol {y}}\\{\text{subject to}}&&A^{T}{\boldsymbol {y}}&\leq {\boldsymbol {c}}\\&&{\boldsymbol {y}}&\geq {\boldsymbol {0}}\end{aligned}}}
 Theorem The dual of a dual is the primal.
Proof.
 The dual program can be written as the following minimization in canonical form: {\displaystyle {\begin{aligned}\min &&-{\boldsymbol {b}}^{T}{\boldsymbol {y}}\\{\text{s.t.}}&&-A^{T}{\boldsymbol {y}}&\geq -{\boldsymbol {c}}\\&&{\boldsymbol {y}}&\geq {\boldsymbol {0}}\end{aligned}}} Its dual is: {\displaystyle {\begin{aligned}\max &&-{\boldsymbol {c}}^{T}{\boldsymbol {x}}\\{\text{s.t.}}&&-A{\boldsymbol {x}}&\leq -{\boldsymbol {b}}\\&&{\boldsymbol {x}}&\geq {\boldsymbol {0}}\end{aligned}}} which is equivalent to the primal: {\displaystyle {\begin{aligned}\min &&{\boldsymbol {c}}^{T}{\boldsymbol {x}}\\{\text{s.t.}}&&A{\boldsymbol {x}}&\geq {\boldsymbol {b}}\\&&{\boldsymbol {x}}&\geq {\boldsymbol {0}}\end{aligned}}}
${\displaystyle \square }$

We have shown that feasible solutions of a dual program can be used to lower bound the optimum of the primal program. This is formalized by the following important theorem.

 Theorem (Weak duality theorem) If there exists an optimal solution to the primal LP: {\displaystyle {\begin{aligned}\min &&{\boldsymbol {c}}^{T}{\boldsymbol {x}}\\{\text{s.t.}}&&A{\boldsymbol {x}}&\geq {\boldsymbol {b}}\\&&{\boldsymbol {x}}&\geq {\boldsymbol {0}}\end{aligned}}} then, {\displaystyle {\begin{aligned}{\begin{aligned}\min &&{\boldsymbol {c}}^{T}{\boldsymbol {x}}\\{\text{s.t.}}&&A{\boldsymbol {x}}&\geq {\boldsymbol {b}}\\&&{\boldsymbol {x}}&\geq {\boldsymbol {0}}\end{aligned}}&{\begin{aligned}\geq \\\\\\\end{aligned}}&\quad {\begin{aligned}\max &&{\boldsymbol {b}}^{T}{\boldsymbol {y}}\\{\text{s.t.}}&&A^{T}{\boldsymbol {y}}&\leq {\boldsymbol {c}}\\&&{\boldsymbol {y}}&\geq {\boldsymbol {0}}\end{aligned}}\end{aligned}}}
Proof.
 Let ${\displaystyle {\boldsymbol {x}}}$ be an arbitrary feasible solution to the primal LP, and ${\displaystyle {\boldsymbol {y}}}$ be an arbitrary feasible solution to the dual LP. We estimate ${\displaystyle {\boldsymbol {y}}^{T}A{\boldsymbol {x}}}$ in two ways. Recall that ${\displaystyle A{\boldsymbol {x}}\geq {\boldsymbol {b}}}$ and ${\displaystyle A^{T}{\boldsymbol {y}}\leq {\boldsymbol {c}}}$, thus ${\displaystyle {\boldsymbol {y}}^{T}{\boldsymbol {b}}\leq {\boldsymbol {y}}^{T}A{\boldsymbol {x}}\leq {\boldsymbol {c}}^{T}{\boldsymbol {x}}}$. Since this holds for any feasible solutions, it must also hold for the optimal solutions.
${\displaystyle \square }$

A harmonically beautiful result is that the optimums of the primal LP and its dual are equal. This is called the strong duality theorem of linear programming.

 Theorem (Strong duality theorem) If there exists an optimal solution to the primal LP: {\displaystyle {\begin{aligned}\min &&{\boldsymbol {c}}^{T}{\boldsymbol {x}}\\{\text{s.t.}}&&A{\boldsymbol {x}}&\geq {\boldsymbol {b}}\\&&{\boldsymbol {x}}&\geq {\boldsymbol {0}}\end{aligned}}} then, {\displaystyle {\begin{aligned}{\begin{aligned}\min &&{\boldsymbol {c}}^{T}{\boldsymbol {x}}\\{\text{s.t.}}&&A{\boldsymbol {x}}&\geq {\boldsymbol {b}}\\&&{\boldsymbol {x}}&\geq {\boldsymbol {0}}\end{aligned}}&{\begin{aligned}=\\\\\\\end{aligned}}&\quad {\begin{aligned}\max &&{\boldsymbol {b}}^{T}{\boldsymbol {y}}\\{\text{s.t.}}&&A^{T}{\boldsymbol {y}}&\leq {\boldsymbol {c}}\\&&{\boldsymbol {y}}&\geq {\boldsymbol {0}}\end{aligned}}\end{aligned}}}

### Integrality

Consider the maximum integral flow problem: given as input a flow network ${\displaystyle (G(V,E),c,s,t)}$ where for every ${\displaystyle uv\in E}$ the capacity ${\displaystyle c_{uv}}$ is integer. We want to find the integral flow ${\displaystyle f:E\rightarrow \mathbb {Z} }$ with maximum value.

The mathematical programming for the problem is:

{\displaystyle {\begin{aligned}{\text{maximize}}\quad &\sum _{v:(s,v)\in E}f_{sv}\\{\begin{aligned}{\text{subject to}}\\\\\\\\\\\end{aligned}}\quad &{\begin{aligned}f_{uv}&\leq c_{uv}&\quad &\forall (u,v)\in E\\\sum _{u:(u,v)\in E}f_{uv}-\sum _{w:(v,w)\in E}f_{vw}&=0&\quad &\forall v\in V\setminus \{s,t\}\\f_{uv}&\in \mathbb {N} &\quad &\forall (u,v)\in E\end{aligned}}\end{aligned}}}

where ${\displaystyle \mathbb {N} }$ is the set of all nonnegative integers. Compared to the LP for the max-flow problem, we just replace the last line ${\displaystyle f_{uv}\geq 0}$ with ${\displaystyle f_{uv}\in \mathbb {N} }$. The resulting optimization is called an integer programming (IP), or more specific integer linear programming (ILP).

Due to the Flow Integrality Theorem, when capacities are integers, there must be an integral flow whose value is maximum among all flows (integral or not). This means the above IP can be efficiently solved by solving its LP-relaxation. This is usually impossible for general IPs.

Generally, an IP of canonical form is written as

{\displaystyle {\begin{aligned}{\text{maximize}}\quad &{\boldsymbol {c}}^{T}{\boldsymbol {x}}\\{\begin{aligned}{\text{subject to}}\\\\\\\end{aligned}}\quad &{\begin{aligned}A{\boldsymbol {x}}&\geq {\boldsymbol {b}}\\{\boldsymbol {x}}&\geq {\boldsymbol {0}}\\{\boldsymbol {x}}&\in \mathbb {Z} ^{n}\end{aligned}}\end{aligned}}}

Consider the 3SAT problem. Each instance is a 3CNF(conjunctive normal form): ${\displaystyle \bigwedge _{i=1}^{m}(\ell _{i_{1}}\vee \ell _{i_{2}}\vee \ell _{i_{3}})}$, where each ${\displaystyle (\ell _{i_{1}}\vee \ell _{i_{2}}\vee \ell _{i_{3}})}$ is a clause and each ${\displaystyle \ell _{i_{r}}\in \{x_{j},\neg x_{j}\mid 1\leq j\leq n\}}$, called a literal, is either a boolean variable or a negation of a boolean variable. We want to determine whether there exists an truth assignment of the ${\displaystyle n}$ boolean variables ${\displaystyle x_{1},\ldots ,x_{n}}$ such that the input formula is satisfied (i.e., is true).

The following IP solves 3SAT:

{\displaystyle {\begin{aligned}{\text{maximize}}\quad &\sum _{i=1}^{m}z_{i}\\{\begin{aligned}{\text{subject to}}\\\\\\\\\end{aligned}}\quad &{\begin{aligned}z_{i}&\leq y_{i_{1}}+y_{i_{2}}+y_{i_{3}}&\quad &\forall 1\leq i\leq m\\y_{i_{r}}&\leq x_{j}&\quad &{\text{if }}\ell _{i_{r}}=x_{j}\\y_{i_{r}}&\leq 1-x_{j}&\quad &{\text{if }}\ell _{i_{r}}=\neg x_{j}\\z_{i},x_{j}&\in \{0,1\}&\quad &\forall 1\leq i\leq m,1\leq j\leq n\end{aligned}}\end{aligned}}}

Since 3SAT is NP-hard (actually it is the first problem known to be NP-hard), generally IP is NP-hard.

#### Integral polytopes

A point in an ${\displaystyle n}$-dimensional space is integral if it belongs to ${\displaystyle \mathbb {Z} ^{n}}$, i.e., if all its coordinates are integers.

A polyhedron is said to be integral if all its vertices are integral.

An easy observation is that an integer programming has the same optimal solutions as its LP-relaxation when the polyhedron defined by the LP-relaxation is integral.

 Theorem (Hoffman 1974) If a polyhedron ${\displaystyle P}$ is integral then for all integer vectors ${\displaystyle {\boldsymbol {c}}}$ there is an optimal solution to ${\displaystyle \max\{{\boldsymbol {c}}^{T}{\boldsymbol {x}}\mid {\boldsymbol {x}}\in P\}}$ which is integral.
Proof.
 There always exists an optimal solution which is a vertex in ${\displaystyle P}$. For integral ${\displaystyle P}$, all vertices are integral.
${\displaystyle \square }$

#### Unimodularity

 Definition (Unimodularity) An ${\displaystyle n\times n}$ integer matrix ${\displaystyle A}$ is called unimodular if ${\displaystyle \det(A)=\pm 1}$. An ${\displaystyle m\times n}$ integer matrix ${\displaystyle A}$ is called total unimodular if every square submatrix ${\displaystyle B}$ of ${\displaystyle A}$ has ${\displaystyle \det(B)\in \{1,-1,0\}}$, that is, every square, nonsingular submatrix of ${\displaystyle A}$ is unimodular.

A totally unimodular matrix defines a integral convex polyhedron.

 Theorem Let ${\displaystyle A}$ be an ${\displaystyle m\times n}$ integer matrix. If ${\displaystyle A}$ is totally unimodualr, then for any integer vector ${\displaystyle {\boldsymbol {b}}\in \mathbb {Z} ^{n}}$ the polyhedron ${\displaystyle \{{\boldsymbol {x}}\in \mathbb {R} ^{n}\mid A{\boldsymbol {x}}={\boldsymbol {b}},{\boldsymbol {x}}\geq {\boldsymbol {0}}\}}$ is integral.
Proof.
 Let ${\displaystyle B}$ be a basis of ${\displaystyle A}$, and let ${\displaystyle {\boldsymbol {b}}'}$ be the corresponding coordinates in ${\displaystyle {\boldsymbol {b}}}$. A basic solution is formed by ${\displaystyle B^{-1}{\boldsymbol {b}}'}$ and zeros. Since ${\displaystyle A}$ is totally unimodular and ${\displaystyle B}$ is a basis thus nonsingular, ${\displaystyle \det(B)\in \{1,-1,0\}}$. By Cramer's rule, ${\displaystyle B^{-1}}$ has integer entries, thus ${\displaystyle B^{-1}{\boldsymbol {b}}'}$ is integral. Therefore, any basic solution of ${\displaystyle A{\boldsymbol {x}}={\boldsymbol {b}},{\boldsymbol {x}}\geq {\boldsymbol {0}}}$ is integral, which means the polyhedron ${\displaystyle \{{\boldsymbol {x}}\in \mathbb {R} ^{n}\mid A{\boldsymbol {x}}={\boldsymbol {b}},{\boldsymbol {x}}\geq {\boldsymbol {0}}\}}$ is integral.
${\displaystyle \square }$

Our next result is the famous Hoffman-Kruskal theorem.

 Theorem (Hoffman-Kruskal 1956) Let ${\displaystyle A}$ be an ${\displaystyle m\times n}$ integer matrix. If ${\displaystyle A}$ is totally unimodualr, then for any integer vector ${\displaystyle {\boldsymbol {b}}\in \mathbb {Z} ^{n}}$ the polyhedron ${\displaystyle \{{\boldsymbol {x}}\in \mathbb {R} ^{n}\mid A{\boldsymbol {x}}\geq {\boldsymbol {b}},{\boldsymbol {x}}\geq {\boldsymbol {0}}\}}$ is integral.
Proof.
 Let ${\displaystyle A'={\begin{bmatrix}A&-I\end{bmatrix}}}$. We claim that ${\displaystyle A'}$ is also totally unimodular. Any square submatrix ${\displaystyle B}$ of ${\displaystyle A}$ can be written in the following form after permutation: ${\displaystyle B={\begin{bmatrix}C&0\\D&I\end{bmatrix}}}$ where ${\displaystyle C}$ is a square submatrix of ${\displaystyle A}$ and ${\displaystyle I}$ is identity matrix. Therefore, ${\displaystyle \det(B)=\det(C)\in \{1,-1,0\}}$, thus ${\displaystyle A'}$ is totally unimodular. Add slack variables to transform the constraints to the standard form ${\displaystyle A'{\boldsymbol {z}}={\boldsymbol {b}},{\boldsymbol {z}}\geq {\boldsymbol {0}}}$. The polyhedron ${\displaystyle \{{\boldsymbol {x}}\mid A{\boldsymbol {x}}\geq {\boldsymbol {b}},{\boldsymbol {x}}\geq {\boldsymbol {0}}\}}$ is integral if the polyhedron ${\displaystyle \{{\boldsymbol {z}}\mid A'{\boldsymbol {z}}={\boldsymbol {b}},{\boldsymbol {z}}\geq {\boldsymbol {0}}\}}$ is integral, which is implied by the total unimodularity of ${\displaystyle A'\,}$.
${\displaystyle \square }$