Push–relabel maximum flow algorithm

From Wikipedia, the free encyclopedia
  (Redirected from Relabel-to-front algorithm)
Jump to: navigation, search

In mathematical optimization, the push–relabel algorithm (alternatively, preflow–push algorithm) is an algorithm for computing maximum flows. 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 vertices 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(V2E) time complexity, which is asymptotically more efficient than the O(VE2) Edmonds–Karp algorithm.[2] Specific variants of the algorithms achieve even lower time complexities. The variant based on the highest label vertex selection rule has O(V2E) time complexity and is generally regarded as the benchmark for maximum flow algorithms.[3][4] Subcubic O(VE log (V2/E)) time complexity can be achieved using dynamic trees, although in practice it is less efficient.[2]

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]

Concepts[edit]

Definitions and notations[edit]

Main article: Flow network

Consider a flow network G(V, E) with a pair of distinct vertices s and t designated as the source and the sink, respectively. For each edge (u, v) ∈ E, c(u, v) ≥ 0 denotes its capacity; if (u, v) ∉ E, we assume that c(u, v) = 0. A flow on G is a function f: V × VR satisfying the following conditions:

Capacity constraints
f(u, v) ≤ c(u, v) ∀u, vV
Skew symmetry
f(u, v) = −f(v, u) ∀u, vV
Flow conservation
v ∈ V f(v, u) = 0 ∀uV \ {s, t}

The push–relabel algorithm introduces the concept of preflows. A preflow is a function with a definition almost identical to that of a flow except that it relaxes the flow conservation condition. Instead of requiring strict flow balance at vertices other than s and t, it allows them to carry positive excesses. Put symbolically:

Nonnegative excesses
e(u) = ∑v ∈ V f(v, u) ≥ 0 ∀uV \ {s}

e(s) is assumed to be infinite. A vertex u is called active if e(u) > 0.

For each (u, v) ∈ V × V, denote its residual capacity by cf(u, v) = c(u, v) − f(u, v). The residual network of G with respect to a preflow f is defined as Gf(V, Ef) where Ef = {(u, v) | u, vVcf(u, v) > 0}. If there is no path from any active vertex to t in Gf, the preflow is called maximum. In a maximum preflow, e(t) is equal to the value of a maximum flow; if T is the set of vertices from which t is reachable in Gf, and S = V \ T, then (S, T) is a minimum s-t cut.

The push–relabel algorithm makes use of distance labels, or heights, of the vertices denoted by h(u). For each vertex uV \ {s, t}, h(u) is a nonnegative integer satisfying

Valid labeling
h(u) ≤ h(v) + 1 ∀(u, v) ∈ Ef

The heights of s and t are fixed at |V| and 0, respectively. h(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 (h(u) − |V|) is a lower bound of the unweighted distance from u to s. As a result, if a valid height function exists, there are no s-t paths in Gf because no such paths can be longer than (|V| − 1).

An edge (u, v) ∈ Ef is called admissible if h(u) = h(v) + 1. The network f(V, f) where f = {(u, v) | (u, v) ∈ Efh(u) = h(v) + 1} is called the admissible network. The admissible network is acyclic.

Operations[edit]

Push[edit]

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

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

A push operation that causes f(u, v) to reach c(u, v) is called a saturating push; otherwise, it is called an unsaturating push. After an unsaturating push, e(u) = 0.

Relabel[edit]

The relabel operation applies on an active vertex u without any admissible out-edges in Gf. It modifies h(u) to the minimum value such that an admissible out-edge is created. Note that this always increases h(u) and never creates a steep edge (an edge (u, v) such that cf(u, v) > 0, and h(u) > h(v) + 1).

relabel(u):
    assert e[u] > 0 and h[u] <= h[v] ∀v such that f[u][v] < c[u][v]
    h[u] = min(h[v] ∀v such that f[u][v] < c[u][v]) + 1

Effects of push and relabel[edit]

After a push or relabel operation, h remains a valid height function with respect to f.

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

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

The generic push–relabel algorithm[edit]

Description[edit]

Since h(s) = |V|, h(t) = 0, and there are no paths longer than (|V| − 1) in Gf, in order for h(s) to satisfy the valid labeling condition, s must be disconnected from t. At initialization, the algorithm fulfills this requirement by creating a preflow f that saturates all out-edges of s, after which h(u) = 0 is trivially valid for all vV \ {s, t}.

After initialization, the algorithm repeatedly executes an applicable push or relabel operation until no such operations apply, at which point the preflow has been converted into a maximum flow.

generic-push-relabel(G(V, E), s, t):
    create a preflow f that saturates all out-edges of s
    let h[u] = 0 ∀v ∈ V
    while there is an applicable push or relabel operation
        execute the operation

Correctness[edit]

Because push and relabel operations preserve the validity of preflow f and height function h, when the algorithm terminates, there are no active vertices other than s and t, and thus the preflow becomes a valid flow. Since it is also guaranteed throughout that there are no s-t paths in residual network Gf, the algorithm terminates with a maximum flow.

Time complexity[edit]

We bound the numbers of relabels, saturating pushes and nonsaturating pushes separately. Because 0 ≤ h(u) ≤ 2n − 1 for every vertex u, and each relabel increases h(u) by at least one, the total number of relabels on all vertices is O(V2). Each saturating push on an admissible edge (u, v) removes the edge from Gf. For the edge to be reinserted into Gf for another saturating push, v must be first relabeled, followed by a push on edge (v, u), then u must be relabeled. In the process, h(u) increases by at least two. Therefore, there are O(V) saturating pushes on (u, v), and the total number of saturating pushes on all edges is O(VE).

Bounding the number of nonsaturating pushes can be achieved via a potential argument. We use the potential function Φ = ∑u ∈ V ∧ e(u) > 0 h(u), i.e., Φ is the sum of the heights of all active vertices. It is obvious that Φ is |V| initially and stays nonnegative throughout the execution of the algorithm. Both relabels and saturating pushes can increase Φ. Relabels increase h(u) by O(V) for every vertex u and thus contribute O(V2) increase to Φ. A saturating push on (u, v) activates v if it was inactive before the push, increasing Φ by O(V). Hence, the total contribution of all saturating pushes is O(V2E). An unsaturating 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 h(u) − h(v) = 1. Since relabels and saturating pushes increase Φ by O(V2 + V2E) = O(V2E), the total number of unsaturating pushes is O(V2E).

In sum, the algorithm executes O(V2) relabels, O(VE) saturating pushes and O(V2E) 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(V2E).[1]

Practical implementations[edit]

While the generic push–relabel algorithm has O(V2E) time complexity, efficient implementations achieve O(V3) 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-edge" data structure and discharge operation[edit]

The "current-edge" data structure is a mechanism for visiting the in- and out-neighbors of a vertex in the flow network in a static circular order. If a singly linked list of neighbors is created for a vertex, 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-edge" 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 edges in the process.

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

Active vertex 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 vertices in the following discussion.

FIFO selection rule[edit]

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

The algorithm has O(V3) time complexity.

Relabel-to-front selection rule[edit]

The relabel-to-front push–relabel algorithm[1] organizes all vertices 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 vertex 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(V3) time complexity.

Highest label selection rule[edit]

The highest-label push–relabel algorithm[7] organizes all vertices into buckets indexed by their heights. The algorithm always selects an active vertex with the largest height to discharge.

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

Implementation techniques[edit]

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

The algorithm is typically separated into two phases. Phase one computes a maximum preflow by discharging only active vertices whose heights 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.[8]

Heuristics are crucial to improving the empirical performance of the algorithm.[9] Two commonly used heuristics are the gap heuristic and the global relabeling heuristic.[2][10] The gap heuristic detects gaps in the height function. If there is a height 0 < < |V| for which there is no vertex u such that h(u) = , then any vertex u with < h(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 heights of the vertices. 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]

References[edit]

  1. ^ a b c Cormen, T. H.; Leiserson, C. E.; Rivest, R. L.; Stein, C. (2001). "§26 Maximum flow". Introduction to Algorithms (2nd ed.). The MIT Press. pp. 643–698. ISBN 0262032937. 
  2. ^ a b c d e Goldberg, A. V.; Tarjan, R. E. (1986). "A new approach to the maximum flow problem". Proceedings of the Eighteenth Annual ACM Symposium on Theory of Computing — STOC '86. pp. 136–146. doi:10.1145/12130.12144. ISBN 0897911938.  edit
  3. ^ a b Ahuja, R. K.; Kodialam, M.; Mishra, A. K.; Orlin, J. B. (1997). "Computational investigations of maximum flow algorithms". European Journal of Operational Research 97 (3): 509–542. doi:10.1016/S0377-2217(96)00269-X.  edit
  4. ^ a b c Goldberg, A. V. (2008). "The partial augment-relabel algorithm for the maximum flow problem". Algorithms — ESA 2008. Lecture Notes in Computer Science 5193. pp. 466–477. doi:10.1007/978-3-540-87744-8_39. ISBN 978-3-540-87743-1.  edit
  5. ^ Goldberg, A. V. (1997). "An efficient implementation of a scaling minimum-cost flow algorithm". Journal of Algorithms 22: 1–29. doi:10.1006/jagm.1995.0805.  edit
  6. ^ Ahuja, R. K.; Orlin, J. B. (1991). "Distance-directed augmenting path algorithms for maximum flow and parametric maximum flow problems". Naval Research Logistics 38 (3): 413–430. doi:10.1002/1520-6750(199106)38:3<413::AID-NAV3220380310>3.0.CO;2-J.  edit
  7. ^ Cheriyan, J.; Maheshwari, S. N. (1988). "Analysis of preflow push algorithms for maximum network flow". Foundations of Software Technology and Theoretical Computer Science. Lecture Notes in Computer Science 338. pp. 30−48. doi:10.1007/3-540-50517-2_69. ISBN 978-3-540-50517-4.  edit
  8. ^ Ahuja, R. K.; Magnanti, T. L.; Orlin, J. B. (1993). Network Flows: Theory, Algorithms, and Applications (1st ed.). Prentice Hall. ISBN 013617549X.  edit
  9. ^ Cherkassky, B. V.; Goldberg, A. V. (1995). "On implementing push-relabel method for the maximum flow problem". Integer Programming and Combinatorial Optimization. Lecture Notes in Computer Science 920. pp. 157−171. doi:10.1007/3-540-59408-6_49. ISBN 978-3-540-59408-6.  edit
  10. ^ Derigs, U.; Meier, W. (1989). "Implementing Goldberg's max-flow-algorithm — A computational investigation". Zeitschrift für Operations Research 33 (6): 383–403. doi:10.1007/BF01415937.  edit