The Generic Push–Relabel Algorithm #
The generic push–relabel maximum-flow algorithm of Goldberg and Tarjan ([GT88]; [CLRS09], Section 26.4), with its operation bounds, its correctness at termination, and an executable scheduler.
Model and source mapping #
- Runs (
PushRelabel.State.IsRun): a state is a preflow with heights; a run is a list of operations (Op.push u v,Op.relabel u), each admissible (Preflow.CanPush,Preflow.CanRelabel) in the state it is applied to. Any order of admissible operations is a run, as in the generic algorithm of [CLRS09], Section 26.4. - Counts:
numRelabels,numSatPushes(pushes moving the whole residual capacity) andnumNonsatPushescount the operations of a run along the states it visits. - Executable (
pushRelabelWith,pushRelabel): repeatedly picks the first active vertex in a vertex list and pushes along its first admissible arc, else relabels it;pushRelabelonFin ntabulates the state as a matrix and a vector after every step, so the kernel can evaluate it (decide). - Edge measure: the bounds are stated with
N.symArcs(ordered pairsu ≠ vwithcap u v + cap v u > 0, the arcs that can ever be residual) and, in [CLRS09]'s form, withN.posArcs(non-loop arcs of positive capacity, the edge setE).
Main definitions #
PushRelabel.State,PushRelabel.Op,PushRelabel.init,State.apply,State.Admissible,State.run,State.IsRun,State.IsSatPush.State.numRelabels,State.numSatPushes,State.numNonsatPushes,PushRelabel.maxOps.State.selectOp,State.loop,pushRelabelWith,pushRelabel.
Main results #
PushRelabel.numRelabels_le: at most(|V| - 2)(2|V| - 1)relabels;numRelabels_lt: fewer than2|V|²([CLRS09], Corollary 26.21).PushRelabel.numSatPushes_le: at most|V| |N.symArcs|saturating pushes;numSatPushes_le_posArcs: at most2|V| |E|([CLRS09], Lemma 26.22, which states<; the non-strict form also coversE = ∅).PushRelabel.numNonsatPushes_le: at most(|V| - 2)(2|V| - 1) + (2|V| - 1)|V| |N.symArcs|nonsaturating pushes;numNonsatPushes_lt_posArcs: fewer than4|V|²(|V| + |E|)([CLRS09], Lemma 26.23).PushRelabel.length_le: every run from the initial state has at mostmaxOps Noperations, andmaxOps_le:maxOps N ≤ 4|V|²(1 + |E|), so the generic algorithm terminates afterO(|V|² (|E| + 1))operations ([CLRS09], Theorem 26.24, operation count).PushRelabel.isMaxFlow_isMinCut_of_isRun: a run under any selection rule that reaches a state admitting no operation ends with a maximum flow and a minimum gap cut of equal value ([CLRS09], Lemma 26.14 and Theorem 26.18).pushRelabelWith_correct,pushRelabel_correct: the executable returns a maximum flow and a minimum cut of equal value after a run of at mostmaxOps Noperations ([CLRS09], Theorems 26.18 and 26.24).
Limitations #
The bounds count operations; no cost is charged for selecting an operation, so this is not a
machine running-time bound. Only the generic algorithm is treated here: see
CslibFrontier.Algorithms.Lean.MaxFlow.RelabelToFront for the pure relabel-to-front scheduler and
its O(|V|³) push/relabel operation, discharge, and current-arc advance count bounds. Word-RAM
running times (O(|V|³)), FIFO and highest-label (O(|V|² √|E|)) selection rules, gap and global
relabelling heuristics, and dynamic trees ([GT88]) are not formalized here.
References #
o is a push.
Instances For
o is a relabel.
Instances For
The initial state: the initial preflow and heights ([CLRS09], Section 26.4).
The effect of an operation (meaningful when it is admissible).
The state reached by applying a list of operations in order.
os is a run of the generic algorithm from σ: each operation is admissible when applied.
Instances For
The number of relabels in a run.
The number of saturating pushes in a run.
The number of nonsaturating pushes in a run.
The number of saturating pushes from a to b in a run.
Every operation of a run is a relabel, a saturating push or a nonsaturating push.
Invariants #
The invariant of the generic algorithm: a valid labeling with heights at most 2|V| - 1.
The heights form a valid labeling.
Every height is at most
2|V| - 1([CLRS09], Lemma 26.20).
A state satisfying the invariant and admitting no operation has no active vertex ([CLRS09], Lemma 26.14).
Relabels #
Saturating pushes #
Nonsaturating pushes #
The potential Φ = ∑_{v active} h(v) of [CLRS09], proof of Lemma 26.23.
One admissible operation raises the potential by at most the height increase, plus 2|V| - 1
for a saturating push, and lowers it by at least one for a nonsaturating push ([CLRS09], proof of
Lemma 26.23).
Bounds from the initial state #
Relabel bound ([CLRS09], Corollary 26.21): a run from the initial state performs at most
(|V| - 2)(2|V| - 1) relabels.
Saturating-push bound ([CLRS09], Lemma 26.22): a run from the initial state performs at
most |V| saturating pushes per pair of N.symArcs.
Saturating-push bound, [CLRS09]'s form (Lemma 26.22): at most 2|V| |E| saturating
pushes, where E = N.posArcs. The source states <; the non-strict form also covers E = ∅.
Nonsaturating-push bound ([CLRS09], Lemma 26.23): a run from the initial state performs at
most (|V| - 2)(2|V| - 1) + (2|V| - 1) |V| |N.symArcs| nonsaturating pushes.
Nonsaturating-push bound, [CLRS09]'s form (Lemma 26.23): fewer than 4|V|²(|V| + |E|)
nonsaturating pushes, where E = N.posArcs.
The total operation bound 2 (|V| - 2)(2|V| - 1) + 2|V| · |V| |N.symArcs|; at most
4|V|²(1 + |E|) by maxOps_le.
Operation bound ([CLRS09], Theorem 26.24, operation count): every run of the generic
algorithm from the initial state has at most maxOps N ≤ 4|V|²(1 + |E|) operations
(maxOps_le).
Correctness of every run ([CLRS09], Lemma 26.14 and Theorem 26.18): if a run of the
generic algorithm from the initial state, under any selection rule, reaches a state admitting no
operation, then its preflow is a maximum flow and the gap cut of its heights is a minimum cut of
the same value. By length_le, every run reaches such a state within maxOps N operations.
An executable scheduler #
The operation chosen by scanning vs: the first active vertex u of vs pushes to the first
v of vs with (u, v) admissible, or is relabelled if there is none; none if no vertex of vs
is active.
Apply operations chosen by selectOp vs until none applies or fuel runs out, normalizing the
state with norm after every step; returns the operations performed and the final state.
Executable instances use norm to tabulate the state (see PushRelabel.tabulate); correctness
assumes that norm is the identity.
The executable algorithm #
The output of pushRelabelWith.
- ops : List (Network.PushRelabel.Op V)
The operations performed, in order.
- flow : N.Flow
The final flow.
- cut : Finset V
The gap cut of the final labeling.
The output read off a final state: its preflow as a flow when every excess off N.s, N.t
vanishes (the zero flow otherwise), and its gap cut.
The generic push–relabel algorithm with the scheduler State.selectOp vs, normalizing states
with norm, for at most maxOps N + 1 steps from the initial state.
Correctness of the executable generic algorithm ([CLRS09], Theorems 26.18 and 26.24): if
vs lists every vertex, norm is the identity and N.s ≠ N.t, then pushRelabelWith N vs norm
performs a run of at most maxOps N operations of the generic algorithm from the initial state and
returns a maximum flow and a minimum cut of equal value.
The generic push–relabel algorithm on Fin n: scan the vertices in increasing order, tabulating
the state after every operation.
Correctness of pushRelabel ([CLRS09], Theorems 26.18 and 26.24).