Proofs: Successive shortest path algorithm
These are the human proofs of Successive shortest path algorithm, at full length.
The successive shortest path algorithm returns a cheapest flow of the requested value full
This proof shows: correctness, termination.
Setting. is a directed graph with integer capacities , real costs , a source , a sink , and a target . The edges of positive capacity contain no cycle of negative cost. For a flow , the residual graph has, for each edge , a forward edge with capacity and cost , and a backward edge with capacity and cost ; only edges of positive capacity are present. For potentials , the reduced cost of a residual edge is . Let be the set of vertices that reaches in .
Lemma 1 (potentials cancel on cycles). For every directed cycle , .
Proof. Each vertex of is the tail of one edge of and the head of one, so the terms sum to 0.
Lemma 2 (negative cycle optimality). A flow of value is a cheapest flow of value if has no cycle of negative cost.
Proof. Let be a flow of value . For each edge put on its forward residual edge if this is positive, and on its backward residual edge otherwise. The result respects the residual capacities. Both flows have value and satisfy conservation, so is conserved at every vertex, including and : it is a circulation in , with cost . A circulation is a nonnegative sum of flows around directed cycles of its support, which are cycles of . Each has cost at least 0, so .
Lemma 3 (the start). After line L2, for every edge of positive capacity, and the zero flow is a cheapest flow of value 0.
Proof. With no negative cycle, Bellman-Ford from the root returns shortest distances , and for each edge that it uses, which is . At the residual graph has exactly these edges, so by Lemma 1 it has no negative cycle, and Lemma 2 applies.
Invariant. Before each round: (a) for each residual edge of whose tail is in ; (b) has no cycle of negative cost; (c) is a cheapest flow of its value.
It holds at the start by Lemma 3; (a) holds for all edges then.
It is preserved. Let be the distances of line L4, which are correct because Dijkstra only scans edges with tails in , whose lengths are nonnegative by (a). Let on and elsewhere. For a residual edge with , also , and , so . For the edges of the shortest path equality holds, so on . Let be the flow after line L8. Each residual edge of is either a residual edge of or the reverse of an edge of , which has reduced cost . The new reverse edges join vertices of , and the other edges were already there, so . Hence every edge of with tail in has , which is (a).
For (b), take a cycle of . Each edge of is either an edge of or the reverse of an edge of . Case 1: has a vertex in . An edge of with tail in has its head in , and a reversed edge has both ends in ; so, walking around , every vertex of is in . Then every edge of has by the computation above, and by Lemma 1 the cost of is at least 0. Case 2: has no vertex in . Then uses no reversed edge, so it is a cycle of , and its cost is at least 0 by (b) for .
(c) follows from (b) by Lemma 2.
Lemma 4 (termination). The loop runs at most rounds when this is finite, and stops with value , where is the maximum flow value.
Proof. Capacities are integers, so by induction the flow and the residual capacities stay integral and each is a positive integer, because inside the loop. The value grows by at least 1 per round and never exceeds or . The loop stops when the value reaches , or when ; in the second case has no - path, so is a maximum flow by the max-flow min-cut theorem. is finite, because .
Theorem. The algorithm returns a flow of value that has the least cost among all flows of that value.
Proof. By Lemma 4 it stops with that value, and by part (c) of the invariant the flow is a cheapest one of its value.