Algorithm Search⌘K

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. G=(V,E)G = (V, E) is a directed graph with capacities c≥0c \ge 0, real or integer, and s≠ts \ne t. Each edge ee has a residual pair; GfG_f is the residual graph of a flow ff, with edges of positive residual capacity only. df(v)d_f(v) is the distance from ss to vv in GfG_f. The level graph LfL_f has the edges (u,v)(u, v) of GfG_f with df(v)=df(u)+1d_f(v) = d_f(u) + 1. In a phase, LL is a subgraph of LfL_f whose residual capacities shrink as the phase pushes flow, and from which vertices and edges are deleted.

In LL, in(v)\mathrm{in}(v) and out(v)\mathrm{out}(v) count only the edges of LL whose other end is still in LL. Residual capacities of the edges of LfL_f only decrease during a phase, because the phase sends flow only along edges of LfL_f, from one level to the next, and never along their reverses, which are not in LfL_f.

Invariant of a phase. At the start of each step of line L4: (a) the flow is a feasible flow of GG; (b) every vertex of LL other than ss has in(v)>0\mathrm{in}(v) > 0, and every vertex other than tt has out(v)>0\mathrm{out}(v) > 0. Line L3 makes (b) true by deleting dead ends, and (a) holds at the start of the phase.

Lemma 1 (a step succeeds). Let vv be chosen at line L5 with d=p(v)d = p(v). The push of line L7 moves exactly dd units from vv to tt along edges of LL, and the pull of line L8 moves exactly dd units from ss to vv; the flow stays feasible, and its value grows by dd.

Proof. Consider the push. Let vv be at level ii. We show by induction on j≥ij \ge i that, when layer jj is processed, the total excess on layer jj is dd, and each vertex uu of layer jj has excess xu≤dx_u \le d. For j=ij = i the only vertex with excess is vv, with dd. Assume it for jj. Each uu on layer jj other than tt has xu≤d≤p(u)≤out(u)x_u \le d \le p(u) \le \mathrm{out}(u), so walking its leaving edges and sending min⁡(x,residual)\min(x, \text{residual}) along each sends all of xux_u to layer j+1j + 1; edges of LL go only from layer jj to layer j+1j + 1. So layer j+1j + 1 receives exactly dd in total, and each vertex there has excess at most dd. When the layer of tt is reached, tt is the only vertex of LL at that layer, since line L3 removed all others at levels ≥df(t)\ge d_f(t) without leaving edges, so all dd units are at tt. Each push along (u,w)(u, w) adds to the flow on the edge or cancels flow on its pair, within the residual capacity, and every vertex other than vv and tt sends exactly what it receives. The pull is the same argument with entering edges and layers i,i−1,…,0i, i - 1, \ldots, 0: all dd units are drawn from ss, and every vertex other than ss and vv keeps conservation. Together, vv receives dd and sends dd, and the net effect is a flow of value dd from ss to tt added to ff. □\square

Lemma 2 (the invariant is kept). After line L9, (a) and (b) still hold, and vv has been deleted.

Proof. (a) is Lemma 1. The push lowers out(v)\mathrm{out}(v) by dd and the pull lowers in(v)\mathrm{in}(v) by dd, and d=min⁡(in(v),out(v))d = \min(\mathrm{in}(v), \mathrm{out}(v)), so after the step one of them is 0 and vv is deleted. The cascade deletes vertices until no vertex other than ss has in=0\mathrm{in} = 0 and none other than tt has out=0\mathrm{out} = 0, which is (b). □\square

Lemma 3 (a phase ends with a blocking flow). Each phase stops after at most nn steps, and then every ss-tt path of LfL_f 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 nn steps, and the phase stops when ss or tt has been deleted. Suppose some ss-tt path PP of LfL_f 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 PP was deleted, since ss or tt was. Let uu be the first vertex of PP to be deleted. At that moment, its neighbors on PP were in LL, so the edges of PP at uu were counted: if u≠su \ne s, in(u)>0\mathrm{in}(u) > 0, and if u≠tu \ne t, out(u)>0\mathrm{out}(u) > 0. But a vertex is deleted only when it is ss with out(s)=0\mathrm{out}(s) = 0, tt with in(t)=0\mathrm{in}(t) = 0, or another vertex with in=0\mathrm{in} = 0 or out=0\mathrm{out} = 0, including the chosen vv after Lemma 2. This is a contradiction. □\square

Lemma 4 (distances grow). Let f′f' be the flow after a phase that started with ff. Then df′(t)>df(t)d_{f'}(t) > d_f(t).

Proof. This is the lemma of Dinic's algorithm and the level graph. Every edge of Gf′G_{f'} is an edge of GfG_f or the reverse of an edge of LfL_f, so it goes up at most one level of dfd_f, or down one level. A path from ss to tt in Gf′G_{f'} of length df(t)d_f(t) would have to go up exactly one level on every edge, so it would consist of edges of LfL_f only, none of them reversed; it would be a path of LfL_f that is not blocked, which contradicts Lemma 3. □\square

Theorem. MPM returns a maximum flow and a minimum cut, after at most n−1n - 1 phases, in O(n3)O(n^3) time.

Proof. By Lemma 4, df(t)d_f(t) grows in each phase and is at most n−1n - 1 while tt is reachable, so there are at most n−1n - 1 phases. When line L2 finds tt unreachable, the set SS of vertices that ss reaches in GfG_f is an ss-tt cut whose leaving edges are full and whose entering edges are empty, so ∣f∣=c(S)|f| = c(S), and by the max-flow min-cut theorem ff is maximum and SS is a minimum cut.

Time per phase. Building LL and line L3 take O(n+m)O(n + m). There are at most nn steps, and a scan for the least potential costs O(n)O(n). 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 2m2m times per phase in all; besides those, each vertex makes at most one push that does not saturate its edge per step, at most nn per step and n2n^2 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 O(n2+m)=O(n2)O(n^2 + m) = O(n^2), and the run takes O(n3)O(n^3). ■\blacksquare

Back to Malhotra-Pramodh Kumar-Maheshwari algorithm