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. March 23, 2017 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 30 2.4. Linear programming 33 3. Matchings and covers in bipartite graphs 39 3.1. Matchings, covers, and Gallai’s theorem 39 3.2. M-augmenting paths 40 3.3. K˝onig’s theorems 41 3.4. Cardinality bipartite matching algorithm 45 3.5. Weighted bipartite matching 47 3.6. The matching polytope 50 4. Menger’s theorem, flows, and circulations 54 4.1. Menger’s theorem 54 4.2. Flows in networks 58 4.3. Finding a maximum flow 60 4.4. Speeding up the maximum flow algorithm 65 4.5. Circulations 68 4.6. Minimum-cost flows 70 5. Nonbipartite matching 78 5.1. Tutte’s 1-factor theorem and the Tutte-Berge formula 78 5.2. Cardinality matching algorithm 81 5.3. Weighted matching algorithm 85 5.4. The matching polytope 91 5.5. The Cunningham-Marsh formula 94 6. Problems, algorithms, and running time 97 6.1. Introduction 97 6.2. Words 98 6.3. Problems 100 6.4. Algorithms and running time 100 6.5. The class NP 101 6.6. The class co-NP 102 6.7. NP-completeness 103 6.8. NP-completeness of the satisfiability problem 103 6.9. NP-completeness of some other problems 106 6.10. Turing machines 108 7. Cliques, stable sets, and colourings 111 7.1. Introduction 111 7.2. Edge-colourings of bipartite graphs 115 7.3. Partially ordered sets 121 7.4. Perfect graphs 125 7.5. Chordal graphs 128 8. Integer linear programming and totally unimodular matrices 132 8.1. Integer linear programming 132 8.2. Totally unimodular matrices 134 8.3. Totally unimodular matrices from bipartite graphs 139 8.4. Totally unimodular matrices from directed graphs 143 9. Multicommodity flows and disjoint paths 148 9.1. Introduction 148 9.2. Two commodities 153 9.3. Disjoint paths in acyclic directed graphs 157 9.4. Vertex-disjoint paths in planar graphs 159 9.5. Edge-disjoint paths in planar graphs 165 9.6. A column generation technique for multicommodity flows 168 10. Matroids 173 10.1. Matroids and the greedy algorithm 173 10.2. Equivalent axioms for matroids 176 10.3. Examples of matroids 180 10.4. Two technical lemmas 183 10.5. Matroid intersection 184 10.6. Weighted matroid intersection 190 10.7. Matroids and polyhedra 194 References 199 Name index 210 Subject index 212 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 = ∈ (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 .) − − ∞ 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) Vi+1 is equal to the set of vertices v V (V0 V1 Vi) for which (u,v) A for some u V . ∈ \ ∪ ∪···∪ ∈ ∈ i This gives us directly an algorithm for determining the sets V : we set V := s and i 0 { } next we determine with rule (1) the sets V ,V ,... successively, until V = . 1 2 i+1 ∅ In fact, it gives a linear-time algorithm: Theorem 1.1. The algorithm has running time O( A ). | | 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 ′,A′), with root s, such that V ′ is the set of vertices reachable in D from s and such that for each u,v V ′, each directed u v path in T is a shortest u v 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 A′ of A an s t cut if A′ = δout(U) for some subset− U of V satisfying s U and t U.2 Then− the following was observed by Robacker [1956]: ∈ 6∈ 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 = (v0,a1,v1,...,am,vm), let l(P ) be the length of P . That is:→ m (2) l(P ) := l(ai). i=1 X 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 + . − − ∞ 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 apply− the following iteratively: ∞ 6 (3) Find u U minimizing f(u) over u U. For each a =(u,v) A for which f(v) >f∈(u)+ l(a), reset f(v) := f(u∈)+ l(a). Reset U := U ∈ u . \ { } 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 ∈ \ 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 = v0,v1,...,vk = u be a shortest s u path. Let∈ i be the smallest index with v U. − i ∈ 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 ∈ \ (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. So the algorithm has a running time O( V| 2|). In fact, by storing for each vertex| | v the last arc a for which (3) applied we find| a| rooted tree T = (V ′,A′) with root s such that V ′ is the set of vertices reachable from s and such that if u,v V ′ are such that T contains a directed u v path, then this path is a shortest u ∈v path in D. − − Thus we have: Theorem 1.4. Given a directed graph D = (V, A), s,t V , and a length function l : A Q , a shortest s t path can be found in time O∈( V 2). → + − | | Proof. See above. For an improvement, see Section 1.2. A weighted version of Theorem 1.2 is as follows: Theorem 1.5. Let D = (V, A) be a directed graph, s,t V , and let l : A Z+. Then the minimum length of an s t path is equal to the maximum∈ number k of→s t − − cuts C1,...,Ck (repetition allowed) such that each arc a is in at most l(a) of the cuts Ci.