Proofs: Push-relabel algorithm
These are the human proofs of Push-relabel algorithm, at full length.
The FIFO push-relabel algorithm returns a maximum flow in O(n^3 + nm) time full
This proof shows: correctness, termination, complexity.
Setting. is a directed graph with vertices, edges, real capacities , a source and a sink . Self-loops are removed. The residual graph has, for each edge , a forward edge of capacity and a backward edge of capacity , and contains the edges of positive residual capacity. A labeling is valid for if , , and for each edge of . A residual edge is admissible if . A vertex is active if .
Lemma 1 (invariants). At all times, is a preflow and is valid for . Heights never decrease, and , throughout.
Proof. After lines L1 and L2, every edge out of is full, so has no edge out of except backward edges of edges into , which carry no flow and so are absent. All other residual edges join vertices of height 0, or go into from height 0. So is valid, and for .
Push along an admissible by keeps and , and raises . It may add the residual edge , for which ; it may remove , which keeps validity.
Relabel of happens at line L8 only when the current edge has passed the end of the list. Claim: then has no admissible edge. Each edge was passed over at line L10 only when it was not admissible, and an edge can become admissible only if rises (only a relabel of does that, which resets the pointer) or if newly enters or falls. Heights never fall; enters only by a push along , which needs , after which is not admissible. So no admissible edge out of exists. By validity, for every residual , and since none is admissible, . Lemma 3 below shows that the set of residual edges out of is not empty. So the new value is larger than , and it keeps for edges out of . Edges into , , stay valid because only grew. The vertices and are never active, so they are never relabeled.
Lemma 2 (no augmenting path). For a valid labeling, has no - path.
Proof. A simple path has at most edges, each lowers by at most 1, and .
Lemma 3 (active vertices reach the source). If for , then has a path from to .
Proof. Let be the set of vertices that reaches in , and suppose . No residual edge leaves , so edges from to are full and edges from to are empty. Summing excesses over , the edges inside cancel, and . Every term is at least 0 since , and , a contradiction.
Lemma 4 (height bound). Always for every .
Proof. Heights change only by relabels of active vertices. When is relabeled it is active, so by Lemma 3 a simple residual path from to of at most edges exists. Validity after the relabel gives .
Lemma 5 (operation counts). (a) There are at most relabels, and each raises one height by at least 1. (b) There are at most saturating pushes. (c) With the FIFO queue there are at most passes, and at most nonsaturating pushes.
Proof. (a) Only the inner vertices are relabeled, each starts at 0 and ends at most by Lemma 4.
(b) Fix an edge of with ends , , and consider the saturating pushes from to along a residual edge of . At such a push . Before the next one from to , some push from to must restore residual capacity, which needs at that time; since heights never fall, has grown by at least 2 between the two pushes from to . At each such push . So there are at most saturating pushes from to , and at most from to , for each edge of : at most in total.
(c) Pass 1 discharges the vertices in after line L3, and pass discharges the vertices enqueued during pass . A vertex is in at most once at a time, so each pass discharges each vertex at most once. A discharge ends when , and only its last push can be nonsaturating; so each pass has at most nonsaturating pushes. Let be the largest height of an active vertex, or 0 if there is none; at the start. If a pass has no relabel, every vertex active at its start loses all excess to vertices one level lower, and heights do not change, so falls by at least 1 over the pass. If a pass has relabels, grows by at most the total height increase of that pass. By (a) the total height increase over the run is less than . Hence there are fewer than passes with a relabel and at most passes without one, at most in all, and at most nonsaturating pushes.
Lemma 6 (running time). The FIFO algorithm runs in time.
Proof. A push is , so pushes cost by Lemma 5. A relabel of scans its list in ; with at most relabels per vertex this is . Between two relabels of the current pointer advances at most times, which is in total.
Theorem. The algorithm stops, and returns a maximum flow and a minimum cut .
Proof. By Lemma 5 the number of operations is finite, so the loop stops; then is empty. Every vertex that becomes active is enqueued at that moment (line L9), and a dequeued vertex is discharged until its excess is 0; so when is empty no vertex is active, and is a flow by conservation at every inner vertex. By Lemmas 1 and 2, has no - path, so is maximum by the max-flow min-cut theorem, and the set of vertices that reaches in satisfies and , so it is a minimum cut.