why gym rats love ford-fulkerson

what most people associate with the passage of water and time; a nightmarish combinatorial optimization problem for those in cs.

In any standard algorithms class, there’s going to be an entire section of the course dedicated to what computer scientists refer to as “flow”. Besides being creatively named, it is also quite powerful in solving a variety of problems. For the purposes of motivation, I will go over some background, one of the more important network flow algorithms, and an application of this algorithm in the context of proving a seemingly unnatural equivalence.

background and definitions

the problem

flow network 1

flow network 2

flow network 3

the solution and where ford and fulkerson come in

we finally stop the dilly-dallying and get to the main point of this post, the max-flow min-cut theorem.

max-flow min-cut theorem

Let \((\mathcal{G}, s, t, c)\) be a flow network, \(C(S, T)\) be an \(s-t\) cut, and \(f\) be a flow in \(\mathcal{G}\), then the following are equivalent:

  • \(f\) is a maximum flow in \(\mathcal{G}\).
  • \(\mathcal{G}_f\) contains no augmenting paths.
  • there exists a cut \(C(S, T)\) such that \(c(S, T) = \text{val}(f)\).

the proof

Lemma 1

Let \((\mathcal{G}, s, t, c)\) be a flow network, \(C(S, T)\) be an \(s-t\) cut, and \(f\) be a flow in \(\mathcal{G}\), then:

$$\begin{align*}f(S, T) \leq c(S, T)\end{align*}$$

proof: For every edge \((u, v)\) by a consequence of the capacity constraint, we know that \(f(u, v) \leq c(u, v)\). Therefore, we can ascertain

$$ \begin{align*} f(S, T) &= \sum_{u \in S} \sum_{v \in T} f(u, v) - \sum_{u \in S} \sum_{v \in T} f(v, u) && \text{definition of flow} \\ &\leq \sum_{u \in S} \sum_{v \in T} f(u, v) &&\text{non-negativity of a flow} \\ &\leq \sum_{u \in S} \sum_{v \in T} c(u, v) &&\text{capacity constraint} \\ &= c(S, T) &&\text{definition of capacity} \end{align*} $$

The larger consequence of this lemma is that for any cut you choose in the flow network, the flow going through \(C(S, T)\) is always bounded by its capacity.

Lemma 2

Let \((\mathcal{G}, s, t, c)\) be a flow network, \(C(S, T)\) be an \(s-t\) cut, and \(f\) be a flow in \(\mathcal{G}\), with \(v \in T\), then:

$$ \begin{align*}f(S, T) = f(S \cup \{v\}, T \setminus \{v\}) \end{align*} $$

proof: Let \(C(S, T)\) be any \(s-t\) cut and \(v\) an element in \(T\). Remove \(v\) from \(T\) and place it in \(S\). Let us now evaluate the flow of the new cut (call it \(C'(S', T')\)) where \(S' = S \cup \{v\}\) and \(T' = T \setminus \{v\}\).

For the sake of notational convenience, we define the following sets

$$ \textsf{In}(v) = \{(u, v) \in E \mid u \in V\} \quad \text{and} \quad \textsf{Out}(v) = \{(v, w) \in E \mid w \in V\} $$

Intuitively, \(\textsf{In}(v)\) is the set of edges going into \(v\) and \(\textsf{Out}(v)\) is the set of edges going out of \(v\). We know that from the conservation of flow

\[\sum \limits_{(u, v) \in \textsf{In}(v)} f(u, v) = \sum \limits_{(v, w) \in \textsf{Out}(v)} f(v, w)\]

We now partition \(\textsf{In}(v)\) and \(\textsf{Out}(v)\) based on where the end-points of the edges in the set fall as follows

$$ \begin{align*} \textsf{In}_{S}(v) &= \big\{(u, v) \in E \mid u \in S\big\} \\ \textsf{In}_{T}(v) &= \big\{(u, v) \in E \mid u \in T\big\} \\ \textsf{Out}_{S}(v) &= \big\{(v, w) \in E \mid w \in S\big\} \\ \textsf{Out}_{T}(v) &= \big\{(v, w) \in E \mid w \in T\big\} \end{align*} $$

Finally let us evaluate the flow of this new cut. Moving \(v\) into \(S\) result in losing \(v\)’s contribution in the original cut capacity but also in gaining the contribution of the edges going out of \(v\), and therefore:

$$ \begin{align*} f(S', T') &= f(S, T) - \sum \limits_{(u, v) \in \textsf{In}_{S}(v)} f(u, v) - \sum \limits_{(u, v) \in \textsf{In}_{T}(v)} f(u, v) \\ &+ \sum \limits_{(v, w) \in \textsf{Out}_{S}(v)} f(v, w) + \sum \limits_{(v, w) \in \textsf{Out}_{T}(v)} f(v, w) \\ &= f(S, T) - \sum \limits_{(u, v) \in \textsf{In}(v)} f(u, v) + \sum \limits_{(v, w) \in \textsf{Out}(v)} f(v, w) &&\text{since } \textsf{In}_{S}(v) \cup \textsf{In}_{T}(v) = \textsf{In}(v) \\ &= f(S, T) &&\text{by conservation of flow} \end{align*} $$

Lemma 3

Let \((\mathcal{G}, s, t, c)\) be a flow network, \(C(S, T)\) be an \(s-t\) cut, and \(f\) be a flow in \(\mathcal{G}\), then:

$$\begin{align*} f(S, T) = \text{val}(f) \end{align*} $$

proof: consider applying lemma 2 to the following cut \(C(S, T)\) where \(S = \{s\}\) and \(T = V \setminus \{s\}\), then:

\[f(\{s\}, V \setminus \{s\}) = f(\{s\} \cup S', V \setminus (\{s\} \cup S')) = f(S', T')\]

Essentially this implies that the flow of any cut is equal to the flow of the cut \(C(S, T)\) where \(S = \{s\}\) and \(T = V \setminus \{s\}\). How nice is that!! You may ask why is this nice? Well evaluating the flow of \(C(S, T)\) is much easier than evaluating the flow of any other cut. This is because the flow of \(C(S, T)\) is simply the flow leaving the source and this is the flow of the network :)

$$ \begin{align*} \text{val}(f) &= \sum_{(u, v) \in E} f(u, v) \\ &= f(\{s\}, V \setminus \{s\}) = f(S, T) &&\text{by lemma 2} \end{align*} $$

Corollary 1

Let \((\mathcal{G}, s, t, c)\) be a flow network, \(C(S, T)\) be an \(s-t\) cut, and \(f\) be a flow in \(\mathcal{G}\), then:

$$\begin{align*}\text{val}(f) \leq c(S, T)\end{align*}$$

now FINALLY, we can proceed with the proof of the max-flow min-cut theorem. we want to show that the 3 points of the theorem are equivalent. in the same vain,