Contents / Combinatorics / Flows and Linear Programming Duality
Chapter 11
Flows and Linear Programming Duality
Max-flow min-cut, the algorithms that realise it, and the linear programming duality that explains every min–max theorem here.
Introduction
Max-flow min-cut, the algorithms that realise it, and the linear programming duality that explains every min–max theorem in this subject.
The previous chapter closed with a family of min–max theorems — Hall's condition, König's theorem, the matroid intersection formula — each proved by an argument tailored to its own setting. This chapter explains where they come from. The mechanism has two layers. The combinatorial layer is the max-flow min-cut theorem: a maximum flow is certified optimal by a cut of equal capacity, and the certificate is produced by the very algorithm that finds the flow. The analytic layer is linear programming duality: every linear program has a dual whose optimum equals its own, so every linear optimisation problem has a certificate of optimality. Max-flow min-cut is what duality says about one particular constraint matrix — and that matrix is totally unimodular, which is why the certificate comes out integral rather than fractional.
11.1Flow Networks and Feasible Flows
A flow network models a transport system: a directed graph whose arcs have throughput limits, with one point where material enters and one where it leaves. Everything in this chapter rests on two rules — no arc carries more than its capacity, and nothing accumulates at an intermediate vertex — so we state them precisely before doing anything with them.
Definition 11.1 (Flow network). A flow network is a quadruple where is a finite directed graph, is the source, is the sink, and is the capacity function. We write for the capacity of the arc , with the convention when .
Definition 11.2 (Feasible flow and its value). A flow on is a function satisfying
- capacity constraints: for every ;
- conservation: for every ,
The value of is the net amount leaving the source,
Notation. For sets write and , again with missing arcs contributing . Conservation then reads for internal , and .
Intuition. Read the network as a system of pipes and the flow as water. A capacity is the width of a pipe; conservation says junctions are not tanks — whatever arrives leaves at once. The value is what you would measure at the tap: the rate at which water leaves the source, which is also the rate at which it reaches the sink, because the interior stores nothing.
Conservation is a local condition, imposed one vertex at a time. Its power comes from the fact that summing it over a set of vertices turns it into a global statement about how much crosses the boundary of that set. That observation is the whole of the elementary theory, so we record it as a theorem and prove it carefully.
Definition 11.4 ( - cut). An - cut of is a partition , , with and . Its capacity is , the sum of the capacities of the arcs directed from to . Arcs from back to contribute nothing.
Theorem 11.5 (Flow across a cut). Let be a flow on and an - cut. Then
Proof. Start from the value and add zero once for each internal vertex of . For , conservation says , while by definition . Summing over all ,
Two consequences follow at once, and the second is half of the main theorem of the chapter.
Corollary 11.6 (Value measured at the sink). For every flow the net flow into equals . Indeed is an - cut, and Theorem Flow across a cut gives .
Theorem 11.7 (Weak duality for flows). For every flow and every - cut ,
Proof. By Theorem Flow across a cut, because on every arc. Each term of is at most the matching capacity, so . For the last sentence: the inequality holds for every pair, so a pair achieving equality pins both sides — no flow can exceed that cut's capacity and no cut can fall below that flow's value.∎
Intuition. Everything leaving must eventually cross the frontier between and , since is on the far side. Forward arcs carry it across; backward arcs only return material to be carried across again. So the forward capacity of any frontier is a ceiling on the value, and the cheapest frontier is the most informative ceiling. The content of the next section is that this ceiling is always attained.
Pitfall. The capacity of a cut counts only arcs from to . Adding the arcs from to inflates every cut and destroys the min–max equality. The asymmetry is exactly right: a backward arc does not help material reach , and in Theorem Flow across a cut it enters the value with a minus sign.
Example 11.8 (A flow and the cuts that bound it). In the network of the figure — arcs of capacity , of capacity , of capacity , of capacity , of capacity — verify that
Solution. Feasibility. Each value lies between and its capacity: , , , , . At : in , out . At : in , out . Both internal vertices conserve, so is a flow.
Value. , and Corollary Value measured at the sink confirms it at the other end: .
Cuts. There are four, one for each subset of adjoined to .
| forward arcs | capacity | |
|---|---|---|
The minimum is . Since the flow also has value , Theorem Weak duality for flows certifies both at once: is maximum and , are minimum cuts. Note that the cut has capacity : a cut chosen at random bounds the flow but need not be tight, which is why the theorem minimises over cuts.□
Before going further, it is worth knowing how flexible the model is, because several apparent restrictions are not restrictions at all.
Proposition 11.9 (Standard reductions). Each of the following reduces to the single-source, single-sink, arc-capacitated problem above without changing the optimum.
- Several sources and sinks. Add a super-source with an arc of infinite capacity to each source, and a super-sink with an arc of infinite capacity from each sink.
- Vertex capacities. Replace a vertex of capacity by two vertices joined by an arc of capacity ; arcs into enter , arcs out of leave .
- Undirected edges. Replace each undirected edge of capacity by the two arcs and , each of capacity .
- Lower bounds . These are genuinely harder: feasibility is no longer automatic and needs a preliminary flow computation. We do not pursue them here.
Proof. In (1), a flow in the enlarged network restricts to a flow of the same value in the original and conversely, since the added arcs are uncapacitated and no conservation constraint is imposed at or . In (2), all traffic through is forced along the single arc , whose capacity is exactly the vertex bound. In (3), a flow using both antiparallel arcs may be decreased by on both without changing its value or violating capacities, so we may assume at most one direction carries flow, which is an orientation of the undirected edge. Item (4) is a statement, not a claim proved here.∎
Remark. Vertex capacities in (2) are what make the vertex form of Menger's theorem a flow statement; we use exactly this device later in the chapter. Conversely, reduction (3) is why an undirected min cut and a directed min cut can be discussed in the same breath.
11.2The Max-Flow Min-Cut Theorem
Weak duality gives for free. The reverse inequality is the theorem of Ford and Fulkerson, and it is proved constructively: given a flow that cannot be improved, we exhibit a cut of exactly its value. The tool that makes this possible is the residual graph, which records how much each arc could still absorb — and, crucially, how much of an earlier decision could still be undone.
Definition 11.10 (Residual capacity and residual graph). Let be a flow on . For an ordered pair of distinct vertices define the residual capacity
Intuition. A residual arc means "one more unit can be made to move from to ", and there are two ways that can be true: the pipe is not yet full, or the pipe is carrying flow that we may cancel. Cancellation is not cheating. Flow is anonymous — reducing by one unit and simultaneously adding a unit somewhere else re-routes the same material, and the result is still a flow. Without backward residual arcs a greedy algorithm can paint itself into a corner; with them it never can.
Definition 11.11 (Augmenting path). An augmenting path for is a directed - path in the residual graph . Its bottleneck is .
Lemma 11.12 (Augmentation). Let be a flow and an augmenting path with bottleneck . Define by processing each arc of : first cancel units of reverse flow, setting , then add the remaining units forward, ; leave all other arcs unchanged. Then is a flow with .
Proof. Capacities. On the reverse arc, . On the forward arc we must check . If there is nothing to add. Otherwise , and the definition of residual capacity gives , which rearranges to exactly the required inequality.
Conservation. Let be an internal vertex of , entered by and left by . The modification changes the net flow into by (whether the units arrive as added forward flow on or as cancelled flow on , the net inflow rises by ) and the net flow out of by for the same reason. The two changes cancel, so conservation still holds. Vertices not on are untouched. (If repeats a vertex, delete the cycle between the repetitions first; a shortest residual - path never repeats one.)
Value. The first arc of leaves , and the net flow out of increases by , so .∎
Theorem 11.13 (Max-flow min-cut). Let be a flow network and a flow on it. The following are equivalent:
- is a maximum flow;
- contains no augmenting path;
- there is an - cut with .
Consequently the maximum value of a flow equals the minimum capacity of an - cut.
Proof. (1) (2). If an augmenting path existed, Lemma Augmentation would produce a flow of value , contradicting maximality.
(2) (3). Suppose no augmenting path exists. Let
(3) (1). Immediate from Theorem Weak duality for flows: a flow whose value equals some cut's capacity cannot be beaten, since every flow is bounded by that capacity.
For the final sentence, a maximum flow exists (see the remark below), so by (1) (3) some cut has capacity ; by weak duality no cut is cheaper.∎
Remark. Existence of a maximum flow is not quite free when capacities are real. The set of flows is a compact subset of — it is closed, being defined by finitely many non-strict linear equations and inequalities, and bounded, since — and is continuous, so the maximum is attained. With integral capacities the argument is even simpler: the values are integers bounded by . This is also a first instance of the Fundamental theorem of linear programming, proved in a later section.
Intuition. The proof of (2) (3) is the part worth remembering, because it is an algorithm as well as a proof. When you get stuck, look at which vertices you can still reach in the residual graph. Everything you can reach goes into . Every arc leaving must be full — otherwise you could have gone further — and every arc entering must be empty — otherwise you could have gone backwards along it. A cut that is full forward and empty backward carries exactly the flow's value, so being stuck is the same as being optimal, with the cut as the receipt.
The construction in (2) (3) has a consequence that no other proof of the theorem would give for free.
Corollary 11.14 (Integrality of maximum flow). If every capacity is an integer, then some maximum flow is integral: for all . More generally, if all capacities are integer multiples of , some maximum flow takes values in .
Proof. Start with , which is integral. If is integral then so is every residual capacity, hence the bottleneck of any augmenting path is a positive integer and the augmented flow of Lemma Augmentation is again integral, with . Since values are bounded above by , the process halts after at most augmentations, at an integral flow with no augmenting path — a maximum flow by Theorem Max-flow min-cut. Rescaling capacities by gives the general statement.∎
Pitfall. Integrality says some maximum flow is integral, not that every one is. A network with two parallel routes of equal capacity has fractional maximum flows as well; they simply split the load. Every application in this chapter needs only the existence of an integral optimum — which is exactly what an augmenting-path algorithm returns.
Method 11.15 (Ford–Fulkerson method).
- Set for every arc.
- Build the residual graph and search for a directed - path .
- If none exists, stop: is maximum, and the set of vertices reachable from in is a minimum cut.
- Otherwise compute , augment along as in Lemma Augmentation, and return to step 2.
Step 2 says "search for a path" without saying how, and that vagueness is the method's one weakness. With integral capacities any search rule works, by Corollary Integrality of maximum flow; the number of augmentations is at most the value of the maximum flow, so the running time is — pseudo-polynomial, since can be exponential in the number of bits used to write the capacities. With irrational capacities matters are worse.
Theorem 11.16 (Ford–Fulkerson may fail to terminate). There is a flow network with irrational capacities and a choice of augmenting paths for which the Ford–Fulkerson method runs forever, and the flow values converge to a limit strictly smaller than the maximum flow value.
Proof. Sketch, following Ford and Fulkerson's own example; we describe the construction and the invariant rather than verifying every augmentation. Let , so that . Build a network containing four special arcs of capacities and a large capacity elsewhere, arranged so that a particular cyclic choice of augmenting paths leaves, after each round of three augmentations, residual capacities on the special arcs equal to in some order — the same pattern as at the start of the round, with increased. The -th round therefore adds or so to the value, and the total added over all rounds is a convergent geometric series summing to a value bounded by , whereas the true maximum uses the large arcs and is far greater. The point the example makes is structural: nothing in the method forces progress, because a bottleneck can shrink geometrically. The repair is to fix the search rule, which is the subject of the next theorem.∎
Theorem 11.17 (Edmonds–Karp). If step 2 of Ford–Fulkerson always chooses an augmenting path with the fewest arcs — that is, if the residual search is breadth-first — then the algorithm terminates after at most augmentations, whatever the capacities. Its total running time is .
Proof. Sketch; the two invariants are proved in full in Schrijver or Cormen et al., and we name what the argument rests on.
Distances never decrease. Let be the number of arcs on a shortest - path in . One shows that after a breadth-first augmentation for every . The reason is that augmenting along a shortest path only creates residual arcs that point backwards along that path, and a backward arc cannot shorten a shortest-path distance.
Each arc is a bottleneck rarely. Call critical for an augmentation if it is the bottleneck, so that it disappears from the residual graph. At that moment , because lies on a shortest path. For to become critical again it must first reappear, which happens only when some later augmenting path uses ; at that later moment by monotonicity. So between two critical events for the same arc, grows by at least . Distances are bounded by , so each arc is critical at most times; with arcs, and at least one critical arc per augmentation, there are at most augmentations. Each breadth-first search costs , giving .∎
Remark. The bound involves no capacity at all, so Edmonds–Karp is a genuinely polynomial algorithm and settles the irrational case as well: it terminates on any network. Faster algorithms exist — Dinic's blocking-flow method runs in and in on unit-capacity networks, and push–relabel methods do better still — but every one of them relies on the same residual-graph optimality criterion proved above.
Example 11.18 (Running the method, and reading off the cut). Run Ford–Fulkerson on the network of the previous section: (capacity ), (), (), (), (). Show the augmentations and the certifying cut.
Solution. Augmentation 1. Residual path , bottleneck . Now , ; value .
Augmentation 2. The arc is saturated, so try , bottleneck . Now , ; value .
Augmentation 3. Both and are full. Residual arcs out of : only , with . From : with (and , useless). From : with . So is augmenting with bottleneck ; value , and is now the flow of the previous section.
Termination. Residual arcs out of : and . So and the algorithm stops. The certifying cut is ✓. Had we instead reached the flow by a different route, the reachable set might have been — the other minimum cut — but the value would be the same.□
Example 11.19 (Why the backward arc is indispensable). In the same network, suppose the first augmentation is the greedy path with bottleneck . Show that ignoring backward residual arcs leaves the algorithm stuck below the optimum, and that the residual graph rescues it.
Solution. After that augmentation , value . Forward-only capacity remains on ( unit), ( units), ( units) and ( unit). Using only unsaturated forward arcs, from we can reach and ; from we can reach via . That gives with bottleneck , value , after which is full and only remains, with bottleneck , value . Now every forward route is blocked, yet the maximum is .
The residual graph supplies the missing move. With there is a residual arc of capacity , so the path is augmenting: it pushes a unit on , cancels a unit of , and pushes a unit on . The value rises to . The cancellation re-routed material that had been sent the long way round — precisely the flexibility Lemma Augmentation was built to justify.□
11.3Applications of Max-Flow Min-Cut
A max-flow algorithm is a general-purpose solver, and the skill worth acquiring is the modelling one: recognising a problem as a flow problem and choosing capacities so that integral flows are exactly the combinatorial objects you want. Three reductions below are classical, and a fourth — Menger's theorem — shows the min-cut half of the theorem doing the real work. Throughout we use Corollary Integrality of maximum flow without further comment: capacities will be integers, so an optimal flow may be assumed integral.
Bipartite matching
Theorem 11.20 (Matchings are integral flows). Let be a bipartite graph with parts and . Build the network : vertices ; an arc of capacity for each ; an arc of capacity for each edge with ; an arc of capacity for each . Then the maximum value of a flow in equals the maximum size of a matching in .
Proof. Given a matching , send one unit along for each edge . No two edges of share a vertex, so no arc carries more than one unit, and conservation holds at every and used. The value is .
Conversely, let be an integral maximum flow. Every capacity is , so for every arc, and is a set of edges. If two edges of shared a vertex then would have outflow , hence inflow , exceeding the capacity of ; if they shared then would have inflow , hence outflow , exceeding the capacity of . So is a matching, and by Corollary Value measured at the sink. The two constructions are mutually inverse on values, so the maxima agree.∎
Intuition. The capacity- arcs at the two ends are the entire model. " is matched at most once" is the statement that at most one unit can leave for ; " is matched at most once" is the statement that at most one unit can leave for . The middle arcs merely record which pairings are permitted. Everything specific to matching has been pushed into three numbers.
Example 11.21 (A matching computed as a flow). Let , with edges , , . Find a maximum matching by running augmenting paths on .
Solution. Augment along : value , corresponding to the matching . Now is saturated, so the greedy continuation is blocked. But carries flow, so is a residual arc, and
The residual step is precisely an alternating path in the matching sense: unmatched , unmatched-to-matched edge , matched edge traversed backwards, then the unmatched edge to the unmatched vertex . Augmenting-path matching algorithms and augmenting-path flow algorithms are the same algorithm.□
Corollary 11.22 (König's theorem from min cut). In a bipartite graph , the maximum size of a matching equals the minimum size of a vertex cover.
Proof. A vertex cover always has size at least that of a matching, since it must contain an endpoint of each of the matching's disjoint edges. For the converse, take a minimum cut in ; we may assume its capacity is finite, so it uses no middle arc if those are given capacity — replace each middle arc's capacity by , which changes neither the maximum flow (still bounded by the end arcs) nor the matching correspondence. Let
Remark. This is the pattern the chapter is about. König's theorem was proved in the previous chapter by an alternating-path argument; here it is a two-line consequence of a general theorem about networks. Hall's condition follows the same way, by testing when the minimum cut has capacity .
Disjoint paths and Menger's theorem
Definition 11.23 (Arc- and vertex-disjoint paths). Two directed - paths are arc-disjoint if they share no arc, and internally vertex-disjoint if they share no vertex other than and . An - arc cut is a set meeting every directed - path; an - vertex cut (for non-adjacent ) is a set meeting every directed - path.
Theorem 11.24 (Menger, arc version). For any digraph and distinct , the maximum number of pairwise arc-disjoint directed - paths equals the minimum size of an - arc cut.
Proof. Give every arc capacity and let be an integral maximum flow, of value .
From flow to paths. Since , the arcs carrying flow form a subgraph in which every internal vertex has equal in- and out-degree and has excess out-degree . Repeatedly extract a directed - path from and delete its arcs: after each deletion the degree condition is preserved with excess , so this yields paths, pairwise arc-disjoint because each arc was used once and deleted. (Cycles may remain at the end; discard them.) So there are at least arc-disjoint paths.
From cut to bound. Any - arc cut bounds the number of arc-disjoint paths by , as each path uses at least one arc of and no two share an arc.
Equality. Let be a minimum cut, of capacity by Theorem Max-flow min-cut. The set of arcs from to has and is an - arc cut: any - path starts in and ends in , so it must use an arc from to at its first crossing. Thus max paths max paths, and all are equal.∎
Theorem 11.25 (Menger, vertex version). Let be a digraph and distinct vertices with . The maximum number of internally vertex-disjoint directed - paths equals the minimum size of an - vertex cut.
Proof. Apply the vertex-splitting reduction of Proposition Standard reductions: replace each by of capacity , and give every original arc capacity . A set of internally vertex-disjoint - paths becomes a set of arc-disjoint paths in the split network, and conversely, because passing through requires the unique unit-capacity arc . A finite cut cannot contain an arc of infinite capacity, so a minimum cut consists of split arcs only, and the corresponding vertices form an - vertex cut of the same size; since , every - path has an internal vertex and is well defined. Theorem Menger, arc version applied to the split network now gives the equality.∎
Intuition. Menger's theorem is max-flow min-cut with all capacities set to , and the two directions of the min–max say the two things one wants: you can route disjoint paths, and there is a set of arcs (or vertices) whose removal disconnects from . The second is the certificate: it convinces a sceptic that no disjoint paths exist, without examining them.
Project selection
Example 11.26 (Project selection). Each project in a set yields a profit but requires a set of machines; each machine costs and, once bought, serves any number of projects. Choose a set of projects maximising total profit minus total cost of the machines they need.
Solution. Build a network on with arcs of capacity , arcs of capacity whenever project needs machine , and arcs of capacity . Let be a finite-capacity cut and set (the selected projects). Finiteness forbids any arc from crossing, so every machine needed by a project of lies in too. The cut's capacity is
Pitfall. Infinite capacities are the modelling device that forces a logical implication ("if project is chosen then machine must be bought"). If you give those arcs a large finite capacity instead, a cut may buy its way through them, and the optimum silently becomes wrong for inputs whose profits exceed your "large" number. Use , or a value provably larger than the sum of all finite capacities.
11.4The Linear Programming Problem
Every optimisation problem met so far — maximum flow, maximum matching, maximum weight of an independent set in a matroid — asks for the largest value of a linear function on a set defined by linear inequalities. Linear programming is that question asked in general, and its theory is the reason those problems have min–max answers.
Definition 11.27 (Linear program in standard form). Given , , , the linear program in standard (inequality) form is
Proposition 11.28 (Every linear program can be put in standard form). Any problem of maximising or minimising a linear function subject to finitely many linear equations and inequalities in real variables can be rewritten in the form above, with the same optimal value.
Proof. Minimising is maximising . An inequality becomes . An equation becomes the pair , . A variable not required to be nonnegative is replaced everywhere by with ; every real number is such a difference, so the feasible values of the objective are unchanged.∎
Remark. The equality form is equally standard and is what the simplex method actually manipulates. One passes from inequality to equality form by adding a slack variable per row: becomes , . Slack variables are not bookkeeping noise — the value of at an optimum measures how much of resource is left unused, and complementary slackness will read exactly that number.
Definition 11.29 (Polyhedron, vertex, basic feasible solution). A polyhedron is a set of the form for some matrix and vector ; a bounded polyhedron is a polytope. A point is a vertex (or extreme point) of if it is not the midpoint of two distinct points of : whenever with , we have . Writing the system as with the sign constraints included, is a basic feasible solution if is feasible and the rows of that are tight at (satisfied with equality) have rank .
Theorem 11.30 (Vertices are basic feasible solutions). For a feasible point of , the following are equivalent: is a vertex; is a basic feasible solution; is the unique solution of the subsystem of rows tight at .
Proof. Let be the set of rows tight at and the submatrix they form.
If , choose with . For rows the inequality is strict at , so for small both still satisfy them, while the rows of are satisfied with equality at both. Hence and is their midpoint with : is not a vertex.
Conversely, if and with , then for each tight row we have , and , which forces . So and both solve , a system of rank with solution set a single point; thus and is a vertex. The same rank condition is what makes the unique solution of the tight subsystem.∎
Theorem 11.31 (Fundamental theorem of linear programming). Consider with . Exactly one of the following holds: the program is unbounded, or the optimal value is finite and attained at a vertex of .
Proof. The constraint guarantees contains no line, and a nonempty polyhedron containing no line has at least one vertex: take a feasible with as many tight rows as possible; if their rank were less than , moving along a direction in the kernel as in the previous proof would, since has no line, eventually make a new row tight, contradicting maximality.
Suppose now the value is finite; we first check it is attained. Fix a feasible and choose so large that the box contains and some feasible point of objective value at least . For the set is closed and bounded, so attains a maximum on it; the function is nondecreasing and bounded by , and by definition of the supremum. If no maximiser existed in itself, every would be strictly below and the maximisers would escape to infinity along a ray of on which is strictly increasing — but then would be infinite. So the supremum is attained, and the set of optima is the nonempty polyhedron .
Among the optima choose with the maximum number of tight rows. If at , pick in the kernel of . Then , for otherwise moving in the direction of increase would improve the optimum. Moving along keeps the objective and feasibility until a new row becomes tight, which must happen in at least one of the two directions since contains no line. That yields an optimal point with more tight rows — a contradiction. So and is a vertex by Theorem Vertices are basic feasible solutions.
It remains to know that the supremum is attained at all. If it is finite, intersect with a box for large enough that the box contains a feasible point of objective value within of the supremum. The intersection is a polytope — closed and bounded — so the continuous function attains its maximum on it, and enlarging cannot increase that maximum beyond the finite supremum. A standard compactness argument then identifies the two.∎
Intuition. The objective is constant on each hyperplane perpendicular to , and increasing slides that hyperplane in the direction . Push it as far as it will go: the last contact with the feasible region is either a single corner, or a whole face — in which case its corners are optimal too. Either way an optimum can be found among the corners, and there are finitely many of them, at most . Linear programming is therefore a finite search, which is what makes it tractable at all.
Example 11.33 (A two-variable program). Solve subject to , , , and identify the vertex structure.
Solution. The feasible region is the triangle with boundary lines , , . With , a vertex is a point where two of the three lines meet and which is feasible:
Sanity check. The objective gradient is ; since the binding constraint charges and equally, the variable with the larger coefficient is the one to buy, and indeed the all- corner wins. Had the objective been , the entire edge from to would be optimal — an example of the "whole face" case, with two optimal vertices.□
Pitfall. "The optimum is at a vertex" needs the hypothesis that the region has a vertex. The program over all of has a feasible region containing lines, hence no vertex at all — here it is also unbounded, but a bounded objective over a line-containing region (say ) shows the two issues are separate. The constraint in standard form is what rules this out, which is why standard form is stated with it.
Remark. The simplex method exploits Theorem Fundamental theorem of linear programming directly: it walks from vertex to adjacent vertex, each step not decreasing the objective, and stops when no neighbour is better — a condition that, by duality, certifies global optimality. It is fast in practice but exponential on contrived inputs (the Klee–Minty cubes). That linear programming is solvable in polynomial time was settled instead by the ellipsoid method (Khachiyan, 1979) and then made practical by interior-point methods (Karmarkar, 1984). None of this is needed below: duality is a theorem about the problem, not about any algorithm.
11.5Duality
Suppose someone hands you a feasible with and claims it is optimal. How could they convince you without making you search the whole polyhedron? The only way to certify an upper bound on using the constraints is to combine them: multiply the -th constraint by some and add. The multipliers are useful precisely when the combination dominates the objective, and then is an upper bound. Searching for the best such bound is itself a linear program — the dual.
Definition 11.34 (The dual linear program). The dual of the primal program
Notation. Dual variables are often called prices or potentials: is the value, in objective units, of one extra unit of resource . The dual constraint for column , , then reads "the resources consumed by one unit of activity are worth at least what that activity earns" — a no-arbitrage condition.
Proposition 11.35 (The dual of the dual is the primal). Rewriting (D) in standard form and taking its dual returns (P).
Proof. In standard form (D) is subject to , . Its dual, by Definition The dual linear program, is subject to , ; that is, subject to , , which is (P).∎
Theorem 11.36 (Weak duality). If is feasible for (P) and is feasible for (D), then
Proof. Since and , taking the inner product with preserves the inequality: . Since and , likewise . Chaining the two gives the display. If (P) were unbounded, any dual-feasible would give a finite upper bound on unbounded values — impossible, so no such exists. The other implication is symmetric by Proposition The dual of the dual is the primal.∎
Corollary 11.37 (Optimality certificate). If is feasible for (P), is feasible for (D) and , then is optimal for (P) and is optimal for (D).
Proof. For any primal-feasible , weak duality gives ; the dual statement is symmetric.∎
Weak duality is the easy half and is already useful: it turns "this is optimal" into a claim a sceptic can check in one multiplication. The hard half says the certificate always exists.
Theorem 11.38 (Strong duality). If (P) and (D) are both feasible, then both have optimal solutions and their optimal values are equal:
Proof. Sketch. The proof is not long but it rests on a separation theorem we do not prove here; we name the ingredient and show how it delivers the result.
Ingredient (Farkas' lemma). For and , exactly one of the following has a solution: (i) with ; (ii) with . The forward direction is immediate — both cannot hold, since — and the converse follows from the fact that the cone is closed and convex, so a point outside it can be separated from it by a hyperplane, whose normal is the required .
From Farkas to strong duality. Both programs are feasible, so by weak duality both values are finite; call them . Consider the system in the unknowns :
The trichotomy. Weak duality already rules out "both unbounded" and forbids a finite gap in the feasible–feasible case, which the above closes. That both can be infeasible is shown by an example, given below.∎
Example 11.39 (Both programs infeasible). Take with , , . Show that neither (P) nor (D) has a feasible point, so that the third case of the trichotomy really occurs.
Solution. (P) is subject to , . The constraint reads , which no satisfies, so (P) is infeasible. (D) is subject to , , whose constraint reads : also infeasible. Hence "both infeasible" is a genuine case, and Theorem Strong duality must assume feasibility of both sides rather than deducing it.□
Intuition. Think of the primal as a producer choosing an activity mix and the dual as an accountant pricing the resources. Weak duality says no production plan can earn more than the value of the resources it consumes. Strong duality says the accountant can always set prices making the two exactly equal: at the right prices there is no profit left on the table and no resource is mispriced. Every min–max theorem in combinatorics is an instance of this statement about some particular matrix .
Theorem 11.40 (Complementary slackness). Let be feasible for (P) and feasible for (D). Then and are both optimal if and only if
Proof. Define the two nonnegative quantities
() If all the complementary slackness products vanish then , so and both are optimal by Corollary Optimality certificate.
() If both are optimal then the values are equal by Theorem Strong duality, so ; as both are nonnegative sums of nonnegative terms, every term vanishes.∎
Intuition. Complementary slackness is the economics of the situation and the combinatorics of it at the same time. A resource with slack left over is free — its price is . An activity run at a positive level must break even exactly — it cannot be strictly profitable at equilibrium prices, or you would run more of it. In combinatorial terms: an edge in the optimal matching must have both endpoints "paid for" by the cover, and a vertex not in the optimal cover has nothing to pay for.
Example 11.41 (A primal–dual pair solved both ways). Solve subject to , , together with its dual, and verify complementary slackness.
Solution. Here , , . There is one constraint, hence one dual variable , and two primal variables, hence two dual constraints — one per column of :
Primal. The vertices are , and , with values , , . The maximum is at .
Dual. The binding constraint is , since it implies . The minimum is with value .
Both optima equal , as Theorem Strong duality requires.
Complementary slackness. At , : the primal constraint is tight (), consistent with ; forces its dual constraint to be tight, and it is; permits its dual constraint to be slack, and . All four conditions hold ✓ — and note they would have found the solution: guessing that and the constraint is tight gives and directly.□
Pitfall. The dual of a maximisation with constraints and nonnegative variables is a minimisation with constraints and nonnegative variables. Change any of those features and the dual changes shape: an equality primal constraint gives a dual variable of unrestricted sign, and an unrestricted primal variable gives an equality dual constraint. The rule of thumb is that constraint tightness and variable sign restrictions swap roles, which is exactly what complementary slackness pairs up. Convert to standard form first if you are unsure; Proposition Every linear program can be put in standard form shows nothing is lost.
Summary. The chain to remember is: weak duality is one line of algebra and gives certificates; strong duality says certificates always exist and rests on Farkas' lemma; complementary slackness says which certificate goes with which solution, and is the form in which duality is actually applied to combinatorics.
11.6Combinatorial Applications of Duality
A combinatorial maximum — largest matching, largest set of disjoint paths, largest flow — is an integer program: the variables are forced to be or . Integer programming is hard in general, and its dual theory is nothing like as clean, because dropping the integrality requirement usually changes the answer. The LP relaxation of an integer program is the same program with weakened to . Two questions decide whether relaxing is harmless:
- does the relaxation have the same optimal value (is the integrality gap equal to )?
- if so, what does its dual say?
For the problems in this chapter both answers are as good as they could be, and the reason is a property of the constraint matrix.
Definition 11.42 (Totally unimodular matrix). A matrix with entries in is totally unimodular (TU) if every square submatrix has determinant , or . (Taking submatrices shows the entry condition is forced.)
Theorem 11.43 (Hoffman–Kruskal). Let be an integral matrix. Then is totally unimodular if and only if for every integral vector , every vertex of the polyhedron is integral.
Proof. Sketch of the direction we use (), which is the one with a short argument; the converse is proved by exhibiting, for a non-TU matrix, an integral with a fractional vertex, and we do not do that here.
Let be a vertex of . By Theorem Vertices are basic feasible solutions, is the unique solution of the subsystem of tight rows, which has rank ; choose independent tight rows, forming a nonsingular matrix whose rows come from and from the identity (the rows ). A matrix built from rows of a TU matrix together with rows of the identity is again TU, and . Cramer's rule gives , where is with column replaced by the corresponding integral right-hand side. Both determinants are integers and the denominator is , so .∎
Intuition. Total unimodularity is the precise sense in which a system of constraints is "combinatorial". It says the geometry of the polyhedron has no fractional corners to fall into, so a linear programming solver, which finds corners, cannot return half an edge or a third of a path. It is a property of the matrix alone: once it holds, it holds for every objective and every integral right-hand side, so a single check licenses an unlimited supply of integrality theorems.
Theorem 11.44 (Incidence matrices of digraphs are TU). Let be a digraph and its incidence matrix: if enters , if leaves , and otherwise (with for a loop). Then is totally unimodular.
Proof. Induction on the size of a square submatrix . For the entries are . Let and note that every column of , hence of , has at most one and at most one and no other nonzero entries. Three cases:
- Some column of is zero. Then .
- Some column of has exactly one nonzero entry, . Expanding the determinant along that column gives for a submatrix of , and the induction hypothesis applies.
- Every column of has both a and a . Then every column sums to , so the sum of all rows of is the zero vector: the rows are linearly dependent and .
In every case .∎
Corollary 11.45 (Bipartite incidence matrices are TU). Let be a bipartite graph with parts and let be its (undirected) vertex–edge incidence matrix. Then is totally unimodular.
Proof. Orient every edge from to and let be the incidence matrix of the resulting digraph, which is TU by Theorem Incidence matrices of digraphs are TU. Each edge leaves a vertex of and enters one of , so has in the rows and in the rows exactly where has . Multiplying every row indexed by by turns into , and negating a row multiplies each determinant containing it by , preserving the set . Hence is TU.∎
Pitfall. Bipartiteness is essential. For the triangle the incidence matrix is the matrix with two s per column, whose determinant is — not TU. The consequence is visible: the fractional matching on every edge of a triangle has value , while the largest matching has size , an integrality gap. This is why the LP theory of matchings is clean for bipartite graphs and needs extra inequalities (the odd-set constraints) in general.
Corollary 11.46 (Integral matchings and covers). For a bipartite graph , the LP relaxations
Proof. The first program's constraint matrix is the transpose-free bipartite incidence matrix of Corollary Bipartite incidence matrices are TU, and the second is its dual in the sense of Definition The dual linear program, with constraint matrix — TU, since a matrix is TU exactly when its transpose is. By Theorem Hoffman–Kruskal both polyhedra have integral vertices, and by Theorem Fundamental theorem of linear programming the optima are attained at vertices. An integral vertex of the first is a vector with at most one chosen edge per vertex, i.e. a matching; of the second, a vector hitting every edge, i.e. a vertex cover. Strong duality equates the values, which is König's theorem again — now as a statement about one matrix rather than about alternating paths.∎
We can now do the same for flows, which is the point of putting the two halves of this chapter together.
Theorem 11.47 (Max-flow min-cut as LP duality). Add to an arc of infinite capacity and write the maximum flow problem as the circulation program
Proof. The dual. Assign a free variable to the conservation equation at and to the upper bound . The column of for has in row and in row , so the dual constraint for that column reads ; the column of has objective coefficient and no capacity row, giving . Substituting (so and ) turns into and leaves the objective unchanged.
Every cut gives a dual solution. Given an - cut , set for and for , and exactly for the arcs from to , otherwise. Then and holds arc by arc: the difference is only for an arc from to , where . The objective value is . So .
Every dual solution gives a cut at least as cheap. Let be dual feasible. Replacing by keeps , and can only shrink each difference , so feasibility is preserved; assume . Pick uniformly at random in and set , . Then always and always, so is an - cut. An arc crosses forward exactly when , an event of probability . Therefore
Combining, is exactly the minimum cut capacity. Both programs are feasible — for (P), and the cut for (D) — so Theorem Strong duality gives . Finally for the flow obtained by deleting the arc , since conservation at in the circulation says exactly that carries the net outflow of .∎
Remark. Only finitely many give distinct sets , so the "random" is a device for organising a finite case check; the argument is entirely constructive. Alternatively one can quote Theorem Hoffman–Kruskal: the constraint matrix of (P) is the incidence matrix of a digraph, TU by Theorem Incidence matrices of digraphs are TU, so with integral capacities the primal optimum is integral — which re-proves Corollary Integrality of maximum flow without any reference to augmenting paths.
Intuition. Read the dual variables as a potential — a height assigned to each vertex, with at height and at height at least — and as the length you must pay to climb the arc . Dual feasibility says the lengths are enough to climb from any vertex to any neighbour, so every - path has total length at least . Minimising is therefore buying the cheapest way to make every - path long. The rounding step says the cheapest such purchase can always be made by choosing a single height threshold — that is, by choosing a cut.
Example 11.48 (Reading the dual solution off the algorithm). For the network , , , , of the earlier sections, write down an optimal dual solution and verify complementary slackness against the maximum flow.
Solution. The algorithm terminated with , so take and , and on the two arcs leaving , namely and , and elsewhere. Dual objective: ✓.
Complementary slackness, in the form of Theorem Complementary slackness: a positive dual variable forces its primal constraint to be tight. Here on and , and indeed and — the arcs across a minimum cut are saturated. Conversely a primal variable at a value strictly between its bounds, such as , forces its dual constraint to be tight: ✓. These are the same two conditions the proof of Theorem Max-flow min-cut established by hand — arcs out of full, arcs into empty — now derived from a general principle.□
Summary. The min–max theorems of this subject are one theorem seen from different angles.
| combinatorial max | combinatorial min | mechanism |
|---|---|---|
| maximum flow | minimum - cut | residual reachability; LP duality with a TU matrix |
| maximum matching (bipartite) | minimum vertex cover | max-flow min-cut, or duality with the incidence matrix |
| most arc-disjoint - paths | fewest arcs separating from | unit capacities in max-flow min-cut |
| most internally disjoint paths | fewest vertices separating from | vertex splitting, then the arc version |
| maximum-weight common independent set | matroid intersection minimum | a different mechanism — see the previous chapter |
The first four are instances of one linear program; the last is a reminder that not every min–max theorem in combinatorics is an LP duality in disguise, though a surprising number are.
- Counting backward arcs in a cut's capacity. Only arcs from to count; arcs from to are ignored, and Theorem [Flow across a cut](#flow-across-cut) is why.
- Treating the residual graph as the original graph. A residual arc may exist because carries flow that can be cancelled. Dropping those backward arcs makes the algorithm greedy and wrong.
- **Assuming max flow equals the total capacity out of . ** That is one cut among many, hence only an upper bound; the minimum cut may lie deeper in the network.
- Forgetting that the reachable set is the certificate. After any max-flow computation, the vertices reachable from in the residual graph form a minimum cut — the proof of optimality comes free with the answer.
- Expecting every maximum flow to be integral. Corollary [Integrality of maximum flow](#flow-integrality) says one of them is, when capacities are integers; fractional maximum flows can coexist with it.
- Running Ford–Fulkerson with irrational capacities and no path rule. Termination needs a rule such as breadth-first search (Edmonds–Karp); the plain method can converge to a value below the optimum.
- Applying strong duality without checking feasibility of both sides. Both programs can be infeasible at once, and then there is no common value to speak of.
- Deriving the dual from a program not in standard form. Equality constraints give free dual variables and free variables give dual equalities; convert first, or apply the conversion rules deliberately.
- Expecting every LP relaxation to be integral. It is integral when the constraint matrix is totally unimodular (or the polyhedron is otherwise known to have integral vertices) — and the triangle's fractional matching of value shows what happens when it is not.