Proofs: Malhotra-Pramodh Kumar-Maheshwari algorithm
These are the human proofs of Malhotra-Pramodh Kumar-Maheshwari algorithm, at full length.
The MPM algorithm computes a maximum flow in O(n^3) time full
This proof shows: correctness, termination, complexity.
Setting. is a directed graph with capacities , real or integer, and . Each edge has a residual pair; is the residual graph of a flow , with edges of positive residual capacity only. is the distance from to in . The level graph has the edges of with . In a phase, is a subgraph of whose residual capacities shrink as the phase pushes flow, and from which vertices and edges are deleted.
In , and count only the edges of whose other end is still in . Residual capacities of the edges of only decrease during a phase, because the phase sends flow only along edges of , from one level to the next, and never along their reverses, which are not in .
Invariant of a phase. At the start of each step of line L4: (a) the flow is a feasible flow of ; (b) every vertex of other than has , and every vertex other than has . Line L3 makes (b) true by deleting dead ends, and (a) holds at the start of the phase.
Lemma 1 (a step succeeds). Let be chosen at line L5 with . The push of line L7 moves exactly units from to along edges of , and the pull of line L8 moves exactly units from to ; the flow stays feasible, and its value grows by .
Proof. Consider the push. Let be at level . We show by induction on that, when layer is processed, the total excess on layer is , and each vertex of layer has excess . For the only vertex with excess is , with . Assume it for . Each on layer other than has , so walking its leaving edges and sending along each sends all of to layer ; edges of go only from layer to layer . So layer receives exactly in total, and each vertex there has excess at most . When the layer of is reached, is the only vertex of at that layer, since line L3 removed all others at levels without leaving edges, so all units are at . Each push along adds to the flow on the edge or cancels flow on its pair, within the residual capacity, and every vertex other than and sends exactly what it receives. The pull is the same argument with entering edges and layers : all units are drawn from , and every vertex other than and keeps conservation. Together, receives and sends , and the net effect is a flow of value from to added to .
Lemma 2 (the invariant is kept). After line L9, (a) and (b) still hold, and has been deleted.
Proof. (a) is Lemma 1. The push lowers by and the pull lowers by , and , so after the step one of them is 0 and is deleted. The cascade deletes vertices until no vertex other than has and none other than has , which is (b).
Lemma 3 (a phase ends with a blocking flow). Each phase stops after at most steps, and then every - path of has an edge whose residual capacity is 0: the flow of the phase is blocking.
Proof. Each step deletes the chosen vertex, so there are at most steps, and the phase stops when or has been deleted. Suppose some - path of has positive residual capacity on all its edges at the end; then it had positive capacity on them at all times of the phase. Some vertex of was deleted, since or was. Let be the first vertex of to be deleted. At that moment, its neighbors on were in , so the edges of at were counted: if , , and if , . But a vertex is deleted only when it is with , with , or another vertex with or , including the chosen after Lemma 2. This is a contradiction.
Lemma 4 (distances grow). Let be the flow after a phase that started with . Then .
Proof. This is the lemma of Dinic's algorithm and the level graph. Every edge of is an edge of or the reverse of an edge of , so it goes up at most one level of , or down one level. A path from to in of length would have to go up exactly one level on every edge, so it would consist of edges of only, none of them reversed; it would be a path of that is not blocked, which contradicts Lemma 3.
Theorem. MPM returns a maximum flow and a minimum cut, after at most phases, in time.
Proof. By Lemma 4, grows in each phase and is at most while is reachable, so there are at most phases. When line L2 finds unreachable, the set of vertices that reaches in is an - cut whose leaving edges are full and whose entering edges are empty, so , and by the max-flow min-cut theorem is maximum and is a minimum cut.
Time per phase. Building and line L3 take . There are at most steps, and a scan for the least potential costs . In a push or pull, the edge pointer of a vertex moves past an edge only when the edge is saturated or leads to a deleted vertex, at most times per phase in all; besides those, each vertex makes at most one push that does not saturate its edge per step, at most per step and per phase. The cascade at line L9 deletes each vertex once per phase and looks at each edge at most twice. So a phase takes , and the run takes .