Logo
Published on

Network Flows - Part 2

Authors
  • avatar
    Name
    Till Heller
    Twitter

In Part 1, we motivated network flows with a supply chain example and outlined what this series will cover. Now let's get precise. In this part, we introduce the formal definitions — flow networks, flows, and cuts — and establish the first fundamental relationship between them.

Flow Networks

A flow network is a directed graph where each arc has a capacity — a limit on how much "stuff" can pass through it. There are two special vertices: a source, where flow originates, and a sink, where flow is consumed.

Definition 1. A flow network is a tuple N=(D,s,t,c)N = (D, s, t, c), where:

  • D=(V,A)D = (V, A) is a directed graph,
  • sVs \in V is the source,
  • tVt \in V is the sink, with sts \neq t,
  • c:AR0c: A \rightarrow \mathbb{R}_{\geq 0} is the capacity function, assigning a non-negative capacity c(a)c(a) to each arc aAa \in A.

Think of the arcs as pipes and the capacities as their diameters — a wider pipe can carry more water. The source is the reservoir where water enters the system, and the sink is where it drains out. Everything in between is just routing the water through.

Let's look at a small example. Consider the flow network with vertices {s,a,b,t}\{s, a, b, t\} and arcs {(s,a),(s,b),(a,b),(a,t),(b,t)}\{(s,a), (s,b), (a,b), (a,t), (b,t)\} with capacities c(s,a)=4c(s,a) = 4, c(s,b)=2c(s,b) = 2, c(a,b)=3c(a,b) = 3, c(a,t)=1c(a,t) = 1, and c(b,t)=5c(b,t) = 5. The source ss can push up to 44 units through aa and 22 through bb, and the flow must eventually reach tt.

We will use this example throughout this part to illustrate the definitions.

flow-network

Flows

Now that we have the network, we can define what it means for something to "flow" through it. A flow assigns a value to each arc — how much is actually being transported — subject to two natural constraints: you can't exceed the capacity of an arc, and nothing gets created or destroyed at intermediate vertices.

Definition 2. A flow in a flow network N=(D,s,t,c)N = (D, s, t, c) is a function f:AR0f: A \rightarrow \mathbb{R}_{\geq 0} satisfying:

(i) Capacity constraint: 0f(a)c(a)0 \leq f(a) \leq c(a) for every arc aAa \in A.

(ii) Flow conservation: For every vertex vV{s,t}v \in V \setminus \{s, t\}, the total flow entering vv equals the total flow leaving vv: (u,v)Af(u,v)=(v,w)Af(v,w).\sum_{(u,v) \in A} f(u,v) = \sum_{(v,w) \in A} f(v,w).

The capacity constraint says we can't send more through a pipe than it can handle. Flow conservation says that at every intermediate vertex, what goes in must come out — nothing is lost, nothing is stored. Only the source and the sink are exempt: the source produces flow, and the sink absorbs it.

In our example, one valid flow is f(s,a)=3f(s,a) = 3, f(s,b)=2f(s,b) = 2, f(a,b)=2f(a,b) = 2, f(a,t)=1f(a,t) = 1, f(b,t)=4f(b,t) = 4. Let's verify: at vertex aa, the incoming flow is f(s,a)=3f(s,a) = 3 and the outgoing flow is f(a,b)+f(a,t)=2+1=3f(a,b) + f(a,t) = 2 + 1 = 3 — conservation holds. At vertex bb, the incoming flow is f(s,b)+f(a,b)=2+2=4f(s,b) + f(a,b) = 2 + 2 = 4 and the outgoing flow is f(b,t)=4f(b,t) = 4 — conservation holds again.

The most important number associated with a flow is how much total flow reaches the sink.

Definition 3. The value of a flow ff, denoted f|f|, is the net flow leaving the source: f=(s,w)Af(s,w)(u,s)Af(u,s).|f| = \sum_{(s,w) \in A} f(s,w) - \sum_{(u,s) \in A} f(u,s).

In most networks, no arcs point into the source, so the value is simply the total flow on all arcs leaving ss. In our example, f=f(s,a)+f(s,b)=3+2=5|f| = f(s,a) + f(s,b) = 3 + 2 = 5.

flow-example

By flow conservation, the value of a flow also equals the net flow arriving at the sink — what enters the system must eventually leave it.

Observation 1. For any flow ff, the net flow leaving the source equals the net flow entering the sink: (s,w)Af(s,w)(u,s)Af(u,s)=(u,t)Af(u,t)(t,w)Af(t,w).\sum_{(s,w) \in A} f(s,w) - \sum_{(u,s) \in A} f(u,s) = \sum_{(u,t) \in A} f(u,t) - \sum_{(t,w) \in A} f(t,w).

Proof. Sum the flow conservation equation over all vertices vV{s,t}v \in V \setminus \{s,t\}. On the left, we have the total flow on all arcs, counting each arc's flow once as incoming at its head. On the right, we have the total flow on all arcs, counting each arc's flow once as outgoing at its tail. Every arc with both endpoints in V{s,t}V \setminus \{s,t\} appears on both sides and cancels. What remains on the left are arcs arriving from ss or from tt, and on the right are arcs leaving toward ss or toward tt. Rearranging gives the desired equality.

The Maximum Flow Problem

Given a flow network, we naturally want to push as much flow as possible from source to sink. This is the central question of the series.

Maximum Flow Problem. Given a flow network N=(D,s,t,c)N = (D, s, t, c), find a flow ff of maximum value f|f|.

In our example, can we do better than f=5|f| = 5? The source can push at most c(s,a)+c(s,b)=4+2=6c(s,a) + c(s,b) = 4 + 2 = 6 units total. But can all 66 units reach tt? It turns out the answer is 55 — we'll see why after we introduce cuts.

Cuts

If a flow represents how much we can push through a network, a cut represents a bottleneck — a place where the network can be severed to separate the source from the sink. The capacity of the narrowest such bottleneck gives an upper bound on how much flow we can send.

Definition 4. An ss-tt-cut in a flow network N=(D,s,t,c)N = (D, s, t, c) is a partition of the vertex set VV into two sets SS and T=VST = V \setminus S such that sSs \in S and tTt \in T.

Definition 5. The capacity of an ss-tt-cut (S,T)(S, T) is the total capacity of all arcs going from SS to TT: c(S,T)=(u,v)AuS,vTc(u,v).c(S, T) = \sum_{\substack{(u,v) \in A \\ u \in S, \, v \in T}} c(u,v).

Notice that we only count arcs going from SS to TT, not the other way around. Arcs from TT to SS don't contribute to the cut capacity — they carry flow in the "wrong" direction.

In our example, consider the cut S={s,a}S = \{s, a\}, T={b,t}T = \{b, t\}. The arcs from SS to TT are (s,b)(s,b) with capacity 22, (a,b)(a,b) with capacity 33, and (a,t)(a,t) with capacity 11. So c(S,T)=2+3+1=6c(S,T) = 2 + 3 + 1 = 6. Another cut is S={s}S = \{s\}, T={a,b,t}T = \{a, b, t\}, which gives c(S,T)=c(s,a)+c(s,b)=4+2=6c(S,T) = c(s,a) + c(s,b) = 4 + 2 = 6. And the cut S={s,a,b}S = \{s, a, b\}, T={t}T = \{t\} gives c(S,T)=c(a,t)+c(b,t)=1+5=6c(S,T) = c(a,t) + c(b,t) = 1 + 5 = 6.

Interestingly, all three cuts in this example have capacity 66. That won't always be the case — different cuts can have very different capacities.

st-cut

Weak Duality

Now we arrive at the key relationship between flows and cuts. It turns out that the value of any flow is bounded above by the capacity of any cut. This is a powerful result: every cut provides a certificate that no flow can exceed a certain value.

Lemma 1 (Weak Duality). For any flow ff and any ss-tt-cut (S,T)(S, T) in a flow network, we have fc(S,T).|f| \leq c(S, T).

Proof. We first show that the value of any flow can be expressed using any cut. By summing the flow conservation equation over all vertices in S{s}S \setminus \{s\} and adding the definition of f|f|, we get: f=(u,v)AuS,vTf(u,v)(u,v)AuT,vSf(u,v).|f| = \sum_{\substack{(u,v) \in A \\ u \in S, \, v \in T}} f(u,v) - \sum_{\substack{(u,v) \in A \\ u \in T, \, v \in S}} f(u,v).

This says the value of the flow equals the net flow crossing the cut from SS to TT1. Now, the second sum is non-negative, so: f(u,v)AuS,vTf(u,v)(u,v)AuS,vTc(u,v)=c(S,T),|f| \leq \sum_{\substack{(u,v) \in A \\ u \in S, \, v \in T}} f(u,v) \leq \sum_{\substack{(u,v) \in A \\ u \in S, \, v \in T}} c(u,v) = c(S, T),

where the last inequality uses the capacity constraint f(u,v)c(u,v)f(u,v) \leq c(u,v).

Let's verify this in our example. We found a flow of value 55 and three cuts, each with capacity 66. The lemma confirms 565 \leq 6. But is the maximum flow actually 55, or can we do better? And what is the minimum cut capacity? Trying cuts by hand is tedious and error-prone — we need a systematic approach. We'll develop exactly that in the next part, where we introduce residual graphs and prove the Max-Flow Min-Cut Theorem: the statement that the maximum flow value always equals the minimum cut capacity.

Looking Ahead

We've set up the formal framework: flow networks, flows, cuts, and the weak duality between them. The natural question is: can weak duality be strengthened to an equality? In the next part, we'll answer this with the Max-Flow Min-Cut Theorem — one of the most important results in combinatorial optimization. To prove it, we'll introduce residual graphs and augmenting paths, which will also lead us directly to the first algorithms for computing maximum flows.

Footnotes

  1. This identity is sometimes called the flow-cut identity and is useful far beyond this proof.