Hubbry Logo
Push–relabel maximum flow algorithmPush–relabel maximum flow algorithmMain
Open search
Push–relabel maximum flow algorithm
Community hub
Push–relabel maximum flow algorithm
logo
7 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Push–relabel maximum flow algorithm
Push–relabel maximum flow algorithm
from Wikipedia

In mathematical optimization, the push–relabel algorithm (alternatively, preflow–push algorithm) is an algorithm for computing maximum flows in a flow network. The name "push–relabel" comes from the two basic operations used in the algorithm. Throughout its execution, the algorithm maintains a "preflow" and gradually converts it into a maximum flow by moving flow locally between neighboring nodes using push operations under the guidance of an admissible network maintained by relabel operations. In comparison, the Ford–Fulkerson algorithm performs global augmentations that send flow following paths from the source all the way to the sink.[1]

The push–relabel algorithm is considered one of the most efficient maximum flow algorithms. The generic algorithm has a strongly polynomial O(V 2E) time complexity, which is asymptotically more efficient than the O(VE 2) Edmonds–Karp algorithm.[2] Specific variants of the algorithms achieve even lower time complexities. The variant based on the highest label node selection rule has O(V 2E) time complexity and is generally regarded as the benchmark for maximum flow algorithms.[3][4] Subcubic O(VElog(V 2/E)) time complexity can be achieved using dynamic trees,[2] although in practice it is less efficient.[citation needed]

The push–relabel algorithm has been extended to compute minimum cost flows.[5] The idea of distance labels has led to a more efficient augmenting path algorithm, which in turn can be incorporated back into the push–relabel algorithm to create a variant with even higher empirical performance.[4][6]

History

[edit]

The concept of a preflow was originally designed by Alexander V. Karzanov and was published in 1974 in Soviet Mathematical Dokladi 15. This pre-flow algorithm also used a push operation; however, it used distances in the auxiliary network to determine where to push the flow instead of a labeling system.[2][7]

The push-relabel algorithm was designed by Andrew V. Goldberg and Robert Tarjan. The algorithm was initially presented in November 1986 in STOC '86: Proceedings of the eighteenth annual ACM symposium on Theory of computing, and then officially in October 1988 as an article in the Journal of the ACM. Both papers detail a generic form of the algorithm terminating in O(V 2E) along with a O(V 3) sequential implementation, a O(VE log(V 2/E)) implementation using dynamic trees, and parallel/distributed implementation.[2][8] As explained in,[9] Goldberg-Tarjan introduced distance labels by incorporating them into the parallel maximum flow algorithm of Yossi Shiloach and Uzi Vishkin.[10]

Concepts

[edit]

Definitions and notations

[edit]

Let:

  • G = (V, E) be a network with capacity function c: V × V,
  • F = (G, c, s, t) a flow network, where sV and tV are chosen source and sink vertices respectively,
  • f : V × V denote a pre-flow in F,
  • xf : V denote the excess function with respect to the flow f, defined by xf (u) = ΣvV f (v, u) − ΣvV f (u, v),
  • cf : V × V denote the residual capacity function with respect to the flow f, defined by cf (e) = c(e) − f (e),
  • EfE being the edges where f < c,

and

The push–relabel algorithm uses a nonnegative integer valid labeling function which makes use of distance labels, or heights, on nodes to determine which arcs should be selected for the push operation. This labeling function is denoted by 𝓁 : V. This function must satisfy the following conditions in order to be considered valid:

Valid labeling:
𝓁(u) ≤ 𝓁(v) + 1 for all (u, v) ∈ Ef
Source condition:
𝓁(s) = | V |
Sink conservation:
𝓁(t) = 0

In the algorithm, the label values of s and t are fixed. 𝓁(u) is a lower bound of the unweighted distance from u to t in Gf  if t is reachable from u. If u has been disconnected from t, then 𝓁(u) − | V | is a lower bound of the unweighted distance from u to s. As a result, if a valid labeling function exists, there are no s-t paths in Gf  because no such paths can be longer than V | − 1.

An arc (u, v) ∈ Ef  is called admissible if 𝓁(u) = 𝓁(v) + 1. The admissible network f (V, f ) is composed of the set of arcs eEf  that are admissible. The admissible network is acyclic.

For a fixed flow f, a vertex v ∉ {s, t} is called active if it has positive excess with respect to f, i.e., xf (u) > 0.

Operations

[edit]

Initialization

[edit]

The algorithm starts by creating a residual graph, initializing the preflow values to zero and performing a set of saturating push operations on residual arcs (s, v) exiting the source, where vV \ {s}. Similarly, the labels are initialized such that the label at the source is the number of nodes in the graph, 𝓁(s) = | V |, and all other nodes are given a label of zero. Once the initialization is complete the algorithm repeatedly performs either the push or relabel operations against active nodes until no applicable operation can be performed.

Push

[edit]

The push operation applies on an admissible out-arc (u, v) of an active node u in Gf. It moves min{xf (u), cf (u,v)} units of flow from u to v.

push(u, v):
    assert xf[u] > 0 and 𝓁[u] == 𝓁[v] + 1
    Δ = min(xf[u], c[u][v] - f[u][v])
    f[u][v] += Δ
    f[v][u] -= Δ
    xf[u] -= Δ
    xf[v] += Δ

A push operation that causes f (u, v) to reach c(u, v) is called a saturating push since it uses up all the available capacity of the residual arc. Otherwise, all of the excess at the node is pushed across the residual arc. This is called an unsaturating or non-saturating push.

Relabel

[edit]

The relabel operation applies on an active node u which is neither the source nor the sink without any admissible out-arcs in Gf. It modifies 𝓁(u) to be the minimum value such that an admissible out-arc is created. Note that this always increases 𝓁(u) and never creates a steep arc, which is an arc (u, v) such that cf (u, v) > 0, and 𝓁(u) > 𝓁(v) + 1.

relabel(u):
    assert xf[u] > 0 and 𝓁[u] <= 𝓁[v] for all v such that cf[u][v] > 0
    𝓁[u] = 1 + min(𝓁[v] for all v such that cf[u][v] > 0)

Effects of push and relabel

[edit]

After a push or relabel operation, 𝓁 remains a valid labeling function with respect to f.

For a push operation on an admissible arc (u, v), it may add an arc (v, u) to Ef, where 𝓁(v) = 𝓁(u) − 1 ≤ 𝓁(u) + 1; it may also remove the arc (u, v) from Ef, where it effectively removes the constraint 𝓁(u) ≤ 𝓁(v) + 1.

To see that a relabel operation on node u preserves the validity of 𝓁(u), notice that this is trivially guaranteed by definition for the out-arcs of u in Gf. For the in-arcs of u in Gf, the increased 𝓁(u) can only satisfy the constraints less tightly, not violate them.

The generic push–relabel algorithm

[edit]

The generic push–relabel algorithm is used as a proof of concept only and does not contain implementation details on how to select an active node for the push and relabel operations. This generic version of the algorithm will terminate in O(V2E).

Since 𝓁(s) = | V |, 𝓁(t) = 0, and there are no paths longer than V | − 1 in Gf, in order for 𝓁(s) to satisfy the valid labeling condition s must be disconnected from t. At initialisation, the algorithm fulfills this requirement by creating a pre-flow f that saturates all out-arcs of s, after which 𝓁(v) = 0 is trivially valid for all vV \ {s, t}. After initialisation, the algorithm repeatedly executes an applicable push or relabel operation until no such operations apply, at which point the pre-flow has been converted into a maximum flow.

generic-push-relabel(G, c, s, t):
    create a pre-flow f that saturates all out-arcs of s
    let 𝓁[s] = |V|
    let 𝓁[v] = 0 for all v ∈ V \ {s}
    while there is an applicable push or relabel operation do
        execute the operation

Correctness

[edit]

The algorithm maintains the condition that 𝓁 is a valid labeling during its execution. This can be proven true by examining the effects of the push and relabel operations on the label function 𝓁. The relabel operation increases the label value by the associated minimum plus one which will always satisfy the 𝓁(u) ≤ 𝓁(v) + 1 constraint. The push operation can send flow from u to v if 𝓁(u) = 𝓁(v) + 1. This may add (v, u) to Gf  and may delete (u, v) from Gf . The addition of (v, u) to Gf  will not affect the valid labeling since 𝓁(v) = 𝓁(u) − 1. The deletion of (u, v) from Gf  removes the corresponding constraint since the valid labeling property 𝓁(u) ≤ 𝓁(v) + 1 only applies to residual arcs in Gf .[8]

If a preflow f and a valid labeling 𝓁 for f exists then there is no augmenting path from s to t in the residual graph Gf . This can be proven by contradiction based on inequalities which arise in the labeling function when supposing that an augmenting path does exist. If the algorithm terminates, then all nodes in V \ {s, t} are not active. This means all vV \ {s, t} have no excess flow, and with no excess the preflow f obeys the flow conservation constraint and can be considered a normal flow. This flow is the maximum flow according to the max-flow min-cut theorem since there is no augmenting path from s to t.[8]

Therefore, the algorithm will return the maximum flow upon termination.

Time complexity

[edit]

In order to bound the time complexity of the algorithm, we must analyze the number of push and relabel operations which occur within the main loop. The numbers of relabel, saturating push and nonsaturating push operations are analyzed separately.

In the algorithm, the relabel operation can be performed at most (2| V | − 1)(| V | − 2) < 2| V |2 times. This is because the labeling 𝓁(u) value for any node u can never decrease, and the maximum label value is at most 2| V | − 1 for all nodes. This means the relabel operation could potentially be performed 2| V | − 1 times for all nodes V \ {s, t} (i.e. V | − 2). This results in a bound of O(V 2) for the relabel operation.

Each saturating push on an admissible arc (u, v) removes the arc from Gf . For the arc to be reinserted into Gf  for another saturating push, v must first be relabeled, followed by a push on the arc (v, u), then u must be relabeled. In the process, 𝓁(u) increases by at least two. Therefore, there are O(V) saturating pushes on (u, v), and the total number of saturating pushes is at most 2| V || E |. This results in a time bound of O(VE) for the saturating push operations.

Bounding the number of nonsaturating pushes can be achieved via a potential argument. We use the potential function Φ = Σ[uVxf (u) > 0] 𝓁(u) (i.e. Φ is the sum of the labels of all active nodes). It is obvious that Φ is 0 initially and stays nonnegative throughout the execution of the algorithm. Both relabels and saturating pushes can increase Φ. However, the value of Φ must be equal to 0 at termination since there cannot be any remaining active nodes at the end of the algorithm's execution. This means that over the execution of the algorithm, the nonsaturating pushes must make up the difference of the relabel and saturating push operations in order for Φ to terminate with a value of 0. The relabel operation can increase Φ by at most (2| V | − 1)(| V | − 2). A saturating push on (u, v) activates v if it was inactive before the push, increasing Φ by at most 2| V | − 1. Hence, the total contribution of all saturating pushes operations to Φ is at most (2| V | − 1)(2| V || E |). A nonsaturating push on (u, v) always deactivates u, but it can also activate v as in a saturating push. As a result, it decreases Φ by at least 𝓁(u) − 𝓁(v) = 1. Since relabels and saturating pushes increase Φ, the total number of nonsaturating pushes must make up the difference of (2| V | − 1)(| V | − 2) + (2| V | − 1)(2| V || E |) ≤ 4| V |2E |. This results in a time bound of O(V 2E) for the nonsaturating push operations.

In sum, the algorithm executes O(V 2) relabels, O(VE) saturating pushes and O(V 2E) nonsaturating pushes. Data structures can be designed to pick and execute an applicable operation in O(1) time. Therefore, the time complexity of the algorithm is O(V 2E).[1][8]

Example

[edit]

The following is a sample execution of the generic push-relabel algorithm, as defined above, on the following simple network flow graph diagram.

Initial flow network graph
Initial flow network graph
Final maximum flow network graph
Final maximum flow network graph

In the example, the h and e values denote the label 𝓁 and excess xf , respectively, of the node during the execution of the algorithm. Each residual graph in the example only contains the residual arcs with a capacity larger than zero. Each residual graph may contain multiple iterations of the perform operation loop.

Algorithm Operation(s) Residual Graph
Initialise the residual graph by setting the preflow to values 0 and initialising the labeling. Step 1
Initial saturating push is performed across all preflow arcs out of the source, s. Step 2
Node a is relabeled in order to push its excess flow towards the sink, t.

The excess at a is then pushed to b then d in two subsequent saturating pushes; which still leaves a with some excess.

Step 3
Once again, a is relabeled in order to push its excess along its last remaining positive residual (i.e. push the excess back to s).

The node a is then removed from the set of active nodes.

Step 4
Relabel b and then push its excess to t and c. Step 5
Relabel c and then push its excess to d. Step 6
Relabel d and then push its excess to t. Step 7
This leaves the node b as the only remaining active node, but it cannot push its excess flow towards the sink.

Relabel b and then push its excess towards the source, s, via the node a.

Step 8
Push the last bit of excess at a back to the source, s.

There are no remaining active nodes. The algorithm terminates and returns the maximum flow of the graph (as seen above).

Step 9

The example (but with initial flow of 0) can be run here interactively.

Practical implementations

[edit]

While the generic push–relabel algorithm has O(V 2E) time complexity, efficient implementations achieve O(V 3) or lower time complexity by enforcing appropriate rules in selecting applicable push and relabel operations. The empirical performance can be further improved by heuristics.

"Current-arc" data structure and discharge operation

[edit]

The "current-arc" data structure is a mechanism for visiting the in- and out-neighbors of a node in the flow network in a static circular order. If a singly linked list of neighbors is created for a node, the data structure can be as simple as a pointer into the list that steps through the list and rewinds to the head when it runs off the end.

Based on the "current-arc" data structure, the discharge operation can be defined. A discharge operation applies on an active node and repeatedly pushes flow from the node until it becomes inactive, relabeling it as necessary to create admissible arcs in the process.

discharge(u):
    while xf[u] > 0 do
        if current-arc[u] has run off the end of neighbors[u] then
            relabel(u)
            rewind current-arc[u]
        else
            let (u, v) = current-arc[u]
            if (u, v) is admissible then
                push(u, v)
            let current-arc[u] point to the next neighbor of u

Finding the next admissible edge to push on has amortized complexity. The current-arc pointer only moves to the next neighbor when the edge to the current neighbor is saturated or non-admissible, and neither of these two properties can change until the active node is relabelled. Therefore, when the pointer runs off, there are no admissible unsaturated edges and we have to relabel the active node , so having moved the pointer times is paid for by the relabel operation.[8]

Active node selection rules

[edit]

Definition of the discharge operation reduces the push–relabel algorithm to repeatedly selecting an active node to discharge. Depending on the selection rule, the algorithm exhibits different time complexities. For the sake of brevity, we ignore s and t when referring to the nodes in the following discussion.

FIFO selection rule

[edit]

The FIFO push–relabel algorithm[2] organizes the active nodes into a queue. The initial active nodes can be inserted in arbitrary order. The algorithm always removes the node at the front of the queue for discharging. Whenever an inactive node becomes active, it is appended to the back of the queue.

The algorithm has O(V 3) time complexity.

Relabel-to-front selection rule

[edit]

The relabel-to-front push–relabel algorithm[1] organizes all nodes into a linked list and maintains the invariant that the list is topologically sorted with respect to the admissible network. The algorithm scans the list from front to back and performs a discharge operation on the current node if it is active. If the node is relabeled, it is moved to the front of the list, and the scan is restarted from the front.

The algorithm also has O(V 3) time complexity.

Highest label selection rule

[edit]

The highest-label push–relabel algorithm[11] organizes all nodes into buckets indexed by their labels. The algorithm always selects an active node with the largest label to discharge.

The algorithm has O(V 2E) time complexity. If the lowest-label selection rule is used instead, the time complexity becomes O(V 2E).[3]

Implementation techniques

[edit]

Although in the description of the generic push–relabel algorithm above, 𝓁(u) is set to zero for each node u other than s and t at the beginning, it is preferable to perform a backward breadth-first search from t to compute exact labels.[2]

The algorithm is typically separated into two phases. Phase one computes a maximum pre-flow by discharging only active nodes whose labels are below n. Phase two converts the maximum preflow into a maximum flow by returning excess flow that cannot reach t to s. It can be shown that phase two has O(VE) time complexity regardless of the order of push and relabel operations and is therefore dominated by phase one. Alternatively, it can be implemented using flow decomposition.[9]

Heuristics are crucial to improving the empirical performance of the algorithm.[12] Two commonly used heuristics are the gap heuristic and the global relabeling heuristic.[2][13] The gap heuristic detects gaps in the labeling function. If there is a label 0 < 𝓁' < | V | for which there is no node u such that 𝓁(u) = 𝓁', then any node u with 𝓁' < 𝓁(u) < | V | has been disconnected from t and can be relabeled to (| V | + 1) immediately. The global relabeling heuristic periodically performs backward breadth-first search from t in Gf  to compute the exact labels of the nodes. Both heuristics skip unhelpful relabel operations, which are a bottleneck of the algorithm and contribute to the ineffectiveness of dynamic trees.[4]

Sample implementations

[edit]
C implementation
#include <stdlib.h>
#include <stdio.h>

#define NODES 6
#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
#define INFINITE 10000000

void push(const int * const * C, int ** F, int *excess, int u, int v) {
  int send = MIN(excess[u], C[u][v] - F[u][v]);
  F[u][v] += send;
  F[v][u] -= send;
  excess[u] -= send;
  excess[v] += send;
}

void relabel(const int * const * C, const int * const * F, int *height, int u) {
  int v;
  int min_height = INFINITE;
  for (v = 0; v < NODES; v++) {
    if (C[u][v] - F[u][v] > 0) {
      min_height = MIN(min_height, height[v]);
      height[u] = min_height + 1;
    }
  }
};

void discharge(const int * const * C, int ** F, int *excess, int *height, int *seen, int u) {
  while (excess[u] > 0) {
    if (seen[u] < NODES) {
      int v = seen[u];
      if ((C[u][v] - F[u][v] > 0) && (height[u] > height[v])) {
        push(C, F, excess, u, v);
      } else {
        seen[u] += 1;
      }
    } else {
      relabel(C, F, height, u);
      seen[u] = 0;
    }
  }
}

void moveToFront(int i, int *A) {
  int temp = A[i];
  int n;
  for (n = i; n > 0; n--) {
    A[n] = A[n-1];
  }
  A[0] = temp;
}

int pushRelabel(const int * const * C, int ** F, int source, int sink) {
  int *excess, *height, *list, *seen, i, p;

  excess = (int *) calloc(NODES, sizeof(int));
  height = (int *) calloc(NODES, sizeof(int));
  seen = (int *) calloc(NODES, sizeof(int));

  list = (int *) calloc((NODES-2), sizeof(int));

  for (i = 0, p = 0; i < NODES; i++){
    if ((i != source) && (i != sink)) {
      list[p] = i;
      p++;
    }
  }

  height[source] = NODES;
  excess[source] = INFINITE;
  for (i = 0; i < NODES; i++)
    push(C, F, excess, source, i);

  p = 0;
  while (p < NODES - 2) {
    int u = list[p];
    int old_height = height[u];
    discharge(C, F, excess, height, seen, u);
    if (height[u] > old_height) {
      moveToFront(p, list);
      p = 0;
    } else {
      p += 1;
    }
  }
  int maxflow = 0;
  for (i = 0; i < NODES; i++)
    maxflow += F[source][i];

  free(list);

  free(seen);
  free(height);
  free(excess);

  return maxflow;
}

void printMatrix(const int * const * M) {
  int i, j;
  for (i = 0; i < NODES; i++) {
    for (j = 0; j < NODES; j++)
      printf("%d\t",M[i][j]);
    printf("\n");
  }
}

int main(void) {
  int **flow, **capacities, i;
  flow = (int **) calloc(NODES, sizeof(int*));
  capacities = (int **) calloc(NODES, sizeof(int*));
  for (i = 0; i < NODES; i++) {
    flow[i] = (int *) calloc(NODES, sizeof(int));
    capacities[i] = (int *) calloc(NODES, sizeof(int));
  }

  // Sample graph
  capacities[0][1] = 2;
  capacities[0][2] = 9;
  capacities[1][2] = 1;
  capacities[1][3] = 0;
  capacities[1][4] = 0;
  capacities[2][4] = 7;
  capacities[3][5] = 7;
  capacities[4][5] = 4;

  printf("Capacity:\n");
  printMatrix(capacities);

  printf("Max Flow:\n%d\n", pushRelabel(capacities, flow, 0, 5));

  printf("Flows:\n");
  printMatrix(flow);

  return 0;
}
Python implementation
def relabel_to_front(C, source: int, sink: int) -> int:
    n = len(C)  # C is the capacity matrix
    F = [[0] * n for _ in range(n)]
    # residual capacity from u to v is C[u][v] - F[u][v]

    height = [0] * n  # height of node
    excess = [0] * n  # flow into node minus flow from node
    seen   = [0] * n  # neighbours seen since last relabel
    # node "queue"
    nodelist = [i for i in range(n) if i != source and i != sink]

    def push(u, v):
        send = min(excess[u], C[u][v] - F[u][v])
        F[u][v] += send
        F[v][u] -= send
        excess[u] -= send
        excess[v] += send

    def relabel(u):
        # Find smallest new height making a push possible,
        # if such a push is possible at all.
        min_height = 
        for v in range(n):
            if C[u][v] - F[u][v] > 0:
                min_height = min(min_height, height[v])
                height[u] = min_height + 1

    def discharge(u):
        while excess[u] > 0:
            if seen[u] < n:  # check next neighbour
                v = seen[u]
                if C[u][v] - F[u][v] > 0 and height[u] > height[v]:
                    push(u, v)
                else:
                    seen[u] += 1
            else:  # we have checked all neighbours. must relabel
                relabel(u)
                seen[u] = 0

    height[source] = n  # longest path from source to sink is less than n long
    excess[source] =   # send as much flow as possible to neighbours of source
    for v in range(n):
        push(source, v)

    p = 0
    while p < len(nodelist):
        u = nodelist[p]
        old_height = height[u]
        discharge(u)
        if height[u] > old_height:
            nodelist.insert(0, nodelist.pop(p))  # move to front of list
            p = 0  # start from front of list
        else:
            p += 1

    return sum(F[source])

References

[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
The push–relabel maximum flow algorithm, also known as the preflow-push algorithm, is a method for computing the maximum flow in a capacitated directed graph (flow network) from a source vertex to a sink vertex. It operates by initializing a preflow—a flow that satisfies capacity constraints but may violate conservation at intermediate vertices, creating excess flow—and then iteratively performing push operations to move excess along admissible edges and relabel operations to update vertex labels (or heights) when no push is possible, guiding flow downhill toward the sink until a valid maximum flow is achieved. Introduced by Andrew V. Goldberg and Robert E. Tarjan in their 1988 paper, the algorithm represents a departure from earlier augmenting path approaches, such as the Ford-Fulkerson method, by relaxing flow feasibility from the outset to enable local corrections rather than global path searches. Unlike augmenting path algorithms that maintain a feasible flow and repeatedly find source-sink paths in the residual graph, the push–relabel method ensures no path exists from source to in the residual graph throughout execution while restoring feasibility only at termination. This preflow-based strategy allows for efficient handling of dense graphs and supports parallel implementations. Key data structures include distance labels, which estimate shortest-path distances from vertices to the in the residual graph and ensure pushes reduce labels by at most one per edge, preventing cycles. The algorithm's phases typically involve selecting active vertices (those with excess) using rules like FIFO or highest-label priority to bound the number of operations. In terms of , the basic implementation runs in O(V³) time for a graph with V vertices, with at most O(V²) relabels and O(V³) pushes; an enhanced version using dynamic trees achieves O(VE log(V²/E)), where E is the number of edges, making it competitive across sparse and dense networks. Subsequent refinements, such as the highest-label selection rule, improve the bound to O(V²√E), establishing it as a benchmark for practical maximum flow computations.

Introduction

Algorithm overview

The push–relabel algorithm, also known as the preflow–push algorithm, is a method for computing the maximum flow in a by maintaining a preflow—a relaxation of a valid flow that allows excess flow at intermediate nodes—and using node labels to direct adjustments toward the . Introduced as an alternative to traditional augmenting path approaches, it initializes a preflow by saturating edges from the source and then iteratively refines it without requiring global path searches. At its core, the algorithm identifies nodes with excess flow and pushes portions of this excess along admissible edges, defined by the current , to neighboring nodes closer to the . When no admissible edges are available from a node with excess, the algorithm relabels the node by increasing its label to approximate the to the in the residual graph, thereby creating new admissible opportunities for pushing. This local adjustment process continues until all excesses are resolved, yielding a maximum flow. Unlike augmenting path methods, the push–relabel operates in-place on the network structure, updating flows and labels directly without explicitly constructing or traversing full paths from source to in each . This design avoids the overhead of repeated path-finding, making it particularly efficient for networks where such searches would be costly. In practice, the algorithm often outperforms path-based methods like Ford–Fulkerson on dense graphs, achieving a of O(n³) for n-vertex networks in its basic form, due to its ability to handle local operations scalably.

Relation to other maximum flow algorithms

The Ford–Fulkerson algorithm establishes the foundational approach to computing maximum flows by iteratively identifying augmenting paths in the residual graph and augmenting the flow along them until saturation, providing a flexible framework but without guaranteed polynomial runtime in general cases. The Edmonds–Karp implementation refines this method by employing breadth-first search to consistently select shortest augmenting paths, yielding polynomial-time performance and particular efficiency on sparse graphs where path lengths remain manageable. Dinic's algorithm builds on the augmenting path strategy by introducing level graphs—via from the source—to partition the network and compute blocking flows within each level, enabling multiple augmentations per phase and improving overall efficiency across varied network structures. Unlike these path-based methods, the push–relabel algorithm shifts to a preflow framework, where an initial feasible preflow is established, and excess flow is locally redistributed through push operations along admissible edges or relabel operations to update distance labels, avoiding global path searches and often achieving superior practical performance. Push–relabel particularly excels in dense networks, where its structure supports rapid excess propagation without the overhead of repeated path finding, whereas Edmonds–Karp demonstrates greater efficiency in sparse graphs due to its BFS-guided augmentations that minimize path exploration costs. Empirical studies confirm that preflow-push variants, including push–relabel, generally outperform augmenting path algorithms like and Edmonds–Karp across diverse problem classes.

History

Origins and development

The push–relabel maximum flow algorithm was introduced in 1986 by Andrew V. Goldberg and Robert E. Tarjan as a novel approach to computing maximum flows in directed graphs with capacities, building on the preflow concept originally developed by A. V. Karzanov in 1974. Their method sought to address the limitations of traditional path-augmenting algorithms, such as those by Ford and Fulkerson or Dinic, which often perform poorly on large-scale networks due to the repeated search for augmenting paths that can become computationally expensive as the flow increases. This work connected to earlier precursors in flow computation, notably the 1979 algorithm by Alon Itai and Yossi Shiloach for maximum flows in planar networks, which employed level-based pushing of flow excesses without full path augmentation, laying groundwork for local flow adjustments. Itai and Shiloach's technique highlighted the potential of non-path-based strategies for efficiency in restricted graph classes, influencing the generalization to arbitrary networks in the push–relabel framework. The algorithm was first presented at the 18th Annual ACM Symposium on Theory of Computing in 1986 and formally published in the Journal of the ACM in 1988, where Goldberg and Tarjan established a of O(V2E)O(V^2 E) for the generic , with a highest-label variant achieving O(V3)O(V^3) for dense graphs, demonstrating polynomial-time solvability without relying on augmenting paths. This bound marked a significant theoretical advancement, particularly for dense graphs.

Key contributors and publications

The push–relabel maximum flow algorithm was primarily developed by Andrew V. Goldberg during his PhD research at MIT, in collaboration with Robert E. Tarjan at Princeton, with the foundational ideas emerging from Goldberg's 1987 dissertation and culminating in their collaborative publication. The core algorithm was formally presented in the 1988 paper "A New Approach to the Maximum-Flow Problem," published in the Journal of the Association for Computing Machinery, where they introduced the preflow-push framework, basic operations, and initial time bounds including O(V^3) for a highest-label variant. In the , contributions from researchers such as Harold N. Gabow advanced the broader field of maximum flow algorithms through refined data structures and scaling methods, which influenced efficient implementations of push–relabel and related techniques. Gabow's 1985 paper "Scaling Algorithms for Network Problems" provided key insights into parameter scaling for network optimization, enabling faster handling of capacities and supporting subsequent refinements in flow computation. Early extensions focused on practical s, notably the gap relabeling technique introduced by U. Derigs and W. Meier in their 1989 computational study "Implementing Goldberg's Max-Flow Algorithm—A Computational Investigation." This detects gaps in values to accelerate relabeling, significantly improving empirical performance without altering the theoretical foundations. Subsequent works in the 1990s refined selection rules and implementations for better practicality. Boris V. Cherkassky and Andrew V. Goldberg's 1995 paper "On Implementing Push–Relabel Method for the Maximum Flow Problem," presented at the International Conference on and , analyzed operation orderings like highest-label first, leading to robust codes that achieved the O(V^3) bound in practice while outperforming prior variants on large instances. This publication emphasized the algorithm's evolution toward efficient, heuristic-driven versions suitable for real-world networks. The development and impact of push–relabel are comprehensively surveyed in the 1993 textbook Network Flows: Theory, Algorithms, and Applications by Ravindra K. Ahuja, Thomas L. Magnanti, and James B. Orlin, which dedicates a chapter to the algorithm, its variants, and 1990s advancements achieving improved practical speeds through combined heuristics and data structures. By the mid-1990s, these efforts had established push–relabel as a cornerstone method, with O(V^3) implementations and heuristic enhancements making it competitive for dense graphs up to thousands of vertices.

Core Concepts

Definitions and notation

The push–relabel algorithm operates on a , which is a G=(V,E)G = (V, E) consisting of a set of vertices VV and a set of directed edges EV×VE \subseteq V \times V, with a distinguished source vertex sVs \in V and vertex tVt \in V. Each edge (u,v)E(u, v) \in E is assigned a nonnegative real-valued capacity c(u,v)0c(u, v) \geq 0, while c(u,v)=0c(u, v) = 0 if (u,v)E(u, v) \notin E. A preflow in this network is a real-valued function f:V×VRf: V \times V \to \mathbb{R} that satisfies two conditions: the capacity constraint 0f(u,v)c(u,v)0 \leq f(u, v) \leq c(u, v) for all u,vVu, v \in V, and skew symmetry f(u,v)=f(v,u)f(u, v) = -f(v, u) for all u,vVu, v \in V. Unlike a standard flow, a preflow does not necessarily satisfy the flow conservation property at all vertices except ss and tt; instead, it allows for excess flow accumulation at intermediate vertices. The excess at a vertex vVv \in V under preflow ff is defined as ef(v)=uVf(u,v)e_f(v) = \sum_{u \in V} f(u, v), representing the net flow into vv. For all vsv \neq s, a valid preflow requires ef(v)0e_f(v) \geq 0. The residual graph Gf=(V,Ef)G_f = (V, E_f) with respect to a preflow ff has the same vertex set VV but an edge set Ef={(u,v)V×Vcf(u,v)>0}E_f = \{ (u, v) \in V \times V \mid c_f(u, v) > 0 \}, where the residual capacity is given by cf(u,v)=c(u,v)f(u,v)c_f(u, v) = c(u, v) - f(u, v). This formulation accounts for both forward edges and potential backward edges induced by the skew-symmetric flow. Standard notation for the algorithm includes n=Vn = |V| for the number of vertices and m=Em = |E| for the number of edges in the original network. Additionally, d(v)d(v) denotes the distance label (or height) assigned to each vertex vVv \in V.

Labels, excesses, and distances

In the push–relabel algorithm, the excess at a vertex vv, denoted e(v)e(v), quantifies the imbalance of flow at vv and is defined as the net flow into vv: e(v)=uVf(u,v)e(v) = \sum_{u \in V} f(u, v), where ff is the current preflow and VV is the set of vertices. This value is zero for a valid flow satisfying conservation at intermediate vertices but positive for excess flow at non-sink vertices in the preflow used by the algorithm; at the source, it is negative. The excess plays a central role in tracking deviations from flow conservation, with the algorithm aiming to reduce all positive excesses to zero except at the . Each vertex vv is assigned a label d(v)d(v), a non-negative that serves as an estimate of the shortest-path from vv to the tt in the residual graph. Initially, the labels are set such that d(t)=0d(t) = 0, d(s)=nd(s) = n where ss is the source and n=Vn = |V| is the number of vertices, and d(v)=0d(v) = 0 for all other vertices vs,tv \neq s, t. These initial labels provide a conservative starting point, ensuring d(s)d(s) is sufficiently large to bound potential increases while keeping other labels minimal. An admissible edge in the residual graph is a directed edge (u,v)(u, v) with positive residual capacity such that d(u)=d(v)+1d(u) = d(v) + 1. This condition enforces a strict decrease in labels along the edge, guiding flow pushes toward the sink along paths that mimic shortest paths in terms of label distances. Admissible edges thus restrict operations to "downhill" directions in the label landscape, preventing cycles and promoting progress toward resolving excesses. The algorithm maintains a validity condition on the labels to ensure correctness: for every vertex vs,tv \neq s, t with e(v)>0e(v) > 0, d(v)min{d(w)+1(v,w)Ef}d(v) \leq \min \{ d(w) + 1 \mid (v, w) \in E_f \}, where EfE_f denotes the edges in the residual graph. This guarantees that any vertex holding excess has at least one outgoing residual edge to a vertex with a label exactly one less, allowing potential reduction of the excess while preserving the overall label structure. The condition, combined with the global labeling property that d(u)d(v)+1d(u) \leq d(v) + 1 for all residual edges (u,v)(u, v), upholds the estimates' reliability throughout execution.

Basic Operations

Initialization

The initialization phase of the push–relabel algorithm establishes an initial preflow and labels to prepare the for subsequent operations. The flow function ff is set to zero on all edges, meaning f(u,v)=0f(u, v) = 0 for every edge (u,v)(u, v) in the network, ensuring no flow traverses the graph initially. labels are then assigned as follows: the source vertex ss receives label d(s)=nd(s) = n, where nn is the total number of vertices in the network, while all other vertices vsv \neq s are assigned d(v)=0d(v) = 0. This setup positions the source at a maximal , reflecting its role as the origin of flow, and initializes other nodes at the minimum level. To create an initial preflow, all outgoing edges from the source are saturated by setting f(s,v)=c(s,v)f(s, v) = c(s, v) for each neighbor vv of ss, where c(s,v)c(s, v) denotes the capacity of edge (s,v)(s, v); correspondingly, the reverse edges receive f(v,s)=c(s,v)f(v, s) = -c(s, v) to maintain antisymmetry in the residual graph. This saturation introduces excesses (defined as the net inflow imbalance at a node, as detailed in the section on labels, excesses, and distances) solely at the vertices adjacent to the source, with e(v)=c(s,v)e(v) = c(s, v) for those vv, while the sink has no excess and no flow has yet reached it. The resulting structure is a valid preflow with all excess concentrated near the source, setting the stage for flow propagation without violating capacity constraints.

Push operation

The push operation in the push–relabel algorithm is the primary mechanism for redistributing excess flow from an active vertex to one of its admissible neighbors in the residual graph, thereby progressing toward a valid maximum flow without violating network constraints. An admissible edge from vertex uu to vertex vv exists when the residual capacity cf(u,v)>0c_f(u,v) > 0 and the distance labels satisfy d(u)=d(v)+1d(u) = d(v) + 1. This operation is applicable when vertex uu (distinct from the source ss and sink tt) is active, meaning it has positive excess e(u)>0e(u) > 0 and a finite distance label d(u)<d(u) < \infty, and at least one admissible neighbor vv is available with cf(u,v)>0c_f(u,v) > 0. Upon selecting such a neighbor vv, the algorithm determines the push amount δ\delta as the minimum of the current excess at uu and the residual capacity along the edge: δ=min(e(u),cf(u,v)).\delta = \min\left(e(u), c_f(u,v)\right). This ensures that the push neither exhausts the excess at uu beyond zero nor saturates the edge prematurely if limited by capacity. The flow is then updated by augmenting δ\delta units along the edge: f(u,v)f(u,v)+δf(u,v) \leftarrow f(u,v) + \delta and f(v,u)f(v,u)δf(v,u) \leftarrow f(v,u) - \delta, where f(v,u)f(v,u) represents the flow on the reverse edge (potentially introducing negative flow to maintain antisymmetry). Simultaneously, the excesses are recalculated: e(u)e(u)δe(u) \leftarrow e(u) - \delta and e(v)e(v)+δe(v) \leftarrow e(v) + \delta. As a result, the push reduces the excess at the active vertex uu while transferring it to vv, preserving the overall preflow properties—such as non-negative excesses, capacity bounds, and flow antisymmetry—along with the validity of the distance labeling, where labels remain valid estimates that underestimate the shortest-path distances to the in the residual graph. This step maintains algorithmic progress by decreasing local imbalances without altering the total excess in the network.

Relabel operation

The relabel operation in the push–relabel algorithm is performed on an active node uu (i.e., a node distinct from the source ss and tt with excess e(u)>0e(u) > 0) when no admissible outgoing residual edges exist, meaning there is no neighbor ww such that the residual capacity cf(u,w)>0c_f(u, w) > 0 and the label satisfies d(w)=d(u)+1d(w) = d(u) + 1. This condition arises after repeated push operations have saturated all admissible edges from uu, preventing further flow discharge via pushes. To execute the relabel, the algorithm updates the label of uu to the smallest possible value that maintains label validity: d(u)min{d(w)+1(u,w)Ef,cf(u,w)>0},d(u) \leftarrow \min \{ d(w) + 1 \mid (u, w) \in E_f, \, c_f(u, w) > 0 \}, where EfE_f denotes the residual edges; if no such ww exists, then d(u)nd(u) \leftarrow n, with n=Vn = |V| representing infinity in this context. This computation scans the outgoing residual edges of uu to find the minimum over neighboring labels plus one, ensuring the new d(u)d(u) is a lower bound on the shortest-path distance from uu to the sink tt in the residual graph GfG_f. The relabel operation preserves the validity of labels as distance estimates, where for any node vv with d(v)<nd(v) < n, d(v)d(v) underestimates the distance to tt, and edges in GfG_f satisfy d(w)d(u)+1d(w) \leq d(u) + 1. Critically, each relabel strictly increases d(u)d(u) by at least 1, as the previous label was already the minimum possible before the update, which bounds the number of relabels per node to O(n)O(n) and the total across all nodes to O(n2)O(n^2). This monotonic increase unblocks the node by potentially creating new admissible edges in subsequent operations, allowing the algorithm to progress toward excess elimination at the sink.

Generic Algorithm

Algorithm description and pseudocode

The push–relabel algorithm, also known as the preflow-push algorithm, computes the maximum flow in a capacitated directed graph by maintaining a preflow—a relaxation of a flow that allows excess flow at vertices—and using distance labels to estimate shortest paths in the residual graph, guiding saturating pushes of excess toward the sink. The algorithm proceeds in two phases: initialization, which saturates all outgoing edges from the source to create initial excesses at neighboring vertices, and a refinement phase that iteratively reduces excesses at non-source, non-sink vertices through local operations until the preflow becomes a valid maximum flow. Initialization sets the preflow ff such that f(s,v)=c(s,v)f(s, v) = c(s, v) and f(v,s)=c(s,v)f(v, s) = -c(s, v) for all edges (s,v)(s, v) from the source ss, with f(u,w)=0f(u, w) = 0 otherwise; distance labels are set to d(s)=nd(s) = n (where nn is the number of vertices) and d(v)=0d(v) = 0 for all other vertices vv; excesses e(v)e(v) are then computed as the net inflow minus outflow at each vv. The refinement phase operates in a loop: while there exists an active vertex vv (i.e., vs,tv \neq s, t, e(v)>0e(v) > 0, and d(v)<nd(v) < n), select such a vv and invoke the discharge procedure on it. The discharge procedure for vv repeatedly applies the push operation to an admissible residual neighbor ww (where residual capacity rf(v,w)>0r_f(v, w) > 0 and d(v)=d(w)+1d(v) = d(w) + 1) if one exists, transferring δ=min(e(v),rf(v,w))\delta = \min(e(v), r_f(v, w)) units of flow and updating excesses and the preflow; otherwise, it applies the relabel operation, setting d(v)d(v) to min{d(w)+1rf(v,w)>0}\min\{d(w) + 1 \mid r_f(v, w) > 0\} (or nn if no such ww exists), until e(v)=0e(v) = 0 or d(v)nd(v) \geq n. These push and relabel operations, detailed in prior sections, ensure excess is propagated downhill along estimated shortest paths in the residual graph. The algorithm terminates when no active vertices remain, at which point the preflow ff is a maximum flow, with value equal to the net outflow from the source, e(s)-e(s). The following outlines the generic push–relabel algorithm, based on the original presentation.

procedure Initialize(V, E, s, t, c) for each vertex v ≠ s d(v) ← 0 d(s) ← |V| for each edge (u, v) ∈ E f(u, v) ← 0 f(v, u) ← 0 for each edge (s, v) ∈ E f(s, v) ← c(s, v) f(v, s) ← -c(s, v) for each vertex v ∈ V e(v) ← ∑_{u:(u,v)∈E} f(u, v) - ∑_{w:(v,w)∈E} f(v, w) procedure Push(v, w) δ ← min(e(v), r_f(v, w)) f(v, w) ← f(v, w) + δ f(w, v) ← f(w, v) - δ e(v) ← e(v) - δ e(w) ← e(w) + δ procedure Relabel(v) if there exists w such that (v, w) ∈ E_f d(v) ← min { d(w) + 1 | (v, w) ∈ E_f } else d(v) ← |V| procedure Discharge(v) while e(v) > 0 and d(v) < |V| if exists w such that (v, w) ∈ E_f and r_f(v, w) > 0 and d(v) = d(w) + 1 Push(v, w) else Relabel(v) procedure GenericPushRelabel(V, E, s, t, c) Initialize(V, E, s, t, c) while exists v ≠ s, t with e(v) > 0 and d(v) < |V| select such a v Discharge(v) return f // now a maximum flow

procedure Initialize(V, E, s, t, c) for each vertex v ≠ s d(v) ← 0 d(s) ← |V| for each edge (u, v) ∈ E f(u, v) ← 0 f(v, u) ← 0 for each edge (s, v) ∈ E f(s, v) ← c(s, v) f(v, s) ← -c(s, v) for each vertex v ∈ V e(v) ← ∑_{u:(u,v)∈E} f(u, v) - ∑_{w:(v,w)∈E} f(v, w) procedure Push(v, w) δ ← min(e(v), r_f(v, w)) f(v, w) ← f(v, w) + δ f(w, v) ← f(w, v) - δ e(v) ← e(v) - δ e(w) ← e(w) + δ procedure Relabel(v) if there exists w such that (v, w) ∈ E_f d(v) ← min { d(w) + 1 | (v, w) ∈ E_f } else d(v) ← |V| procedure Discharge(v) while e(v) > 0 and d(v) < |V| if exists w such that (v, w) ∈ E_f and r_f(v, w) > 0 and d(v) = d(w) + 1 Push(v, w) else Relabel(v) procedure GenericPushRelabel(V, E, s, t, c) Initialize(V, E, s, t, c) while exists v ≠ s, t with e(v) > 0 and d(v) < |V| select such a v Discharge(v) return f // now a maximum flow

Correctness

The push–relabel algorithm maintains the invariant that the current flow ff is always a preflow, meaning it respects edge capacities (0f(u,v)c(u,v)0 \leq f(u,v) \leq c(u,v) for all edges) and satisfies the excess condition (e(v)=uf(u,v)wf(v,w)0e(v) = \sum_{u} f(u,v) - \sum_{w} f(v,w) \geq 0 for all vertices vs,tv \neq s, t). This property holds initially after setting the preflow from the source and is preserved by the push and relabel operations, as pushes only occur along admissible residual edges without violating capacities, and relabels do not alter the flow. A second key invariant ensures the labels are feasible: for every vertex vv with e(v)=0e(v) = 0, the label d(v)d(v) satisfies d(v)distGf(v,t)d(v) \leq \mathrm{dist}_{G_f}(v, t), where distGf(v,t)\mathrm{dist}_{G_f}(v, t) is the shortest-path distance from vv to the sink tt in the residual graph GfG_f, and admissible edges (residual edges (v,w)(v,w) where d(v)=d(w)+1d(v) = d(w) + 1) respect the labeling condition d(v)d(w)+1d(v) \leq d(w) + 1. This feasibility is established by the initial labeling (with d(t)=0d(t) = 0 and d(v)=0d(v) = 0 for vtv \neq t, except d(s)=nd(s) = n) and maintained through operations, as pushes preserve shortest-path distances for zero-excess vertices and relabels update labels to values ≤ actual distances in the residual graph. The algorithm terminates because labels are bounded above by 2n12n - 1 (where nn is the number of vertices), each relabel operation strictly increases the label of some vertex, and the total number of such operations across all vertices is at most O(n2)O(n^2), leading to an overall bound of O(n2m)O(n^2 m) operations (with mm edges), after which no active vertices (those with e(v)>0e(v) > 0 and d(v)<nd(v) < n) remain. Upon termination, the preflow ff is a maximum flow because no augmenting path exists from ss to tt in GfG_f: if such a path existed, its vertices would form a sequence with non-increasing labels (due to the admissible edge condition), contradicting the feasibility invariant and the absence of active vertices that could initiate a push sequence toward tt. Moreover, the value of the flow equals the capacity of the minimum ss-tt cut defined by the sets S={vd(v)n}S = \{v \mid d(v) \geq n\} and T=VST = V \setminus S (with sSs \in S, tTt \in T), as no residual edges cross from SS to TT (labels in SS are n>\geq n > labels in T<nT < n; by the labeling lemma d(v)d(w)+1d(v) \leq d(w) + 1 for residual (v,w)(v, w), any such edge would require d(v)=nd(v) = n, d(w)=n1d(w) = n-1, but at termination no admissible edges exist from vertices in SS), and all excess has been pushed to tt.

Time complexity

The time complexity of the generic push–relabel algorithm is determined by bounding the number of push and relabel operations executed during its run. Each operation is assumed to take constant time when implemented with appropriate data structures, such as adjacency lists for examining admissible edges. Saturating pushes, which fill an edge to its residual capacity, occur at most O(nm)O(n m) times. This bound arises because each such push reduces the total excess flow in the network by at least 1 unit, and the initial total excess introduced during initialization is bounded by O(nm)O(n m) in the worst case, considering the structure of the flow network with nn vertices and mm edges. Non-saturating pushes, which partially reduce excess without saturating an edge, are bounded by O(n2m)O(n^2 m). This tighter analysis employs a potential function Φ=vs,td(v)\Phi = \sum_{v \neq s,t} d(v), where d(v)d(v) is the distance label of vertex vv. Each non-saturating push either decreases the excess at a vertex or increases Φ\Phi by at most 1, while relabels can increase Φ\Phi by at most O(n)O(n). Since Φ\Phi starts at 0 and is bounded above by O(n2)O(n^2), the total number of such pushes across all vertices is limited to O(n2m)O(n^2 m), as each push examines edges incident to a vertex. Relabel operations, which update a vertex's distance label to reflect the shortest path estimate to the sink, occur at most O(n2)O(n^2) times in total. For each vertex, the label d(v)d(v) is non-decreasing and increases by at least 1 each time it is relabeled, with the maximum possible value being 2n12n-1; thus, each of the nn vertices (excluding source and sink) can be relabeled at most 2n2n times. Combining these bounds, the overall time complexity of the generic algorithm is O(n2m)O(n^2 m), dominated by the non-saturating pushes. For networks with unit capacities on all edges, the analysis simplifies further, yielding an improved bound of O(n3)O(n^3), as the reduced excess propagation limits the number of operations per vertex.

Example

Step-by-step walkthrough

Consider a simple flow network with nodes ss (source), aa, bb, and tt (sink). The directed edges and their capacities are: sas \to a with capacity 4, sbs \to b with capacity 3, aba \to b with capacity 2, ata \to t with capacity 3, and btb \to t with capacity 2. The maximum flow in this network is 5. Initialization. Saturate the outgoing edges from the source to establish the initial preflow: set flow on sas \to a to 4 and on sbs \to b to 3. This yields excesses e(a)=4e(a) = 4 and e(b)=3e(b) = 3. The distance labels (heights) are set to d(s)=4d(s) = 4, d(a)=d(b)=d(t)=0d(a) = d(b) = d(t) = 0. The active nodes (with positive excess, excluding ss and tt) are aa and bb. Residual capacities are updated accordingly: cf(sa)=0cf(s \to a) = 0, cf(as)=4cf(a \to s) = 4; cf(sb)=0cf(s \to b) = 0, cf(bs)=3cf(b \to s) = 3; all other forward residuals remain at their capacities, with backward residuals at 0. Select active node aa for discharge (while e(a)>0e(a) > 0). With d(a)=0d(a) = 0, no admissible edges exist (requiring a neighbor ww with d(w)=d(a)1d(w) = d(a)-1 and positive residual capacity). Relabel aa: the neighbors with positive residual are ss (d=4d=4), bb (d=0d=0), and tt (d=0d=0); the minimum d(w)+1=1d(w) + 1 = 1, so d(a)=1d(a) = 1. Now admissible edges are to bb and tt (both d=0d=0, residuals 2 and 3). Select edge ata \to t for push: δ=min(4,3)=3\delta = \min(4, 3) = 3. Push 3 units: flow at=3a \to t = 3, e(a)=1e(a) = 1, update residuals cf(at)=0cf(a \to t) = 0, cf(ta)=3cf(t \to a) = 3. Still e(a)>0e(a) > 0; next admissible edge is aba \to b: δ=min(1,2)=1\delta = \min(1, 2) = 1. Push 1 unit: flow ab=1a \to b = 1, e(a)=0e(a) = 0, e(b)=4e(b) = 4; residuals cf(ab)=1cf(a \to b) = 1, cf(ba)=1cf(b \to a) = 1. Node aa is now inactive. Select active node bb for discharge (while e(b)>0e(b) > 0). With d(b)=0d(b) = 0, no admissible edges. Relabel bb: neighbors with positive residual are ss (d=4d=4, cf(bs)=3cf(b \to s)=3), tt (d=0d=0, cf(bt)=2cf(b \to t)=2), and aa (d=1d=1, cf(ba)=1cf(b \to a)=1); minimum d(w)+1=1d(w) + 1 = 1, so d(b)=1d(b) = 1. Now admissible edge is to tt (d=0d=0): δ=min(4,2)=2\delta = \min(4, 2) = 2. Push 2 units: flow bt=2b \to t = 2, e(b)=2e(b) = 2; residuals cf(bt)=0cf(b \to t) = 0, cf(tb)=2cf(t \to b) = 2. Still e(b)>0e(b) > 0, but no remaining admissible edges. Relabel bb: neighbors now ss (d=4d=4), aa (d=1d=1), tt (residual 0); minimum d(w)+1=2d(w) + 1 = 2, so d(b)=2d(b) = 2. Admissible edge is to aa (d=1d=1, cf(ba)=1cf(b \to a)=1): δ=min(2,1)=1\delta = \min(2, 1) = 1. Push 1 unit along backward edge bab \to a: reduce flow aba \to b to 0, e(b)=1e(b) = 1, e(a)=1e(a) = 1; residuals cf(ba)=0cf(b \to a) = 0, cf(ab)=2cf(a \to b) = 2. Still e(b)>0e(b) > 0, no admissible edges. Relabel bb: only ss (d=4d=4, residual 3); d(b)=5d(b) = 5. Admissible edge to ss (d=4d=4): δ=min(1,3)=1\delta = \min(1, 3) = 1. Push 1 unit along backward bsb \to s: reduce flow sbs \to b to 2, e(b)=0e(b) = 0; residuals cf(bs)=2cf(b \to s) = 2, cf(sb)=1cf(s \to b) = 1. Node bb is inactive. Now the only active node is aa (e(a)=1e(a) = 1, d(a)=1d(a) = 1). No admissible edges (to bb d=50d=5 \neq 0, to tt residual 0). Relabel aa: neighbors ss (d=4d=4, cf(as)=4cf(a \to s)=4), bb (d=5d=5, cf(ab)=2cf(a \to b)=2); minimum d(w)+1=5d(w) + 1 = 5, so d(a)=5d(a) = 5. Now admissible edge to ss (d=4d=4): δ=min(1,4)=1\delta = \min(1, 4) = 1. Push 1 unit along backward asa \to s: reduce flow sas \to a to 3, e(a)=0e(a) = 0; residuals cf(as)=3cf(a \to s) = 3, cf(sa)=1cf(s \to a) = 1. No active nodes remain. The final flow values are: sa=3s \to a = 3, sb=2s \to b = 2, at=3a \to t = 3, ab=0a \to b = 0, bt=2b \to t = 2. The value of the maximum flow is 5 (total outflow from ss). The residual graph has: cf(sa)=1cf(s \to a) = 1, cf(as)=3cf(a \to s) = 3; cf(sb)=1cf(s \to b) = 1, cf(bs)=2cf(b \to s) = 2; cf(ab)=2cf(a \to b) = 2, cf(ba)=0cf(b \to a) = 0; cf(at)=0cf(a \to t) = 0, cf(ta)=3cf(t \to a) = 3; cf(bt)=0cf(b \to t) = 0, cf(tb)=2cf(t \to b) = 2. All intermediate excesses are zero, confirming a valid maximum flow.
EdgeOriginal CapacityFinal FlowFinal Residual ForwardFinal Residual Backward
s → a4313
s → b3212
a → b2020
a → t3303
b → t2202

Flow network illustration

A standard illustrative example for the push–relabel algorithm uses a simple with four nodes: source ss, intermediate nodes vv and ww, and tt. The edges and their capacities are as follows: svs \to v with capacity 1, sws \to w with capacity 100, vwv \to w with capacity 100, vtv \to t with capacity 1, and wtw \to t with capacity 1. The initial network diagram can be visualized as:

s / \ 1 100 v w | \ | 1 100 1 | \ | t t

s / \ 1 100 v w | \ | 1 100 1 | \ | t t

Here, arrows represent directed edges with capacities labeled. After initialization, the preflow saturates the edges from ss, setting flow f(s,v)=1f(s,v) = 1 and f(s,w)=100f(s,w) = 100, resulting in excesses of 1 at vv and 100 at ww. Node labels (heights) are initialized as h(s)=4h(s) = 4, h(v)=h(w)=h(t)=0h(v) = h(w) = h(t) = 0. The evolution of the algorithm's state can be tracked through correct execution, but due to the large excess at ww, the full step-by-step trace is lengthy. In summary, the algorithm relabels vv to 1 and pushes its excess to ww or directly to tt, then processes ww by pushing to tt until saturated (1 unit), relabeling as needed, and returning excess back to ss via pushes and relabels. The net effect routes 1 unit through svts \to v \to t, 1 unit through swts \to w \to t, totaling maximum flow of 2 (limited by sink incoming capacities). For detailed steps, refer to the cited lecture notes, which illustrate the mechanism with similar parameters. This visualization underscores the algorithm's ability to identify the min-cut implicitly through label convergence. The min-cut is {s,v,w}\{s, v, w\} vs. {t}\{t\}, with capacity 1 + 1 = 2.

Practical Implementations

Data structures and discharge

The push–relabel algorithm relies on carefully designed data structures to implement push and relabel operations efficiently, ensuring that the overall remains practical despite potentially many iterations. The residual graph is typically represented using adjacency lists, where each vertex maintains a list of its outgoing residual edges along with associated capacities and current flow values. This structure allows O(1) access to residual capacities cf(u,v)=c(u,v)f(u,v)c_f(u,v) = c(u,v) - f(u,v) for potential pushes and supports dynamic updates as flow changes, using O(m) space where m is the number of edges. To avoid repeatedly scanning all outgoing edges from a vertex during discharge, the current-arc structure is employed. Each vertex stores a pointer to its "current arc," which is the last edge checked for a push operation, initializing to the first edge in the adjacency list. When attempting a push from vertex u, the algorithm starts from this current arc and advances the pointer only when no admissible push is possible, effectively amortizing the edge traversal cost over multiple operations and limiting full list scans to O(n) times per relabeling phase per vertex. This technique, analyzed to contribute O(nm) total time across all pushes, is crucial for implementations achieving O(n^3) or better bounds. The discharge operation integrates pushes and relabels for a single active vertex u (with excess e(u) > 0) in a loop until e(u) = 0 or no further progress is possible, systematically reducing excess by repeatedly selecting the current admissible edge for a push if the neighbor's is strictly lower, or advancing the current arc otherwise. If all edges are exhausted without reducing excess, a relabel occurs, resetting the current arc to the first edge. This combined procedure ensures that each discharge fully processes one vertex before moving on, with the following simplified illustrating its structure:

procedure discharge(u): while e(u) > 0: if current_arc(u) has an admissible neighbor v ([label](/page/Label)(u) > [label](/page/Label)(v) and c_f(u,v) > 0): push(u, v) else: advance current_arc(u) if no more edges from current_arc(u): relabel(u) reset current_arc(u) to first edge

procedure discharge(u): while e(u) > 0: if current_arc(u) has an admissible neighbor v ([label](/page/Label)(u) > [label](/page/Label)(v) and c_f(u,v) > 0): push(u, v) else: advance current_arc(u) if no more edges from current_arc(u): relabel(u) reset current_arc(u) to first edge

The operation's stems from O(1)-amortized time per push or arc advance, bounding total discharges by the number of active vertices. For managing active nodes (those with positive excess), a bucket-sort structure organizes them by label value to enable rapid selection of the highest-labeled active node, which is key for variants like highest-label selection. An array of buckets B[0..2n] is used, where B is a set (often a doubly-linked list) containing active nodes with i, and a pointer tracks the maximum i with non-empty B. Insertions and deletions occur in O(1) time by appending to the appropriate bucket, while selecting and removing the highest-labeled node involves checking from the current max downward until a non-empty bucket is found, followed by dequeuing its front element. This supports O(n^2) total active node operations across the algorithm, as each node enters and leaves buckets O(n) times due to label increases bounded by 2n.

Node selection rules

In the push–relabel algorithm, node selection determines which active node (one with positive excess flow) is chosen for discharge next, a choice that does not affect the algorithm's correctness but significantly influences practical by minimizing the number of relabel operations and optimizing the sequence of pushes. The generic rule allows selection of any active node, ensuring the preflow remains valid while progressing toward a maximum flow, though arbitrary choices can lead to excessive relabels and higher computational cost. Common heuristics prioritize nodes to reduce total work: the FIFO (first-in, first-out) rule maintains a queue of active nodes and processes them in the order they become active, promoting balanced workload distribution and often achieving O(nm) in practice, where n is the number of nodes and m is the number of edges. The highest-label rule selects the active node with the maximum distance label, focusing pushes on nodes closest to the and bounding nonsaturating pushes at O(n²√m), which enhances convergence and is particularly effective for dense networks. The relabel-to-front , when a node is relabeled, moves it to the front of the selection list (often combined with FIFO), improving cache efficiency by reusing recently updated nodes and further reducing iterations. These rules impact performance by improving cache locality—through sequential access in FIFO or localized updates in relabel-to-front—and distributing work to avoid bottlenecks, with empirical studies showing that well-chosen selections can yield near-linear running times on real-world networks despite worst-case bounds.

Optimization techniques

Several optimization techniques have been developed to enhance the practical performance of the push–relabel algorithm, addressing issues such as inflated distance labels that lead to inefficient relabel operations. These refinements focus on reducing the number of relabels and improving the efficiency of finding admissible edges, often at the cost of additional preprocessing or maintenance. Seminal implementations incorporate multiple such heuristics to achieve runtimes significantly better than the generic version's worst-case bounds. Gap relabeling is a that detects and skips "gaps" in the distance , where no active nodes exist at certain label values between 0 and nn (the number of vertices). When a gap is identified—such as no nodes with label gg where 0<g<n0 < g < n—all nodes with labels greater than or equal to gg are immediately relabeled to nn, marking them as unreachable from the sink and deactivating them without further processing. This avoids unnecessary relabel attempts on disconnected nodes and was independently proposed by Cherkassky and by Derigs and Meier. The technique can be implemented efficiently using a linked list or array to track nodes by label, with low overhead per detection, and it significantly improves runtime by ensuring most work on gaps is useful. In combination with other heuristics, gap relabeling contributes to a practical time complexity of O(nmlogn)O(n m \log n) for dense graphs. Global relabeling periodically recomputes exact shortest-path distances from all nodes to the sink in the current residual graph using a backward breadth-first search (BFS), resetting potentially inflated labels to their true values. This is performed after a fixed number of relabels, such as every nn operations, to prevent label values from growing excessively and causing redundant pushes. The BFS takes O(n+m)O(n + m) time per invocation, making it computationally intensive but effective in reducing the total number of relabels over the algorithm's execution. Introduced as a key refinement in efficient implementations, global relabeling complements gap relabeling by addressing broader label inaccuracies and has been shown to drastically improve practical performance on large instances. For networks with unit capacities (where all edge capacities are 1), optimizations treat such edges specially to accelerate push operations, as saturating a unit-capacity edge immediately removes it from consideration in the residual graph. In these "simple" networks, pushes on unit edges are simplified since the excess is typically small (at most 1 per node after initialization), and relabels are bounded more tightly due to the limited possible label increases. This leads to an overall time complexity of O(nm)O(\sqrt{n} \, m)
Add your contribution
Related Hubs
User Avatar
No comments yet.