Sub topic 13
Integer Capacities Give Integer Flows
This chapter assumes you already know the Ford-Fulkerson method, residual graphs, augmenting paths, and the max-flow min-cut theorem from earlier chapters. You should also be comfortable with proofs by invariant. The question here is narrow but important: if every capacity is a whole number, can the maximum flow always be made of whole numbers too? The answer is yes. That fact turns maximum flow from a numeric tool into a way to solve yes-or-no selection problems.
The Theorem
The integrality theorem states:
If every edge capacity in a flow network is an integer, then there is a maximum flow in which the flow on every edge is an integer. Ford-Fulkerson, with any rule for choosing augmenting paths, finds such a flow.
The theorem makes three separate claims:
| Claim | What it guarantees |
|---|---|
| The maximum flow value is an integer | The answer is a whole number |
| Some maximum flow has an integer on every edge | You can read the flow as discrete units |
| Ford-Fulkerson returns such a flow | You don't need a separate rounding step |
The theorem doesn't say that every maximum flow is integral. A network can have fractional maximum flows alongside the integral ones. The algorithm just never produces the fractional ones.
Proof by Invariant
The proof follows one invariant through the loop of Ford-Fulkerson.
Invariant: before each iteration, the flow on every edge is an integer, so every residual capacity is an integer.
Initialization. The algorithm starts with zero flow on every edge. Zero is an integer. The residual capacity of a forward edge is c(u, v) - f(u, v) = c(u, v), which is an integer. The residual capacity of a reverse edge is f(u, v) = 0, also an integer.
Maintenance. Suppose the invariant holds and the algorithm finds an augmenting path. The bottleneck is the minimum residual capacity along the path. A minimum of integers is an integer. Every edge on the path has positive residual capacity, so the bottleneck is at least 1. Augmenting adds the bottleneck to forward edges and subtracts it from the edges whose flow is being cancelled. Adding or subtracting an integer keeps an integer an integer. After augmenting, every flow value is still an integer, and so is every residual capacity, since each one is either c - f or f.
Termination. Each augmentation raises the flow value by the bottleneck, which is at least 1. The flow value can never exceed the capacity of any s-t cut, for example the total capacity of the edges leaving s. Call that bound C. So there are at most C augmentations, and the loop ends. When it ends, no augmenting path exists. By the max-flow min-cut theorem the current flow is maximum, and by the invariant it is integral.
The termination step also gives the O(E · C) bound on Ford-Fulkerson, where C is the maximum flow value. Integrality and termination come from the same argument: the bottleneck is at least 1 because it is a positive integer.
Checking It in Code
The block below runs Edmonds-Karp on the six-node example network, reads the flow on each original edge as capacity - residual, and checks that every value is a Python int. Edmonds-Karp is a form of Ford-Fulkerson, so the theorem applies to it. The function is listed again so the block runs on its own.
from collections import deque
def edmonds_karp(capacity, s, t):
n = len(capacity)
residual = [row[:] for row in capacity]
max_flow = 0
while True:
parent = [-1] * n
parent[s] = s
queue = deque([s])
while queue and parent[t] == -1:
u = queue.popleft()
for v in range(n):
if parent[v] == -1 and residual[u][v] > 0:
parent[v] = u
queue.append(v)
if parent[t] == -1:
return max_flow, residual
bottleneck = float('inf')
v = t
while v != s:
u = parent[v]
bottleneck = min(bottleneck, residual[u][v])
v = u
v = t
while v != s:
u = parent[v]
residual[u][v] -= bottleneck
residual[v][u] += bottleneck
v = u
max_flow += bottleneck
capacity = [
[0, 16, 13, 0, 0, 0],
[0, 0, 0, 12, 0, 0],
[0, 4, 0, 0, 14, 0],
[0, 0, 9, 0, 0, 20],
[0, 0, 0, 7, 0, 4],
[0, 0, 0, 0, 0, 0],
]
value, residual = edmonds_karp(capacity, 0, 5)
# This network has no pair of opposite edges, so the flow on an
# original edge u -> v is simply capacity minus residual.
flows = {}
for u in range(6):
for v in range(6):
if capacity[u][v] > 0:
flows[(u, v)] = capacity[u][v] - residual[u][v]
for (u, v), f in flows.items():
print(f"{u}->{v}: {f}/{capacity[u][v]}")
print("value:", value)
print("all integral:", all(isinstance(f, int) for f in flows.values()))Output:
0->1: 12/16
0->2: 11/13
1->3: 12/12
2->1: 0/4
2->4: 11/14
3->2: 0/9
3->5: 19/20
4->3: 7/7
4->5: 4/4
value: 23
all integral: TrueThe bottleneck starts as float('inf'), but min(float('inf'), 16) returns the integer 16, so no float leaks into the flow.
Integral Is Not the Only Maximum
Consider this network. The edge s -> a has capacity 1, and from a two routes reach t: a -> b -> t and a -> c -> t, with every edge of capacity 1. The maximum flow is 1, limited by s -> a.
The flow below sends 0.5 along each route. It satisfies capacity and conservation, and its value is 1, so it is a maximum flow with fractional edge values:
| Edge | Integral max flow | Fractional max flow |
|---|---|---|
| s -> a | 1 | 1 |
| a -> b | 1 | 0.5 |
| b -> t | 1 | 0.5 |
| a -> c | 0 | 0.5 |
| c -> t | 0 | 0.5 |
Ford-Fulkerson would return the left column, or its mirror with the c route. The theorem guarantees that an integral optimum exists and that the augmenting-path algorithms find one. If you get a flow from somewhere else, such as a general linear-programming solver, you can't assume it is integral. An interior-point LP solver can return the fractional column.
Non-Integer Capacities
| Capacities | Integral flow guaranteed? | Ford-Fulkerson terminates? |
|---|---|---|
| Integers | Yes | Yes, at most `C` augmentations |
| Rationals | Not integral, but multiples of `1/D` | Yes |
| Irrationals | No | Not always with arbitrary path choice; Edmonds-Karp always does |
For rational capacities, multiply everything by D, the least common denominator. The network becomes an integer network, the theorem applies, and dividing the result by D gives a maximum flow whose values are multiples of 1/D. Edmonds-Karp terminates in O(V E^2) augmentations whatever the capacities are, because that bound doesn't depend on the capacity values.
Why This Matters: Flow as Selection
When every capacity is 1, an integral flow puts either 0 or 1 unit on each edge. Each edge is then either chosen or not chosen, so a maximum flow becomes a maximum set of choices. Without the theorem, the optimum might send half a unit down two edges, and that has no meaning for a yes-or-no decision.
One direct use is counting edge-disjoint paths, which are s-t paths that share no edge. Give every edge capacity 1. An integral flow of value k puts 0 or 1 on each edge. Starting at s, follow edges carrying flow 1 to t, remove that path, and repeat. Conservation guarantees you can always continue, and you find k paths that share no edge. In the other direction, k edge-disjoint paths give a flow of value k. So the maximum flow equals the maximum number of edge-disjoint paths, which is one form of Menger's theorem. The bipartite matching chapter uses the same reasoning with unit capacities on a specially built network.
Exercise
A network has integer capacities, and you run Ford-Fulkerson using DFS to choose augmenting paths. A colleague says the result might contain fractional edge flows because DFS picks paths in an arbitrary order. Are they right? Justify using the invariant.
Show answer
No. The invariant doesn't depend on which augmenting path is chosen. Residual capacities start as integers. Any path's bottleneck is a minimum of positive integers, so it is an integer of at least 1. Augmenting adds or subtracts that integer, so all flows and residuals stay integral. The path-selection rule affects only how many iterations run, not integrality.
Exercise
Capacities are 1/2, 3/4, and 5/6 on various edges. Describe how to compute a maximum flow using only integer arithmetic, and say what granularity the final edge flows will have.
Show answer
The least common denominator of 2, 4, and 6 is 12. Multiply every capacity by 12 to get 6, 9, and 10. Run Ford-Fulkerson or Edmonds-Karp on the integer network, then divide every edge flow and the flow value by 12. The theorem makes the scaled flow integral, so the original edge flows are multiples of 1/12.
Exercise
In a directed graph with every edge given capacity 1, the maximum s-t flow is 3. Explain why there are exactly 3 edge-disjoint s-t paths at most and at least.
Show answer
At least 3: by the integrality theorem there is an integral maximum flow, so each edge carries 0 or 1. Follow edges carrying 1 from s to t to peel off a path, remove its flow, and repeat. Conservation lets each walk reach t, and you get 3 paths with no shared edge. At most 3: any set of k edge-disjoint paths gives a feasible flow of value k by sending 1 unit on each, so k is at most the maximum flow, 3.