Sub topic 13
Integer Capacities Give Integer Flows
This chapter assumes you know the Ford-Fulkerson method, residual graphs, and the max-flow min-cut theorem from earlier chapters. It also assumes you can follow a proof by invariant. The result here looks minor, but it is the reason max flow can solve counting problems such as matching, where a "half edge" means nothing.
The Theorem
Integrality theorem. If every edge capacity in a flow network is an integer, then there is a maximum flow in which every edge carries an integer amount of flow. Ford-Fulkerson, and therefore Edmonds-Karp, finds such a flow.
The theorem says that an integral maximum flow exists. It does not say that every maximum flow is integral. Fractional maximum flows can exist alongside integral ones.
Why It Holds: An Invariant
The proof tracks one invariant through the algorithm: every flow value and every residual capacity is an integer.
- Start. The flow is zero on every edge. The residual capacities equal the original capacities, which are integers.
- Bottleneck. An augmenting path's bottleneck is the minimum of some residual capacities. A minimum of integers is an integer. The path only uses edges with positive residual capacity, so the bottleneck is at least 1.
- Augment. Each forward residual edge loses the bottleneck and each reverse edge gains it. Integers plus or minus an integer stay integers, so the invariant holds after the update.
Each augmentation raises the flow value by at least 1. The flow value can never exceed the capacity of any s-t cut, so the algorithm stops after a finite number of rounds. When it stops, no augmenting path remains, and the max-flow min-cut theorem says the flow is maximum. That final flow satisfies the invariant, so it is integral.
Checking It in Code
This snippet reuses edmonds_karp and the capacity matrix from the Edmonds-Karp chapter. That network has no pair of opposite edges, so the flow on edge u → v equals its capacity minus its final residual capacity.
flow_value, residual = edmonds_karp(capacity, 0, 5)
n = len(capacity)
edge_flows = {(u, v): capacity[u][v] - residual[u][v]
for u in range(n) for v in range(n) if capacity[u][v] > 0}
print(edge_flows)
print(all(isinstance(f, int) for f in edge_flows.values())) # TrueCommon Mistakes
| Mistake | Correction |
|---|---|
| "Every max flow is integral." | Only some are. The algorithm finds an integral one. |
| Applying the theorem to real-valued capacities | Rational capacities work if you scale them to integers first. Irrational capacities break the argument, since the bottleneck can shrink forever. |
| Forgetting the bound on rounds | With integer capacities there are at most f* augmentations, where f* is the max flow value. That bound depends on capacity size, unlike the bound for Edmonds-Karp. |
Exercise
A network has edges s→a (capacity 1), a→t (1), a→b (1), and b→t (1). Give a maximum flow that is not integral, and an integral one.
Show answer
The max flow value is 1, limited by s→a. A fractional maximum flow sends 1 on s→a, 0.5 on a→t, 0.5 on a→b, and 0.5 on b→t. An integral maximum flow sends 1 on s→a and 1 on a→t, with 0 on the other edges.
Exercise
In the proof, why does it matter that the bottleneck is at least 1 and not just positive?
Show answer
A bottleneck of at least 1 means each augmentation raises the flow value by at least 1. Because the value is bounded by a cut capacity, the number of rounds is finite, so the algorithm terminates. A bottleneck that is only positive could keep shrinking, and the algorithm might never stop.