A Course in Combinatorial Optimization
Total Page:16
File Type:pdf, Size:1020Kb
A Course in Combinatorial Optimization Alexander Schrijver CWI, Kruislaan 413, 1098 SJ Amsterdam, The Netherlands and Department of Mathematics, University of Amsterdam, Plantage Muidergracht 24, 1018 TV Amsterdam, The Netherlands. November 9, 2004 copyright c A. Schrijver Contents 1. Shortest paths and trees 5 1.1. Shortest paths with nonnegative lengths 5 1.2. Speeding up Dijkstra's algorithm with heaps 9 1.3. Shortest paths with arbitrary lengths 12 1.4. Minimum spanning trees 19 2. Polytopes, polyhedra, Farkas' lemma, and linear programming 23 2.1. Convex sets 23 2.2. Polytopes and polyhedra 25 2.3. Farkas' lemma 31 2.4. Linear programming 33 3. Matchings and covers in bipartite graphs 39 3.1. Matchings, covers, and Gallai's theorem 39 3.2. K}onig's theorems 40 3.3. Cardinality bipartite matching algorithm 44 3.4. Weighted bipartite matching 47 3.5. The matching polytope 50 4. Menger's theorem, flows, and circulations 53 4.1. Menger's theorem 53 4.2. Path packing algorithmically 57 4.3. Flows in networks 60 4.4. Finding a maximum flow 62 4.5. Speeding up the maximum flow algorithm 67 4.6. Circulations 70 4.7. Minimum-cost flows 72 5. Nonbipartite matching 79 5.1. Tutte's 1-factor theorem and the Tutte-Berge formula 79 5.2. Cardinality matching algorithm 82 5.3. Weighted matching algorithm 86 5.4. The matching polytope 93 5.5. The Cunningham-Marsh formula 96 6. Problems, algorithms, and running time 98 6.1. Introduction 98 6.2. Words 99 6.3. Problems 101 6.4. Algorithms and running time 101 6.5. The class NP 102 6.7. NP-completeness 104 6.8. NP-completeness of the satisfiability problem 104 6.9. NP-completeness of some other problems 107 6.10. Turing machines 109 7. Cliques, cocliques, and colourings 112 7.1. Introduction 112 7.2. Edge-colourings of bipartite graphs 116 7.3. Partially ordered sets 122 7.4. Perfect graphs 125 7.5. Chordal graphs 129 8. Integer linear programming and totally unimodular matrices 133 8.1. Integer linear programming 133 8.2. Totally unimodular matrices 135 8.3. Totally unimodular matrices from bipartite graphs 140 8.4. Totally unimodular matrices from directed graphs 144 9. Multicommodity flows and disjoint paths 149 9.1. Introduction 149 9.2. Two commodities 154 9.3. Disjoint paths in acyclic directed graphs 158 9.4. Vertex-disjoint paths in planar graphs 160 9.5. Edge-disjoint paths in planar graphs 166 9.6. A column generation technique for multicommodity flows 169 10. Matroids 174 10.1. Matroids and the greedy algorithm 174 10.2. Equivalent axioms for matroids 177 10.3. Examples of matroids 181 10.4. Two technical lemmas 184 10.5. Matroid intersection 185 10.6. Weighted matroid intersection 191 10.7. Matroids and polyhedra 195 References 200 Name index 211 Subject index 213 5 1. Shortest paths and trees 1.1. Shortest paths with nonnegative lengths Let D = (V; A) be a directed graph, and let s; t V . A walk is a sequence P = 2 (v0; a1; v1; : : : ; am; vm) where ai is an arc from vi−1 to vi for i = 1; : : : ; m. If v0; : : : ; vm all are different, P is called a path. If s = v0 and t = vm, the vertices s and t are the starting and end vertex of P , respectively, and P is called an s t walk, and, if P is a path, an s t path. The − − length of P is m. The distance from s to t is the minimum length of any s t path. (If no s t path exists, we set the distance from s to t equal to .) − − 1 It is not difficult to determine the distance from s to t: Let Vi denote the set of vertices of D at distance i from s. Note that for each i: (1) V is equal to the set of vertices v V (V V V ) for which i+1 2 n 0 [ 1 [ · · · [ i (u; v) A for some u V . 2 2 i This gives us directly an algorithm for determining the sets Vi: we set V0 := s and next we determine with rule (1) the sets V ; V ; : : : successively, until V = f. g 1 2 i+1 ; In fact, it gives a linear-time algorithm: Theorem 1.1. The algorithm has running time O( A ). j j Proof. Directly from the description. In fact the algorithm finds the distance from s to all vertices reachable from s. Moreover, it gives the shortest paths. These can be described by a rooted (directed) tree T = (V 0; A0), with root s, such that V 0 is the set of vertices reachable in D from s and such that for each u; v V 0, each directed u v path in T is a shortest u v 2 − − path in D.1 Indeed, when we reach a vertex t in the algorithm, we store the arc by which t is reached. Then at the end of the algorithm, all stored arcs form a rooted tree with this property. There is also a trivial min-max relation characterizing the minimum length of an s t path. To this end, call a subset A0 of A an s t cut if A0 = δout(U) for some − − subset U of V satisfying s U and t U.2 Then the following was observed by 2 62 Robacker [1956]: 1A rooted tree, with root s, is a directed graph such that the underlying undirected graph is a tree and such that each vertex t = s has indegree 1. Thus each vertex t is reachable from s by a unique directed s t path. 6 2δout(U) and δ−in(U) denote the sets of arcs leaving and entering U, respectively. 6 Chapter 1. Shortest paths and trees Theorem 1.2. The minimum length of an s t path is equal to the maximum number − of pairwise disjoint s t cuts. − Proof. Trivially, the minimum is at least the maximum, since each s t path intersects − each s t cut in an arc. The fact that the minimum is equal to the maximum follows − by considering the s t cuts δout(U ) for i = 0; : : : ; d 1, where d is the distance from − i − s to t and where Ui is the set of vertices of distance at most i from s. This can be generalized to the case where arcs have a certain `length'. For any `length' function l : A Q and any walk P = (v ; a ; v ; : : : ; a ; v ), let l(P ) be ! + 0 1 1 m m the length of P . That is: m (2) l(P ) := l(a): Xi=1 Now the distance from s to t (with respect to l) is equal to the minimum length of any s t path. If no s t path exists, the distance is + . − − 1 Again there is an easy algorithm, due to Dijkstra [1959], to find a minimum-length s t path for all t. Start with U := V and set f(s) := 0 and f(v) = if v = s. Next − 1 6 apply the following iteratively: (3) Find u U minimizing f(u) over u U. For each a = (u; v) A for which 2 2 2 f(v) > f(u) + l(a), reset f(v) := f(u) + l(a). Reset U := U u . n f g We stop if U = . Then: ; Theorem 1.3. The final function f gives the distances from s. Proof. Let dist(v) denote the distance from s to v, for any vertex v. Trivially, f(v) dist(v) for all v, throughout the iterations. We prove that throughout the iterations,≥ f(v) = dist(v) for each v V U. At the start of the algorithm this is 2 n trivial (as U = V ). Consider any iteration (3). It suffices to show that f(u) = dist(u) for the chosen u U. Suppose f(u) > dist(u). Let s = v ; v ; : : : ; v = u be a shortest s u path. 2 0 1 k − Let i be the smallest index with v U. i 2 Then f(vi) = dist(vi). Indeed, if i = 0, then f(vi) = f(s) = 0 = dist(s) = dist(vi). If i > 0, then (as v V U): i−1 2 n (4) f(v ) f(v ) + l(v ; v ) = dist(v ) + l(v ; v ) = dist(v ): i ≤ i−1 i−1 i i−1 i−1 i i This implies f(v ) dist(v ) dist(u) < f(u), contradicting the choice of u. i ≤ i ≤ Section 1.1. Shortest paths with nonnegative lengths 7 Clearly, the number of iterations is V , while each iteration takes O( V ) time. j j j j So the algorithm has a running time O( V 2). In fact, by storing for each vertex v the j j last arc a for which (3) applied we find a rooted tree T = (V 0; A0) with root s such that V 0 is the set of vertices reachable from s and such that for each u; v V 0, each directed u v path in T is a shortest u v path in D. 2 − − Thus we have: Theorem 1.4. Given a directed graph D = (V; A), s; t V , and a length function 2 l : A Q , a shortest s t path can be found in time O( V 2). ! + − j j Proof. See above. For an improvement, see Section 1.2. A weighted version of Theorem 1.2 is as follows: Theorem 1.5.