Short answer: Push-relabel maintains a preflow: every vertex except the source may hold excess, and no residual edge runs from a higher label to a lower one except when the algorithm is mid-push. A vertex with excess pushes flow along a residual edge to a neighbor labeled exactly one lower. If no such edge exists, the vertex relabels to one more than the minimum label of its residual neighbors. The source starts at label |V|. A practical FIFO or highest-label selection, plus periodic global relabeling, is the usual implementation. The generic bound is O(V²E).
What the problem actually asks
Augmenting-path algorithms keep a feasible flow and search for a residual path. Push-relabel keeps conservation broken on purpose. Excess at a vertex is flow that has arrived and not left. Labels estimate the residual distance to the sink. Pushing downhill moves excess toward the sink. When the excess cannot move, the label is too low and relabel raises it. Excess that cannot reach the sink eventually falls back to the source, which started at the highest label.
The method never looks for a path. Local pushes and relabels are the whole step, which is why it is fast on some large graphs and awkward to prove by hand.
What the algorithm guarantees
When no vertex except source and sink has excess, the preflow is a maximum flow. The generic algorithm, which relabels and pushes in any order that always picks a vertex with excess, runs in O(V²E). Highest-label selection improves the bound to O(V² √E). Extra memory is labels, excess, and the residual graph. A gap heuristic or a global relabel by reverse BFS from the sink does not change correctness and often dominates the practical running time.
Integer capacities are not required for termination of the standard label-based algorithm, unlike arbitrary Ford-Fulkerson. The cut is available from the labels: vertices that can still reach the sink in the residual graph form the sink side, and a reverse BFS from the sink finds them.
The working steps
- Set the source’s label to |V| and every other label to 0. Saturate every edge out of the source, put the resulting excess on its heads, and set those residual capacities.
- While some vertex other than source and sink has excess, select one. FIFO and highest label are the common policies.
- If it has a residual edge to a vertex labeled exactly one less, push the minimum of its excess and that residual. Update both residuals.
- Otherwise relabel it to one plus the minimum label of its residual neighbors. A vertex with no residual neighbor can be given a label that parks it.
- When no excess remains outside the source and the sink, read the flow off the residual capacities. Optionally global-relabel by a reverse BFS from the sink to keep labels equal to true residual distances.
The algorithm computes a maximum s-t flow, the same number Dinic computes. It does not compute a min-cost flow. The O(V²E) generic bound is not a license to pick a vertex at random and expect the practical speed of a tuned highest-label code with global relabeling. Those heuristics are part of a serious implementation.
Approaches that look simpler and fail
| Approach | Why it fails when a push ignores the label gap |
|---|---|
| Push along any residual edge | A push to an arbitrary neighbor can cycle excess forever. The one-lower rule is what drives excess toward the sink or back to the source. |
| Relabel by adding one with no look at the neighbors | The new label has to be one more than a real residual neighbor’s label, or the downhill invariant and the termination proof break. |
| Stop while excess sits on a non-sink vertex | A preflow is not a flow until that excess has been pushed away. The value is not yet the maximum-flow value. |
| Omit saturation of the source edges at the start | The initial preflow is exactly that saturation. Starting from the zero flow with every label 0 gives the algorithm nothing to push. |
Path-based maximum flow belongs to Dinic or Edmonds-Karp. A cost on each edge, with a cheapest augmenting path, is successive shortest paths for min-cost flow. Push-relabel replaces the path search and not the cost optimization.
A working example
This Python fragment pushes preflow downhill to a vertex whose label is exactly one lower, and relabels a vertex that has excess and no such neighbor. The source starts with label |V|. On the same small network the excess that reaches the sink is 5.
n = 4
res = {(0, 1): 3, (0, 2): 2, (1, 3): 2, (2, 3): 3, (1, 2): 1}
excess = [0] * n
height = [0] * n
height[0] = n
for v, c in list(res.items()):
if v[0] == 0 and c:
excess[v[1]] += c
res[(v[1], 0)] = res.get((v[1], 0), 0) + c
res[v] = 0
def push(u, v):
send = min(excess[u], res.get((u, v), 0))
res[(u, v)] -= send
res[(v, u)] = res.get((v, u), 0) + send
excess[u] -= send
excess[v] += send
active = [i for i in range(1, n - 1) if excess[i] > 0]
while active:
u = active.pop()
pushed = False
for v in range(n):
if res.get((u, v), 0) and height[u] == height[v] + 1:
push(u, v)
if v not in (0, n - 1) and excess[v] > 0 and v not in active:
active.append(v)
pushed = True
if excess[u] == 0:
break
if excess[u] > 0:
height[u] = 1 + min(height[v] for v in range(n) if res.get((u, v), 0))
active.append(u)
assert excess[n - 1] == 5
print(excess[n - 1])
Where it is used
Push-relabel computes a maximum flow by moving excess downhill, and it is a standard choice for large flow instances and for some graph-cut image segmentations. Dinic’s algorithm is the blocking-flow alternative. Both compute the same maximum value.
When you can drop this algorithm
Drop a from-scratch push-relabel if Dinic is already trusted and fast enough. Keep push-relabel, with global relabeling, for large flow instances where path search is the bottleneck and the implementation can be tested against Dinic on small graphs.
Why this stays published
We publish this so a search for push-relabel returns the downhill push, the relabel, and the initial saturation out of the source. Push-relabel computes a maximum flow by pushing excess downhill along residual edges and relabeling a vertex when it has nowhere legal to push.
本文由 HoHo 與 AI 協作整理,最後更新於 2026 年 11 月 13 日。
