Also known as: push-relabel algorithm or Goldberg-Tarjan algorithm
Algorithmic problem: max-flow problem (standard version)
Type of algorithm: loop.
- A nonnegative integral value for each node .
- Each node has a current arc, which may be implemented as an iterator on the list of outgoing residual arcs of .
- The excess of a node with respect to the current preflow.
- A (dynamically changing) set of nodes.
Invariant: Before and after each iteration:
- For each arc , it is . If all upper bounds are integral, all -values are integral, too.
- For each node , it is . In other words, is a preflow.
- The node labels form a valid distance labeling, and it is .
- The currently active nodes are stored in .
- The current arc of a node is an outgoing arc of the node's in the residual graph. In the list of all of these arcs, no admissible arc precedes the current arc.
Variant: No label is ever decreased. In each iteration, one of the following three actions will take place:
- The label of at least one node is increased.
- A saturating push is performed.
- The value of decreases.
Break condition: .
- For all arcs , set .
- For each arc , overwrite this value by and put into .
- Compute a valid distance labeling for with respect to , for example, the true distances from all nodes to in the residual network of .
- Set .
- For all , reset the current arc of so as to point to the first arc in the list of outgoing arcs of .
Proof: For the subgraph induced by , the arguments in the correctness proof for the Ahuja-Orlin algorithm prove that the -labels form a valid distance labeling here as well. For , nothing is to show because all outgoing arcs are saturated.
- Choose an active node from .
- While the current arc of is not void and not admissible either, move the current arc one step forward.
- If the current arc of is not void now but an (admissible) outgoing arc , say:
- If and and , insert in .
- Increase the flow over by the minimum of and the residual capacity of .
- Increase by that value and decrease by the same value.
- If now, extract from .
- Let denote the minimal label of any arc in the residual network.
- Set .
- Reset the current arc of so as to point to the beginning of the list of outgoing arcs of .
Remark: The preflow-push algorithm is also known as the push-relabel algorithm. The push operation is step 3; the relabel operation is step 4.
Proof: Points 1, 2, and 4 of the invariant and are obviously fulfilled. The rest of point 3 of the invariant is affected by step 4 only, and the outgoing arcs of are the only arcs where the distance labeling may become invalid. However, the extremely conservative increase of ensures point 3 of the invariant.
To prove the variant, consider a step in which neither any -value is increased nor a saturating push is performed. This means step 3.2 is applied, but the arc is not saturated by that. Potentially, becomes active. However, definitely becomes inactive since the push step is non-saturating. Now the variant follows from the fact that for an admissible arc .
It remains to show termination; this is proved by the following complexity considerations.
Statement: The asymptotic complexity is in , where and .
Proof: First we show that the total number of relabel operations (step 4 of the main loop) is in . To see that, let be an active node between two iterations of the main loop. A straightforward induction over the number of push operations shows that there is at least one simple -path with positive flow on all arcs. The transpose of is augmenting. Due to the validity of (induction hypothesis), cannot be larger than the number of arcs on , which is not larger than . Therefore, no node label can be larger than . Since node labels are nonnegative and increase at least by one in each relabel operation, the claimed upper bound on the relabel operations follows.
From this bound, we may immediately conclude that the current arc of a node is reset times, so the total number of forward steps of the current arcs of all nodes is in .
Finally, we consider the non-saturating push operations. First note that before and after each iteration. The value of is increased in each relabel operation exactly by the amount by which the label of the current node is increased. Since node labels are never decreased and bounded from above by , increases by less than in total over all relabel operations. On the other hand, a saturating push operation may increase by at most (namely, in the case that was not active immediately before the push). In summary, the total sum of all values by which is increased throughout the algorithm is in . Due to the variant, the value of is decreased by at least one in each non-saturating push operation. This proves the claim.
Heuristic speedup techniques
- After iterations of the main loop, the -values are recomputed analogously to the induction basis: as the current distance of each node to in the residual network. This modification is seldom enough, so the asymptotic complexity is not increased. In practice, this technique may save many unnecessary relabel steps.
- The main loop may be decomposed into two phases: First, as much flow as possible is sent into ; second, all surplus flow that cannot reach is sent back to . The first phase may be finished once there is no more path in the residual network from any active node to . A sufficient and easy-to-check condition for that is for all active nodes . All nodes from which is reachable may be safely disregarded in the second phase. For any other node, to save unnecessary relabel operations, the distance label may be safely increased to the minimum number of arcs in the residual network from this node back to .