This preview shows page 1. Sign up to view the full content.
Unformatted text preview: 18.415 6.854 Advanced Algorithms
Lecturer: Michel X. Goemans November 1994 Network ows In these notes, we study some problems in "Network Flows". For a more comprehensive treatment, the reader is referred to the surveys 12, 1 , or to the recent book 2 . Network ow problems arise in a variety of settings; the underlying networks might be transportation networks, communication networks, hydraulic networks, computer chips, or some abstract network. The eld was born from applications in the 40's and 50's and has since developed into a strong methodological core with numerous algorithmic issues. The rst polynomial time algorithms for network ow problems have been developed in the 70's, and constant progress towards faster and faster algorithms has been made in the 80's. Network ow problems can be formulated as linear programs and, as a result, all the methodology of linear programming can be applied. Duality plays a crucial role, and the simplex algorithm can take advantage of the structure of network ow problems bases can be nicely characterized. Some of the basic problems in this area include the single source shortest path problem, the maximum ow problem, and the minimum cost ow problem. First, we shall brie y review each of them and then we shall describe a polynomial time algorithm due to Goldberg and Tarjan 14 for the minimum cost ow problem. 1 Single Source Shortest Path Problem
We are interested in the following problem: Given a directed graph G = V; E where V is the set of vertices and E is the set of edges, and a length function l : E ! Z, a distinguished vertex s 2 V the source vertex, Find for all v 2 V the length v of the shortest path from s to v. This is NPhard if we allow negative length cycles i.e. cycles for which the sum of the lengths of its edges is negative. However, if all lengths are nonnegative lu; v 0 for all edges u; v 2 E then a standard algorithm that solves this problem is Dijkstra's algorithm 6 see also 4 . The implementation of Dijkstra's algorithm is based on the implementation of a priority queue and various implementations of this priority queue lead to di erent worstcase running times. Using a Fibonacci heap implementation 10 of the priority queue, it can be shown that the algorithm has a Flow1 total running time of Om + n log n where m = jE j and n = jV j. This is the best known strongly polynomial algorithm for the singlesource shortest path problem. An algorithm is said to be strongly polynomial if 1. It performs a polynomially bounded number of operations in the number of input data in this case m and n. We allow the operations +,,*, and rational division. 2. The sizes of the numbers occurring during the algorithm are polynomially bounded in the size of the input. There are also singlesource shortest path algorithms which may not be strongly polynomial, i.e. algorithms whose running time depends on L = max lu; v+1. These algorithms may achieve a better running time than Dijkstra's algorithm, provided L is not too large. Listed below are four such algorithms: Dial 5 Om + nL Johnson 16 Om log log L Gabow 11 Om logdp where d = max2; dm=ne L Ahuja, Mehlhorn, Orlin, Tarjan 3 Om + n log L Observe that all these algorithms except Dial's algorithm are polynomial since the size of the input is at least log L. If negative lengths are allowed then the problem can still be solved in polynomial time provided that no negative length cycle exists. The algorithm of BellmanFord solves this problem in Onm time. We would like to point out that these problems are de ned on a directed graph. An undirected shortest path problem can easily be reduced to a directed instance by replacing every edge by bidirected edges. This reduction is ne if all lengths are nonnegative in which case Dijkstra's algorithm can be used, but does not work if there are edges of negative length. In this case, indeed, a negative length cycle would be created. However, the undirected shortest path problem on an undirected graph with possibly negative edge lengths but no negative length cycle can still be solved in polynomial time. The algorithm is, however, fairly complicated and is based on a reduction of the problem to nonbipartite matching. 2 The Maximum Flow Problem
Given a directed graph G = V; E where V is the set of vertices and E is the set of edges, capacity uv; w 0 for v; w 2 E , source s 2 V , Flow2 sink t 2 V , a ow f is an assignment of values to the edges which satis es f v; w uv; w for all edges v; w and which satis es the ow conservation constraints X X f v; w = f w; v
w:v;w2E w:w;v2E for all vertices v except s and t. The goal is to nd a ow such that the net ow P f s; w out of s P w v:s;v2E f s; v is maximum. One can easily derive that the net ow out of s is equal to the net ow into t, and thus we could maximize this latter quantity as well. All these constraints are linear constraints and the objective function is linear, so the maximum ow problem MAX FLOW is a linear program. We could therefore exploit the structure of the linear program to tailor the simplex algorithm. This has been done and, in fact, although no version of the simplex algorithm is known to run in polynomial time for general linear programs, it is known that it can be made to run in polynomial time or even in strongly polynomial time for the maximum ow problem. Goldfarb and Hao 15 have developed a version of the simplex which makes at most nm pivots and run in On2 m time. However, there are some more e cient combinatorial algorithms which exploit the structure of the problem. Most known algorithms are based on the concept of "augmenting paths", introduced by Ford and Fulkerson 8 . There are a variety of algorithms with di erent running times. The best strongly polynomial running time of a max ow algorithm is Onm log n2=m due to Goldberg and Tarjan 13 . 3 Minimum Cost Circulation Problem
In the minimum cost circulation problem, we are given a directed graph G = V; E . For each arc v; w 2 E , we are given a cost cv; w, a lower bound lv; w and an upper bound uv; w. Throughout, we assume that l:; :; u:; : and c:; : are integral unless mentioned otherwise. We will associate a ow f with each arc of the graph. This ow will be required to satisfy lv; w f v; w uv; w and the cost of the ow on v; w is de ned to be cv; wf v; w. This is the classical notation. However, in our lectures, we adopt Goldberg and Tarjan's notation 14 in which every directed arc v; w is represented by arcs v; w and w; v see Figure 1. This will simplify the proofs later on. In this notation, the ow f w; v on w; v is assumed to be equal to ,f v; w, i.e. the ow is antisymmetric. Using this antisymmetry assumption, the lower bound on the ow f v; w is equivalent to an upper bound of ,lv; w on f w; v. Also, the cost cw; v on the arc w; v is de ned to be ,cv; w. This ensures that, if we push some ow on v; w and then decide to push it back from w to v, we get a full refund of the cost incurred i.e. cv; wf v; w. Notice that the total cost of the ow on the arcs v; w and w; v is equal to Flow3 l(v,w) f(v,w) u(v,w) c(v,w) f(v,w) u(v,w) c(v,w) v w v
c(w.v) = c(v,w) w f(w,v) = f(v.w) l(v,w) = u(w,v) Figure 1: Standard notation vs. GoldbergTarjan notation. cv; wf v; w + cw; vf w; v = cv; wf v; w , cv; wf w; v = 2cv; wf v; w = 2cw; vf w; v. To recapitulate, we are given a bidirected1 graph G = V; E , a capacity function u : E ! Z and a cost function c : E ! Z. The cost function is assumed to be antisymmetric: cv; w = ,cw; v 8v; w 2 E: A ow is a function f : E ,! R, which is assumed 1. to be antisymmetric, i.e. f v; w = ,f w; v, and 2. to satisfy the capacity constraints: f v; w uv; w for all v; w 2 E . The cost of a ow is de ned as: X cf = cv; wuv; w:
v;w2E A ow is said to be a circulation if X
w f v; w = 0 for all v 2 V . Using the antisymmetry constraints, this is equivalent to saying that the ow out of vertex v minus the ow into v is equal to 0 for all v 2 V . These conditions are thus the ow conservation constraints. The minimum cost circulation problem is the problem of nding a circulation of minimum cost. A closely related problem to the minimum cost circulation problem is the minimum cost ow problem. In this problem, we are also given a supply function b : V ! Z satisfying Pv2V bv = 0 and the ow is required to satisfy X 1 f v; w = bv
w for all v 2 V . The goal is to nd a ow satisfying 1 of minimum cost. The minimum cost circulation problem is clearly a special case of the minimum cost ow problem simply take bv = 0 for all v 2 V . However, the converse is also true. Consider Flow4 f(s,v) < b(v) G
v s c(s,v) = c(v,s) = 0 f(v,s) < b(v) Figure 2: How to convert a minimum cost ow problem into a minimum cost circulation problem. the following transformation that converts any instance of the minimum cost ow problem into an instance of the minimum cost circulation problem see Figure 3. Let G0 = V 0; E 0 be the graph obtained by extending G with one extra vertex, say s, linked to all other vertices, i.e. V 0 = V fsg and E 0 = E fs; v : v 2 V g fv; s : v 2 V g. For these new edges, let cs; v = cv; s = 0 and us; v = bv = ,uv; s, the other costs and capacities remaining unchanged. The capacities on the bidirected edges incident to s have been chosen in such a way that, for any ow f on this extended graph, we have f s; v = bv. Therefore, any circulation f on G0 induces a ow on G satisfying 1 and vice versa. Since this circulation on G0 and this ow on G have the same cost, we can solve the minimum cost ow problem by solving a minimum cost circulation problem. In these notes, we develop a purely combinatorial algorithm to solve the minimum cost circulation problem and we will also show that this problem can be solved in strongly polynomial time. We'd like to point out that for the minimum cost ow or circulation problem, it is not known whether the simplex method can be adapted to run in strongly polynomial time contrary to the case for the maximum ow problem. In many situations, the circulation is required to be integral. This additional restriction is not restrictive as indicated in the following Theorem  sometimes referred to as the integrality theorem. Theorem 1 If uv; w 2 Zfor all v; w 2 E then there exists an optimal circulation or ow with f v; w 2 Z.
Although there are several ways to prove this result, we will deduce it later in the notes from a simple algorithm for the minimum cost circulation problem. More precisely, we will show that, at every iteration of the algorithm, the current circulation is integral and, hence, it is also integral when the algorithm terminates. The minimum cost circulation problem has some interesting special cases as described in the next sections. Our strongly polynomial time algorithm for the minimum cost circulation problem will thus lead to strongly polynomial time algorithms
1 v; w 2 implies E w; v 2 .
E Flow5 for these special cases although more e cient algorithms can be designed for these special cases. 3.1 The Maximum Flow Problem The maximum ow problem is a special case of the minimum cost circulation problem. Indeed, given an instance of the maximum ow problem, add an edge between s and t see Figure 3.1 and de ne ut; s = 1, us; t = 0, ct; s = ,1 = ,cs; t and cv; w = 0 for all v; w 6= s; t.
G
s ... Figure 3: How to transform a maximum ow problem into a minimum cost circulation problem. The capacities on the bidirected edge s; t is such that f t; s 0, implying that the ow goes from t to s. There is a onetoone correspondence between circulations in this extended graph and ows in the original graph satisfying all ow conservation constraints in V n fs; tg. Moreover, the cost of any circulation in this extended graph is exactly equal to minus the net ow out of s or into t in the original graph. As a result, the maximum ow problem in G is equivalent to the minimum cost circulation problem in the extended graph. Using the integrality theorem Theorem 1, we obtain that the ow of maximum value can be assumed to be integral whenever the capacities are integral. ...
u(s,t) = 0 c(s,t) = 1 t u(t,s) = + c(t,s) = 1 3.2 Bipartite Matching The maximum cardinality matching problem on a bipartite graph G = A; B; E A and B denotes the bipartition of the vertex set is the problem of nding the largest number of disjoint edges. This problem is a special case of the maximum ow problem and, hence, of the minimum cost circulation problem. To transform the maximum cardinality bipartite matching problem into a maximum ow problem see Figure 3.2, we 1. direct all the edges from A to B , 2. add a source vertex s, a sink vertex t, Flow6 3. add the edges s; a for all vertices a 2 A and the edges b; t for all vertices b 2 B and 4. de ne the capacity of all existing edges to be 1 and the capacity of their reverse edges to be 0 in other words, the ow on the existing edges have a lower bound of 0. By the integrality theorem, we know that the ow on any existing edge can be assumed to be either 0 or 1. Therefore, to any ow f , there corresponds a matching M = fv; w 2 E : f v; w = 1g whose cardinality is precisely equal to the net amount of ow out of vertex s.
u(w,v) = 0 v
1 u( v, s) u(v,w) = 1 = w 0 s u( s,v )= t Figure 4: Maximum cardinality bipartite matching is a special case of maximum ow. It is also easy to construct from a matching M a ow of value jM j. As a result, any integral ow of maximum value will correspond to a matching of maximum cardinality. In fact, the minimum weighted bipartite matching problem is also a special case of the minimum cost circulation problem. We can modify the above transformation in the following way. De ne the cost of any edge of the original graph to be its original cost and the cost of any new edge to be 0. Now, we can model three versions of the minimum weighted bipartite matching problem by appropriately de ning the capacities on the edges t; s and s; t: 1. If ut; s = n and us; t = ,n where n = jAj = jB j, we get the minimum weighted perfect a perfect matching is a matching that covers all the vertices matching. 2. If ut; s = n and us; t = 0, we obtain the minimum weighted matching. 3. If ut; s = k and us; t = ,k, we obtain the minimum weighted matching of size k. Flow7 3.3 Shortest paths The single source shortest path problem is also a special case of the minimum cost ow problem. Indeed, by setting lv; w = 0 and uv; w = 1 for every edge and letting their cost be the original cost, and introducing an edge from t to s with ut; s = lt; s = 1 and ct; s = 0, we obtain an equivalent instance of the minimum cost circulation problem. 4 Some Important Notions
We now go back to the minimum cost circulation problem, and before describing a polynomial time algorithm for it, we present some useful tools. 4.1 Residual Graph Given a minimum cost circulation problem and a circulation f , we de ne the residual graph Gf = V; Ef with respect to f by Ef = fv; w : f v; w uv; wg. For example, if uv; w = 5, uw; v = ,1 and f v; w = 3 hence, f w; v = ,3 by antisymmetry then both v; w and w; v will be present in Ef . However, if f v; w = 1 i.e. f w; v = ,1, only v; w will be in Ef . With respect to f , we de ne the residual capacity of the edge v; w by uf v; w = uv; w , f v; w: Notice that the edges of the residual graph have a positive residual capacity. 4.2 Potentials We associate with each vertex v a vertex potential pv. The potential of a vertex can be interpreted as the dual variable corresponding to the ow conservation constraints in the linear programming formulation of the problem. The reduced cost of the edge v; w is then de ned as cpv; w := cv; w+ pv , pw. Note that the reduced costs are still antisymmetric i.e. cpw; v = cw; v+ pw , pv = ,cv; w , pv+ pw = ,cpv; w. Note also that the cost X c, := cv; w
v;w2, of a directed cycle , is equal to its reduced cost X cp, = cpv; w
v;w2, since the vertex potential of any vertex v on the cycle is added and subtracted exactly once. More generally, we have the following result. Flow8 Theorem 2 For any p : V ! Z and any circulation f , we have c f = cp f . Proof: By de nition, X X X cp f = cpv; wf v; w = cv; wf v; w + pvf v; w
v;w2E pwf v; w X X = c f + pv f v; w v2V w:v;w2E X X , pw f v; w
v;w2E v;w2E , X v;w2E = c f + 0 , 0 = c f; X since by de nition of a circulation f v; w = 0.
w:v;w2E w2V v:v;w2E 5 When is a circulation Optimal?
The next theorem characterizes a circulation of minimum cost. Theorem 3 For a circulation f , the following are equivalent: 1. f is of minimum cost, 2. there are no negative reduced cost cycles in the residual graph, 3. there exist potentials p such that cp v; w 0 for v; w 2 Ef . This is essentially strong duality, but we will not refer to linear programming in the proof. Proof: :2 :1: Let , be a negative cost cycle in Ef . Let = v;w2, uf v; w 0: min ~ By pushing units of ow along ,, we mean replacing f by f where 8 f v; w + v; w 2 , f~v; w = f v; w , w; v 2 , : : f v; w otherwise Notice that, as de ned, f~ also satis es the antisymmetry constraints and is a circulation. Moreover, c f~ = c f + c, c f . This implies that f is not of minimum cost. Flow9 2 3: Let G0 be obtained from the residual graph Gf by adding a vertex s linked to all other vertices by edges of cost 0 the costs of these edges do not matter. Let pv be the length of the shortest path from s to v in G0 with respect to the costs c:; :. This quantities are wellde ned since Gf does not contain any negative cost directed cycle. By de nition of the shortest paths, we have pw pv+ cv; w for all edges v; w 2 Ef . This implies that cpv; w 0 whenever v; w 2 Ef . 3 1: The proof is by contradiction. Let f be a circulation such that c f c f . Consider f 0v; w = f v; w , f v; w. By de nition of the residual capacities, f 0 is a feasible circulation with respect to uf :; :. Its cost is X c f 0 = cp f 0 = cpv; wf 0v; w v;w2E X = 2 cpv; wf 0v; w 0; v;w2E :f v;w 0
0 since f 0v; w 0 implies that v; w 2 Ef and, hence, cpv; w 0. This contradicts the fact that c f 0 = c f , c f 0. A problem is well characterized if its decision version belongs to NP co,NP . The above theorem gives a good characterization for the minimum cost circulation problem to be precise, we would also need to show that the potentials can be compactly encoded. It also naturally leads to a simple algorithm, rst discovered by Klein 17 also known as the `Cycle Cancelling Algorithm'. 6 Klein's Cycle Canceling Algorithm
Cycle canceling algorithm Klein:
1. Let f be any circulation. 2. While Gf contains a negative cycle , do push = v;w2, uf v; w along ,. min Recall that in the previous code push" means that we increase the ow by along the well oriented edges of , and decrease it by along the other edges of ,. In Step 1, we will assume that f = 0 satis es the capacity constraints i.e. f = 0 is a circulation. If this is not the case then a circulation can be obtained by solving Flow10 ...
View
Full
Document
This note was uploaded on 02/13/2012 for the course CSE 4101 taught by Professor Mirzaian during the Winter '12 term at York University.
 Winter '12
 Mirzaian
 Algorithms, Data Structures

Click to edit the document details