A Computational Study of The Pseudoflow and Push-Relabel Algorithms For The Maximum Flow Problem PDF
A Computational Study of The Pseudoflow and Push-Relabel Algorithms For The Maximum Flow Problem PDF
Bala G. Chandran
Analytics Operations Engineering, Inc., Boston, Massachusetts 02109, [email protected]
Dorit S. Hochbaum
Department of Industrial Engineering and Operations Research, and Walter A. Haas School of Business,
University of California, Berkeley, California 94720, [email protected]
We present the results of a computational investigation of the pseudoflow and push-relabel algorithms for the maximum flow
and minimum s-t cut problems. The two algorithms were tested on several problem instances from the literature. Our results
show that our implementation of the pseudoflow algorithm is faster than the best-known implementation of push-relabel
on most of the problem instances within our computational study.
Subject classifications: flow algorithms; parametric flow; normalized tree; lowest label; pseudoflow algorithm;
maximum flow.
Area of review: Optimization.
History: Received January 2006; revisions received April 2007, December 2007; accepted March 2008. Published online
in Articles in Advance January 21, 2009.
Anderson and Hochbaum (2002) observed that pseudoflow is allowed to exceed its outflow. A node with strictly posi-
algorithms can sometimes be sped up significantly if started tive excess is said to be active.
with a good initial pseudoflow. Each node v is assigned a label lv that satisfies
The contribution of this paper is that we demonstrate (i) lt = 0, and (ii) lu lv + 1 if u v ∈ Af . A resid-
that our implementation of the highest-label pseudoflow ual arc u v is said to be admissible if lu = lv + 1.
algorithm with a generic initialization is faster than the Initially, all nodes are assigned a label of zero, and
best-known implementation of highest-level push-relabel source-adjacent arcs are saturated creating a set of source-
on most instance classes. adjacent active nodes (all other nodes have zero excess).
Additional information, including rights and permission policies, is available at http://journals.informs.org/.
INFORMS holds copyright to this article and distributed this copy as a courtesy to the author(s).
This paper is organized as follows: We establish our no- An iteration of the algorithm consists of selecting an active
tation in §2. We describe the push-relabel in §3, followed node in V , and attempting to push its excess to its neighbors
by the pseudoflow algorithm in §4. In §5, we show how the along an admissible arc. If no such arc exists, the node’s
pseudoflow and push-relabel algorithms can be initialized label is increased by one. The algorithm terminates with a
with a pseudoflow. We then present our experimental setup maximum preflow when there are no more active nodes with
in §6, followed by our results in §7. Section 8 contains label less than n. The set of nodes of label n then forms
concluding remarks. the source set of a minimum cut, and the current preflow is
maximum in that it sends as much flow into the sink node as
possible. This ends Phase 1 of the push-relabel algorithm.
2. Preliminaries In Phase 2, the algorithm transforms the maximum preflow
Let Gst be a graph Vst Ast , where Vst = V ∪
s t and into a maximum flow. In practice, Phase 2 is much faster
Ast = A ∪ As ∪ At , in which As and At are the source- than Phase 1. A high-level description of the push-relabel
adjacent and sink-adjacent arcs, respectively. The number algorithm is shown in Figure 1.
of nodes Vst is denoted by n, whereas the number of arcs In the highest-label and lowest-label variants, an active
Ast is denoted by m. A flow vector f =
fij i j∈Ast is said node with highest and lowest labels, respectively, are cho-
to be feasible if it satisfies: sen for processing at each iteration. In the FIFO variant, the
(i) Flow balance constraints: For each j ∈ V , i j∈Ast active nodes are maintained as a queue in which nodes are
fij = j k∈Ast fjk (i.e., inflow(j) = outflow(j)), and added to the queue from the rear and removed from the
(ii) Capacity constraints: The flow value is between the front for processing.
lower-bound and upper-bound capacity of the arc, i.e., The generic version of the push-relabel algorithm runs
lij fij uij . We assume henceforth that lij = 0. in On2 m time. Using the dynamic trees data structure of
A maximum flow is a feasible flow f ∗ that maximizes Sleator and Tarjan (1983), the complexity is improved to
the flow out of the source (or into the sink). The value of Onm logn2 /m.
Two heuristics that are employed in practice significantly
the maximum flow is s i∈As fsi∗ .
Given a capacity-feasible flow, an arc i j is said to be improve the running time of the algorithm:
a residual arc if i j ∈ Ast and fij < cij or j i ∈ Ast and 1. Gap relabeling: If the label of an active node is l and
fji > 0. For i j ∈ Ast , the residual capacity of arc i j there are no nodes of label l − 1, the sink is no longer re-
with respect to the flow f is cijf = cij − fij , and the residual achable through this node. The node is now known to be in
capacity of the reverse arc j i is cjif = fij . Let Af denote
the set of residual arcs for flow f in Gst , which are all arcs Figure 1. High-level description of Phase 1 of the
or reverse arcs with positive residual capacity. generic push-relabel algorithm.
A preflow is a flow vector that satisfies capacity con-
straints, but inflow into a node is allowed to exceed the /*
Generic push-relabel algorithm for maximum flow. The nodes
outflow. The excess of a node v ∈ V is the inflow into that
with label equal to n at termination form the source set of the
node minus the outflow denoted by ev = u v∈Ast fuv −
minimum cut.
v w∈Ast fvw . A pseudoflow is a flow vector that satis- */
fies capacity constraints but may violate flow balance in procedure push-relabel Vst Ast c:
either direction (inflow into a node need not equal outflow). begin
A negative excess is called a deficit. Set the label of s to n and that of all other
nodes to 0;
Saturate all arcs in As ;
3. The Push-Relabel Algorithm while there exists an active node u ∈ V of
The push-relabel algorithm was developed by Goldberg label less than n do
and Tarjan (1988). In this section, we provide a sketch of if there exists an admissible arc u v do
f
a straightforward implementation of the algorithm. For a Push a flow of min
eu cuv along arc u v;
more detailed description, see Ahuja et al. (1993). else do
Increase label of u by 1 unit;
The push-relabel algorithm works with preflows, i.e., a
end
flow that satisfies capacity constraints, but flow into a node
Chandran and Hochbaum: A Computational Study of the Pseudoflow and Push-Relabel Algorithms
360 Operations Research 57(2), pp. 358–376, © 2009 INFORMS
the source set, and this node and all its arcs are removed Although it is tempting to view the ability to maintain
from the graph for the rest of Phase 1 of the algorithm. pseudoflows as an important difference between the two al-
2. Global relabeling: The labels of the nodes are periodi- gorithms, it is trivial to modify the push-relabel algorithm
cally recomputed by finding the distance of each node from (as shown in §5) to handle pseudoflows.
the sink in the residual graph. This “tightens” the labels and The key difference between the pseudoflow and push-
leads to significantly improved performance in practice. relabel algorithms is that the pseudoflow algorithm allows
Once a minimum cut has been identified, a feasible flow to be pushed along arcs u v in which lu = lv,
flow is recovered by flow decomposition (discussed in §5). whereas this is not allowed in push-relabel. Goldberg and
Additional information, including rights and permission policies, is available at http://journals.informs.org/.
INFORMS holds copyright to this article and distributed this copy as a courtesy to the author(s).
In practice, the time for Phase 1 dominates the time for Rao (1998) proposed a maximum flow algorithm with com-
Phase 2. plexity superior to that of push-relabel that relied on being
able to send flow along arcs with lu = lv.
A node is said to be active if it has strictly positive Figure 3. Generic labeling pseudoflow algorithm.
excess. Given an admissible arc u v with nodes u and v
in different components, we define an admissible path to /*
be the path from rootu to rootv along the set of current Min-cut stage of the generic labeling pseudoflow algorithm. All
nodes in label-n components form the nodes in the source set of
arcs from rootu to u, the arc u v, and the set of current
the min-cut.
arcs (in the reverse direction) from v to rootv.
*/
We say that a component of the current forest is a label-n procedure GenericPseudoflow (Vst Ast c):
component if for every node v of the component lv = n. begin
Additional information, including rights and permission policies, is available at http://journals.informs.org/.
INFORMS holds copyright to this article and distributed this copy as a courtesy to the author(s).
We say that a component is a good active component if its SimpleInit (As At c);
root node is active and if it is not a label-n component. while ∃ a good active component T do
An iteration of the pseudoflow algorithm consists of Find a lowest labeled node u ∈ T ;
choosing a good active component and attempting to find if ∃ admissible arc u v do
Merger (rootu u v rootv);
an admissible arc from a lowest-labeled node u in this
else do
component. (Choosing a lowest-labeled node for processing lu ← lu + 1;
ensures that an admissible arc is never between two nodes end
of the same component.) If an admissible arc u v is
found, a merger operation is performed. The merger opera-
tion consists of pushing the entire excess of rootu toward
rootv along the admissible path and updating the excesses
Figure 4. Simple initialization in the generic labeling
and the arcs in the current forest to preserve Property 1. pseudoflow algorithm.
If no admissible arc is found, lu is increased by
one unit. A schematic description of the merger operation is /*
shown in Figure 2. The pseudocode for the generic labeling Saturates source- and sink-adjacent arcs.
pseudoflow algorithm is given in Figures 3 through 5. */
procedure SimpleInitAs At c:
begin
4.3. The Monotone Pseudoflow Algorithm f e ← 0;
In the generic labeling pseudoflow algorithm, finding the for each s i ∈ As do
ei ← ei + csi ;
lowest-labeled node within a component may take exces-
for each i t ∈ At do
sive time. The monotone implementation of the pseudoflow ei ← ei − cit ;
algorithm efficiently finds the lowest-labeled node within a for each v ∈ V do
component by maintaining an additional property of mono- lv ← 0;
tonicity among labels in a component. current v ← ;
end
Property 4 (Hochbaum 2008). For every current arc
u v, lu = lv or lu = lv − 1.
Figure 2. (a) Components before merger. (b) Before Figure 5. Push operation in the generic labeling
pushing flow along admissible path from ri to pseudoflow algorithm.
rj . (c) New components generated when arc
u v leaves the current forest due to insuf- /*
ficient residual capacity. Pushes flow along an admissible path and preserves invariants.
*/
rj procedure Merger (v1 vk ):
rj u begin
D
rj ri
ri for each j = 1 to k − 1 do
j D E
D A if evj > 0 do
u i j
C ← min
cvj vj+1 evj ;
i
E
v v C A evj ← evj − ;
B
j i F u v evj+1 ← evj+1 + ;
F B if evj > 0 do
C B ri
E F currentvj ← ;
Admissible arc else do
A
currentvj ← vj+1 ;
(a) (b) (c) end
Chandran and Hochbaum: A Computational Study of the Pseudoflow and Push-Relabel Algorithms
362 Operations Research 57(2), pp. 358–376, © 2009 INFORMS
This property implies that within each component, the cases, the only way u v can become admissible again is
root is the lowest-labeled node and node labels are nonde- for arc v u to belong to an admissible path, which would
creasing with their distance from the root. Given this prop- require lv lu, and then for node u to be relabeled at
erty, all the lowest-labeled nodes within a component form least once so that lu = lv + 1. Because lu is bounded
a subtree rooted at the root of the component. Thus, once a by n, u v can lead to On mergers. Because there are
good active component is identified, all the lowest-labeled Om residual arcs, the number of mergers is Onm.
nodes within the component are examined for admissible The work done per merger is On because an admissible
arcs by performing a depth-first search in the subtree start- path is of length On. Thus, total work done in mergers,
Additional information, including rights and permission policies, is available at http://journals.informs.org/.
INFORMS holds copyright to this article and distributed this copy as a courtesy to the author(s).
ing at the root. including pushes, updating the excesses, and maintaining
In the generic labeling algorithm, a node was relabeled the arcs in the current forest, is On2 m.
if no admissible arc was found from the node. In the Each arc u v needs to be scanned at most once for each
monotone implementation, a node u is relabeled only if no value of lu to determine if it is admissible because node
admissible arc is found and for all current arcs u v in labels are nondecreasing and lu lv + 1 by Property 3.
the component, lv = lu + 1. This feature, along with Thus, if arc u v were not admissible for some value of
the merger process, inductively preserves the monotonic- lu, it can become admissible only if lu increases. The
ity property. The pseudocode for the min-cut stage of the number of arc scans is thus Onm because there are Om
monotone implementation of the pseudoflow algorithm is residual arcs, and each arc is examined On times.
given in Figure 6. The work done in relabels is On2 because there are
The monotone implementation simply delays relabel- On nodes whose labels are bounded by n.
ing of a node until a later point in the algorithm, which Finally, we need to bound the work done in the depth-
does not affect correctness of the labeling pseudoflow first search for examining nodes within a component. Each
algorithm. time a depth-first search is executed, either a merger is
found or at least one node is relabeled. Thus, the number
of times a depth-first search is executed is Onm + n2 ,
4.4. Complexity Summary
which is Onm. The work done for each depth-first search
In the monotone pseudoflow implementation, the node is On; thus, total work done is On2 m.
labels in the admissible path are nondecreasing. To see that,
notice that for a merger along an admissible arc u v the Lemma 4.1. The complexity of the monotone pseudoflow
nodes along the path rootu u all have equal labels algorithm is On2 m.
and the nodes along the path v rootv have non- Regarding the complexity of the algorithm, Hochbaum
decreasing labels (from Property 4). A merger along an (2008) showed that an enhanced variant of the pseudoflow
admissible arc u v either results in arc u v becoming algorithm is of complexity Omn log n. That variant uses
current, or in u v leaving the residual network. In both dynamic trees data structure and is not implemented here.
Recently, however, Hochbaum and Orlin (2007) showed
that the highest-label version of the pseudoflow algorithm
Figure 6. The monotone pseudoflow algorithm.
has complexity Omn logn2 /m and On3 , with and
/*
without the use of dynamic trees, respectively.
Min-cut stage of the monotone implementation of the pseudoflow
algorithm. All nodes in label-n components form the nodes in 4.5. Lowest- and Highest-Label Variants
the source set of the min-cut. In the lowest-label pseudoflow algorithm, a good active
*/ component with the lowest-labeled root is processed at each
procedure MonotonePseudoflow (Vst Ast c):
iteration. In the highest-label algorithm, a good active com-
begin
ponent with the highest-labeled root node is processed at
SimpleInit (As At c);
while ∃ a good active component T with root r do each iteration.
u ← r;
while u = do 4.6. Implementation
if ∃ admissible arc u v do We now describe some details of our implementation. To
Merger (rootu u v rootv); maintain simplicity of the code, we do not use any sophis-
u ← ;
ticated data structures.
else do
if ∃w ∈ T currentw = u∧ lw = lu do 4.6.1. Limiting the Number of Arc Scans. During the
u ← w; labeling algorithm, the arcs adjacent to each node are exam-
else do ined at most once for each value of the node’s label. To
lu ← lu + 1; implement this, we maintain a pointer at each node to the
u ← currentu;
arc that was last scanned to find a merger. If any node is
end
visited more than once for a given label, the search for
Chandran and Hochbaum: A Computational Study of the Pseudoflow and Push-Relabel Algorithms
Operations Research 57(2), pp. 358–376, © 2009 INFORMS 363
0.1
Simple initialization
9100 41760 0111 0183 1000 1649 0126 0213 1000 1689
15488 71687 0208 0330 1000 1588 0234 0375 1000 1602
30589 143364 0587 0665 1000 1132 0652 0779 1000 1195
65536 311040 1395 1484 1000 1064 1512 1711 1000 1132
130682 625537 2935 5472 1000 1864 3325 6081 1000 1829
270848 1306607 7627 17509 1000 2295 8169 18582 1000 2275
651600 3170220 23483 73272 1000 3120 24893 76553 1000 3075
9100 41760 62168 65820 53765 38953 192386 384584
15488 71687 103083 117142 93847 69189 337308 656046
30589 143364 223333 228170 205848 137018 754240 1283615
65536 311040 542475 473126 511926 292081 1913935 2933002
130682 625537 1175273 1620216 1046223 1158262 3958944 11401882
270848 1306607 2650312 4685107 2564604 3381599 9808078 30466028
651600 3170220 7858941 16987429 6826351 13254386 26496009 131500478
mergers resumes from the last scanned arc, thus ensuring experimented with three root management policies:
that each arc is scanned at most once for each label. When 1. FIFO: Each bucket is maintained as a queue; roots
a node is relabeled, the pointer is reset to the start of its are added to the rear of the queue, and roots are retrieved
list of adjacent arcs. from the front of the queue.
2. LIFO: Each bucket is maintained as a stack; roots
are added to the top of the stack, and roots are retrieved
4.6.2. Root Management. The lowest- and highest-
from the top of the stack.
label variants require that all roots with positive excess and 3. Wave: This is a variant of the LIFO policy. Each
of a particular label be available when queried. To achieve bucket is still maintained as a stack, with roots being added
this, the roots are maintained in an array of buckets, where to the top of the stack and being retrieved from the top.
a bucket contains all roots with positive excess and with a However, when the excess of a root changes while it is in
particular label. The order in which roots within a bucket the bucket, it is moved up to the top of the stack.
are processed for mergers appears to make a difference to Note that the wave management policy is the same as the
the pseudoflow algorithm. Anderson and Hochbaum (2002) LIFO policy for the lowest-label variant because the excess
Chandran and Hochbaum: A Computational Study of the Pseudoflow and Push-Relabel Algorithms
364 Operations Research 57(2), pp. 358–376, © 2009 INFORMS
pseudo_hi_fifo
100 hi_pr
10
Simple initialization
8214 38813 0304 0679 1000 2229 0321 0735 1000 2292
16807 80262 0808 1920 1000 2375 0872 2078 1000 2384
32768 157696 2184 4540 1000 2079 2313 5668 1000 2450
63504 307440 4803 11575 1000 2410 5046 16255 1000 3221
123210 599289 14489 29938 1000 2066 15906 37209 1000 2339
259308 1267875 45228 84931 1000 1878 50007 107161 1000 2143
526904 2586020 99951 223596 1000 2237 102228 301137 1000 2946
8214 38813 318368 242160 79765 119899 324192 1264679
16807 80262 795596 610992 185494 302675 760255 3118748
32768 157696 1906289 1245410 385992 677448 1581645 7157116
63504 307440 4109525 2946034 850820 1627468 3509773 17566754
123210 599289 13924860 7446489 1798138 4018154 7442460 41840711
259308 1267875 40741173 19432456 3902188 10923983 16160617 117956644
526904 2586020 82202433 46445026 9423555 26388184 38835979 283460191
of a root with positive excess does not change while it is 4.7. Flow Recovery
in a bucket. (When a root is processed in the lowest-label The min-cut stage of the pseudoflow algorithm terminates
algorithm, all mergers are from a component with positive
with the minimum cut and a pseudoflow. Flow recovery
excess to one with nonpositive excess, leaving all other
roots with positive excess unchanged.) refers to the process of converting the pseudoflow at the end
of the min-cut stage to a maximum feasible flow.
4.6.3. Gap Relabeling. We use the gap-relabeling Given a feasible flow in a network, flow decomposition
heuristic of Derigs and Meier (1989), who introduced it in
refers to the process of representing the flow as the sum
the context of push-relabel. When we process a component
of flows along a set of s-t paths, and flows along a set
whose root has label l and there are no nodes in the graph
with label l − 1, we conclude that the entire component has of directed cycles, such that no two paths or cycles are
no residual paths to the sink and is hence a part of the source comprised of the same set of arcs (details are in Ahuja
set of a min cut. The entire component can thus be ignored et al. 1993, pp. 79–83). Hochbaum (2008) showed that flow
for the rest of the algorithm. In practice, this is achieved by recovery can be done in Om log n by flow decomposition
setting the labels of all nodes in that component to n. in a related network.
Chandran and Hochbaum: A Computational Study of the Pseudoflow and Push-Relabel Algorithms
Operations Research 57(2), pp. 358–376, © 2009 INFORMS 365
Figure 9. Run times and operation counts for AK instances with simple initialization.
AK scaling (simple initialization)
1,000
pseudo_hi_fifo
hi_pr
10
Simple initialization
8198 12295 0852 1806 1000 2120 0856 1810 1000 2114
16390 24583 3428 7520 1000 2194 3438 7534 1000 2191
32774 49159 16428 30876 1000 1879 16446 30906 1000 1879
65542 98311 76322 133248 1000 1746 76356 133310 1000 1746
131078 196615 317770 544794 1000 1714 317840 544926 1000 1714
8198 12295 2108420 2112487 10243 10245 16388 2141498
16390 24583 8411140 8419460 20483 20 485 32772 8478188
32774 49159 33599492 33615862 40963 40965 65540 33731795
65542 98311 134307844 134341737 81923 81925 131076 134576974
131078 196615 537051140 537116756 163843 163845 262148 537581429
An equivalent implementation of flow decomposition that Our experiments indicated that the time spent in flow
was used by Hochbaum (2008) starts with each excess node recovery is in most cases small compared to the time to
and performs a depth-first search in the reverse flow graph find the minimum cut.
(arcs with strictly positive flow) to identify paths back to the
source node or cycles, and decreases flow along these paths 5. Initialization for Push-Relabel and
or cycles until all excesses have been returned to the source. Pseudoflow Algorithms
For the strict deficit nodes, a depth-first search is performed As discussed in §4.1, the pseudoflow algorithm can be ini-
starting at each deficit node to find paths to the sink, and tialized with any pseudoflow and a corresponding current
flow is reduced along these paths until all deficits have been forest. In this section, we describe how to initialize both
returned to the sink. the pseudoflow and push-relabel algorithms with an arbi-
Our initial experiments indicated that this form of flow trary pseudoflow. We do this by constructing a graph
recovery is not very robust because this procedure could corresponding to the pseudoflow such that the min-cut and
end up finding several paths/cycles with relatively small max-flow can be obtained by solving the min-cut and max-
amounts of flow on them. To correct this, we use a different flow problems on this new graph.
approach that is theoretically less efficient, but is faster and For a pseudoflow f in the graph Gst = Vst Ast , we
more reliable in practice. construct a graph G , where pseudoflow f is feasible, by
Chandran and Hochbaum: A Computational Study of the Pseudoflow and Push-Relabel Algorithms
366 Operations Research 57(2), pp. 358–376, © 2009 INFORMS
Figure 10. Run times and operation counts for AK instances with saturate-all initialization.
AK Scaling (saturate-all initialization)
1
pseudo_hi_fifo
hi_pr
0.01
Saturate-all initialization
Minimum cut
adding the following arcs to Ast : This leads to the following claim:
1. A set of excess arcs denoted by As =
i s ∀ i ∈ V
ei > 0. Each arc i s has capacity cis = ei. Claim 5.1. The minimum cut in graph Gst initialized with
2. A set of deficit arcs denoted by At =
t i ∀ i ∈ V an arbitrary pseudoflow f can be obtained using any
ei < 0. Each arc t i has capacity cti = ei. minimum cut algorithm by solving for the minimum cut in
The capacities of all other arcs in G are the same as that the graph Gf .
in G, i.e., cij = cij ∀ i j ∈ Ast . Because only added arcs
are directed from the sink and into the source, the minimum To summarize, our initialization procedure, given a
cut partition in G is the same as that in Gst . pseudoflow f in Gst , is to generate the graph Gf , which
Let the flow vector f in G be obtained by setting has node set Vst and the following arcs:
fij = fij ∀ i j ∈ Ast and fij = cij ∀ i j ∈ As ∪ At . The
1. For each i j ∈ Ast with flow fij and capacity cij ,
flow f is feasible in G because flow balance is enforced at Af contains two arcs—an arc i j with capacity cij − fij
all nodes by construction. Hence, the residual graph Gf for and an arc j i with capacity fij .
this feasible flow will have the same minimum cut partition 2. For each node i ∈ V with excess ei > 0, Af con-
as that in G , and hence the same as that in Gst . tains the arc s i with capacity ei.
Chandran and Hochbaum: A Computational Study of the Pseudoflow and Push-Relabel Algorithms
Operations Research 57(2), pp. 358–376, © 2009 INFORMS 367
Figure 11. Run times and operation counts for acyclic dense (AC) instances.
AC scaling
10 pseudo_hi_fifo
hi_pr
0.1
0.01
0.001
256 512 1,024 2,048
Nodes
Simple initialization
256 32640 0005 0050 1000 10870 0007 0057 1000 8576
512 130816 0041 0369 1000 8903 0053 0395 1000 7489
1024 523776 0123 1862 1000 15189 0146 1968 1000 13481
2048 2096128 1149 9056 1000 7880 1342 9493 1000 7072
3. For each node i ∈ V with excess ei < 0, Af con- arcs As and At is zero. This flow vector is feasible to Gst
tains the arc i t with capacity ei. because:
We now show how to convert a maximum flow in Gf
1. The flows on As and At are zero, so these arcs can be
to a maximum flow in Gst . removed from G ; this gives us Gst .
2. Eliminating cycles preserves flow balance at all
Claim 5.2. Given a maximum flow in Gf , it is possible to nodes.
construct a maximum flow in Gst in Om log n time. 3. The flow f cij = cij for all arcs in Ast . Therefore,
Proof. Let the maximum flow in Gf be denoted by f ∗ .
reducing f will generate a capacity-feasible flow in Gst .
Because Gf is simply the residual graph corresponding to Further, because we only eliminated flows along cycles,
a feasible flow in G , the maximum flow in G is given by the resulting flow vector achieves the same total flow as the
fij + fij∗ − fji∗ for each arc i j ∈ A . maximum flow in G and is hence optimal to Gst .
Because we have a feasible flow, we decompose the max- G has at most m + n arcs and n nodes, so the total
imum flow in G into a set of simple paths and cycles. work done in flow decomposition is Omn. Using the
Because arcs in As ∪ At are either directed into the source dynamic trees data structure of Sleator and Tarjan (1983),
or out of the sink, they cannot belong to any of the sim- this can be improved to Om log n.
ple paths from s to t. Thus, the flows on arcs As and At
can only belong to the set of cycles in the decomposed 6. Experiments
flow. Eliminating the flow on all cycles that contain As This section describes our experimental setup and testing
and At , we obtain a flow vector such that the flow on the methodology.
Chandran and Hochbaum: A Computational Study of the Pseudoflow and Push-Relabel Algorithms
368 Operations Research 57(2), pp. 358–376, © 2009 INFORMS
Figure 12. Run times and operation counts for line-moderate instances.
Line-moderate scaling
10
pseudo_hi_fifo
hi_pr
0.1
Simple initialization
4098 65023 0038 0077 1000 2037 0045 0099 1000 2181
8194 187352 0124 0221 1000 1780 0164 0304 1000 1851
16386 522235 0252 0637 1000 2523 0294 0778 1000 2650
32770 1470491 0904 2002 1000 2215 1185 2651 1000 2238
65538 4186085 2215 6880 1000 3106 2852 8499 1000 2980
6.1. Implementations were written in C and compiled with the gcc compiler
We implemented five variants of the pseudoflow algorithm: using the -O4 optimization flag.
highest label with FIFO buckets (pseudo_hi_fifo), highest We performed the machine calibration experiment as sug-
label with LIFO buckets (pseudo_hi_lifo), highest label with gested by DIMACS (2007). Table 1 shows the running times
wave buckets (pseudo_hi_wave), lowest label with FIFO for the two tests with and without compiler optimization.
buckets (pseudo_lo_fifo), and lowest label with LIFO buck-
ets (pseudo_lo_lifo). The latest version of the code (ver- 6.3. Problem Classes
sion 3.21) is available at Pseudoflow solver (Chandran and
The problem instances we use are the well-known gener-
Hochbaum 2007).
ators used in DIMACS (1990) and are available as part
The implementation of the highest-level push-relabel
algorithm hi_pr (version 3.6) was obtained from Goldberg
(2007). This implementation is an improvement over the Table 1. Average running times for Dimacs machine
h_prf implementation by Goldberg and Cherkassky calibration tests.
(1997), which was previously considered to be the best
Test 1 Test 2
implementation of push-relabel.
Real User System Real User System
6.2. Computing Environment
The experiments were run on a Sun UltraSPARC worksta- No optimization 04 04 00 33 33 00
-O4 flag 02 01 00 20 19 00
tion with a 270 MHz CPU and 192 MB of RAM. All codes
Chandran and Hochbaum: A Computational Study of the Pseudoflow and Push-Relabel Algorithms
Operations Research 57(2), pp. 358–376, © 2009 INFORMS 369
Figure 13. Run times and operation counts for RLG-Long instances.
RLG-Long scaling
pseudo_hi_fifo
10
hi_pr
0.1
16,386 32,770 65,538 131,074 262,146 524,290 1,048,578
Nodes
Simple initialization
16386 49088 0164 0272 1000 1653 0188 0310 1000 1653
32770 98240 0319 0484 1000 1517 0357 0548 1000 1535
65538 196544 0687 1073 1000 1562 0778 1220 1000 1568
131074 393152 1449 2054 1000 1417 1646 2365 1000 1437
262146 786368 2744 3863 1000 1408 3156 4472 1000 1417
524290 1572800 6771 7318 1000 1081 7637 8614 1000 1128
1048578 3145664 12867 12007 1072 1000 14552 14195 1025 1000
16386 49088 95273 146351 80491 49978 191360 424079
32770 98240 176177 278940 154187 97107 362301 826264
65538 196544 343385 580581 327157 207667 757382 1757393
131074 393152 678708 1096443 693000 386306 1587599 3303730
262146 786368 1285622 1995391 1294217 699376 2957115 6080414
524290 1572800 2498234 3711744 2689543 1283366 6081694 11327436
1048578 3145664 4797765 6087748 5058970 1969792 11425647 18228497
of CATS (2007). Unless otherwise stated, the instance A network with n = 2x nodes is generated using parameters
generated depends on a random seed. These problem a = 2x/4 and b = 2x/2 .
classes are: • GENRMF-Wide: This family is created by the
• AC: The acyclic dense network family with parame- RMFGEN generator. A network with n = 2x nodes is gen-
ter k has n = 2k nodes and nn + 1/2 arcs. erated using parameters a = 22x/5 and b = 2x/5 .
• AK: The AK generator was designed by Goldberg and • Washington RLG-Long: A network with n = 2x
Cherkassky (1997) as a hard set of instances for push-relabel nodes in this family is generated by the Washington gen-
and Dinic’s (1970) algorithms. Given a parameter k, the pro- erator using function = 2, arg1 = 64, arg2 = 2x−6 , and
gram generates a unique network with 4k + 6 nodes and arg3 = 104 .
6k + 7 arcs. The instance does not depend on a random seed • Washington RLG-Wide: A network with n = 2x
in that the graph, given the number of nodes, is unique. nodes in this family is generated by the Washington gen-
• GENRMF-Long: This family is created by the erator using function = 2, arg1 = 2x−6 , arg2 = 64, and
RMFGEN generator of Goldfarb and Grigoriadis (1988). arg3 = 104 .
Chandran and Hochbaum: A Computational Study of the Pseudoflow and Push-Relabel Algorithms
370 Operations Research 57(2), pp. 358–376, © 2009 INFORMS
Figure 14. Run times and operation counts for RLG-Wide instances.
RLG-Wide scaling
100
pseudo_hi_fifo
hi_pr
0.1
Simple initialization
8194 24448 0101 0168 1000 1666 0114 0188 1000 1652
16386 48896 0234 0437 1000 1872 0257 0474 1000 1841
32770 97792 0624 1293 1000 2072 0680 1375 1000 2022
65538 195584 1719 3521 1000 2049 1843 3691 1000 2002
131074 391168 4299 11163 1000 2597 4627 11506 1000 2487
262146 782336 10135 30838 1000 3043 11181 31618 1000 2828
524290 1564672 26488 78538 1000 2965 30359 80322 1000 2646
8194 24448 59204 100287 45181 35101 110922 291507
16386 48896 127923 230186 91458 81527 226446 670912
32770 97792 276483 587053 201804 216799 496752 1753941
65538 195584 588634 1296152 456952 482079 1108638 3882692
131074 391168 1303234 3345024 979796 1291646 2372407 10169333
262146 782336 2723785 7895722 2105484 3137422 5060915 24296062
524290 1564672 5780423 18368338 5081726 7440283 11899792 56996936
• Washington Line-Moderate: A network with n = 2x s-t cut problem in a so-called “closure” graph where all
nodes in this family is generated by the Washington source-adjacent and sink-adjacent arcs have finite capacity,
generator using function = 6, arg1 = 2x−2 , arg2 = 4, and and all other arcs have infinite capacity.
arg3 = 2x/2−2 . The instance generator creates graphs from the following
• Maximum Closure: A set of nodes D ⊆ V in a four inputs:
directed graph G = V A is called closed if all the succes- 1. n: number of nodes in the graph.
sors of nodes in D are also contained in D. The maximum 2. p: probability of existence of each arc i j. Note that
closure problem is stated as follows: given a directed graph this could create cycles in the graph.
G = V A, and node weights (positive, negative, or zero) 3. w: probability that each node is weighted. Given that
bi for all i ∈ V , find a closed subset V ⊆ V such that
a node is weighted, its weight is an integer uniformly dis-
j∈V bj is maximum. The maximum closure problem has tributed in %−10000 10000&.
many applications such as open-pit mining (Picard 1976). 4. s: a random seed to initialize the random number
The maximum closure problem reduces to a minimum generator.
Chandran and Hochbaum: A Computational Study of the Pseudoflow and Push-Relabel Algorithms
Operations Research 57(2), pp. 358–376, © 2009 INFORMS 371
Table 2. Relative running times of highest- and lowest-label pseudoflow algorithms on “small” instances.
Highest label Lowest label
Figure 15. Results for low-density closure instances (arc density 0.5%).
Closure scaling (low density, 1% of nodes weighted)
pseudo_hi_fifo
1 1% of nodes weighted
hi_pr
Time (CPU seconds)
Minimum cut
0.1
n m Pseudoflow Push-relabel Pseudoflow Push-relabel
pseudo_hi_fifo
1
10% of nodes weighted
hi_pr
Minimum cut
Time (CPU seconds)
pseudo_hi_fifo
100% of nodes weighted
hi_pr
Time (CPU seconds)
1 Minimum cut
Figure 16. Results for medium-density closure instances (arc density 5%).
Closure scaling (medium density, 1% of nodes weighted)
pseudo_hi_fifo
1% of nodes weighted
1 hi_pr
Minimum cut
Time (CPU seconds)
Figure 17. Results for high-density closure instances (arc density 50%).
Closure scaling (high density, 1% of nodes weighted)
roughly the same number of pushes and relabels, push- work (equivalent to flow decomposition) needs to be done
relabel performs a significantly larger number of arc scans. to recover the maximum flow in the original graph.
The run time of both algorithms decreases signifi- An AK instance is an acyclic network in which saturating
cantly when the saturate-all initialization is used, as shown all arcs preserves flow balance for many nodes. This results
in Figure 10. We report only the time to minimum cut for in a residual network in which a large number of nodes are
this initialization because the transformation described in §5 unreachable from the source and/or from which the sink is
preserves only the minimum cut in the graph and additional unreachable, which makes the problem easy to solve.
Chandran and Hochbaum: A Computational Study of the Pseudoflow and Push-Relabel Algorithms
Operations Research 57(2), pp. 358–376, © 2009 INFORMS 375
7.4. Acyclic Dense Among the different pseudoflow variants, the highest-
The pseudoflow implementation is significantly faster than label algorithm was in general faster and more robust across
push-relabel on all instance sizes; we observe that push- different problem families than the lowest-label algorithm.
relabel performs significantly many more arc scans and This is similar to past findings for push relabel (for example,
pushes. We noticed that the number of pushes per merger by Ahuja et al. 1997) in which the lowest-label variant was
was comparable to the number of nodes (for the largest found to be slower than the highest-label variant.
instances, it is 40%–50% of the number of nodes). We We observed that the number of relabels performed by
suspect that these long push sequences (along arcs in push-relabel was generally greater than that of pseudoflow,
Additional information, including rights and permission policies, is available at http://journals.informs.org/.
INFORMS holds copyright to this article and distributed this copy as a courtesy to the author(s).
which both end points possibly have the same label) are in spite of the global relabeling heuristic used in push-
responsible for pseudoflow’s good performance. relabel. One possible explanation is that pseudoflow allows
pushes along arcs where both ends of the arc have the
same label. Such arcs would be inadmissible in push-
7.5. Line Moderate
relabel, needing at least one relabel to push flow along such
The pseudoflow implementation is again faster on all an arc.
instances due to fewer arc scans. This was one of only two
families where pseudoflow performed more relabels.
Endnote
7.6. RLG-Long 1. We thank an anonymous referee for proposing this
description.
Push-relabel scales better than pseudoflow with problem
size, although it is better than pseudoflow only in the
largest instances. This was one of only two families where Acknowledgments
pseudoflow performed more relabels. This research was supported in part by NSF award no.
DMI-0620677.
7.7. RLG-Wide
Pseudoflow is faster in all instances in addition to scaling
better than push-relabel. The operation counts do not pro- References
vide much insight into the differences between the two Ahuja, R. K., T. L. Magnanti, J. B. Orlin. 1993. Network Flows Theory,
Algorithms, and Applications. Prentice-Hall, Englewood Cliffs, NJ.
algorithms.
Ahuja, R. K., M. Kodialam, A. K. Mishra, J. B. Orlin. 1997. Computa-
tional investigations of maximum flow algorithms. Eur. J. Oper. Res.
7.8. Maximum Closure 97(3) 509–542.
Anderson, C., D. S. Hochbaum. 2002. The performance of the pseudo-
We report the results of our instances on nine classes of flow algorithm for the maximum flow and minimum cut problems.
graphs: three values of density of weighted nodes in the Manuscript, University of California, Berkeley.
graph (1%, 10%, and 100%), and three values of arc densi- Anderson, R. J., J. C. Setubal. 1993. Goldberg’s algorithm for the maxi-
ties (0.05%, 5%, and 50%) for each of the weight densities. mum flow in perspective: A computational study. D. S. Johnson, C. C.
We report only the time to the minimum cut because the McGeoch, eds. Network Flows and Matching First DIMACS Imple-
mentation Challenge. American Mathematical Society, Providence,
maximum closure problem, by definition, is only to solve RI, 1–18.
for the minimum cut. CATS: Combinatorial Algorithms Test Sets. 2007. Retrieved January
The pseudoflow code is faster across all closure instances, 2007, http://www.avglab.com/andrew/CATS/gens/.
and it scales better for the low-density instances. The only Chandran, B., D. S. Hochbaum. 2007. Pseudoflow solver. Retrieved Jan-
observation we made from the operation counts was that uary 2007, http://riot.ieor.berkeley.edu/riot/Applications/Pseudoflow/
while the number of pushes and relabels were roughly the maxflow.html.
same for both implementations, push-relabel performed an Derigs, M., W. Meier. 1989. Implementing Goldberg’s max-flow algo-
rithm—A computational investigation. ZOR—Methods and Models
order of magnitude more arc scans than pseudoflow. Oper. Res. 33 383–403.
DIMACS. 1990. The first DIMACS algorithm implementation chal-
8. Conclusions lenge: The core experiments. Retrieved October 2004, http://dimacs.
rutgers.edu/pub/netflow/general-info/.
The highest-label pseudoflow implementation is faster than Dinic, E. A. 1970. Algorithm for the solution of a problem of maximal
push-relabel on all but the largest instances of one problem flow in networks with power estimation. Soviet Math. Doklady 11
class (RLG-Long). Our work is of significance because it 1277–1280.
was widely accepted until now that push-relabel was the Ford, L. R., D. R. Fulkerson. 1956. Maximal flow through a network.
Canadian J. Math. 8 339–404.
fastest algorithm in practice for the maximum flow prob-
Goldberg, A. V. 2007. Andrew Goldberg’s network optimization library.
lem. Because the min-cut and max-flow are of interest
Retrieved January 2007, http://www.avglab.com/andrew/soft.html.
both as stand-alone problems and as subroutines in other Goldberg, A. V., B. V. Cherkassky. 1997. On implementing the push-
algorithms, our implementation could be used to efficiently relabel method for the maximum flow problem. Algorithmica 19
solve a wide range of problems. 390–410.
Chandran and Hochbaum: A Computational Study of the Pseudoflow and Push-Relabel Algorithms
376 Operations Research 57(2), pp. 358–376, © 2009 INFORMS
Goldberg, A. V., S. Rao. 1998. Beyond the flow decomposition barrier. Hochbaum, D. S., J. B. Orlin. 2007. The pseudoflow algorithm in
J. ACM 45(5) 783–797. Omn logn2 /m and On3 . Manuscript, University of California,
Goldberg, A. V., R. E. Tarjan. 1988. A new approach to the maximum Berkeley.
flow problem. J. ACM 35(4) 921–940. Lerchs, H., I. Grossman. 1965. Optimum design of open pit mines. Trans.,
Goldfarb, D., M. Grigoriadis. 1988. A computational comparison of the Canadian Inst. Mining and Metallurgy 68 17–24.
Dinic and network simplex algorithms for maximum flow. Ann. Oper. Picard, J. 1976. Maximal closure of a graph and applications to combina-
Res. 13 83–123. torial problems. Management Sci. 22 1268–1272.
Hochbaum, D. S. 2008. The pseudoflow algorithm: A new algorithm for Sleator, D. D., R. E. Tarjan. 1983. A data structure for dynamic trees.
the maximum flow problem. Oper. Res. 56(4) 992–1009. J. Comp. System Sci. 26 362–391.
Additional information, including rights and permission policies, is available at http://journals.informs.org/.
INFORMS holds copyright to this article and distributed this copy as a courtesy to the author(s).