HD28 .M414 Oe^'«cey ALFRED P. WORKING PAPER SLOAN SCHOOL OF MANAGEMENT A FAST AND SIMPLE ALGORITHM FOR THE MAXIMUM FLOW PROBLEM R. K. Ahuja and James B. Orlin Sloan W.P. No. 1905-87 June 1987 Revised: March 1988 MASSACHUSETTS INSTITUTE OF TECHNOLOGY 50 MEMORIAL DRIVE CAMBRIDGE, MASSACHUSETTS 02139 A FAST AND SIMPLE ALGORITHM FOR THE MAXIMUM FLOW PROBLEM R. K. Ahuja and James B. Orlin Sloan W.P. No. 1905-87 June 1987 Revised: March 1988 M.I.T. LIBRARIES A Fast and Simple Algorithm for the Maximum Flow Problem Ravindra K. Ahuja* and James B. Orlin Sloan School of Management Massachusetts Institute of Technology Cambridge, MA. 02139 USA , Abstract We present a simple 0(nm + n log U) flow problem on a network with n bounded by U. n , Under factor of log nodes, m in time 0(nm 0(nm + n and integer arc arcs, the practical assumption that our algorithm runs previous best bound of sequential algorithm for the log U is polynomially bounded * On in This result improves the n). log {vr/m)), obtained by Goldberg and Tarjan structures. Subject Classification A capacities , by a n for networks that are both non-sparse and non-dense without using any complex data 484. maximum Fast and Simple Algorithm for the Maximum Flow Problem leave from Indian Institute of Technology, Kanpur - 208 016 , INDIA The maximum flow problem one of the most fundamental problems is network flow theory and has been investigated extensively. This problem was in first formulated by Fulkerson and Dantzig [1955] and Dantzig and Fulkerson [1956], and solved by Ford and Fulkerson [1956] using their well-known augmenting path algorithm. number Since then, a of algorithms problem; some of them are tabulated below. In the m is the number of arcs, and U have been developed table, n is the number for this of nodes, an upper bound on the integral arc capacities. The is algorithms whose time bounds involve U assume integral capacities, whereas others run on arbitrary rational or real capacities. Due # Running Time to 1 Ford and Fulkerson [1956] O(nmU) 2 Edmonds and Karp CXnm^) 3 Dinic [1970] 0(n^) 4 Karzanov [1974] 0(n3) 5 Cherkasky[1977] CXn^^^) 6 Malhotra. 7 Galil[1980] 8 Galil and 9 Shiloach and Vishkin 10 Sleator and Taijan [1983] 0(nm 11 Tarjan[1984] CXn^) 12 Gabow 0(nm 13 Goldberg [1985] 0{n3) 14 Goldberg and Tarjan [1986] 0(nm 15 Cheriyan and Maheshwari [1987] 16 Ahuja and Oilin [1987] 17 Ahuja, Orlin and Tarjan [1987] Table 1. [1972] Kumar and Maheshwari Naamad 0(nm log^ [1980]; Shiloach [1978] log n) log U) log (n^An)) 0(nm + n^ Running times of the [1972] algorithm runs in time O(nm^) if n) 0(n3) [1982] [1985] Edmonds and Karp source to sink. CXn^) [1978] maximum flow showed that the log U) algorithms. Ford and Fulkerson [1956] flows are augmented along shortest paths from Independently, Dinic [1970] introduced the concept of shortest path and obtained an O(n^m) algorithm. This bound networks, called layered networks, was improved O(n^) by Karzanov [1974] in a layered into a to A network. preflow is who introduced the concept of preflows amount flowing similar to a flow except that the node may exceed the amount flowing out of a node. Since then, researchers have improved the complexity of Dinic's algorithm for sparse networks by devising sophisticated data structures. Among dynamic the tree data structure The algorithms of is these contributions, Sleator most attractive and Tarjan's [1983] from a worst case point of view. Goldberg [1985] and of Goldberg and Tarjan [1986] were a novel departure from these approaches in the sense that they do not construct Their method maintains a preflow, as per Karzanov, and layered networks. proceeds by pushing flows to nodes estimated to be closer to the sink. which nodes are closer to the sink, lower bound on the length of it To estimate maintains a distance label for each node that a shortest augmenting path is a Distance labels to the sink. are a better computational device than layered networks because the labels are simpler to understand, easier to manipulate, algorithm. use in a parallel to Moreover, by cleverly using the dynamic tree data structure, Goldberg and Tarjan obtained the networks. and easier best computational complexity for sparse as well as dense (For applications of distance labels to augmenting path algorithms, see Orlin and Ahuja [1987].) For problems with arc capacities polynomially bounded in n flow algorithm is Edmonds and Karp flow problem and later extended by . Gabow The bottleneck operation Goldberg and Tarjan's algorithm O(n^) is [1972] for the [1985] for other clever application of the the number dynamic minimum to 0(nm We show 0(n^ log U) by using algorithm modifies the Goldberg-Tarjan algorithm as follows. which sufficiently large excesses to that the number excess scaling. performs It nodes with while never allowing the excesses to become too time of our algorithm is 0(nm + n'^ log U). large. is log (n^/m)) by a each scaling iteration requires O(n^) non-saturating pushes push flows from nodes with cost implementation of of non-saturating pushes tree data structure. non-saturating pushes can be reduced to excesses maximum network optimization in the straightforward However, they reduce the computational time scaling iterations; our an improvement of Goldberg and Tarjan's algorithm and uses concepts of scaling introduced by problems. , of Our log if U we sufficiently small The computational Under n) 0(nm our algorithm runs in time , non-dense and non-sparse, m i.e., + = GCn'"*"^ for some log (vr/m)) on such networks by a factor of log n. implement and should be more easier to < with e e < 1, our 0(nm), which improves Goldberg and Tarjan's bound of algorithm runs in time 0(nm U=0(n^^^b (i.e., it is polynomialin n'^ log n). On networks that are both the reasonable assumption that elementary data structures with Moreover, our algorithm efficient in practice, since it is requires only computational overheads. little Notation 1. Let every arc G W, = A) be a directed network vdth a positive integer capacity e A. Let (i, j) n = N I m= A and I I We distinguished nodes of the network. from source of the paths detected in no arcs but 0(m) Let e A: Uj; < U= "^a^ (s, j) A I {j: (j, i) We . We further (i, j) flow network contains some Xji x I - : therefore e A) (j: I {j: (j, A— R assume have that all arcs finite capacity, t) satisfying » = X|j , (i, j) Xjf for aU i 6 N - (s, t), (1) e A) = v , Ujj , (2) € A) < xjj none infinite capacity A a function that such a path can be easily ««) is e A, an arc assume {"sjl e are two then the capacity of such arcs can be replaced by infinite capacity path, Ujj the if t no arcs directed into the that for every arc to sink has infinite capacity as Observe that time. V {(i, j) assumed and sink s loss of generality that the that there are also contained in A, possibly with zero capacity. is (j, i) also It is The source . assume without network does not contain multiple arcs and source or directed from the sink. I Uj; for < for all (i, j) e A , (3) for some V is v > The maximum flow problem . determine a flow x for which maximized. A x preflow is following relaxation of I (j: to is a function I > Xj| e A) (), i) A— R which > : satisfies (2) , (3), and the (1): - Xjj x (j: , for all N- e i (4) (s, t). e A} (i, j) The algorithms described in paper maintain this preflow a at each intermediate stage. For a given preflow x = Cj (j,i)€ {j: A The given by active. maximum (j, define for each node A) i). rjj = - + xj; the node i, referred to as an to any arc Xjj e The network consisting only of Figure i.e., A(i) : = {(i, A k) € of it nodes d distance function : N^ CL CZ d(t) d(i) = < Z"*" . node to i of arc node (i, j) + 1 node i e list is represents the (i, j) N is as the set of arcs directed out of We say (i, j) list is a set of arcs rather as a set of nodes. for a preflow for every arc define the illustrates these definitions. x is a function that a distance function two conditions: , We using the arcs j ; d(j) . with respect to a given preflow x k € N}. Note that our adjacency to the non-negative integers also satisfies the following the excess arcs with positive residual capacities A(i) of a list : 1 than the more conventional definition of the A A additional flow that can be sent from define the arc adjacency , consequently, these nodes are never be zero; (i, j) active node The residual capacity . referred to as the residual network. We is and sink nodes uj; t} aj)e A) {j: residual capacity of N - (s, e i Xjj 2, node with positive excess excess of the source and - Xjj 2- we , € A vdth Tj; > . from the d is set valid if a. Network with Node sink. 1 is arc capacities. the source and node 4 is the (Arcs with zero capacities are not shown.) b. c. Figure 1. Network with preflow x The residual network with residual arc capacities Illustrations of a preflow and the residual network Our algorithm maintains refer to d(i) as the distance label of that d(i) a lower is residual network. bound on Let < d(i2 any path ) + d(i2 1, ) i < d(i3 ) of length k shortest path too. any path from If to i - node for each - • • • 1(c), -i^^ + i, d= - dCij^) 1 i\^+i < = to i in the t be any path of length k t dUi^^;, ) + 1 = 1. This yields d(i) in the minimum the distance label d(i) equals the network, then we call = for for the length of the distance label exact. a valid distance label, is d(i) <k network and, hence, must also hold (0, 0, 0, 0) also easy to demonstrate using induction Then from condition C2 we have, to the sink. in the residual t It is i. the length of the shortest path from i2 in the residual For example, in Figure 0) i-| node residual network from d(i|) = i We a valid distance function at each iteration. though d = (3, 1, 2, represents the exact distance labels. d(i) = An arc d(j) + (i, 1. j) An in the residual arc which network not admissible is called is is admissible if it satisfies called an inadmissible arc. The algorithms discussed in this paper push flow only on admissible arcs. All logarithms in this paper are assumed to be of base 2 unless stated otherwise. Preflow-Push Algorithms 2. The preflow-push algorithms preflow The at first maximum flow problem maintain a every step and proceed by pushing the node excesses closer to the sink. preflow-push algorithm suggested a simplified version of [1985] for the and Goldberg and Tarjan is due to Karzanov The recent algorithms this algorithm. [1986] are [1974]. Tarjan [1984] based on ideas similar of has Goldberg to those presented in Tarjan [1984], but use distance labels to direct flows closer to the sink instead of constructing layered networks. preflow-push algorithm. We refer to their algorithm as the (distance-directed) In this section, algorithm, which for the sake of brevity, algorithm. Here we describe the presented by Goldberg [1987]. The we we review the basic features of their shall simply refer to as the preflow-push 1-phase version of the preflow-push algorithm results in this section are due to Goldberg and Tarjan [1986]. All operations of the preflow-push algorithm are performed using information. At each iteration of the algorithm (except only local at the initialization and at . 8 termination) the network contains at least one active node, The goal non-sink node with positive excess. active node and to send i.e., of each iterative step and a non-source to is choose some excess "closer" to the sink, with closer being judged with its respect to the current distance labels. nodes with smaller distance If excess flow at this node can not be sent to then the distance label of the node labels, The algorithm terminates when the network contains no increased. is The active nodes. preflow-push algorithm uses the following subroutines: PRE-PROCESS. On each and d(t) = Let . arc d(i) labeling can be used, = (s, j) 1 e A(s) for each node t. Select an active node PUSH(i). Select an admissible arc flow from node RELABEL(i). t node i to i Replace is (i, j) Send 6 = min in A(i). is (i, j) saturating if d(i) by nunf d(j) + 1 The (i : , j) e A(i) and (e^ , 6 = rj: rj: ) , units of and of the preflow-push algorithm is given below. PRE-PROCESS; an active node do begin is SELECT there {let is i denote the node selected}; an admissible arc else RELABEL(i); > ). is to which further pushes can be performed. PREFLOW-PUSH; there r^j result of the relabel step begin end; can be t i called a relabel step. The generic version end; s, j. create at least one admissible arc on if ^t otherwise. This step while any valid (Alternatively, . search on the residual network first say that a push of flow on arc non-saturating algorithm i^ s or ) SELECT. We send Ugj units of flow. Let d(s) = n the distance label for each e.g., determined by a backward breadth starting at , in A(i) then PUSH(i) d(3)=l d(l) =4 The (a) d(4) d(2) = 62 =2 1 residual network after the pre-processing step. d(3) d(l) = 1 =4 d(4) d(2) = Co = (b) = = l 1 After the execution of step PUSH(2). d(3) = 1 e3=4 d(l) (c) Figure = 4 (T d(4) After the execution of step 2. Illustrations of = RELABEL(2). Push and Relabel steps. 10 network Figure in and min{ node 2 network 2, 1} 1 , the excess of from the residual network and arc node 2 3) is still and an active node, condition. (4, 2) min {d(3) + 1 , to s immediate. length of the to the residual 1 5 = of value 1. Arc (2,4) to = r24 deleted is network. Since d(l) + 1} = min (2, node 2 =2 {2, 5} a new . several important tasks. First, causes the it have positive excess, so that we can subsequently execute the Third, since minimum push RELABEL(2), and gives Second, by saturating arcs incident select step. is to The SELECT but they do not satisfy the distance capacities, The pre-process step accomplishes nodes adjacent node 2 added is Hence the algorithm performs distance d'(2) = residual capacity. step. a saturating to the can be selected again for further pushes. The arcs it have positive residual (2, 1) PRE-PROCESS after the the algorithm performs The push reduces units. its for examination. Since arc (2, 4) has residual capacity = d(4) + d(2) RELABEL(i) as applied The number beside each arc represents 1(a). Figiire 2(a) specifies the residual step selects and PUSH(i) illustrates the steps Figure 2 the distance label path from to s t , to , the feasibility of setting d(s) = n d(s) = there since distance labels are non-decreasing (see s n is a lower no path from is Lemma 1 s to to follow), bound on t the Further, . we are also guaranteed that in subsequent iterations the residual network will never contain a directed path from s to t, and so there can never be any need to push flow from s again. In our improvement results given in order to Lemma make 1. each step. we need of the preflow-push algorithm, Goldberg and Tarjan more this presentation [1986]. We include some a few of the of their proofs in self-contained. The generic preflow-push algorithm maintains valid distance labels at Moreover, at each relabel step the distance label of some node strictly increases. Assume Proof. First note that the pre-process step constructs valid distance labels. inductively that the distance function to be satisfied. (j, i) valid prior to an operation, and C2 A push operation on the with Tjj > and an additional condition the validity conditions Cl additional arc is . arc , (i, j) d(j) < This validity condition remains satisfied since d(i) = property of the push operation. A push operation on arc (i, j) i.e., it satisfies may create an d(i) + + needs 1 1 by the might delete this arc d(j) 1 1 from the residual network, but During function. d'(i) = min{d(j) + 1: with 0} = = d(j)+l and d(i) d'(i) Lemma , e A(i) and relabel step rj: > > r^: 0) which , l: no arc is (i, j) At any stage 2. of the prefloiv-push algorithm, for each node a directed path is from By the flow decomposition theory of non-negative flows along (i) node to i of preflow X in G. , each arc reversed) in is Then the i. in the residual i (ii) G paths from s from > , with any , into the to s sum to active nodes, to the in the flow i P (P vAth the orientation of and hence there a path is from i to the residual network. Corollary 1. Proof. The For each node last e i time node i N , was d(i) < 2n. relabeled, had it that d(s) Lemma = n and condition C2 imply that d(i) a positive excess, n - residual network contained a path of length at most < d(s) + n - The number of 2. relabel steps is less than 2n^ Proof. Each relabel step increases the distance label of a Corollary 1 Corollary 3. Proof. from 1 1 < i no node can be relabeled more than 2n Suppose The number of saturating pushes that arc (i, j) becomes saturated +1). Then no more flow can be sent on (i, j) and hence the to s. The fact 2n. empty 2 also implies that a relabel step never minimizes over an Corollary d(j) rj: and flows around cycles do not t reversal of network i be an active node relative P a path since paths from s to contribute to the excess at node t, Let Then there must be decomposition of x s € A(i) j) in the residual network. s Ford and Fulkerson [1962] paths from s to flows around directed cycles. (iii) (i, e A(i) and preflow X can be decomposed with respect to the original network and is i again consistent with the is < min{d(j) + d(i) node distance label of performed when there is Hence, . new the step, affect the validity of the distance thereby proving the second part of the lemma. positive excess, there Proof. (i, j) The validity conditions. relabel a does not this set. . node by and by at least one, times. is at no more than some nm . iteration (at until flow is sent which back from j d(i) = to at i, 12 which time increases d(j) = d'(j) by network Lemma that total + d(i) = 1 d(j) + Thus by Corollary m arc 1, A are both in is (i, j) no more than nm. so the , When number non-saturating pushes and Tarjan is and CI conditions [1986] is (Recall that of arcs in the residual at 2n^m. most . N C2 and = n d(s) , it termination criterion for the Fulkerson [1962] follows that to maximum t , . upon termination, the This condition of non-saturating pushes. A residual network. number in why of saturating pushes — This observation leads to a pushes -no matter algorithms, such as the partial explanation of saturating pushes cause structural changes is the number bound 0(nm) of on the number their flow this is difficult to is tight. dramatically reduce the number trees to Cheriyan and Maheshwari [1987] of non-saturating pushes can be decreased to In the next section, 0{t\^) Goldberg and Tarjan [1986] always pushed from a node with highest distance bound is network flow algorithm by using dynamic reduce the average time per non-saturating push. number of which order they are performed. The non-saturating are examined in a first-in-first-out order. that the of they delete saturated arcs from the Goldberg [1985] showed that the number of non-saturating pushes reduced the running time of is The as follows: pushes do not change the structure of the residual network and seem more showed the is Tarjan [1984], and Goldberg and Tarjan [1986], non-saturating pushes dominates the when nodes so flow algorithm of Ford and many preflow based in algorithms due to Karzanov [1974] saturating has zero excess; (s, t) . The bottleneck operation number - since the distance labels satisfy Further, a feasible flow. residual network contains no directed path from s bound. most at ) . the algorithm terminates, each node in the final preflow the can become saturated The algorithm terminates with a maximum flow. 4. classical flow change cannot occur until this 2; of arc saturations (j, i) The number of Proof. See Goldberg Proof. and (i, j) ^ 1 number no more than is 3. Lemma + at least 2. n times, and the we assume d'(i) we show that label, ^) if and they showed that we can by using of non-saturating pushes to 0(n^ m^' scaling, ©(n-^ log U) . We have 13 new recently discovered a log UA O fr?- iTT non-saturating pushes to which further reduces the number scaling algorithm ^ ^^^^ result • of presented in Ahuja, Orlin and is Tarjan [1987]. The Scaling Algorithm 3. Our maximum flow algorithm improves of Section 2 by using "excess scaling" from O(n'^m) with to 0(n^ log U) sufficiently large excesses to become letting the excesses reduce the number of non-saturating pushes to The . basic idea nodes with flog iteration, the excess-dominator is defined to to and satisfies e^ <A for all i e N Further . we a new at least we select a that scaling iteration A/2 most Srr- of at least 2, and all a new to zero distance label { i € considered and that each non-saturating N : ej and we obtain a K After at most among such > A/2 elements in 0(1) time. and nodes, d(i) The variable label. We show select the eligible arc for list, This that maximum flow. = r) we maintain the for each r = 1, and with A/2 [1974]), lists . . . , 2n-l . These lists (see, for which enables insertion and deletion level indicates the a smallest index r for of which non-empty. As per Goldberg and the push has scaling iterations, an active node with excess more than example, Aho, Hopcroft and Ullman is that the ; can be maintained in the form of either linked stacks or linked queues LIST(r) we more than A/2 and among node with minimum distance scaling iteration begins. In order to select LIST(r) = is non-saturating pushes, the excess-dominator decreases by a factor node excesses drop minimum of a units of flow choice ensures that the flow will be sent to a node with small excess. after at power is In a scaling iteration 2. consider only nodes with excess these nodes with large excess, A least integer a factor of To ensure excess-dominator does not increase. , , For a scaling scaling iterations. 1 be the guarantee that each non-saturating push sends A/2 while never sufficiently small excesses U1 + A decreases by have begun whenever value at least push flow from active nodes is to too large. The algorithm performs K = 2 the generic preflow-push algorithm A(i) , Tarjan, we use the following data structure to efficiently pushing flow out of a node. of arcs directed out of it. Arcs in each We maintain list with each node can be arranged i arbitrarily. 1 A but the order, once decided, remains unchanged throughout the algorithm. arc named which node is the made null arc is arc in first the current arc list is appended is end to the of each list. Each node the current candidate for pushing flow out of is i null its found is arc to At When this time, the to the first arc in the arc list is the current arc of node relabeled and the current arc list. as follows: MAX-FLOW; begin PRE-PROCESS; K : = + riog U1 1 for k = : 1 to ; K do begin A = 2K-k i€ for each level : while = 1 do if ei>A/2 then add i to LIST(d(i)); ; level if N < 2n do LIST(level) = then level : = level + else begin select a node i from PUSH/RELABEL(i); end; end; end; in the arc has been completely examined, list The algorithm can be formally described algorithm Initially, (i, j) examined sequentially, and whenever the arc is special has a current arc be inadmissible for pushing flow, the next arc the current arc. reached. This list. i. i 4 LIST(level); 1 is the again set ; ; 15 procedure PUSH/RELABEL(i); begin found = : let (i, j) false ; be the current arc of node while found = if and (i, and false = d(i) + d(j) ^ null do j) 1 i; Tj; > then found replace the current arc of node else i = true : by the next arc found = true then begin (found an admissible if push min (ej , rj: A - , units of flow e;} update the residual capacity if if updated excess) ej<A/2 (the j ?t and r^: or s and and t , set level : = level - arc) on arc (i, j) the excesses ej then delete node (the ufxiated excess) e; (i, j); > A /2 i ; and e; from LIST(d(i)); then add node] , to LIST(d(j)) 1; end else begin (finished arc delete node update add node first from i d(i) : node of i) LIST(d(i)); = min{d(j) + to i list LlST(d(i)) 1 ; (i, j) and € A(i) and > rj; 0} set the current arc of node to the i arc of A(i); end; end; 4. Complexity of the Algorithm In this section , we show that the distance-directed excess scaling correctly computes a Lemma 5. C3. The scaling algorithm satisfies Each non-saturating push from A/2 C4. maximum hlo 0(nm flow in the following a preflow-push algorithm with node i + n'^ log U) time. two conditions: to a node j sends at least units of flow. excess increases above A increase subsequent to a push). (i.e., the excess-dominator does not 6 1 push on Proof. For every arc node with smallest distance d(j) = (ej rjj , - d(i) < e; ) A- 1 , label e'; remain = > min {A/2 + min e: ej { , rj:) , rj; A/2 , A- e; < ) way efficient < A/2 e; A- + e; by sending min , Further, < A All . the push operation node at after the push. j node excesses thus that the algorithm always C3 and C4, pushing flow from A/2 and with minimum node with a among such nodes distance sufficiently large to its Its i equally in the network. iteration. is to It is likely that to the sink, in would have C4 ensures In particular, may be node its be returned. to i maximum that the may is from exceeding e: A. make it easier for fairly nodes distance label to a single node j creating a large send the accumulated flow closer to would phenomenon increase is and much of its excess prevented by maintaining condition C4. Lemma 6. If to also be important because of the following would not be able This j excess "encourage" flow excesses to be distributed This j push from a kind of rather than greedily getting rid This distribution of flows should which case to a simple is very useful in practice as well as in suppose several nodes send flow consideration: that the restraint so as to prevent lower excess send flow towards the sink. excess. Property shows some major impact C3 ensures Property effective. during an maximum Keeping the theory. be node excess, the satisfies of enforcing these conditions. "restrained greedy approach." of all a more than A/2, and is With properties C3 and C4, the push operation may be viewed as never exceeds A is i ensure that in a non-saturating be the excess e'; node since , . properties stated in the conditions and e; excess units of flow. Let only. j we units of flow, While there are other ways of ensuring excess greater than and among nodes whose least than or equal to A less > A/2 e^ by the property of the push operation. Hence d(i) push the algorithm sends at increases the excess at node Then we have (i, j) C3 each push satisfies conditions non-saturating pushes per scaling iteration Proof. Consider the potential function F = is at most £ e^ ieN and C4, 8n^ d(i)/A. then the number of . The initial value of F at the 1 beginning of A-scaling phase d(i) bounded by 2n is . bounded by is When because Zn-^ the algorithm examines ej node bounded by A and is i, 7 one of the following two cases must apply: Case The algorithm 1. pushed. In label of this case node no goes up by i the total increase in bounded by all Case 2. initial to A j and since is and to relabelings of to and the distance > rj: nodes is is is i most at Irr- which flow can be pushed d(j) = d(i) - (i, 1, this j) sends A/2 units of flow from at least Oirr- log U) value of the excess-dominator initial - decreases F by at least sum units to at A < {s, t). maximum Theorem 2. Oinm + n^ new 1; . As the most 4rr , Srr- times. The scaling algorithm performs 1. F In either case, A is 2' '°8 non-saturating pushes. '-^ ' < 2U . the value of the excess-dominator decreases by a factor of 2 N- Since bounded by 2rr node relabelings able to identify an arc on can not occur more than scaling iterations, a F due non-saturating push on arc non-saturating pushes and a e 1 This increases F by at most e units. phase (Actually, the increase in F due node The Proof. i + value of F for a scaling phase plus the increases in F Theorem , units. 1 d(j) performs either a saturating or a non-saturating push. it this case 6 > d(i) along which flow can be an arc scaling phases). decreases. i = throughout the running of the algorithm for each The algorithm and so node d(i) (i, j) e to find 2n, the total increase in in the scaling over arc unable satisfies is scaling iteration begins. and by the The algorithm thus obtains a After 1 integrality of the flows feasible flow, which by By Lemma 8n^ within + flog e^ U = Lemma 1 such for all 4 must be flow. The log W complexity . of the maximum flow scaling algorithm is 18 The complexity Proof: the while loop PUSH/RELABEL(i) main program. the in depends upon the number of the algorithm step In of executions of such execution either each a performed or the value of the variable level increases. is Each execution of the procedure PUSH/RELABEL(i) results in one of the following outcomes: A push Case 1. the number 0(nm Case performed. Since the number of saturating pushes is + n^ log U) label of 0(n) times for each node i calls the The to find number I needed A(i) node and Thus the algorithm effort an arc perform the push operation to node V is operations. This i€ I A(i) i 2n I A(i) I is log U) times. plus the 0(1) label of node After i goes = 0(nm) plus the number of N is clearly 0(nm + n^ log U). requires examining arcs in = 0(nm) time for I case occurs replaced by the next arc in A(i). Computing consider the time needed for relabel operations. distance label of node 2n is i Case 2 occurs and distance i. ie PUSH/RELABEL(i) 0(nm + n^ procedure PUSH/RELABEL(i) up. Thus, the total effort needed V this OCn'^) in total. of times the current arc of Now , goes up. By Corollary!, this outcome can occur i such replacements for node I 0(n^ log U) is 0(nm) and times. The distance 2. pushes non-saturating of is all The new This yields a total of A(i). relabel operations. the lists LIST(r) are stored N as linked stacks time. and queues, hence addition and deletion Consequently, updating these Finally, we need each scaling iteration, Hence its number decreases plus 2n such a case it bounded by 0(nm to level is the number of increases of the variable bounded above by 2n - Further, level can decrease only . number the . 1. of Hence its any element takes 0(1) not a bottleneck operation. of increases per scaling iteration decreases by + n^ log U) bound lists is of is level. and bounded below by 1 bounded by the number when a increases over push all is performed and In 1. of in scaling iterations are pushes plus 2n(l + riogUl), which is again 9 1 Refinements 5. As its a practical matter, several modifications of the algorithm might improve actual execution time without affecting worst case complexity. its We suggest three modifications: 1. Modify the 2. Allow some non-saturating pushes of small amount. 3. Try The scale factor. nodes disconnected from the to locate suggestion first is no less 2, however, some other fixed integer scaling factor The excess-dominator will then be the least power of than the excess at any node, and property C3 becomes Each non-saturating push from a node C3'. in the reduces the excess-dominator by a factor 2 i.e., it In practice, P > 2 might yield better results. P that The algorithm to consider the scale factor. is present form uses a scale factor of in each scaling iteration. sink. node to a i j sends at least A/p units of flow. The scaling algorithm presented earlier can easily be altered to incorporate the p scale factor by letting LIST(r) = shown run to in fixed value of p 0(nm + is pn'^ (i e N ej : logg U) >A/p and time. optimum; the best choice From d(i) = r ). The algorithm can be the worst case point of view any p in practice should be for the value of determined empirically. The second suggestion focuses on as stated selects a push. We node uith e^ variation might produce pushes after A/2 its many A/2 or reduce saturating pushes from the we its excess to zero. This node and even allow excess has decreased below A/2. Also, the algorithm as stated sends at is obtained if for some non-saturating pushes sends at least number at least uruts of flow during every non-saturating push. the algorithm The Our algorithm a saturating or a non-saturating could, however, keep pushing the flow out of this node until either perform a non-saturating push of value least the non-saturating pushes. and performs > A/2 fixed A/2 > 1 , one out of every r of > 1 units of flow. third suggestion recognizes that of relabels. r The same complexity one potential bottleneck in practice is the In particular, the algorithm "recognizes" that the residual network contains no path from node i to node t only when d(i) exceeds n - 2 . 20 Goldberg [1987] suggested search so as to first of breadth An distance make that with distance greater than k path from until all is to j is to is after is up discovered that a judicious use the algorithm. any relabel for of nodes nj^ some whose then each node k, disconnected from the sink in the residual network. disconnected from the sink, t He keep track of the number decreases to nj^ If k. j desirable to occasionally perform a breadth the distance labels exact. alternative approach (Once node may be search could dramatically speed first is it it stays disconnected since the shortest We nondecreasing in length.) would avoid selecting such nodes vdth positive excess become disconnected from the sink. At nodes this time, the excesses of nodes are sent back to the source. This approach essentially yields the two phase approach Tarjan [1986] maximum . The to solve the first maximum phase constructs a flow problem as outined in Goldberg and maximum preflow which is converted to a flow in the second phase. Fuhire Directions 6. Our improvement of the distance directed preflow-push algorithm has maximum flow problem. Our for the maximum flow problem several advantages over other algorithms for the algorithm is superior to all previous algorithms under the reasonable assumption that U is polynomially bounded in the algorithm utilizes very simple data structures which makes it n. attractive Further, from an implementation viewpoint. Our algorithm even if U is computationally attractive from a worst-case perspective not 0(n^'^'); that In this case, the take 0(1) steps, model is is, if uniform model of computation, is arguably inappropriate. of computation (as described number of bit operations. modifying our algorithm It is in more which all realistic to more U ) which counts the most arithmetic operations take OQog U) slightly to speed up arithmetic operations on large integers, 0(nm log n + n^ log n log U) time. corresponding time bound for the Goldberg-Tarjan algorithm Hence, as adopt the logarithmic Using the logarithmic model of computation and claim that our algorithm would run in log U). arithmetic operations by Cook and Reckhow [1973] In this model, steps rather than 0(1) steps. we the arc capacities are exponentially large numbers. becomes exponentially large, is 0(nm log The {vr/m) our algorithm becomes more and attractive relative to the Goldberg-Tarjan algorithm. Our logarithmic model of computation will be presented in a future paper. results in the — 21 CXir algorithm is a novel approach previous scaling algorithms developed by Gabow Edmonds and Karp and right-hand-sides, coefficients or the capacities w^ith the costs approximated by C/2^ reoptimize so as to solve the problem w^ith method does not C some for [1980] would , and integer T. We framework. and so , v^ould then , The recent of relaxation. Tarjan [1987] for the minimum problem is Our Rather, our algorithm cost scaling algorithm of cost flow and then forth.) works with true data, relaxes the flow conservations constraints and maximum amount solve the first approximated by C/2-^~^ into this standard fit (e.g., vs'e C approximated by C/2^~^ reoptimize for the problem with scaling Rock [1972], In the scaling involved a sequential approximation of either the cost [1985], problem to combinatorial scaling algorithms. scales the Goldberg and similar in nature ~ this algorithm scales the relaxation of the complementary slackness conditions. The scaling algorithm for the by using more clever rules improvements factor in to > flow problem can be improved further push flow or by using dynamic Ahuja, Orlin and Tarjan [1987]. We show algorithm runs in Use 4.). of the / algorithm to We dynamic f V Q nm T\ log U describe such by using a larger scale label —U n^ log + tree data structure further Oj^nm logj^— We trees. that and pushing flow from a node with highest distance sufficiently large excess, the U maximum | among nodes having A tj -, time (Assume that improves the complexity of this \\ ,^^-f^^+2jJ. have also undertaken an extensive empirical study to assess the computational merits of the preflow-push algorithms versus the previous best algorithms, those of Dinic and Karzanov. Our experiments so far suggest that preflow-push algorithms are substantially faster than Dinic's and Karzanov's algorithms. Our algorithms and those due to Goldberg and Tarjan suggest the superiority of distance label based approaches over the layered improvements we have obtained do not seem utilizing layered networks. The distance layered networks and hence are in to network based approaches. The be possible for the algorithms labels implicitly store more powerful. We show dynamically changing the use of distance labels augmenting path algorithms, capacity scaling algorithms and networks in Orlin and Ahuja [1987]. for unit capacity 22 The maximum flow problem on maximum bipartite Ac bipartite networks an important class of the is flow problem (see Gusfield, Martel and Fernandez-Baca [1985]). network N2 N-j X maximum Let . a is n-j G network = I N-j I and n2 = I N2 flow algorithm can be modified resulting in significant network flows speedup over the appear will in a future Our maximum flow algorithm we push = (N, A) flow from one node processors we to • I run jointly is difficult in at a time. with to = N| For cases where 0(n|m original algorithm. paper N such that Our n-j u N2 The and < < n2, our 2 + n, log U), thus results on bipartite C Stein and R. Tarjan. make "massively parallel" since d = fm/nl parallel Nevertheless, with can obtain an 0(n^ log Ud) time bound. Under the assumption that = O(n^^^^0, the algorithms runs in 0(n^ log n) time, which available time bounds obtained by Shiloach and Vishkin Tarjan [1986] using situations for which n parallel processors. is comparable [1982] and U to the best Goldberg and Thus, our algorithm has an advantage in parallel processors are at a premium. Our work on the parallel algorithms will also appear in a future paper. Acknowledgements We wish thank John Bartholdi, to Tom Magnanti, and Hershel Safer for their suggestions which led to improvements in the presentation. supported in part This research was by the Presidential Young Investigator Grant 8451517-ECS of the National Science Foundation, by Grant AFOSR-88-0088 from the Air Force Office of Scientific Research, Prime Computer. and by Grants from Analog Devices, Apple Computer, Inc., and 23 REFERENCES Aho, A.V. J.E. , Hopcroft and J.D. Ullman. Computer Algorithms. Addison-Wesley, Ahuja, R.K., and the J.B. Orlin, Maximum Flow Management, Cheriyan, M.I.T., 1987. Research Algorithms for Maximum Network Sloan of School Analysis of Preflow Push Flow. Technical Report, Dept. of Institute of Technology, New INDIA. 1977 Cherkasky, R.V. . Networks with Complexity Algorithm for Construction of Maximal Flow and S.A., Machines /. . of R.A. Comput. System of Networks. Time Bounded Random Access 1973. Sci. Dantzig, G.B., and D.R. Fulkerson. 112-125 (in Russian). 7, Reckhow. 7 , 354 1956. - On 375 the . Max-Flow Min-Cut Theorem Linear Inequalities and Related Systems, edited and A.W. Tucker, Annals of in Mathematical Methods OCV"^ VE) Operation, of of Solution of Economical Problems Cook, for Report, 1987. Computer Science and Engineering, Indian Delhi, Improved Time Bounds Cambridge, MA. 02139. and S.N. Maheshwari. J., of MA. Reading, R.E. Tarjan. Problem. The Design and Analysis 1974. Mathematics Study by H.W. Kuhn 38, Princeton University Press, 215-221. Dinic, E.A. 1970. Algorithm for Solution of a Networks with Power Estimation, Soviet Math. Edmonds, 1972. J., and R.M. Karp. Problem Dokl. 11 in 1277-1280. /. Assoc. Comput Mach. 248-264. Ford, L.R., and D.R. Fulkerson. Can. , Maximum Flow Theoretical Improvements in Algorithmic Efficiency for Network Flow Problems. 19, of J. Math. 8, 399-404. 1956. Maximal Flow through a Network. 24 Ford, L.R., and Fulkerson. D.R. University Press, Princeton, New Gabow, Computations of 1955. Scaling Algorithms for 1985. Network Problems. /. of R.E. Tarjan. Faster Scaling Algorithms for 1987. Graph New Jersey. Princeton, Acta Informatica 14 and Galil, Z. , A. Naamad. Problem. Goldberg, A.V. 1985 Mrr/LCS/TM-291 , Goldberg, A.V. Cambridge, MA. /. . 1980. Comput. System Efficient , 203-217. Technical Report Algorithm. , Cambridge, MA. and Parallel Laboratory for Computer Science, M.I.T., for Sequential Available as Tech. Rep. MIT/LCS/TR-374. 1986. A New Approach Proceedings of the Eighteenth Annual and (to R.E. Tarjan. appear Symposium on Gusfield, D., C. Martel, in 1987. Problem by Successive Approximation. ACM 21 Graph Algorithms Dissertation, the Theory of Computing, 136-146. Goldberg, A.V., log^ V^ Algorithm for the Sci. A New Max- Flow Goldberg, A.V., and R.E. Tarjan. Flow Problem. An 0(VE Laboratory for Computer Science, M.I.T. 1987. Ph.D. Row Problem, 221-242. Maximum Flow Computers. E^/S) Algorithm for the Maximal An 0(v5/3 1980. Bipartite in Research Report, Computer Science Dept., Princeton University, Matching. Annual Maximum Flow 148-168. 31, Sci. Gabow, H.N., and Galil, Z. Princeton Res. Log. Quart. 2, 277-283. H.N. Comput. System Networks. in Jersey. Fulkerson, D.R., and G.B. Dantzig. Networks. Naval Flows 1962. the Theory of J. of to the ACM Maximum Symposium on ACM.) Solving Minimum Cost Flow Proceedings of the Nineteenth Computing, 7-18. and D. Femandez-Baca. 1985. Fast Algorithms for Network Flow. Technical Report No. YALEV/DCS/TR-356, Dept. Computer Science, Yale University, Yale. of 25 Karzanov, A.V. Method Algorithm for Finding Process. Lett. 7 J.B., Maximum Flow and Maheshwari. S.N. Maximum Flows MA. 1987. New in 1978. Networks. An Inform. Distance-Directed Algorithms for Maximum Flow Parametric Problems. Management, Massachusetts 1908-87, Sloan School of Rock, H. 434-437. 277-278. , and R.K. Ahuja. Cambridge, , Pramodh Kumar, and Malhotra, V.M., M. Orlin, Soviet Math. Dokl. 15 of Preflows, O(IVI^) Determining the Maximal Flow in a Network by the 1974. Sloan W.P. No. Institute of Technology, 02139. Scaling Techniques for Minimal Cost 1980. Discrete Structures and Algorithms, Ed. Network Flows, V. Page, Carl Hanser, Miinchen, 181-191. An Shiloach, Y., 1978. 0(nl log^ Maximum Flow (I)) Algorithm. Technical Report STAN-CS-78-702, Computer Science Dept., Stanford University, CA. Shiloach, Y. , and U. Vishkin. Algorithm. /. Algorithms 3 Sleator, D.D., and Comput. System Tarjan, R.E. Algorithm, Oper. Res. / V. J U 6 log n) Parallel Max-How 1983. A Data Structure for Dynamic Trees, /. 362-391. 24, 1984. An 0(n2 128-146. , R.E. Tarjan. Sci. 1982. , Lett. A 2 Simple Version of Karzanov's Blocking Flow , 265-268. \\f , I Date Due SEP. 1 7 1992 Lib-26-6T MIT LIBRARIES 3 TDfiD DD5 37b 72S