Max flow, min cut, and a Cold War railway Image: J. Beyerl User:Jbeyerl, public domain

Max flow, min cut, and a Cold War railway

In 1955 T. E. Harris of the RAND Corporation and General F. S. Ross of the United States Air Force wrote a report on the railway network connecting the Soviet Union with its satellite countries in Eastern Europe. The network was drawn as a graph with 44 vertices and 105 edges, each edge a rail line with a capacity in thousands of tons per day. The report asked two questions. How much could be shipped from the Soviet interior to Eastern Europe per day, and what was the cheapest set of lines to interdict, with bombs, to cut the flow? The two answers were the same number, 163,000 tons, and the report said so. It was classified secret, declassified in 1999, and described by Alexander Schrijver in a history paper of 2002 that reproduces the map.

Flows and cuts

A flow network is a directed graph with a source s, a sink t, and a capacity on every edge. A flow sends an amount along each edge, at most its capacity, so that at every vertex other than s and t the amount coming in equals the amount going out. The value of the flow is the amount leaving s. A cut is a set of vertices containing s and not t, and its capacity is the total capacity of the edges leaving the set. All the flow has to cross every cut on its way from s to t, so the value of any flow is at most the capacity of any cut. That much is one sentence, and it is what Harris and Ross used to argue that 163,000 tons was an upper bound.

The theorem is that the bound is reached: the largest flow value equals the smallest cut capacity. Lester Ford and Delbert Fulkerson, also at RAND, proved it in 1956 in the Canadian Journal of Mathematics, after hearing of the railway problem from Harris. Elias, Feinstein, and Shannon proved it independently in the same year for the capacities of communication channels. Unit 9 of the Graph Theory Masterclass proves it the way Ford and Fulkerson did.

The proof, which is also the algorithm

Given a flow, build the residual network: for every edge with spare capacity, an edge with that spare capacity in the same direction, and for every edge carrying flow, an edge backwards carrying the amount that could be cancelled. If the residual network has a path from s to t, push flow along it, as much as its tightest edge allows; the backwards edges mean that this may reroute existing flow, which is why the method never gets stuck. Such a path is an augmenting path. If the residual network has no path from s to t, take the set of vertices reachable from s. Every edge leaving the set is full, every edge entering it is empty, so the flow across this cut equals its capacity, and since no flow can exceed any cut, the flow is maximum and the cut is minimum. The theorem follows, with the augmenting path method as the procedure that finds both.

For integer capacities the method terminates, since each augmentation raises the value by at least one, and the maximum flow it finds is integral. That last fact is why flows solve matching problems: join a source to all vertices on one side of a bipartite graph, join the other side to a sink, give every edge capacity 1, and a maximum integral flow is a maximum matching. Kőnig's theorem and Hall's theorem of Unit 5 both fall out of the max-flow min-cut theorem in a few lines, and Unit 9 derives them.

Where the method is slow

The method as stated chooses any augmenting path, and a bad choice can be expensive. Take four vertices s, a, b, t, with edges s to a, s to b, a to t, b to t of capacity 1,000 and an edge a to b of capacity 1. Augmenting alternately along s, a, b, t and s, b, a, t raises the flow by 1 each time and needs 2,000 steps for a flow that two steps would have found. With irrational capacities, as Ford and Fulkerson noticed, the method need not terminate at all. Jack Edmonds and Richard Karp showed in 1972 that choosing the shortest augmenting path each time, by breadth-first search, bounds the number of augmentations by about nm/2 for n vertices and m edges, whatever the capacities; Dinic had found a related bound in 1970. From then on the question was how fast maximum flow could be computed, and the answer improved roughly once a decade.

Almost linear time

In 2022 Li Chen, Rasmus Kyng, Yang Liu, Richard Peng, Maximilian Probst Gutenberg, and Sushant Sachdeva gave an algorithm that computes a maximum flow, and a minimum-cost flow, in time m to the power 1 + o(1), which is to say in time that grows barely faster than the time needed to read the input. The paper abandons augmenting paths entirely. It treats the problem as a continuous optimization, moves the flow by a sequence of very small updates along cycles, and uses a data structure that finds the right cycle quickly in a graph that keeps changing. The analysis is long and the algorithm has not been implemented in a form that competes with the old ones on real instances, and it settled a question open since 1956: maximum flow is, in principle, as easy as reading the graph. Kyng's work is the research spotlight of Unit 9.

What flows are used for

Shipping on railways was the first application and remains one. Others look nothing like it. To segment an image into foreground and background, make a vertex for every pixel, join neighbouring pixels by edges whose capacity measures how similar they are, and connect the source to pixels known to be foreground and the sink to pixels known to be background; the minimum cut is the boundary. To decide whether a baseball team can still finish first, build a flow network of the remaining games and check whether the maximum flow saturates them all. To schedule jobs on machines, to select the most profitable set of projects subject to dependencies, to find how many disjoint routes a network has between two points, which is Menger's theorem of 1927, one builds a flow network and computes a maximum flow. Unit 9 works three of these examples.

Harris and Ross wanted to know where to drop bombs. Ford and Fulkerson wanted to know why the two numbers in the report agreed. The theorem that answers the second question is the one that outlasted the war.

Study graph theory properly

The Graph Theory Masterclass: weekly units, quizzes, a final exam, and a certificate.
About the program