Minimum Cost Flow Algorithms

Similar documents
The Budget-Constrained Maximum Flow Problem

The min cost flow problem Course notes for Optimization Spring 2007

Week 4. (1) 0 f ij u ij.

The min cost flow problem Course notes for Search and Optimization Spring 2004

Lecture 13: Polynomial-Time Algorithms for Min Cost Flows. (Reading: AM&O Chapter 10)

directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time

Math 5490 Network Flows

Duality of LPs and Applications

4. Duality Duality 4.1 Duality of LPs and the duality theorem. min c T x x R n, c R n. s.t. ai Tx = b i i M a i R n

Chapter 7 Network Flow Problems, I

Graphs and Network Flows IE411. Lecture 12. Dr. Ted Ralphs

Part V. Matchings. Matching. 19 Augmenting Paths for Matchings. 18 Bipartite Matching via Flows

Mathematics for Decision Making: An Introduction. Lecture 13

6.854 Advanced Algorithms

Discrete Optimization 2010 Lecture 3 Maximum Flows

Combinatorial Optimization

7. Lecture notes on the ellipsoid algorithm

Discrete Optimization 23

Discrete Wiskunde II. Lecture 5: Shortest Paths & Spanning Trees

3. Linear Programming and Polyhedral Combinatorics

Discrete Optimization

Strongly Polynomial Algorithm for a Class of Minimum-Cost Flow Problems with Separable Convex Objectives

Contents. Introduction

3. Linear Programming and Polyhedral Combinatorics

Minimum cost transportation problem

Algorithms and Theory of Computation. Lecture 11: Network Flow

Maximum flow problem

Algorithms: Lecture 12. Chalmers University of Technology

CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs. Instructor: Shaddin Dughmi

Relation of Pure Minimum Cost Flow Model to Linear Programming

Lecture #21. c T x Ax b. maximize subject to

Maximum Integer Flows in Directed Planar Graphs with Multiple Sources and Sinks and Vertex Capacities

Lecture notes on the ellipsoid algorithm

Lecture 3. 1 Polynomial-time algorithms for the maximum flow problem

Advanced Combinatorial Optimization September 22, Lecture 4

Lectures 6, 7 and part of 8

CS 6820 Fall 2014 Lectures, October 3-20, 2014

1 Matchings in Non-Bipartite Graphs

(P ) Minimize 4x 1 + 6x 2 + 5x 3 s.t. 2x 1 3x 3 3 3x 2 2x 3 6

Computer Science & Engineering 423/823 Design and Analysis of Algorithms

Introduction to Mathematical Programming IE406. Lecture 10. Dr. Ted Ralphs

Two Applications of Maximum Flow

Maximum flow problem (part I)

Solutions to Exercises

Flows. Chapter Circulations

1 Integer Decomposition Property

Advanced Linear Programming: The Exercises

Network Design and Game Theory Spring 2008 Lecture 6

Topic: Balanced Cut, Sparsest Cut, and Metric Embeddings Date: 3/21/2007

- Well-characterized problems, min-max relations, approximate certificates. - LP problems in the standard form, primal and dual linear programs

CSC373: Algorithm Design, Analysis and Complexity Fall 2017 DENIS PANKRATOV NOVEMBER 1, 2017

Breadth First Search, Dijkstra s Algorithm for Shortest Paths

Multicommodity Flows and Column Generation

min 4x 1 5x 2 + 3x 3 s.t. x 1 + 2x 2 + x 3 = 10 x 1 x 2 6 x 1 + 3x 2 + x 3 14

"SYMMETRIC" PRIMAL-DUAL PAIR

Flows and Cuts. 1 Concepts. CS 787: Advanced Algorithms. Instructor: Dieter van Melkebeek

III. Linear Programming

3.10 Lagrangian relaxation

Preliminaries. Graphs. E : set of edges (arcs) (Undirected) Graph : (i, j) = (j, i) (edges) V = {1, 2, 3, 4, 5}, E = {(1, 3), (3, 2), (2, 4)}

IE 5531: Engineering Optimization I

Dynamic Programming: Shortest Paths and DFA to Reg Exps

The Steiner Network Problem

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths

Introduction 1.1 PROBLEM FORMULATION

Technische Universität München, Zentrum Mathematik Lehrstuhl für Angewandte Geometrie und Diskrete Mathematik. Combinatorial Optimization (MA 4502)

Cutting Plane Methods II

Robust Network Codes for Unicast Connections: A Case Study

Linear Programming Duality

Linear Programming. Jie Wang. University of Massachusetts Lowell Department of Computer Science. J. Wang (UMass Lowell) Linear Programming 1 / 47

The simplex algorithm

CS675: Convex and Combinatorial Optimization Fall 2016 Combinatorial Problems as Linear and Convex Programs. Instructor: Shaddin Dughmi

Flow Network. The following figure shows an example of a flow network:

Santa Claus Schedules Jobs on Unrelated Machines

Exact and Approximate Equilibria for Optimal Group Network Formation

Dynamic Programming: Shortest Paths and DFA to Reg Exps

Topic: Primal-Dual Algorithms Date: We finished our discussion of randomized rounding and began talking about LP Duality.

On shredders and vertex connectivity augmentation

Shortest paths with negative lengths

Worst case analysis for a general class of on-line lot-sizing heuristics

A simplex method for uncapacitated pure-supply and pure-demand infinite network flow problems

The Maximum Flows in Planar Dynamic Networks

16.1 Min-Cut as an LP

CS261: A Second Course in Algorithms Lecture #9: Linear Programming Duality (Part 2)

Lecture 15 (Oct 6): LP Duality

The Simplex Algorithm

Linear Programming Redux

Breadth-First Search of Graphs

Chapter 1 Linear Programming. Paragraph 5 Duality

A FAST MAX FLOW ALGORITHM

Linear Programming Duality P&S Chapter 3 Last Revised Nov 1, 2004

Chap6 Duality Theory and Sensitivity Analysis

ECE 307 Techniques for Engineering Decisions

5 Flows and cuts in digraphs

CSCE423/823. Introduction. Flow Networks. Ford-Fulkerson Method. Edmonds-Karp Algorithm. Maximum Bipartite Matching 2/35 CSCE423/823.

An Analysis of the Highest-Level Selection Rule in the Preflow-Push Max-Flow Algorithm

Nowhere-zero flows in signed series-parallel graphs arxiv: v1 [math.co] 6 Nov 2014

Extreme Point Solutions for Infinite Network Flow Problems

Recall: Matchings. Examples. K n,m, K n, Petersen graph, Q k ; graphs without perfect matching

Semidefinite and Second Order Cone Programming Seminar Fall 2001 Lecture 5

We say that a flow is feasible for G (or just feasible if the graph and capacity function in question are obvious) if

Transcription:

4 Minimum Cost Flow Algorithms Assumption 4.1 In this chapter we will always use G =(V,R,,!) to denote a finite graph and l, c be real-valued functions which assign lower and upper capacities to the arcs of G, where 0 apple l(r) apple c(r) for all r 2 R. We allow the case that c(r) =+1 for some arcs r 2 R with the meaning that these arcs have unlimited capacity. We also use b: V! R to denote a function which assigns desired excesses to the vertices (cf. Definition 2.8). Finally, we let k : R! R be a function which assigns flow costs to the arcs. For a b-flow f its cost is given by k(f) := r2r k(r) f(r). We extend the cost function k to the arcs of the residual network by k(+r) :=k(r) and k( r) := k(r). If h: R(G f )! R, wedefineitscostby k(h) := k( r) h(r). r2r(g f ) Definition 4.2 (Minimum Cost Flow Problem) Given all data as in Assumption 4.1, the minimum cost flow problem is to find a b-flow f which is feasible with respect to the lower and upper capacities, i.e., l(r) apple f(r) apple c(r) for all r 2 R whose cost k(f) is minimum among all feasible b-flows. In the above definition we have somewhat neglected the situation that there might be no feasible b-flow. However, as the In-Class Exercise 2 of the first Homework shows, one can determine whether there exist such a feasible b-flow by a maximum flow computation. Thus, for the rest of the chapter we will always assume that there exists a feasible solution. Observe that we have allowed negative costs on the arcs. This together with the fact that we allow infinite capacities allows us to view the maximum flow problem as a special case of the minimum cost flow problem: we extend the graph G of the maximum flow problem by adding an arc (t, s) of infinite capacity and cost k(t, s) = 1. All other arcs have cost 0. Call the resulting graph G 0. We set b(v) =0for all v 2 V (G) =V (G 0 ) and l(r) =0for all arcs r 2 R(G 0 ). It is now easy to see

30 Minimum Cost Flow Algorithms that there exists a feasible (s, t)-flow f in G of value val(f) =F if and only if there exists a feasible circulation in G 0 of cost F. Recall that for computing maximum flows we augmented an (s, t)-flow along an augmenting path P by a value >0 by increasing the flow value by for all arcs r such that +r 2 P and decreasing the flow value by for all arcs r such that r 2 P. Similarly, we can augment flow along a simple cycle. Let C be a simple cycle in the residual network of a feasible b-flow f. If apple min{c f ( r) : r 2 C} we can modify f by increasing the flow value by for all arcs r such that +r 2 C and decreasing the flow value by for all arcs r such that r 2 C. This augmentation leaves all excesses of vertices unchanged. In this chapter we need the following result due to Hoffmann which can be derived easily from the Maximum-Flow-Minimum-Cut-Theorem: Corollary 4.3 Let b: V! R and G be a graph with lower and upper capacities on the arcs. Then, there exists a feasible b-flow in G with respect to l and c, if and only if c( + (S)) l( (S)) + b(t ) for all cuts (S, T ) in G. Ifl and c are integral, then the b-flow can be chosen to be integral (provided it exists at all). 2 4.1 Optimality Conditions For the following optimality condition it turns out to be helpful to write the augmentation along a cycle C in G f as the sum of f and a circulation C. Let f be a b-flow and C be a circulation on a simple cycle C in G f with value >0. We define f + C by 8 >< f(r)+, if +r 2 C (f + C )(r) := f(r), if r 2 C (4.1) >: f(r), else. Obviously, f + C is again a b-flow in G and its cost is k(f + C )=k(f)+k( C ). Theorem 4.4 Let f and f 0 be both feasible b-flows with respect to the lower and upper capacities l and c. Then f 0 can be written as the sum of f and at most 2m circulations on cycles C 1,..., C p in G f. We have k(f 0 )=k(f)+ P p i=1 k( C i ). Proof: The function f f 0 is a (not necessarily feasible) circulation in G. This circulation induces a circulation f 0 in G f : If f 0 (r) f(r) > 0, weset f 0(+r) := f 0 (r) f(r) apple c(r) f(r) = c f (+r). If f 0 (r) f(r) < 0, we set f 0( r) := f(r) f 0 (r) apple f(r) l(r) =c f ( r). On all other arcs of G f takes the value 0. Then f 0 is a feasible circulation in G f with respect to the lower capacities l 0 0 and the upper capacities c 0 = c f. Applying the flow decomposition theorem (Theorem 2.9) yields a decomposition of f 0 into at most 2m circulations C 1,..., C p in G f, where C i is a simple cycle

4.1 Optimality Conditions 31 in G f. Then k(f 0 )= r2r k(r)f(r)+ r2r k(r)(f 0 (r) f(r)) = k(f)+ r2g f k( r) f 0( r) = k(f)+ r2g f = k(f)+ k( r) Ci ( r) i: r2c i p k( Ci ). i=1 This is what we wanted to prove. 2 The previous theorem gives us the known optimality condition for minimum cost flows: Theorem 4.5 (Cycle Optimality Condition for Minimum Cost Flows) Let G be as in Assumption 4.1. The b-flow f is of minimum cost if and only if the residual network G f does not contain a cycle with negative length (with respect to k). Proof: If C is a cycle of negative length in G f,wecanaugmentf along C by a positive amount as in (4.1) thereby reducing the cost by P r2c k( r) < 0. Now, assume conversely that f is a feasible b-flow such that G f does not contain anegativelengthcycle. Letf 0 be any other feasible b-flow. By Theorem 4.4 we can write f 0 as the sum of f and circulations C 1,..., C p in G f,andk(f 0 )= k(f)+ P p i=1 k( CP i ).BytheassumptionthatG f does not contain a negative length cycle, we have i r2c i k( r) 0 for all i, which implies that k(f 0 ) k(f). Thus, f is of minimum cost. 2 Theorem 4.6 If there exists a b-flow f of minimum cost, then there is also an optimum flow f 0 such that l(r) apple f 0 (r) apple (n + m)(c + B) for all r 2 R, where C = max { c(r) :r 2 R ^ c(r) < +1} and B = max { b(v) : v 2 V }. Proof: Let f be an optimum b-flow. Then, in G there can not be any negative length cycle whose arcs have all unbounded capacities (else we could reduce the flow cost arbitrarily). By the Flow Decomposition Theorem 2.9 we can decompose f into at most n + m flows on paths and circulations on cycles. We can assume that any cycle in the decomposition has negative cost, otherwise we could remove the circulation along the cycle without changing excesses and without increasing the cost of the flow. As we have argued, any cycle must contain at least one arc with finite capacity. Thus the value of any circulation in the decomposition is at most C. Consequently, for any arc r 2 R all the circulations in the decomposition contribute at most (n + m)c to the flow value f(r) of f on the arc. The sum of the flows on paths is P v2v :b(v)>0 b(v) apple nb apple (n + m)b and, thus, the flows on paths contribute at most (n + m)b to the flow value on arc r. 2 We will now derive a second helpful optimality condition. Let G =(V,R,,!) be an arbitrary graph and k : R! R be arbitrary. Given p: V! R, wecanalsodefine the reduced costs k p : R! R with respect to p by k p (r) :=k(r)+p( (r)) p(!(r)).

32 Minimum Cost Flow Algorithms Let P =[v 0,...,v q ] be a path from v 0 to v q. Then q 1 k p (P )= (k(v i,v i+1 )+p(v i ) p(v i+1 )) i=0 q 1 q 1 = k(v i,v i+1 )+ (p(v i ) p(v i+1 )) i=0 Thus, for any path P in G we have i=0 = k(p )+p(v 0 ) p(v q ), k(p )=k p (P )+p(!(p )) p( (P )). (4.2) In particular, if P is a cycle in G, the (P )=!(P ) and we have k(p )=k p (P ), if P is a cycle. (4.3) Afunctionp: V! R is called a potential in G if and only if we have p(!(r)) apple p( (r)) + k(r) for all r 2 R. Then, clearly p is a potential if and only if k p (r) 0 for all r 2 R. If p is a potential in G, thenbyk p (r) 0 for all r 2 R and (4.3) we have k(c) = k p (C) 0 for all cycles C in G. So, the existence of a potential implies that there is no negative length cycle. Assume conversely that G does not contain a negative length cycle. Then, we can add a new node s 0 to G which is connected to all v 2 V (G) by arcs (s 0,v) of length 0. The shortest path distances dist(s 0,v,G) from s 0 are well defined and finite (since all vertices are reachable from s 0 and there is no negative length cycle). These satisfy dist(s 0,!(r),G) apple dist(s 0, (r),g)+k(r) for all r 2 R (4.4) and thus p(v) :=dist(s 0,v,G) is a potential in G. If k is integer valued, then the potential obtained this way is also integral. We summarize our findings: Theorem 4.7 Let G be a directed graph and k : R(G)! R. Then, there exists a potential in G if and only if G does not have a negative length cycle. If k is integral, the potential (if it exists) can be chosen to be integral. 2 The above theorem gives us a nice second optimality condition for minimum cost flows: Theorem 4.8 (Reduced Cost Optimality Condition for Min. Cost Flows) Let G be as in Assumption 4.1. The b-flow f is of minimum cost if and only if there exists a potential in G f, i.e. if there exists p: V! R such that p(v) apple k( r)+p(u) for all r 2 G f, where u = ( r) and v =!( r). Proof: Directly from Theorem 4.5 and Theorem 4.7. 2 For the remainder of this chapter we will make the following assumptions: Assumption 4.9 (i) There exists a b-flow which is feasible with respect to the lower and upper capacities, in particular, we have P v2v b(v) =0. (ii) For all u, v 2 V with u 6= v there is a path from u to v which consists only of arcs of infinite capacity +1 (thus, this path also exists in any residual network G f )

4.2 Network Transformations 33 (iii) We have l(r) =0and k(r) 0 for all r 2 R. None of the above is a restriction on the generality of our results. We can always enforce these conditions: Condition (i) ensures that there exists a feasible solution. This condition can be checked by a maximum flow computation. Condition (ii) can be enforced by adding new arcs with high costs (By Theorem 4.6 it suffices to take (n + m)(c + B)(K + 1), wherek = max{k(r) :r 2 R}) an infinite capacities between any pair of vertices where we do not have an arc. We will handle Condition (iii) in Section 4.2 and show how we can reduce the general case to this case. 4.2 Network Transformations In this section we show how we can enforce zero lower capacities and nonnegative costs on the arcs. In order to simplify the notation in this section we will write (u, v) for an arc r from u to v although there may be several of those arcs. Let G be with capacities l, c! R(G)! R + and b: V! R with P v2v b(v) =0. Suppose that we have an arc (u, v) such that l(u, v) > 0. Wesendl(u, v) > 0 units of flow along (u, v), therebyincreasingb(u) by l(u, v) units and decreasing b(v) by l(u, v) units. More formally, we set and b 0 (u) :=b(u)+l(u, v) b 0 (v) :=b(v) l(u, v) b 0 (w) :=b(w) for w 2 V \{u, v}, l 0 (u, v) :=0 c 0 (u, v) :=c(u, v) l(u, v) l 0 (r) :=l(r) c 0 (r) :=c(r) for r 2 R \{(u, v)}. Clearly, f 0 is a feasible b 0 -flow with respect to l 0 and c 0 if and only if, f defined by ( f 0 (r)+l(r), if r =(u, v) f(r) = f 0 (r), else is a feasible b-flow with respect to l and c. The value f 0 (u, v) corresponds to the additional flow on the arc (u, v) compared to the necessary minimum value l(u, v). We have k(f) =k(f 0 )+l(u, v)c(u, v), so that the costs of the two flows differ by a constant independent from f and f 0. Repeating this transformation, we can eliminate all nonzero lower capacities. We have not even increased the size of the network. We now show the somewhat surprising fact that we can also eliminate all finite upper capacities. A minimum cost flow problem where l(r) =0and c(r) =+1 for all arcs r is also called transshipment problem. Let (u, v) be an arc such that c(u, v) < +1. Wereplaceu, v and the arc (u, v) by a subgraph as shown in Figure 4.1. The idea of the transformation is to make the capacity constraint on (u, v) the mass balance constraint for some new nodes.

34 Minimum Cost Flow Algorithms (k(u, v), c(u, v)) b(v) v c(u, v) x (k(u, v), 1) (0, 1) (0, 1) y c(u, v) b(v) v " c(u, v) x y " c(u, v) " c(u, v) b(v) v u b(u) (a) An arc r =(u, v) with cost k(u, v) and capacity c(u, v) < +1 u b(u) (b) The transformed network with new vertices x and y u b(u) (c) Situation for a flow in the transformed network Figure 4.1: Elimination of finite capacities b(u) u (k(u, v), c(u, v)) b(v) v b(u) + c(u, v) b(v) c(u, v) ( k(u, v), c(u, v)) u v (a) An arc (u, v) with negative cost k(u, v) < 0 (b) Result of the transformation Figure 4.2: Elimination of negative cost arcs It is straightforward to verify that for any feasible b 0 -flow in the resulting network we have f(u, x) =f(y, v) apple c(u, v). Byconstruction,alsothecostscarryover,this time without change. Repeating the transformation for all arcs with finite capacity, we obtain an equivalent instance of the transshipment problem which has at most n + m vertices and at most 3m arcs. We finally show how to eliminate negative cost arcs. We will assume that we have already enforced the condition l(r) =0for all r 2 R. Supposethatk(u, v) < 0. By Theorem 4.6 we can assume that c(u, v) < +1. The transformation is similar as for elimination of nontrivial lower capacities. We send c(u, v) units of flow along (u, v) thereby saturating (u, v), increasingb(u) by c(u, v) and decreasing b(v) by c(u, v). We replace (u, v) by the inverse arc (v, u) with cost k(v, u) := k(u, v) > 0. The transformation is illustrated in Figure 4.2. 4.3 The Successive Shortest Path Algorithm In this section we repeat the Successive Shortest Path Algorithm for solving the Minimum Cost Flow Problem (this algorithm should be known to you from undergraduate classes). Although the algorithm is not a polynomial time algorithm, we will use it as a building block for deriving more efficient, i.e., polynomial time algorithms in subsequent sections. Definition 4.10 (Pseudoflow) Let G be as in Assumption 4.1 and l 0. A feasible pseudoflow in G is a function f : R! R such that 0 apple f(r) apple c(r) for all r 2 R. For a pseudoflow f we define the imbalance of a node v 2 V by imbal f (v) :=excess f (v) b(v). If imbal f (v) > 0, we call v a surplus node, if imbal f (v) < 0, we call v a deficit node). A node with zero imbalance is a balanced node.

4.3 The Successive Shortest Path Algorithm 35 Algorithm 4.1 Successive-Shortest-Path Algorithmus Successive-Shortest-Path(G, c, b, k) Input: AdirectedgraphG =(V,R,,!) with capacities l 0, c: R! R +, desired excesses b: V! R and costs k : R! R + 1 Set f(r) :=0for all r 2 R and p(v) :=0for all v 2 V. 2 Set imbal f (v) := b(v) for all v 2 V. 3 Compute the sets of surplus and deficit nodes: S f = { v 2 V : imbal f (v) > 0 } D f = { v 2 V : imbal f (v) < 0 } 4 while S f 6=? do 5 Choose s 2 S f and t 2 D f. 6 Compute the distances d(v) =dist k p(s, v, G f ) from s to all other vertices in G f with respect to the reduced costs k p. 7 Let P be a shortest path from s to t. 8 Let :=min{ c f ( r) : r 2 P } 9 Update p := p + d 10 " := min {imbal f (s), imbal f (t), }. 11 Increase f along P by " units. 12 Update f, G f, S f and D f. 13 end while 14 return f The following lemma lays the foundations for the correctness of the Successive Shortest Path Algorithm. Lemma 4.11 Let f be a pseudoflow and s 2 V. Let G 0 v G f be obtained by removing some arcs from G f, such that in G 0 all vertices are still reachable from s. Assume that k p ( r) 0 for all r 2 G 0 and denote by d(v) :=dist k p(s, v, G 0 ) for v 2 V. Then, the following statements are true: (i) For p 0 := p + d we also have k p0 ( r) 0 for all r 2 G 0. (ii) If r is an arc in G 0 on a shortest path from s to t, then k p+d ( r) =0. Proof: (i) By assumption we have k p ( r) 0 for all r 2 G 0. In particular, G 0 does not have a negative length cycle and all distances d(v) =dist k p(s, v, G 0 ) are finite and well defined. Let r 2 G 0 with u = ( r) and v =!( r). Then d(v) apple d(u)+k p ( r) =d(u)+k( r)+p(u) p(v). Rearranging yields: k( r)+(p(u)+d(u)) (p(v)+d(v)) 0, and thus k p+d ( r) 0. (ii) If r is on a shortest path from s to t with ( r) =u and!( r) =v, then d(v) =d(u)+k p ( r) and we have k p+d ( r) =0.

36 Minimum Cost Flow Algorithms This completes the proof. 2 Start Lecture: 09.05.2016 Corollary 4.12 Let f be a pseudoflow which satisfies the Reduced Cost Optimality Conditions and f 0 be a pseudoflow obtained from f by sending flow from a vertex s to some other vertex t along a shortest path P in G f (with respect to the reduced costs k p ). Then, f 0 also satisfies the Reduced Cost Optimality Condition. Proof: We apply Lemma 4.11 with G 0 := G f. Lemma 4.11. Let p and p 0 := p + d be as in By Assumption 4.9 (ii) all vertices are reachable from s in G f.bylemma4.11we have k p0 ( r) =0for all r 2 P.BysendingflowalongP we may add r to the residual network for some arc r. But,sincek p0 ( r) = k p0 ( r) =0,allarcsstill have nonnegative reduced costs. 2 Theorem 4.13 Assume that all data is integral. Then, the Successive Shortest Path Algorithm terminates after at most nb iterations where B = max { b(v) : v 2 V }. The pseudoflow upon termination is a minimum cost b-flow. The total running time of the algorithm is O(nB(m + n log n)). Proof: The total sum of all deficits of deficit nodes before the first iteration is at most nb. In every iteration, the deficit of at least one deficit node decreases by an integral amount, i.e., by at least 1. Thus, we have at most nb iterations until termination. In every iteration we can use Dijkstra s Algorithm to determine shortest paths in O(m + n log n) time, since the edge lengths are nonnegative. Upon termination, we have S f =?. Thus, since the sum of all b-values is 0, we also have D f =?. Hence, f must be a feasible b-flow. By Corollary 4.12, the flow satisfies the Reduced Cost Optimality Condition and, consequently, must be optimal. 2 We observe that it is, in fact, not necessary to initialize the Successive-Shortest- Path-Algorithm by the flow f 0 and the potential p 0. The number of iterations of the algorithm is then bounded by P v2v :imbal f (v)>0 imbal f (v). This will be helpful in the next sections. 4.4 The Successive Scaling Algorithm The presentation of the successive scaling algorithm in this section and the scale and shrink algorithm in the following section will be done for the transshipment problem, i.e., we will assume that l(r) =0, c(r) =+1 and k(r) > 0 for all r 2 R. Our presentation makes one more assumption about the instance of the transshipment problem to solve. We require the existence of a special node z 2 V such that b(z) =0, (v, z) 2 R with k(v, z) =0and (z,v) /2 R for all v 2 V \{z}. This assumption merely simplifies the presentation of the algorithm, since we can enforce this property by adding a new node z and the required arcs without changing anything. An instance (G, k, b) of the transshipment problem is then given by the graph G, the nonnegative costs k and the required imbalances b. The successive scaling algorithm was in fact the first polynomial time algorithm for the minimum cost flow problem. To scale an instance (G, k, b) of the transshipment problem by a factor of > 0 means the following:

4.4 The Successive Scaling Algorithm 37 We replace b(v) by b 0 (v) =bb(v)/ c for all v 6= z. We set b 0 (z) = P v6=z b0 (v). The latter definition ensures that P i2v b0 (v) =0so that feasibility of an instance is preserved: Lemma 4.14 Let (G, k, b) be an instance of the transshipment problem and (G, k, b 0 ) be obtained by scaling with a factor of.if(g, k, b) has an optimal solution, then (G, k, b 0 ) has an optimal solution. Proof: Since we have assumed that costs are nonnegative and costs are not affected by scaling, it suffices to show that (G, k, b 0 ) has a feasible solution. By Corollary 4.3 we must show that for every T V with (T )=? we have P v2t b0 (v) apple 0. This condition is trivial if T = V. Thus, assume that T 6= V. The special node z can not be contained in T since (v, z) 2 R for all v 2 V. Thus, b 0 (v) = v2t v2t b(v) apple v2t b(v) = b(v). Since (G, k, b) had a feasible solution, P v2t b(v) apple 0 and the claim follows. 2 The successive scaling algorithm solves an instance I =(G, k, b) of the transshipment problem by solving a series of scaled instances I L,I L 1,...,I 0. Instance I j is the instance I scaled by 2 j.observethati 0 = I. Algorithm 4.2 Successive scaling algorithm for solving the minimum cost flow problem Successive-Scaling(G, k, b) Input: AdirectedgraphG =(V,R,,!) in adjacency list representation; a nonnegative cost function k : R! R + ;requirednodeimbalancesb. 1 Let f 0 and p 0 2 Let L := blog 2 Bc, where B := Pv:b(v)>0 b(v). 3 for j = L, L 1,...,0 do 4 Let I j be the instance obtained by scaling I by 2 j. 5 Solve I j by means of the successive shortest path algorithm which is initialized by the pair (2f,p) 6 Update f to be the obtained optimal flow and p the corresponding potential in G f. 7 end for Suppose that we have a pseudoflow f and a potential p which together satisfy the reduced-cost optimality conditions. Then, we will also call p a dual solution. The reasons for this will become more clear in Section 4.5 when we study the relation to Linear Programming in greater depth. If f is additionally feasible, then f is optimum and we call (f,p) a pair of optimal primal and dual solutions. Suppose that we are given a pair (f,p) of optimal primal and dual solutions for some scaled instance I j+1 =(G, k, b j+1 ). Then, by definition (f,p) satisfy the reduced cost optimality conditions, i.e., k p ( r) 0 for all r 2 G f. Since all capacities are infinite also (2f,p) together satisfy the reduced cost optimality conditions (the residual network does not change). Hence, we can use (2f,p) as an initialization for the successive shortest path algorithm of Section 4.3 to solve I j =(G, k, b j ). The v2t

38 Minimum Cost Flow Algorithms number of iterations is bounded by the total imbalance of the surplus vertices, i.e., by v2v b j(v)>excess 2f (v) imbal 2f (v) = v2v b j(v)>excess 2f (v) (b j (v) excess 2f (v)) apple n 1, where the last inequality stems from the fact that excess 2f (v) = 2b j+1 (v) and 2b j+1 (v) 2{b j (v),b j (v) 1} (Recall that imbal 2f (v) decreases by an integral amount for some v with imbal 2f (v) > 0 in each iteration). Hence, the total time required to solve I j is O(nS(n, m, nk)) provided we are already given an optimal primal-dual pair for I j+1, where S(n, m, nk) is the time needed to compute shortest paths in a graph with n vertices, m arcs and arc lengths in the range {0,...,nK}. Consider the instance I L obtained by scaling with a factor of 2 L =2 blog Bc 2, where B := P v:b(v)>0 b(v). Then, all required node balances in I L are in { 1, 0, +1} such that we can start with the zero flow and corresponding optimal zero potential and apply once more the successive shortest path algorithm which will terminate after at most n 1 augmentations. The successive-scaling algorithm is displayed in Algorithm 4.2. Observe that we have to use B in the definition of L since we have assumed the existence of the special node z. Theorem 4.15 The successive scaling algorithm solves the transshipment problem in time O(n log BS(n, m, nk)), where B := P v:b(v)>0 b(v). Proof: We have already seen that the algorithm solves each instance I j in time O(nS(n, m, nk)). Since there are O(log B) instances, the claimed running time follows. The correctness of the result is a consequence of the fact that I 0 = I. 2 4.5 The Scale-and-Shrink Algorithm Although the running time of successive scaling algorithm in Section 4.4 is polynomial, it is not strongly polynomial, i.e.,thenumberofarithmeticoperationsdepends on the sizes of the numbers in the input. In this section we will present and analyze an algorithm which achieves a strongly polynomial running time. As a warmup, let us derive yet another optimality condition for minimum cost flows: Theorem 4.16 (Compl. Slackness Optimality Condition for b-flows) Let G be as in Assumption 4.1. Then, the b-flow f is of minimum cost, if and only if there exists p: V! R such that the reduced costs k p of the arcs in G satisfy the following properties: k p (r) > 0 ) f(r) =l(r) l(r) <f(r) <c(r) ) k p (r) =0 k p (r) < 0 ) f(r) =c(r). (4.5a) (4.5b) (4.5c) Proof: We show that the conditions in (4.5) are equivalent to the Reduced Cost Optimality Conditions from Theorem 4.8. To this end, assume first that p is a potential in G f,i.e.k p ( r) 0 for all r 2 G f. If k p (r) > 0, thenk p (+r) > 0 and G f can not contain the arc r, sinceitscost is k p ( r) = k p (+r) < 0. Thus, we must have f(r) =0. If l(r) <f(r) <c(r), then G f contains both arcs, +r and r. Since by assumption k p (+r) 0 and

4.5 The Scale-and-Shrink Algorithm 39 k p ( r) 0, wehavek p (r) =k p (+r) =0. Finally, if k p (r) < 0, theng f can not contain +r, sincek p (+r) =k p (r) < 0. Thus, f(r) =c(r). We now show the other direction. Assume that (4.5) holds. We must prove that k p ( r) 0 for all r 2 G f. If k p (r) > 0, thenk p (+r) =k p (r) > 0. By (4.5) we have f(r) =0,henceG f does not contain r. If k p (r) < 0, thenby(4.5)wehavef(r) =c(r) and G f does not contain +r. For r we have k p ( r) = k p (r) > 0. Finally, if l(r) <f(r) <c(r), then k p (r) =0and both arcs +r and r have zero reduced costs. Thus, p is a potential. 2 The presentation of the scale and shrink algorithm in this section will be done for the transshipment problem, i.e., we will assume that l(r) =0, c(r) =+1 and k(r) > 0 for all r 2 R. Our presentation requires again the existence of a special node z 2 V such that b(z) =0, (v, z) 2 R with k(v, z) =0and (z,v) /2 R for all v 2 V \{z}. As seen before, this is without loss of generality. We restate the transshipment problem as a Linear Program together with its dual, which will turn out to be extremely useful in the analysis later on: min r2r k(r)f(r) (4.6a) f(r) r2 (v) f(r) =b(v) for all v 2 V (4.6b) r2 + (v) f(r) 0 for all r 2 R (4.6c) max v2v b(v)p(v) (4.7a) p(!(r)) p( (r)) apple k(r) for all r 2 R (4.7b) The complementary slackness conditions of Linear Programming for the above pair of dual Linear Programs read as follows: f(r) > 0 ) p(!(r)) p( (r)) = k(r) (4.8a) ) p(!(r)) p( (r)) <k(r) ) f(r) =0. (4.8b) One immediately sees that Conditions (4.8) are exactly the Complementary Slackness Conditions which we have derived (in a more general setting) in Theorem 4.16. We first start with an elementary property that also helps us refresh our knowledge about LP-duality in the case of the minimum cost flow problem. Lemma 4.17 Let (G, k, b) be a transshipment problem with b =0, that is b(v) =0, for all v 2 V. Then any feasible solution for the dual Linear Program (4.7) is an optimal solution. Proof: By the nonnegativity of the costs k, theflowf 0 is an optimal solution of the instance, i.e., of the Linear Program (4.6). Since the objective function value of the dual (4.7) is zero for any feasible solution, any feasible solution to (4.7) must be also optimal for the dual. 2

40 Minimum Cost Flow Algorithms The notion of a tight arc will be essential for the algorithm. Start Lecture: 13.05.2016 Definition 4.18 (Tight arc) An arc r 0 2 R is tight if there exists an optimal solution for the transshipment problem with f(r 0 ) > 0. Suppose that r 0 2 R is a tight arc for an instance I of the transshipment problem, where u = (r 0 ) and v =!(r 0 ). The complementary slackness optimality conditions of Theorem 4.16 tell us that k p (r 0 )=0for any optimal solution p for the dual problem. In other words, p(v) =k(r 0 )+p(u) (4.9) for any optimal dual solution. Equation (4.9) tells us that we can remove the variable p(v) from the dual Linear Program by replacing it by k(r 0 )+p(u). Letus rewrite (4.7) by marking specific spots where u and v appear: max b(u)p(u)+b(v)p(v)+ i2v \{u,v} b(i)p(i) (4.10a) p(v) p(i) apple k(i, v) for all (i, v) 2 R (4.10b) p(i) p(v) apple k(v, i) for all (v, i) 2 R (4.10c) p(j) p(i) apple k(i, j) for all (i, j) 2 R with i, j 6= v (4.10d) Using p(v) =k(r 0 )+p(u) reduces (4.10) to the following: max (b(u)+b(v))p(u)+ i2v \{u,v} b(i)p(i) (4.11a) p(u) p(i) apple k(i, v) k(u, v) for all (i, v) 2 R (4.11b) p(i) p(u) apple k(v, i) +k(u, v) for all (v, i) 2 R (4.11c) p(j) p(i) apple k(i, j) for all (i, j) 2 R with i, j 6= v (4.11d) Now, let us have a closer look at (4.11). Consider the graph G/r 0 obtained from G by contracting the arc r 0,thatis,replacingthenodesu and v by the node u and the following operations: Each arc (i, v) 2 R is replaced by an arc (i, u) with cost k(i, u) =k(i, v) k(u, v). Each arc (v, i) is replaced by an arc (u, i) with cost k(u, i) =k(v, i)+k(r 0 ). Each arc (i, j) with i, j 6= v stays and has cost k(i, j) =k(i, j). Node u has required balance b(u) =b(u)+b(v) Each node i 6= u has balance b(i) =b(i). Then (4.11) is the dual of the transshipment problem defined by (G/r 0, k, b). We call this instance (G/r 0, k, b) the instance obtained from I by contracting arc r 0 and denote it by I/r 0. Contracting an arc preserves feasibility of the problem and the existence of an optimum solution to the problem, since there is a correspondence between optimal

4.5 The Scale-and-Shrink Algorithm 41 solutions of the instances I and I/r 0. Observe also that contracting an arc might introduce self loops, which we can safely delete without changing anything. Since any optimal dual solution p for I has p(v) =p(u)+k(r 0 ),wecanretrievean optimal dual solution for I from an optimal dual solution for I/r 0. Lemma 4.19 Let I =(G, k, b) be an instance of the transshipment problem and r 0 be a tight arc with (r 0 )=u and!(r 0 )=v. Let p be an optimal solution for the dual of the instance I/r 0 obtained by contracting r 0. Then an optimal solution p for I is given by p(i) = p(i) for i 6= v p(v) = p(u)+k(r 0 ). Proof: Immediately from the fact that p(v) =p(u) +k(r 0 ) for any optimal dual solution of I (that is of (4.10)) and the relations between the Linear Programs (4.10) and (4.11). 2 Anoteofcaution: Lemma4.19doesnot tell us that an optimal flow for the instance I/r 0 determines an optimal flow of I. It just tells us that we can extend an optimal dual solution for I/r 0 to an optimal dual solution for I. However, we will show that given an optimal dual solution for I we can find an optimal flow by solving a maximum flow problem. Consider the situation where we are given an optimal dual solution p and we want to find an optimal flow f. Forconvenience,werecalltheconditionsthatf needs to satisfy: excess f (i) =b(i) for all i 2 V (4.12a) 0 apple f(r) apple c(r) for all r 2 R (4.12b) f(r) =0 if k p (r) > 0 (4.12c) f(r) =c(r) if k p (r) < 0. (4.12d) Let c 0 and l 0 be defined by ( c 0 0 if k p (r) > 0 (r) = c(r) otherwise ( l 0 c(r) if k p (r) < 0 (r) = 0 otherwise Then, the conditions (4.12) are equivalent to finding a flow subject to the conditions that excess f (i) =b(i) l 0 (r) apple f(r) apple c 0 (r) for all i 2 V for all r 2 R This can be achieved by the method described in In-Class Exercise 2 of the first Homework by a single maximum flow computation. Assume for the moment that we are given an oracle that helps us identify a tight arc. Then, Lemma 4.19 suggests the following method for computing a minimum cost flow for an instance I =(G, k, b). If b =0,thenthezeroflowf 0 is optimal. An optimal dual solution p can be obtained as shown in Theorem 4.7 in time O(S(n, m, nk)) by a shortest path

42 Minimum Cost Flow Algorithms computation. If b 6= 0, thentheremustbeatightarc. Wecalltheoracletoidentify such a tight arc r 0. Then, we continue with the instance I/r 0. Observe that I/r 0 has one node less than I. Again, if all required balances in I/r 0 are zero, then we can find an optimal primal and dual solution easily. Otherwise, we identify again a tight arc and contract it. After at most n 1 contractions we have a network with a single node and the minimum cost flow problem is trivial to solve. By Lemma 4.19 we can reverse the contractions by getting an optimal dual solution for I from an optimal dual solution for I/r 0. As already noted, we then can get an optimal flow from the dual. The algorithm just described is depicted as Algorithm 4.3 in pseudocode. Algorithm 4.3 Scale-and-Shrink algorithm for solving the minimum cost flow problem Scale-and-Shrink(G, k, b) Input: AdirectedgraphG =(V,R,,!) in adjacency list representation; a nonnegative cost function k : R! R + ;requirednodeimbalancesb. 1 Set j := 1 and I 1 =(G, k, b) 2 while b 6= 0do 3 Call Find-Tight-Arc(I j ) to find a tight arc r 0 of I j and set I j+1 := I j /r 0. 4 j := j +1 5 end while 6 Find a feasible solution p for the dual of I j. 7 while j>1 do 8 Extend p to an optimal dual solution of I j 1 9 j := j 1 10 end while 11 Find a feasible flow f of (G, k, b) such that k p (r) =0whenever f(r) > 0. What remains is to implement the oracle that determines a tight arc. To this end, we need the concept of a tree solution for the transshipment problem. Such a tree solution is a function f : R! R satisfying the mass balance constraints (4.6b) and such that there exists a tree T in G with f(r) =0for all r/2 T. Lemma 4.20 A tree T uniquely determines its tree solution (provided it exists). Proof: The proof is an easy induction on the number of vertices n in the tree. If n =1,thetreehasnoarcandtheonlypossiblesolutionisf 0. If n>1, then the tree T has a leaf, say v, which has only one arc r incident with it. In any tree solution we must have f(r) =±b(v), where the sign depends on the direction on r. We can now remove r and v from the tree and proceed inductively. 2 Lemma 4.21 If there is a feasible solution to the transshipment problem, then there is also a feasible solution which is a tree solution. If there exists an optimal solution, then there is also an optimal solution which is a tree solution. Proof: Let f be any feasible solution. If f is not a tree solution, then there is an undirected cycle W in G (i.e., a cycle where we ignore the direction of the arcs) such that each arc of W has nonzero flow. Recall that we have assumed that c(r) =+1 for all r 2 R, sowecanalways increase the flow on an arc without violating the capacity constraints. We can find ">0 such that increasing the flow on any forward arc in W and decreasing the flow on any backward arc in W yields a flow which does not violate

4.5 The Scale-and-Shrink Algorithm 43 the capacity constraints. Observe that this does not change the excesses in the nodes. We could also decrease the flow on any forward arc by ">0 and increase the flow on any backward arc and still obtain a feasible flow (provided ">0is small enough). Thus, if ">0 and the direction in which we increase/decrease is chosen appropriately, at least one arc will get zero flow. We obtain a new flow f 0 which is zero on at least one more arc than f. Afteratmostm steps we must arrive at the situation that the flow is a tree solution. If f is an optimal solution, then since we can decrease/increase flow along the cycle W, then it follows that W must have zero cost. Hence, the procedure given above will not increase the cost of the flow and will terminate with an optimal solution which then is also a tree solution. 2 Tree solutions play an important role in the construction of a very popular algorithm for solving the transshipment problem (respective the minimum cost flow problem). The Network Simplex Method maintains feasible tree solutions and looks for special negative cost cycles. We refer to the books [AMO93, CCPS98] for this method. We are now ready to state our algorithm for finding a tight arc which is displayed in Algorithm 4.4. Recall that to scale an instance (G, k, b) of the transshipment problem by a factor of > 0 means the following: We replace b(v) by b 0 (v) =bb(v)/ c for all v 6= z. We set b 0 (z) = P v6=z b0 (v). The latter definition ensures that P i2v b0 (v) =0so that feasibility of an instance is preserved (cf. Lemma 4.14). Algorithm 4.4 Subroutine to find a tight arc. Find-Tight-Arc(G, k, b) 1 Find a feasible tree solution f for (G, k, b) 2 Scale the instance (G, k, b) by = 1 n(n 1) max{ f(r) :r 2 R } to obtain a new instance (G, k, b 0 ) with b 0 (v) =bb(v)/ c for all v 6= z b 0 (z) = P v6=z b0 (v) 3 Find an optimal tree solution f 0 for the instance (G, k, b 0 ). 4 Find r 0 2 R such that f 0 (r 0 ) n 1. Lemma 4.22 Let r 0 2 R be any arc such that in Step 4 of the Find-Tight-Arc algorithm we have f 0 (r 0 ) n 1. Then, r 0 is a tight arc. Proof: Suppose that we solve the instance (G, k, b) by means of the successive shortest path algorithm, initializing the algorithm with ( f 0, 0 ), where (f 0, 0 ) is a pair of optimal primal and dual solutions for (G, k, b 0 ).Here,weuse f 0 to denote the flow with flow f 0 (r) on an arc r. Observe that ( f 0, 0 ) together satisfy the reduced cost optimality conditions for (G, k, b), sincetheresidualnetworkdoesnotchangeinthetransitionfrom(g, k, b 0 ) to (G, k, b). Hence, ( f 0, 0 ) are a valid initialization. The algorithm terminates with an optimal flow f and a corresponding optimal potential.

44 Minimum Cost Flow Algorithms Since f 0 is feasible for (G, k, b), wehaveexcess f 0(v) =b 0 (v) for all v 2 V. Thus, we get excess f 0(v) = b 0 (v) for all v. Since for v 6= z we have b 0 (v) =bb(v)/ c, it follows that excess f 0(v) 2 (b(v),b(v)]. Hence for any node v with b(v) > excess f 0(v), it follows that b(v) excess f 0(v) <. As noted in the proof of Theorem 4.13, the total value of all augmentations is bounded from above by (b(v) excess f 0(v)) < (n 1). v2v b(v)>excess f 0 (v) Hence, the value of all augmentations is strictly smaller than (n 1). Consequently, since f 0 (r 0 ) (n 1) by the assumption that f 0 (r 0 ) n 1, it follows that after all augmentations, the arc r 0 must still carry positive flow. Hence, we have found an optimal solution where r 0 has positive flow, in other words, r 0 is a tight arc. 2 Lemma 4.23 Find-Tight-Arc is able to find a tight arc. Proof: In view of Lemma 4.22 it suffices to show that there will always be an arc r 0 with f 0 (r 0 ) n 1. Moreover,itsufficestoconsiderthesituationthatb 6= 0,since Find-tight-Arc is only called in this case. Let r be an arc such that f(r) = max{ f(r 0 ):r 0 2 R }. Then = f(r) n(n 1) and f(r) > 0 since b 6= 0. We now exploit the fact that f is a tree solution. Let T be the corresponding tree. Removing r from T cuts the tree into two parts which form apartition [ Y = V of the vertex set of G. Assume without loss of generality that (r) =x,!(r) =y with x 2 and y 2 Y. Then, the total net inflow into Y must equal f(r) and the total net outflow out of must equal f(r). Thus, we have f(r) = P v2y b(v). Consider the cut (, Y ). Then,theflow P r 0 2 + () f 0 (r 0 ) from into Y across the cut is at least P v2y b0 (v) (since the netflow into Y must be exactly P v2y b0 (v)) that is, b 0 (v) apple f 0 (r 0 ). (4.13) v2y r 0 2 + () Since f 0 is a tree solution, there is one arc r 0 in + () with f 0 1 (r 0 ) Thus, this arc r 0 satisfies: f 0 (r 0 ) = n 1 n 1 1 n 1 1 n 1 1 n 1 n 1. r 0 2 + () f 0 (r 0 ) b 0 (v) (by (4.13)) v2y b(v) 1 v2y Y n 1 n(n 1) f(r)! b(v) Y v2y n 1 (since f(r) = v2y P r 0 2 + () f 0 (r 0 ). b(v)) Hence from Lemma 4.22 it follows that r 0 is a tight arc. 2

4.5 The Scale-and-Shrink Algorithm 45 We have shown the correctness of Scale-and-Shrink. We complete our analysis with the running time. Theorem 4.24 Algorithm Scale-and-Shrink finds an optimal solution for the transshipment problem in time O(n 2 log ns(n, m, nk)), where S(n, m, nk) is the time needed to compute shortest path distances from a node in a graph with n vertices, m arcs and nonnegative integer lengths in {0,...,nK}. For instance, using Dijkstra s Algorithm gives S(n, m, nk) 2O(m + n log n). Proof: We first analyze the running time of the Find-Tight-Arc routine which is called at most n times by the algorithm. The first time Find-Tight-Arc is called, we compute a feasible tree solution as follows: We compute a feasible flow by one maximum flow computation. This can be accomplished in O(n 3 ) time by the FIFO-preflow-push algorithm of Section 3.1.4. We then convert the solution into a tree solution as in the proof of Lemma 4.21. This needs time O(nm). In all subsequent calls to Find-Tight-Arc we are faced with the situation that we already have a tree solution f for I, butneedatreesolutionfori/r 0. If r 0 is not in the tree, then f is clearly again a feasible tree solution for I/r 0. Otherwise, the contraction of r 0 causes a cycle W in the flow pattern of f. However, by sending flow along W (as in the proof of Lemma 4.21) we can reduce the flow on at least one arc of W to zero. This procedure needs O(n 2 ) time. We conclude that finding a feasible tree solution needs a total of O(n 3 ) time for all calls to Find-Tight-Arc. The only other major effort in Find-Tight-Arc is to solve the transshipment instance (G, k, b 0 ) in Step 3. We can use the successive scaling algorithm of Section 4.4 for this purpose. Its running time on (G, k, b 0 ) is O(n log BS(n, m, nk)), where B := P v:b 0 (v)>0 b0 (v). We bound b 0 (v) for all v with b 0 (v) > 0 in an appropriate way. First consider anodev 6= z. Since f is a tree solution, there are at most n 1 arcs where f is nonzero. In particular, at most n 1 arcs (j, v) can have nonzero flow. Since b(v) apple P j:(j,v)2r f(j, v), weconcludethatthereisanarc(j 0,v) with f(j 0,v) b(v)/(n 1). Hencethescalingparameter satisfies b 0 (v) apple b(v) = n(n 1) 2. b(v) n(n 1) 2 b(v) n(n 1) 2 and The special node z has required balance b 0 (z) apple n 1. Hence, B = P v:b 0 (v)>0 b0 (v) apple n n(n 1) 2 = O(n 4 ). This yields O(n log BS(n, m, nk)) = O(n log ns(n, m, nk)) for solving the instance (G, k, b 0 ). In summary, the running time for a single call to the procedure Find-Tight-Arc is in O(n log ns(n, m, nk)) and there will be an additional effort of O(n 3 ) for the first call. These running times dominate all other steps in the main part of the algorithm. Since Find-Tight-Arc is called n times, the claimed running time follows. 2