Discrete

A search for room that never ends

The textbook way to find the most that a network can carry is to find any route that still has room, push as much along it as it will take, and repeat until no route has room left. With whole-number capacities that must stop. Give one road a capacity of 0.618…, the golden ratio's reciprocal, and choose the routes badly, and it never stops: every push is positive, the flow converges, and it converges to 4.236 when the network can carry 5. The same choice made carelessly in floating point does stop — because of rounding, at the wrong answer, convinced it has finished.

Worth reading first: The bottleneck is the whole story · The cheapest way to send.

The bottleneck is the whole story proved the max-flow min-cut theorem: the most a network of roads can carry from a source to a sink equals the smallest total capacity of roads whose removal separates them. The proof was a method. Start with nothing flowing. Look for a route from source to sink along which every road still has room — counting, as room, the chance to cancel flow already sent the other way along a road. Push as much as the tightest road on that route allows. Repeat. When no route with room remains, the roads that block every route form a cut, and its capacity equals the flow.

That proof contains a quiet assumption, and the assumption is that the method stops. Lester Ford and Delbert Fulkerson, who published the method in 1956, noted that it stops whenever the capacities are whole numbers, because every push then adds at least one unit and the flow cannot exceed the capacity of any cut. They also showed that it need not stop otherwise. This essay builds a small network on which it does not, and watches what happens instead.

A flow that climbs for ever and falls short. 0:p0 +1.000000 → 1.000000; 1:p1 +0.618034 → 1.618034; 2:p2 +0.618034 → 2.236068; 3:p1 +0.381966 → 2.618034; 4:p3 +0.381966 → 3.000000; 5:p1 +0.236068 → 3.236068; 6:p2 +0.236068 → 3.472136; 7:p1 +0.145898 → 3.618034; 8:p3 +0.145898 → 3.763932; maximum 5.
Fig. 1 A network from s to t with three middle roads of capacity 1, r=(5−1)/2r = (\sqrt5 - 1)/2 and 1, and the total flow as the method pushes along one repeating choice of routes. Every push is positive; the flow converges to 2+52 + \sqrt5 and never reaches the maximum, 5.

Six places and three special roads

The network has a source ss, a sink tt and four places between them. Six ordinary roads, from ss to three of the places and from three of the places to tt, each carry up to two units; they are never the tight ones. Three special roads join the middle places: e1e_1 from v2v_2 to v1v_1 with capacity 1, e2e_2 from v4v_4 to v3v_3 with capacity r=(5−1)/2≈0.618r = (\sqrt5 - 1)/2 \approx 0.618, and e3e_3 from v2v_2 to v3v_3 with capacity 1. Networks of this kind go back to Ford and Fulkerson’s own example of 1962, and Uri Zwick found in 1995 the smallest ones on which the method can fail to stop, of which this is essentially one; the number rr is chosen for a single property, that

r2=1−r.r^2 = 1 - r.

The maximum flow is 5. A cut that separates ss from tt with capacity 5 exists — the road from ss to v4v_4, the road from v1v_1 to tt, and e3e_3, which between them block every route out of the places ss, v1v_1, v2v_2 — and a flow of 5 exists, which the method finds in three pushes when it chooses its routes well, as a figure below shows. The failure is entirely about the choice.

Room, counted both ways

The method’s notion of room deserves a closer look, because the bad routes depend on it. A road that already carries some flow has two kinds of room. It can carry more in its own direction, up to its capacity: that is its forward room. And flow along it can be cancelled by pushing in the opposite direction, up to the amount it carries: that is its backward room. The residual network records both, and a route with room is a route in that network — it may go along some roads and against others.

Going against a road is what lets the method correct its earlier choices. When several pairs share the roads showed what goes wrong without it, for several commodities at once: a greedy choice of routes blocks better ones, and nothing undoes it. With backward room, a later route can reroute flow that an earlier one sent the wrong way, and the max-flow min-cut theorem follows because, when no route with room is left, the places the source can still reach form one side of a cut whose roads are all full forwards and all empty backwards. The cheapest way to send used the same residual network with prices, where pushing against a road refunds its price, and found that a flow is cheapest exactly when no cycle in the residual network pays to push round.

In the example, every one of the bad routes uses backward room. The route p1p_1 goes against e3e_3, undoing part of the opening push; p2p_2 goes against e2e_2; p3p_3 goes against e1e_1. The method keeps undoing and redoing, and each undo leaves a little more room than it should for the next redo. Backward room is what makes the method correct when it stops, and it is also what lets it circle for ever without stopping.

The same position, smaller

The bad choice is a fixed cycle of four routes after one opening route. The opening route p0p_0 goes s,v2,v3,ts, v_2, v_3, t and fills e3e_3. Then the routes repeat: p1p_1, which goes s,v4,v3,v2,v1,ts, v_4, v_3, v_2, v_1, t — along e2e_2, back against the flow on e3e_3, along e1e_1 — then p2p_2, which goes s,v2,v3,v4,ts, v_2, v_3, v_4, t, then p1p_1 again, then p3p_3, which goes s,v1,v2,v3,ts, v_1, v_2, v_3, t.

The same position, shrunk by r squared. the first 13 pushes: p0: 1.00000/0.61803/0.00000; p1: 0.38197/0.00000/0.61803; p2: 0.38197/0.61803/0.00000; p1: 0.00000/0.23607/0.38197; p3: 0.38197/0.23607/0.00000; p1: 0.14590/0.00000/0.23607; p2: 0.14590/0.23607/0.00000; p1: 0.00000/0.09017/0.14590; p3: 0.14590/0.09017/0.00000; p1: 0.05573/0.00000/0.09017; p2: 0.05573/0.09017/0.00000; p1: 0.00000/0.03444/0.05573; p3: 0.05573/0.03444/0.00000
Fig. 2 The room left on each of the three special roads after each of the first thirteen pushes, with the route used and the amount pushed. After the opening push and after every round of four, the room is rnr^n, rn+1r^{n+1} and 00, with nn two larger each round.

The figure follows the room on the three special roads. After the opening push it is 11, rr and 00. The route p1p_1 is limited by e2e_2, so it pushes rr, emptying e2e_2’s room and freeing rr on e3e_3; p2p_2 pushes rr back through, refilling e2e_2’s room and emptying e3e_3’s. The second p1p_1 is now limited by e1e_1, whose room has fallen to 1−r=r21 - r = r^2; it pushes r2r^2. And p3p_3 pushes r2r^2, restoring e1e_1’s room. At the end of the round the room is r2r^2, r3r^3 and 00 — the starting position with every number multiplied by r2r^2, which is exactly what the identity r2=1−rr^2 = 1 - r arranges.

So the next round is the same round, smaller, and the one after it smaller again, for ever. Every route the method uses has room, every push is positive, and the stopping rule — no route with room — is never met. The figure checks the pattern exactly, in numbers of the form a+b5a + b\sqrt5 computed in whole numbers, for ten rounds: the room after round mm is r2mr^{2m}, r2m+1r^{2m+1} and exactly 00.

Converging, but not to the answer

The flow pushed in each round is 2r2m+1+2r2m+2=2r2m2r^{2m+1} + 2r^{2m+2} = 2r^{2m}, and the total, with the opening unit, is

1+2(1+r2+r4+⋯ )=1+21−r2=1+2r=2+5≈4.236.1 + 2\left(1 + r^2 + r^4 + \cdots\right) = 1 + \frac{2}{1 - r^2} = 1 + \frac{2}{r} = 2 + \sqrt5 \approx 4.236.

Converging quickly to the wrong number. 1:0.510, 6:0.000, 11:-0.535, 16:-1.045, 21:-1.580, 26:-2.090, 31:-2.625, 36:-3.135, 41:-3.670
Fig. 3 How far the flow is from its limit 2+52 + \sqrt5 after each push, on a logarithmic scale, against the fixed shortfall of that limit from the true maximum.

The sum is the golden ratio’s arithmetic doing in a network what it does in the rectangle that eats itself: there, cutting a square from a golden rectangle leaves a golden rectangle scaled by rr, and the squares’ sides form a geometric series in rr adding up to the rectangle’s length; here, each round of pushes leaves the same position scaled by r2r^2, and the pushes form a geometric series adding up to 2+52 + \sqrt5. The sum is finite for the same reason the golden rectangle is: a geometric series with ratio less than one converges, however many terms it has.

The gap to the limit shrinks by r2≈0.382r^2 \approx 0.382 every four pushes, so the flow converges quickly — by forty pushes it is within 10−810^{-8} of 2+52 + \sqrt5. And the shortfall from the maximum, 5−(2+5)=3−5≈0.7645 - (2 + \sqrt5) = 3 - \sqrt5 \approx 0.764, never changes. The method has converged, in every practical sense, to a wrong answer, and it has not stopped, so it never announces one.

The method’s two guarantees — that the flow only increases, and that if it stops it stops at the maximum — say nothing about the limit of a run that does not stop.

Choosing the shortest route

Jack Edmonds and Richard Karp showed in 1972 that one rule for choosing routes repairs everything: always push along a route with the fewest roads.

Shortest paths finish in a handful of pushes. s-v1-t:2.000000; s-v4-t:2.000000; s-v2-v3-t:1.000000
Fig. 4 The same network, with each route chosen as one with the fewest roads, found by breadth-first search. Three pushes reach the maximum flow of 5, and then no route with room remains.

On this network the rule finds s,v1,ts, v_1, t and s,v4,ts, v_4, t first, two roads each, pushing 2 along each, and then s,v2,v3,ts, v_2, v_3, t, pushing 1 along e3e_3 — a flow of 5 in three pushes. The rule’s guarantee is general and does not care about capacities. Each push fills some road on a shortest route, and a filled road can only become usable again when flow is pushed back along it, which happens only on a route that is longer; so the shortest-route distance from the source to each place never decreases, and a given road can be the tight one only about as many times as there are places. The method stops after at most a number of pushes proportional to the places times the roads, whatever the capacities are — rational, irrational, or as unhelpful as 0.618…0.618\ldots — and it stops at the maximum, by the max-flow min-cut theorem.

The bad routes in the essay’s example are longer than necessary at every step: p1p_1 uses five roads where routes of two exist. Edmonds and Karp’s rule would never choose it. The non-terminating run is a run in which the method is allowed to choose badly, and the theorem is that the method, as originally stated, does not forbid it. The difference matters in practice wherever maximum flow is a step inside something larger: the cut trees of one tree for every cut are built from a maximum flow between each of many pairs of places, and a method that might not stop at any one of them could not be the foundation of the others.

The max-flow min-cut theorem is one of a family that two numbers that have to meet described in general: a largest quantity of one kind equals a smallest quantity of another, and each certifies the other. One bottleneck and nothing else found the same shape in Hall’s theorem on matchings, which is the flow theorem on a network with unit capacities, and there too the proof is a search for an improving route that stops when none exists.

The example shows that such proofs carry two separate claims. One is that a stopped search proves optimality — when no route has room, the flow equals a cut and is therefore the largest. That claim is unconditional. The other is that the search stops, and that claim needs whole numbers, or a rule for choosing routes, or some other measure of progress that cannot shrink for ever. With whole numbers the measure is the flow itself, which rises by at least one each time. With Edmonds and Karp’s rule it is the shortest-route distance, which can rise only finitely often. With an irrational capacity and a free choice there is no such measure, and the example is the proof that none can be found.

The theorem itself survives, by another route. For real capacities, the maximum flow is the optimum of a linear programme whose dual is the minimum cut, and linear programming duality proves the theorem without any search at all. What fails is not the theorem but one constructive proof of it, which needed a hidden finiteness that the integers had been supplying all along.

Rounding stops what arithmetic cannot

The run above is computed exactly. Computed in ordinary floating point, as almost every program would compute it, it behaves differently.

Rounding stops what arithmetic cannot. float stops at step 80 (p1) with total 4.236067956486561; exact amounts continue.
Fig. 5 The amount pushed at each step, computed exactly and in double-precision floating point. The floating-point run stops at step 80, when rounding leaves a road with no room, reporting that it has finished.

In floating point, rr is a binary fraction close to (5−1)/2(\sqrt5 - 1)/2, and r2=1−rr^2 = 1 - r holds only up to rounding. The repeating pattern depends on that identity at every round, and it magnifies the discrepancy — each round divides the positions by r2r^2 to compare with the last, and so multiplies any error relative to them by about 1/r2≈2.61/r^2 \approx 2.6. Near step 80, when the amounts being pushed are around 10−810^{-8}, a road’s room comes out not as a small positive number but as nought or slightly less, the next route seems to have no room, and the program stops. It reports a flow of 4.236067964.23606796, within 2×10−82 \times 10^{-8} of 2+52 + \sqrt5, and believes the network is full.

That is a sharper failure than not stopping. A program that runs for ever is visibly broken. A program that stops and reports 4.2364.236 for a network whose true maximum is 55 gives no sign that anything has gone wrong, and the residual network it leaves behind even appears to contain a cut of capacity 4.2364.236 — a cut that does not exist, assembled from roads whose room is nought only because of rounding. The orbit a computer draws met the same phenomenon in iteration, where rounding replaced a true orbit by one that looked plausible and was not, and the moral is the same: floating point can turn an argument that relies on an exact identity into a different computation altogether.

Whole numbers stop it, eventually

With whole-number capacities, stopping is guaranteed, and the guarantee is still weaker than it sounds.

Whole numbers stop it, eventually. C=1: 2; C=2: 4; C=5: 10; C=10: 20; C=20: 40; C=50: 100; C=100: 200; C=200: 400; C=500: 1000; C=1000: 2000
Fig. 6 Four roads of capacity CC and a middle road of capacity 1: the number of pushes the method makes when it routes through the middle road every time, alternately forwards and backwards, against the two pushes shortest routes need.

The standard example has four outer roads of capacity CC and one middle road of capacity 1 joining the two intermediate places. Routing every push through the middle road — forwards, then backwards against the flow just sent, then forwards again — moves one unit per push, and reaching the maximum flow of 2C2C takes 2C2C pushes. With C=1000C = 1000 that is two thousand pushes for a network that shortest routes fill in two. The number of pushes is bounded by the size of the answer, and the size of the answer can be exponential in the number of digits needed to write the capacities down, so the plain method is not a polynomial-time algorithm even when it stops. Edmonds and Karp’s paper, which introduced the shortest-route rule, was among the first to make that distinction explicit — between an algorithm that stops and one that stops quickly.

An algorithm and an irrational number

The failure has a family resemblance worth naming. The oldest algorithm, drawn as a tiling showed that Euclid’s algorithm, applied to two lengths in an irrational ratio, never stops: it keeps cutting squares from a rectangle whose shape repeats, smaller each time, exactly as the room on the three roads repeats here. The golden rectangle is the extreme case there — each step leaves a smaller golden rectangle — and the golden ratio is the extreme case here, because r2=1−rr^2 = 1 - r is the identity that makes the position repeat after the fewest pushes.

In both, a procedure that terminates on whole numbers is turned into a self-similar process by an irrational input. And in both, what terminates the procedure on a machine is not the mathematics but the finite precision with which the machine represents the input. The difference is that Euclid’s algorithm was never claimed to stop on irrational lengths — its non-termination is the proof that the lengths are incommensurable — while the augmenting-path method is routinely run on real-valued capacities, by programs that inherit the textbook assumption that it stops.

What the exact computation does and does not show

Every number in the figures except the floating-point run is exact, in the field of numbers a+b5a + b\sqrt5, so the claims that each push is positive, that the room returns to the scaled position, and that the flow stays below 2+52 + \sqrt5 are checked without rounding for forty pushes. They are not checked for ever; the proof that the pattern continues is the one-line induction from r2=1−rr^2 = 1 - r, which the figure’s ten rounds illustrate.

The figures also show only one bad choice of routes. The method may choose any route with room, and on this network many choices terminate. Non-termination is a property of the method’s freedom, exhibited by one adversarial sequence, not something every run does — which is precisely why it went unnoticed by anyone who ran the method rather than reasoning about it.

Still open: how few pushes are needed

The shortest-route rule bounds the number of pushes by a multiple of places times roads. The best algorithms for maximum flow now do much better than augmenting one route at a time: preflow-push methods of Andrew Goldberg and Robert Tarjan, and, in 2022, an algorithm of Li Chen, Rasmus Kyng, Yang Liu, Richard Peng, Maximilian Probst Gutenberg and Sushant Sachdeva running in time close to linear in the number of roads, for integer capacities. Whether maximum flow can be computed in truly linear time, and whether the near-linear methods, which rely on continuous optimisation and careful rounding, can be made practical, are open. So, in a sense the example makes vivid, is the question of what “computing” a maximum flow means when the capacities are real numbers that no machine represents exactly: the exact field arithmetic used here works for quadratic irrationals, and for general real capacities there is no finite representation to compute with at all.