Algorithms and Combinatorics Volume 21 Editorial Board Ronald Graham Bernhard Korte László Lovász Avi Wigderson William...

This content was uploaded by our users and we assume good faith they have the permission to share this book. If you own the copyright to this book and it is wrongfully on our website, we offer a simple DMCA procedure to remove your content from our site. Start by pressing the button below!

Algorithms and Combinatorics Volume 21 Editorial Board Ronald Graham Bernhard Korte László Lovász Avi Wigderson William J. Cook Günter M. Ziegler

For further volumes: http://www.springer.com/series/13

•

Bernhard Korte

Jens Vygen

Combinatorial Optimization Theory and Algorithms Fifth Edition

123

Bernhard Korte Jens Vygen University of Bonn Research Institute for Discrete Mathematics Lennéstr. 2 53113 Bonn Germany [email protected] [email protected]

Algorithms and Combinatorics ISSN 0937-5511 ISBN 978-3-642-24487-2 e-ISBN 978-3-642-24488-9 DOI 10.1007/978-3-642-24488-9 Springer Heidelberg Dordrecht London New York Library of Congress Control Number: 2011945680 Mathematics Subject Classification (2010): 90C27, 68R10, 05C85, 68Q25 c Springer-Verlag Berlin Heidelberg 2000, 2002, 2006, 2008, 2012 This work is subject to copyright. All rights are reserved, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilm or in any other way, and storage in data banks. Duplication of this publication or parts thereof is permitted only under the provisions of the German Copyright Law of September 9, 1965, in its current version, and permission for use must always be obtained from Springer. Violations are liable to prosecution under the German Copyright Law. The use of general descriptive names, registered names, trademarks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use. Printed on acid-free paper Springer is part of Springer Science+Business Media (www.springer.com)

Preface to the Fifth Edition

When preparing the first edition of this book, more than ten years ago, we tried to accomplish two objectives: it should be useful as an advanced graduate textbook, but also as a reference work for research. With each new edition we have to decide how the book can be improved further. Of course, it is less and less possible to describe the growing area comprehensively. If we included everything that we like, the book would grow beyond a single volume. Since the book is used for many courses, now even sometimes at undergraduate level, we thought that adding some classical material might be more useful than including a selection of the latest results. In this edition, we added a proof of Cayley’s formula, more details on blocking flows, the new faster b-matching separation algorithm, an approximation scheme for multidimensional knapsack, and results concerning the multicommodity max-flow min-cut ratio and the sparsest cut problem. There are further small improvements in numerous places and more than 60 new exercises. Of course, we also updated the references to point to the most recent results and corrected some minor errors that were discovered. We would like to thank Takao Asano, Maxim Babenko, Ulrich Brenner, Benjamin Bolten, Christoph Buchheim, Jean Fonlupt, András Frank, Michael Gester, Stephan Held, Stefan Hougardy, Hiroshi Iida, Klaus Jansen, Alexander Karzanov, Levin Keller, Alexander Kleff, Niko Klewinghaus, Stefan Knauf, Barbara Langfeld, Jens Maßberg, Marc Pfetsch, Klaus Radke, Rabe von Randow, Tomás Salles, Jan Schneider, Christian Schulte, András Seb˝o, Martin Skutella, Jácint Szabó, and Simon Wedeking for valuable feedback on the previous edition. We are pleased that this book has been received so well, and further translations are on their way. Editions in Japanese, French, Italian, German, Russian, and Chinese have appeared since 2009 or are scheduled to appear soon. We hope that our book will continue to serve its purpose in teaching and research in combinatorial optimization. Bonn, September 2011

Bernhard Korte and Jens Vygen

V

•

Preface to the Fourth Edition

With four English editions, and translations into four other languages forthcoming, we are very happy with the development of our book. Again, we have revised, updated, and significantly extended it for this fourth edition. We have added some classical material that may have been missed so far, in particular on linear programming, the network simplex algorithm, and the max-cut problem. We have also added a number of new exercises and up-to-date references. We hope that these changes serve to make our book an even better basis for teaching and research. We gratefully acknowledge the continuous support of the Union of the German Academies of Sciences and Humanities and the NRW Academy of Sciences via the long-term research project “Discrete Mathematics and Its Applications”. We also thank those who gave us feedback on the third edition, in particular Takao Asano, Christoph Bartoschek, Bert Besser, Ulrich Brenner, Jean Fonlupt, Satoru Fujishige, Marek Karpinski, Jens Maßberg, Denis Naddef, Sven Peyer, Klaus Radke, Rabe von Randow, Dieter Rautenbach, Martin Skutella, Markus Struzyna, Jürgen Werber, Minyi Yue, and Guochuan Zhang, for their valuable comments. At http://www.or.uni-bonn.de/vygen/co.html we will continue to maintain updated information about this book. Bonn, August 2007

Bernhard Korte and Jens Vygen

VII

•

Preface to the Third Edition

After five years it was time for a thoroughly revised and substantially extended edition. The most significant feature is a completely new chapter on facility location. No constant-factor approximation algorithms were known for this important class of NP-hard problems until eight years ago. Today there are several interesting and very different techniques that lead to good approximation guarantees, which makes this area particularly appealing, also for teaching. In fact, the chapter has arisen from a special course on facility location. Many of the other chapters have also been extended significantly. The new material includes Fibonacci heaps, Fujishige’s new maximum flow algorithm, flows over time, Schrijver’s algorithm for submodular function minimization, and the RobinsZelikovsky Steiner tree approximation algorithm. Several proofs have been streamlined, and many new exercises and references have been added. We thank those who gave us feedback on the second edition, in particular Takao Asano, Yasuhito Asano, Ulrich Brenner, Stephan Held, Tomio Hirata, Dirk Müller, Kazuo Murota, Dieter Rautenbach, Martin Skutella, Markus Struzyna and Jürgen Werber, for their valuable comments. Eminently, Takao Asano’s notes and Jürgen Werber’s proofreading of Chapter 22 helped to improve the presentation at various places. Again we would like to mention the Union of the German Academies of Sciences and Humanities and the Northrhine-Westphalian Academy of Sciences. Their continuous support via the long-term project “Discrete Mathematics and Its Applications” funded by the German Ministry of Education and Research and the State of Northrhine-Westphalia is gratefully acknowledged. Bonn, May 2005

Bernhard Korte and Jens Vygen

IX

•

Preface to the Second Edition

It was more than a surprise to us that the first edition of this book already went out of print about a year after its first appearance. We were flattered by the many positive and even enthusiastic comments and letters from colleagues and the general readership. Several of our colleagues helped us in finding typographical and other errors. In particular, we thank Ulrich Brenner, András Frank, Bernd Gärtner and Rolf Möhring. Of course, all errors detected so far have been corrected in this second edition, and references have been updated. Moreover, the first preface had a flaw. We listed all individuals who helped us in preparing this book. But we forgot to mention the institutional support, for which we make amends here. It is evident that a book project which took seven years benefited from many different grants. We would like to mention explicitly the bilateral HungarianGerman Research Project, sponsored by the Hungarian Academy of Sciences and the Deutsche Forschungsgemeinschaft, two Sonderforschungsbereiche (special research units) of the Deutsche Forschungsgemeinschaft, the Ministère Français de la Recherche et de la Technologie and the Alexander von Humboldt Foundation for support via the Prix Alexandre de Humboldt, and the Commission of the European Communities for participation in two projects DONET. Our most sincere thanks go to the Union of the German Academies of Sciences and Humanities and to the Northrhine-Westphalian Academy of Sciences. Their long-term project “Discrete Mathematics and Its Applications” supported by the German Ministry of Education and Research (BMBF) and the State of Northrhine-Westphalia was of decisive importance for this book. Bonn, October 2001

Bernhard Korte and Jens Vygen

XI

•

Preface to the First Edition

Combinatorial optimization is one of the youngest and most active areas of discrete mathematics, and is probably its driving force today. It became a subject in its own right about 50 years ago. This book describes the most important ideas, theoretical results, and algorithms in combinatorial optimization. We have conceived it as an advanced graduate text which can also be used as an up-to-date reference work for current research. The book includes the essential fundamentals of graph theory, linear and integer programming, and complexity theory. It covers classical topics in combinatorial optimization as well as very recent ones. The emphasis is on theoretical results and algorithms with provably good performance. Applications and heuristics are mentioned only occasionally. Combinatorial optimization has its roots in combinatorics, operations research, and theoretical computer science. A main motivation is that thousands of real-life problems can be formulated as abstract combinatorial optimization problems. We focus on the detailed study of classical problems which occur in many different contexts, together with the underlying theory. Most combinatorial optimization problems can be formulated naturally in terms of graphs and as (integer) linear programs. Therefore this book starts, after an introduction, by reviewing basic graph theory and proving those results in linear and integer programming which are most relevant for combinatorial optimization. Next, the classical topics in combinatorial optimization are studied: minimum spanning trees, shortest paths, network flows, matchings and matroids. Most of the problems discussed in Chapters 6–14 have polynomial-time (“efficient”) algorithms, while most of the problems studied in Chapters 15–21 are NP-hard, i.e. a polynomial-time algorithm is unlikely to exist. In many cases one can at least find approximation algorithms that have a certain performance guarantee. We also mention some other strategies for coping with such “hard” problems. This book goes beyond the scope of a normal textbook on combinatorial optimization in various aspects. For example we cover the equivalence of optimization and separation (for full-dimensional polytopes), O.n3 /-implementations of matching algorithms based on ear-decompositions, Turing machines, the Perfect Graph Theorem, MAXSNP-hardness, the Karmarkar-Karp algorithm for bin packing, recent approximation algorithms for multicommodity flows, survivable network

XIII

XIV

Preface to the First Edition

design and the Euclidean traveling salesman problem. All results are accompanied by detailed proofs. Of course, no book on combinatorial optimization can be absolutely comprehensive. Examples of topics which we mention only briefly or do not cover at all are tree-decompositions, separators, submodular flows, path-matchings, delta-matroids, the matroid parity problem, location and scheduling problems, nonlinear problems, semidefinite programming, average-case analysis of algorithms, advanced data structures, parallel and randomized algorithms, and the theory of probabilistically checkable proofs (we cite the PCP Theorem without proof). At the end of each chapter there are a number of exercises containing additional results and applications of the material in that chapter. Some exercises which might be more difficult are marked with an asterisk. Each chapter ends with a list of references, including texts recommended for further reading. This book arose from several courses on combinatorial optimization and from special classes on topics like polyhedral combinatorics or approximation algorithms. Thus, material for basic and advanced courses can be selected from this book. We have benefited from discussions and suggestions of many colleagues and friends and – of course – from other texts on this subject. Especially we owe sincere thanks to András Frank, László Lovász, András Recski, Alexander Schrijver and Zoltán Szigeti. Our colleagues and students in Bonn, Christoph Albrecht, Ursula Bünnagel, Thomas Emden-Weinert, Mathias Hauptmann, Sven Peyer, Rabe von Randow, André Rohe, Martin Thimm and Jürgen Werber, have carefully read several versions of the manuscript and helped to improve it. Last, but not least we thank Springer Verlag for the most efficient cooperation. Bonn, January 2000

Bernhard Korte and Jens Vygen

Table of Contents

1

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1 Enumeration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 Running Time of Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.3 Linear Optimization Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.4 Sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2

Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1 Basic Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Trees, Circuits, and Cuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4 Eulerian and Bipartite Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5 Planarity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.6 Planar Duality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

13 13 17 24 31 34 41 43 47

3

Linear Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1 Polyhedra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 The Simplex Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3 Implementation of the Simplex Algorithm . . . . . . . . . . . . . . . . . . . . . 3.4 Duality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5 Convex Hulls and Polytopes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

51 52 56 60 63 67 68 70

4

Linear Programming Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1 Size of Vertices and Faces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 Continued Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3 Gaussian Elimination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4 The Ellipsoid Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5 Khachiyan’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6 Separation and Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

73 73 76 79 82 88 90 97 99 XV

XVI

Table of Contents

5

Integer Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 5.1 The Integer Hull of a Polyhedron . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 5.2 Unimodular Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 5.3 Total Dual Integrality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 5.4 Totally Unimodular Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 5.5 Cutting Planes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 5.6 Lagrangean Relaxation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

6

Spanning Trees and Arborescences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 6.1 Minimum Spanning Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 6.2 Minimum Weight Arborescences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 6.3 Polyhedral Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 6.4 Packing Spanning Trees and Arborescences . . . . . . . . . . . . . . . . . . . . 145 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

7

Shortest Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 7.1 Shortest Paths From One Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 7.2 Shortest Paths Between All Pairs of Vertices . . . . . . . . . . . . . . . . . . . 162 7.3 Minimum Mean Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

8

Network Flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 8.1 Max-Flow-Min-Cut Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 8.2 Menger’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 8.3 The Edmonds-Karp Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 8.4 Dinic’s, Karzanov’s, and Fujishige’s Algorithm . . . . . . . . . . . . . . . . . 182 8.5 The Goldberg-Tarjan Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 8.6 Gomory-Hu Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 8.7 The Minimum Capacity of a Cut in an Undirected Graph . . . . . . . . . 196 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

9

Minimum Cost Flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 9.1 Problem Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 9.2 An Optimality Criterion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 9.3 Minimum Mean Cycle-Cancelling Algorithm . . . . . . . . . . . . . . . . . . 216 9.4 Successive Shortest Path Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 9.5 Orlin’s Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 9.6 The Network Simplex Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 9.7 Flows Over Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237

Table of Contents

XVII

10 Maximum Matchings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 10.1 Bipartite Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 10.2 The Tutte Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 10.3 Tutte’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 10.4 Ear-Decompositions of Factor-Critical Graphs . . . . . . . . . . . . . . . . . . 249 10.5 Edmonds’ Matching Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 11 Weighted Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 11.1 The Assignment Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 11.2 Outline of the Weighted Matching Algorithm . . . . . . . . . . . . . . . . . . . 276 11.3 Implementation of the Weighted Matching Algorithm . . . . . . . . . . . . 279 11.4 Postoptimality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 11.5 The Matching Polytope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 12 b-Matchings and T -Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 12.1 b-Matchings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 12.2 Minimum Weight T -Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 12.3 T -Joins and T -Cuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 12.4 The Padberg-Rao Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 13 Matroids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 13.1 Independence Systems and Matroids . . . . . . . . . . . . . . . . . . . . . . . . . . 321 13.2 Other Matroid Axioms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 13.3 Duality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 13.4 The Greedy Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 13.5 Matroid Intersection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 13.6 Matroid Partitioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 13.7 Weighted Matroid Intersection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 14 Generalizations of Matroids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 14.1 Greedoids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 14.2 Polymatroids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359 14.3 Minimizing Submodular Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 14.4 Schrijver’s Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 14.5 Symmetric Submodular Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374

XVIII

Table of Contents

15 NP-Completeness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377 15.1 Turing Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377 15.2 Church’s Thesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380 15.3 P and NP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 15.4 Cook’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 15.5 Some Basic NP-Complete Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 15.6 The Class coNP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400 15.7 NP-Hard Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410 16 Approximation Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413 16.1 Set Covering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414 16.2 The Max-Cut Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419 16.3 Colouring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425 16.4 Approximation Schemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 16.5 Maximum Satisfiability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 16.6 The PCP Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440 16.7 L-Reductions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454 17 The Knapsack Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459 17.1 Fractional Knapsack and Weighted Median Problem . . . . . . . . . . . . . 459 17.2 A Pseudopolynomial Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462 17.3 A Fully Polynomial Approximation Scheme . . . . . . . . . . . . . . . . . . . 464 17.4 Multi-Dimensional Knapsack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469 18 Bin-Packing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471 18.1 Greedy Heuristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471 18.2 An Asymptotic Approximation Scheme . . . . . . . . . . . . . . . . . . . . . . . 477 18.3 The Karmarkar-Karp Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486 19 Multicommodity Flows and Edge-Disjoint Paths . . . . . . . . . . . . . . . . . . 489 19.1 Multicommodity Flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490 19.2 Algorithms for Multicommodity Flows . . . . . . . . . . . . . . . . . . . . . . . . 494 19.3 Sparsest Cut and Max-Flow Min-Cut Ratio . . . . . . . . . . . . . . . . . . . . 499 19.4 The Leighton-Rao Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500 19.5 Directed Edge-Disjoint Paths Problem . . . . . . . . . . . . . . . . . . . . . . . . 503 19.6 Undirected Edge-Disjoint Paths Problem . . . . . . . . . . . . . . . . . . . . . . 507 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517

Table of Contents

XIX

20 Network Design Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521 20.1 Steiner Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522 20.2 The Robins-Zelikovsky Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527 20.3 Survivable Network Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532 20.4 A Primal-Dual Approximation Algorithm . . . . . . . . . . . . . . . . . . . . . . 536 20.5 Jain’s Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553 21 The Traveling Salesman Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557 21.1 Approximation Algorithms for the TSP . . . . . . . . . . . . . . . . . . . . . . . . 557 21.2 Euclidean TSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562 21.3 Local Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569 21.4 The Traveling Salesman Polytope . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575 21.5 Lower Bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581 21.6 Branch-and-Bound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589 22 Facility Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593 22.1 The Uncapacitated Facility Location Problem . . . . . . . . . . . . . . . . . . 593 22.2 Rounding Linear Programming Solutions . . . . . . . . . . . . . . . . . . . . . . 595 22.3 Primal-Dual Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597 22.4 Scaling and Greedy Augmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603 22.5 Bounding the Number of Facilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606 22.6 Local Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609 22.7 Capacitated Facility Location Problems . . . . . . . . . . . . . . . . . . . . . . . . 615 22.8 Universal Facility Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626 Notation Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629 Author Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633 Subject Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645

1 Introduction

Let us start with two examples. A company has a machine which drills holes into printed circuit boards. Since it produces many of these boards it wants the machine to complete one board as fast as possible. We cannot optimize the drilling time but we can try to minimize the time the machine needs to move from one point to another. Usually drilling machines can move in two directions: the table moves horizontally while the drilling arm moves vertically. Since both movements can be done simultaneously, the time needed to adjust the machine from one position to another is proportional to the maximum of the horizontal and the vertical distance. This is often called the `1 -distance. (Older machines can only move either horizontally or vertically at a time; in this case the adjusting time is proportional to the `1 -distance, the sum of the horizontal and the vertical distance.) An optimum drilling path is given by an ordering of the hole positions Pn1 p1 ; : : : ; pn such that i D1 d.pi ; pi C1 / is minimum, where d is the `1 distance: for two points p D .x; y/ and p 0 D .x 0 ; y 0 / in the plane we write d.p; p 0 / WD maxfjx x 0 j; jy y 0 jg. An order of the holes can be represented by a permutation, i.e. a bijection W f1; : : : ; ng ! f1; : : : ; ng. Which permutation is best of course depends on the hole positions; for each list of hole positions we have a different problem instance. We say that one instance of our problem is a list of points in the plane, i.e. the coordinates of the holes to be drilled. Then the problem can be stated formally as follows:

DRILLING PROBLEM Instance:

A set of points p1 ; : : : ; pn 2 R2 .

Task:

Find Pn1a permutation W f1; : : : ; ng ! f1; : : : ; ng such that i D1 d.p.i / ; p.i C1/ / is minimum.

We now explain our second example. We have a set of jobs to be done, each having a specified processing time. Each job can be done by a subset of the employees, and we assume that all employees who can do a job are equally efficient. Several employees can contribute to the same job at the same time, and one employee can contribute to several jobs (but not at the same time). The objective is to get all jobs done as early as possible.

B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__1, c Springer-Verlag Berlin Heidelberg 2012

1

2

1 Introduction

In this model it suffices to prescribe for each employee how long he or she should work on which job. The order in which the employees carry out their jobs is not important, since the time when all jobs are done obviously depends only on the maximum total working time we have assigned to one employee. Hence we have to solve the following problem:

JOB ASSIGNMENT PROBLEM Instance:

Task:

A set of numbers t1 ; : : : ; tn 2 RC (the processing times for n jobs), a number m 2 N of employees, and a nonempty subset Si f1; : : : ; mg of employees for each job i 2 f1; : : : ; ng. Find P numbers xij 2 RC for all i D 1; : : : ; n and j 2PSi such that j 2Si xij D ti for i D 1; : : : ; n and maxj 2f1;:::;mg i Wj 2Si xij is minimum.

These are two typical problems arising in combinatorial optimization. How to model a practical problem as an abstract combinatorial optimization problem is not described in this book; indeed there is no general recipe for this task. Besides giving a precise formulation of the input and the desired output it is often important to ignore irrelevant components (e.g. the drilling time which cannot be optimized or the order in which the employees carry out their jobs). Of course we are not interested in a solution to a particular drilling problem or job assignment problem in some company, but rather we are looking for a way how to solve all problems of these types. We first consider the DRILLING PROBLEM.

1.1 Enumeration How can a solution to the DRILLING PROBLEM look like? There are infinitely many instances (finite sets of points in the plane), so we cannot list an optimum permutation for each instance. Instead, what we look for is an algorithm which, given an instance, computes an optimum solution. Such an algorithm exists: Given a set of n points, just try all possible nŠ orders, and for each compute the `1 -length of the corresponding path. There are different ways of formulating an algorithm, differing mostly in the level of detail and the formal language they use. We certainly would not accept the following as an algorithm: “Given a set of n points, find an optimum path and output it.” It is not specified at all how to find the optimum solution. The above suggestion to enumerate all possible nŠ orders is more useful, but still it is not clear how to enumerate all the orders. Here is one possible way: We enumerate all n-tuples of numbers 1; : : : ; n, i.e. all nn vectors of f1; : : : ; ngn . This can be done similarly to counting: we start with .1; : : : ; 1; 1/, .1; : : : ; 1; 2/ up to .1; : : : ; 1; n/ then switch to .1; : : : ; 1; 2; 1/, and so on. At each step we increment the last entry unless it is already n, in which case we go back to the last entry that is smaller than n, increment it and set all subsequent entries to 1. This technique is

1.1

Enumeration

3

sometimes called backtracking. The order in which the vectors of f1; : : : ; ngn are enumerated is called the lexicographical order: Definition 1.1. Let x; y 2 Rn be two vectors. We say that a vector x is lexicographically smaller than y if there exists an index j 2 f1; : : : ; ng such that xi D yi for i D 1; : : : ; j 1 and xj < yj . Knowing how to enumerate all vectors of f1; : : : ; ngn we can simply check for each vector whether its entries are pairwise distinct and, if so, whether the path represented by this vector is shorter than the best path encountered so far. Since this algorithm enumerates nn vectors it will take at least nn steps (in fact, even more). This is not best possible. There are only nŠ permutations of f1; p: : : ; ng, n and nŠ is significantly smaller than nn . (By Stirling’s formula nŠ 2 n nen (Stirling [1730]); see Exercise 1.) We shall show how to enumerate all paths in approximately n2 nŠ steps. Consider the following algorithm which enumerates all permutations in lexicographical order:

PATH ENUMERATION ALGORITHM Input:

A natural number n 3. A set fp1 ; : : : ; pn g of points in the plane.

Output:

A permutation Pn1W f1; : : : ; ng ! f1; : : : ; ng with cost. / WD i D1 d.p .i / ; p .i C1/ / minimum.

1

Set .i / WD i and .i / WD i for i D 1; : : : ; n. Set i WD n 1.

2

Let k WD min.f.i / C 1; : : : ; n C 1g n f.1/; : : : ; .i 1/g/.

3

If k n then: Set .i / WD k. If i D n and cost./ < cost. / then set WD . If i < n then set .i C 1/ WD 0 and i WD i C 1. If k D n C 1 then set i WD i 1. If i 1 then go to . 2

Starting with ..i //i D1;:::;n D .1; 2; 3; : : : ; n1; n/ and i D n1, the algorithm finds at each step the next possible value of .i / (not using .1/; : : : ; .i 1/). If there is no more possibility for .i / (i.e. k D n C 1), then the algorithm decrements i (backtracking). Otherwise it sets .i / to the new value. If i D n, the new permutation is evaluated, otherwise the algorithm will try all possible values for .i C 1/; : : : ; .n/ and starts by setting .i C 1/ WD 0 and incrementing i . So all permutation vectors ..1/; : : : ; .n// are generated in lexicographical order. For example, the first iterations in the case n D 6 are shown below:

4

1 Introduction

k k k k k k k

WD 6, WD 5, WD 7, WD 7, WD 5, WD 4, WD 6,

WD .1; 2; 3; 4; 5; 6/, i WD 5 WD .1; 2; 3; 4; 6; 0/, i WD 6 WD .1; 2; 3; 4; 6; 5/, cost./ < cost. /? i WD 5 i WD 4 WD .1; 2; 3; 5; 0; 5/, i WD 5 WD .1; 2; 3; 5; 4; 0/, i WD 6 WD .1; 2; 3; 5; 4; 6/, cost./ < cost. /?

Since the algorithm compares the cost of each path to , the best path encountered so far, it indeed outputs the optimum path. But how many steps will this algorithm perform? Of course, the answer depends on what we call a single step. Since we do not want the number of steps to depend on the actual implementation we ignore constant factors. On any reasonable computer, 1 will take at least 2n C 1 steps (this many variable assignments are done) and at most cn steps for some constant c. The following common notation is useful for ignoring constant factors: Definition 1.2. Let f; g W D ! RC be two functions. We say that f is O.g/ (and sometimes write f D O.g/, and also g D .f /) if there exist constants ˛; ˇ > 0 such that f .x/ ˛g.x/ C ˇ for all x 2 D. If f D O.g/ and g D O.f / we also say that f D ‚.g/ (and of course g D ‚.f /). In this case, f and g have the same rate of growth. Note that the use of the equation sign in the O-notation is not symmetric. To illustrate this definition, let D D N, and let f .n/ be the number of elementary steps in 1 and g.n/ D n (n 2 N). Clearly we have f D O.g/ (in fact f D ‚.g/) in this case; we say that 1 takes O.n/ time (or linear time). A single execution of 3 takes a constant number of steps (we speak of O.1/ time or constant time) except in the case k n and i D n; in this case the cost of two paths have to be compared, which takes O.n/ time. What about ? 2 A naive implementation, checking for each j 2 f.i / C 1; : : : ; ng and each h 2 f1; : : : ; i 1g whether j D .h/, takes O..n .i //i / steps, which can be as big as ‚.n2 /. A better implementation of 2 uses an auxiliary array indexed by 1; : : : ; n: For j WD 1 to n do aux.j / WD 0. For j WD 1 to i 1 do aux..j // WD 1. Set k WD .i / C 1. While k n and aux.k/ D 1 do k WD k C 1. Obviously with this implementation a single execution of 2 takes only O.n/ time. Simple techniques like this are usually not elaborated in this book; we assume that the reader can find such implementations himself or herself. Having computed the running time for each single step we now estimate the total amount of work. Since the number of permutations is nŠ we only have to estimate the amount of work which is done between two permutations. The counter i might move back from n to some index i 0 where a new value .i 0 / n is found. Then it moves forward again up to i D n. While the counter i is constant each of 2 and 3 2

1.2

Running Time of Algorithms

5

is performed once, except in the case k n and i D n; in this case 2 and 3 are performed twice. So the total amount of work between two permutations consists of at most 4n times 2 and , 3 i.e. O.n2 /. So the overall running time of the PATH ENUMERATION ALGORITHM is O.n2 nŠ/. One can do slightly better; a more careful analysis shows that the running time is only O.n nŠ/ (Exercise 4). Still the algorithm is too time-consuming if n is large. The problem with the enumeration of all paths is that the number of paths grows exponentially with the number of points; already for 20 points there are 20Š D 2432902008176640000 2:4 1018 different paths and even the fastest computer needs several years to evaluate all of them. So complete enumeration is impossible even for instances of moderate size. The main subject of combinatorial optimization is to find better algorithms for problems like this. Often one has to find the best element of some finite set of feasible solutions (in our example: drilling paths or permutations). This set is not listed explicitly but implicitly depends on the structure of the problem. Therefore an algorithm must exploit this structure. In the case of the DRILLING PROBLEM all information of an instance with n points is given by 2n coordinates. While the naive algorithm enumerates all nŠ paths it might be possible that there is an algorithm which finds the optimum path much faster, say in n2 computation steps. It is not known whether such an algorithm exists (though results of Chapter 15 suggest that it is unlikely). Nevertheless there are much better algorithms than the naive one.

1.2 Running Time of Algorithms One can give a formal definition of an algorithm, and we shall in fact give one in Section 15.1. However, such formal models lead to very long and tedious descriptions as soon as algorithms are a bit more complicated. This is quite similar to mathematical proofs: Although the concept of a proof can be formalized nobody uses such a formalism for writing down proofs since they would become very long and almost unreadable. Therefore all algorithms in this book are written in an informal language. Still the level of detail should allow a reader with a little experience to implement the algorithms on any computer without too much additional effort. Since we are not interested in constant factors when measuring running times we do not have to fix a concrete computing model. We count elementary steps, but we are not really interested in how elementary steps look like. Examples of elementary steps are variable assignments, random access to a variable whose index is stored in another variable, conditional jumps (if – then – go to), and simple arithmetic operations like addition, subtraction, multiplication, division and comparison of numbers. An algorithm consists of a set of valid inputs and a sequence of instructions each of which can be composed of elementary steps, such that for each valid input the

6

1 Introduction

computation of the algorithm is a uniquely defined finite series of elementary steps which produces a certain output. Usually we are not satisfied with finite computation but rather want a good upper bound on the number of elementary steps performed, depending on the input size. The input to an algorithm usually consists of a list of numbers. If all these numbers are integers, we can code them in binary representation, using O.log.jaj C 2// bits for storing an integer a. Rational numbers can be stored by coding the numerator and the denominator separately. The input size size.x/ of an instance x with rational data is the total number of bits needed for the binary representation. Definition 1.3. Let A be an algorithm which accepts inputs from a set X , and let f W N ! RC . If there exist constants ˛; ˇ > 0 such that A terminates its computation after at most ˛f .size.x// C ˇ elementary steps (including arithmetic operations) for each input x 2 X , then we say that A runs in O.f / time. We also say that the running time (or the time complexity) of A is O.f /. Definition 1.4. An algorithm with rational input is said to run in polynomial time if there is an integer k such that it runs in O.nk / time, where n is the input size, and all numbers in intermediate computations can be stored with O.nk / bits. An algorithm with arbitrary input is said to run in strongly polynomial time if there is an integer k such that it runs in O.nk / time for any input consisting of n numbers and it runs in polynomial time for rational input. In the case k D 1 we have a linear-time algorithm. An algorithm which runs in polynomial but not strongly polynomial time is called weakly polynomial. Note that the running time might be different for several instances of the same size (this was not the case with the PATH ENUMERATION ALGORITHM). We consider the worst-case running time, i.e. the function f W N ! N where f .n/ is the maximum running time of an instance with input size n. For some algorithms we do not know the rate of growth of f but only have an upper bound. The worst-case running time might be a pessimistic measure if the worst case occurs rarely. In some cases an average-case running time with some probabilistic model might be appropriate, but we shall not consider this. If A is an algorithm which for each input x 2 X computes the output f .x/2Y , then we say that A computes f W X ! Y . If a function is computed by some polynomial-time algorithm, it is said to be computable in polynomial time. Polynomial-time algorithms are sometimes called “good” or “efficient”. This concept was introduced by Cobham [1964] and Edmonds [1965]. Table 1.1 motivates this by showing hypothetical running times of algorithms with various time complexities. For various input sizes n we show the running time of algorithms that take 100n log n, 10n2 , n3:5 , nlog n , 2n , and nŠ elementary steps; we assume that one elementary step takes one nanosecond. As always in this book, log denotes the logarithm with basis 2.

1.2

Running Time of Algorithms

7

Table 1.1. n 10 20 30 40 50 60 80 100 200 500 1000 104 105 106 107 108 1010 1012

100n log n

10n2

n3:5

nlog n

2n

nŠ

3 s 9 s 15 s 21 s 28 s 35 s 50 s 66 s 153 s 448 s 1 ms 13 ms 166 ms 2s 23 s 266 s 9 hours 46 days

1 s 4 s 9 s 16 s 25 s 36 s 64 s 100 s 400 s 2.5 ms 10 ms 1s 100 s 3 hours 12 days 3 years 3 104 y. 3 108 y.

3 s 36 s 148 s 404 s 884 s 2 ms 5 ms 10 ms 113 ms 3s 32 s 28 hours 10 years 3169 y. 107 y. 3 1010 y.

2 s 420 s 20 ms 340 ms 4s 32 s 1075 s 5 hours 12 years 5 105 y. 3 1013 y.

1 s 1 ms 1s 1100 s 13 days 37 years 4 107 y. 4 1013 y.

4 ms 76 years 8 1015 y.

As Table 1.1 shows, polynomial-time algorithms are faster for large enough instances. The table also illustrates that constant factors of moderate size are not very important when considering the asymptotic growth of the running time. Table 1.2 shows the maximum input sizes solvable within one hour with the above six hypothetical algorithms. In (a) we again assume that one elementary step takes one nanosecond, (b) shows the corresponding figures for a ten times faster machine. Polynomial-time algorithms can handle larger instances in reasonable time. Moreover, even a speedup by a factor of 10 of the computers does not increase the size of solvable instances significantly for exponential-time algorithms, but it does for polynomial-time algorithms. Table 1.2. 100n log n

10n2

n3:5

nlog n

2n

nŠ

(a)

1:19

109

60000

3868

87

41

15

(b)

10:8 109

189737

7468

104

45

16

8

1 Introduction

(Strongly) polynomial-time algorithms, if possible linear-time algorithms, are what we look for. There are some problems where it is known that no polynomialtime algorithm exists, and there are problems for which no algorithm exists at all. (For example, a problem which can be solved in finite time but not in polynomial time is to decide whether a so-called regular expression defines the empty set; see Aho, Hopcroft and Ullman [1974]. A problem for which there exists no algorithm at all, the HALTING PROBLEM, is discussed in Exercise 1 of Chapter 15.) However, almost all problems considered in this book belong to the following two classes. For the problems of the first class we have a polynomial-time algorithm. For each problem of the second class it is an open question whether a polynomial-time algorithm exists. However, we know that if one of these problems has a polynomial-time algorithm, then all problems of this class do. A precise formulation and a proof of this statement will be given in Chapter 15. The JOB ASSIGNMENT PROBLEM belongs to the first class, the DRILLING PROBLEM belongs to the second class. These two classes of problems divide this book roughly into two parts. We first deal with tractable problems for which polynomial-time algorithms are known. Then, starting with Chapter 15, we discuss hard problems. Although no polynomialtime algorithms are known, there are often much better methods than complete enumeration. Moreover, for many problems (including the DRILLING PROBLEM), one can find approximate solutions within a certain percentage of the optimum in polynomial time.

1.3 Linear Optimization Problems We now consider our second example given initially, the JOB ASSIGNMENT PROBLEM, and briefly address some central topics which will be discussed in later chapters. The JOB ASSIGNMENT PROBLEM is quite different to the DRILLING PROBLEM since there are infinitely many feasible solutions for each instance (except for trivial cases). We can reformulate the problem by introducing a variable T for the time when all jobs are done: min T s.t.

X

xij D ti

.i 2 f1; : : : ; ng/

xij 0 xij T

.i 2 f1; : : : ; ng; j 2 Si / .j 2 f1; : : : ; mg/

(1.1)

j 2Si

X i Wj 2Si

The numbers ti and the sets Si (i D 1; : : : ; n) are given, the variables xij and T are what we look for. Such an optimization problem with a linear objective function

1.4

Sorting

9

and linear constraints is called a linear program. The set of feasible solutions of (1.1), a so-called polyhedron, is easily seen to be convex, and one can prove that there always exists an optimum solution which is one of the finitely many extreme points of this set. Therefore a linear program can, theoretically, also be solved by complete enumeration. But there are much better ways as we shall see later. Although there are several algorithms for solving linear programs in general, such general techniques are usually less efficient than special algorithms exploiting the structure of the problem. In our case it is convenient to model the sets Si , i D 1; : : : ; n, by a graph. For each job i and for each employee j we have a point (called vertex), and we connect employee j with job i by an edge if he or she can contribute to this job (i.e. if j 2 Si ). Graphs are a fundamental combinatorial structure; many combinatorial optimization problems are described most naturally in terms of graph theory. Suppose for a moment that the processing time of each job is one hour, and we ask whether we can finish all jobs within one hour. So we look Pfor numbers xij (i 2 f1; : : : ; ng, j P 2 Si ) such that 0 xij 1 for all i and j , j 2Si xij D 1 for i D 1; : : : ; n, and i Wj 2Si xij 1 for j D 1; : : : ; n. One can show that if such a solution exists, then in fact an integral solution exists, i.e. all xij are either 0 or 1. This is equivalent to assigning each job to one employee, such that no employee has to do more than one job. In the language of graph theory we then look for a matching covering all jobs. The problem of finding optimal matchings is one of the best-known combinatorial optimization problems. We review the basics of graph theory and linear programming in Chapters 2 and 3. In Chapter 4 we prove that linear programs can be solved in polynomial time, and in Chapter 5 we discuss integral polyhedra. In the subsequent chapters we discuss some classical combinatorial optimization problems in detail.

1.4 Sorting Let us conclude this chapter by considering a special case of the DRILLING PROBLEM where all holes to be drilled are on one horizontal line. So we are given just one coordinate for each point pi , i D 1; : : : ; n. Then a solution to the drilling problem is easy, all we have to do is sort the points by their coordinates: the drill will just move from left to right. Although there are still nŠ permutations, it is clear that we do not have to consider all of them to find the optimum drilling path, i.e. the sorted list. It is very easy to sort n numbers in nondecreasing order in O.n2 / time. To sort n numbers in O.n log n/ time requires a little more skill. There are several algorithms accomplishing this; we present the well-known MERGE-SORT ALGORITHM. It proceeds as follows. First the list is divided into two sublists of approximately equal size. Then each sublist is sorted (this is done recursively by the same algorithm). Finally the two sorted sublists are merged together. This general strategy, often called “divide and conquer”, can be used quite often. See e.g. Section 17.1 for another example.

10

1 Introduction

We did not discuss recursive algorithms so far. In fact, it is not necessary to discuss them, since any recursive algorithm can be transformed into a sequential algorithm without increasing the running time. But some algorithms are easier to formulate (and implement) using recursion, so we shall use recursion when it is convenient.

MERGE-SORT ALGORITHM Input:

A list a1 ; : : : ; an of real numbers.

Output:

A permutation W f1; : : : ; ng ! f1; : : : ; ng such that a.i / a.i C1/ for all i D 1; : : : ; n 1.

1 2

3

If n D 1 then set .1/ WD 1 and stop (return ). ˘ Set m WD n2 . Let WDMERGE-SORT(a1 ; : : : ; am ). Let WDMERGE-SORT(amC1 ; : : : ; an ). Set k WD 1, l WD 1. While k m and l n m do: If a.k/ amC.l/ then set .k C l 1/ WD .k/ and k WD k C 1 else set .k C l 1/ WD m C .l/ and l WD l C 1. While k m do: Set .k C l 1/ WD .k/ and k WD k C 1. While l n m do: Set .k C l 1/ WD m C .l/ and l WD l C 1.

As an example, consider the list “69,32,56,75,43,99,28”. The algorithm first splits this list into two, “69,32,56” and “75,43,99,28” and recursively sorts each of the two sublists. We get the permutations D .2; 3; 1/ and D .4; 2; 1; 3/ corresponding to the sorted lists “32,56,69” and “28,43,75,99”. Now these lists are merged as shown below: k WD 1; l WD 1 .1/ D 2; .1/ D 4; a.1/ D 32; a.1/ D 28; .1/ WD 7; l WD 2 .1/ D 2; .2/ D 2; a.1/ D 32; a.2/ D 43; .2/ WD 2; k WD 2 .2/ D 3; .2/ D 2; a.2/ D 56; a.2/ D 43; .3/ WD 5; l WD 3 .2/ D 3; .3/ D 1; a.2/ D 56; a.3/ D 75; .4/ WD 3; k WD 3 .3/ D 1; .3/ D 1; a.3/ D 69; a.3/ D 75; .5/ WD 1; k WD 4 .3/ D 1; a.3/ D 75; .6/ WD 4; l WD 4 .4/ D 3; a.4/ D 99; .7/ WD 6; l WD 5 Theorem 1.5. The MERGE-SORT ALGORITHM works correctly and runs in O.n log n/ time. Proof: The correctness is obvious. We denote by T .n/ the running time (number of steps) needed for instances consisting of n numbers and observe that T .1/ D 1 and T .n/ D T .b n2 c/ C T .d n2 e/ C 3n C 6. (The constants in the term 3n C 6 depend on how exactly a computation step is defined; but they do not really matter.)

Exercises

11

We claim that this yields T .n/ 12n log nC1. Since this is trivial for n D 1 we proceed by induction. For n 2, assuming that the inequality is true for 1; : : : ; n1, we get jnk lnm 2 2 T .n/ 12 log n C 1 C 12 log n C 1 C 3n C 6 2 3 2 3 D 12n.log n C 1 log 3/ C 3n C 8 13 12n log n n C 3n C 8 12n log n C 1; 2 because log 3

37 . 24

Of course the algorithm works for sorting the elements of any totally ordered set, assuming that we can compare any two elements in constant time. Can there be a faster, a linear-time algorithm? Suppose that the only way we can get information on the unknown order is to compare two elements. Then we can show that any algorithm needs at least ‚.n log n/ comparisons in the worst case. The outcome of a comparison can be regarded as a zero or one; the outcome of all comparisons an algorithm does is a 0-1-string (a sequence of zeros and ones). Note that two different orders in the input of the algorithm must lead to two different 0-1-strings (otherwise the algorithm could not distinguish between the two orders). For an input of n elements there are nŠ possible orders, so there must be nŠ different 0-1-strings corresponding to the computation. Since the number of 0-1-strings with length less ˘ n n n n n than n2 log n2 is 2b 2 log 2 c 1 < 2 2 log 2 D . n2 / 2 nŠ we conclude that the maximum length of the 0-1-strings, and hence of the computation, must be at least n log n2 D ‚.n log n/. 2 In the above sense, the running time of the MERGE-SORT ALGORITHM is optimal up to a constant factor. However, there is an algorithm for sorting integers (or sorting strings lexicographically) whose running time is linear in the input size; see Exercise 8. An algorithm to sort n integers in O.n log log n/ time was proposed by Han [2004]. Lower bounds like the one above are known only for very few problems (except trivial linear bounds). Often a restriction on the set of operations is necessary to derive a superlinear lower bound.

Exercises 1. Prove that for all n 2 N: e

n n e

nŠ e n

Hint: Use 1 C x e x for all x 2 R. 2. Prove that log.nŠ/ D ‚.n log n/. 3. Prove that n log n D O.n1C / for any > 0.

n n e

:

12

1 Introduction

4. Show that the running time of the PATH ENUMERATION ALGORITHM is O.n nŠ/. 5. Show that there is a polynomial-time algorithm for the DRILLING PROBLEM where d is the `1 -distance if and only if there is one for `1 -distance. Note: Both is unlikely as the problems were proved to be NP-hard (this will be explained in Chapter 15) by Garey, Graham and Johnson [1976]. 6. Suppose we have an algorithm whose running time is ‚.n.t C n1=t //, where n is the input length and t is a positive parameter we can choose arbitrarily. How should t be chosen (depending on n) such that the running time (as a function of n) has a minimum rate of growth? 7. Let s; t be binary strings, both of length m. We say that s is lexicographically smaller than t if there exists an index j 2 f1; : : : ; mg such that si D ti for i D 1; : : : ; j 1 and sj < tj . Now given n strings of length m, we want to sort them lexicographically. Prove that there is a linear-time algorithm for this problem (i.e. one with running time O.nm/). Hint: Group the strings according to the first bit and sort each group. 8. Describe an algorithm which sorts a list of natural numbers a1 ; : : : ; an in linear time; i.e. which finds a permutation with a.i / a.i C1/ (i D 1; : : : ; n 1) and runs in O.log.a1 C 1/ C C log.an C 1// time. Hint: First sort the strings encoding the numbers according to their length. Then apply the algorithm of Exercise 7. Note: The algorithm discussed in this and the previous exercise is often called radix sorting.

References General Literature: Cormen, T.H., Leiserson, C.E., Rivest, R.L., and Stein, C. [2001]: Introduction to Algorithms. Second Edition. MIT Press, Cambridge 2001 Knuth, D.E. [1968]: The Art of Computer Programming; Vol. 1. Fundamental Algorithms. Addison-Wesley, Reading 1968 (third edition: 1997)

Cited References: Aho, A.V., Hopcroft, J.E., and Ullman, J.D. [1974]: The Design and Analysis of Computer Algorithms. Addison-Wesley, Reading 1974 Cobham, A. [1964]: The intrinsic computational difficulty of functions. Proceedings of the 1964 Congress for Logic Methodology and Philosophy of Science (Y. Bar-Hillel, ed.), North-Holland, Amsterdam 1964, pp. 24–30 Edmonds, J. [1965]: Paths, trees, and flowers. Canadian Journal of Mathematics 17 (1965), 449–467 Garey, M.R., Graham, R.L., and Johnson, D.S. [1976]: Some NP-complete geometric problems. Proceedings of the 8th Annual ACM Symposium on the Theory of Computing (1976), 10–22 Han, Y. [2004]: Deterministic sorting in O.n log log n/ time and linear space. Journal of Algorithms 50 (2004), 96–105 Stirling, J. [1730]: Methodus Differentialis. London 1730

2 Graphs

Graphs are a fundamental combinatorial structure used throughout this book. In this chapter we not only review the standard definitions and notation, but also prove some basic theorems and mention some fundamental algorithms. After some basic definitions in Section 2.1 we consider fundamental objects occurring very often in this book: trees, circuits, and cuts. We prove some important properties and relations, and we also consider tree-like set systems in Section 2.2. The first graph algorithms, determining connected and strongly connected components, appear in Section 2.3. In Section 2.4 we prove Euler’s Theorem on closed walks using every edge exactly once. Finally, in Sections 2.5 and 2.6 we consider graphs that can be drawn in the plane without crossings.

2.1 Basic Definitions An undirected graph is a triple .V; E; ‰/, where V and E are finite sets and ‰ W E ! fX V W jX j D 2g. A directed graph or digraph is a triple .V; E; ‰/, where V and E are finite sets and ‰ W E ! f.v; w/ 2 V V W v 6D wg. By a graph we mean either an undirected graph or a digraph. The elements of V are called vertices, the elements of E are the edges. Edges e; e 0 with e 6D e 0 and ‰.e/ D ‰.e 0 / are called parallel. Graphs without parallel edges are called simple. For simple graphs we usually identify an edge e with its image ‰.e/ and write G D .V .G/; E.G//, where E.G/ fX V .G/ W jX j D 2g or E.G/ V .G/ V .G/. We often use this simpler notation even in the presence of parallel edges, then the “set” E.G/ may contain several “identical” elements. jE.G/j denotes the number of edges, and for two edge sets E and F we : always have jE [ F j D jEj C jF j even if parallel edges arise. We write e D fv; wg or e D .v; w/ for each edge e with ‰.e/ D fv; wg or ‰.e/ D .v; w/, respectively. We say that an edge e D fv; wg or e D .v; w/ joins v and w. In this case, v and w are adjacent. v is a neighbour of w (and vice versa). v and w are the endpoints of e. If v is an endpoint of an edge e, we say that v is incident with e. In the directed case we say that e D .v; w/ leaves v (the tail of e) and enters w (the head of e). Two edges which share at least one endpoint are called adjacent. This terminology for graphs is not the only one. Sometimes vertices are called nodes or points, other names for edges are arcs (especially in the directed case) or B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__2, c Springer-Verlag Berlin Heidelberg 2012

13

14

2 Graphs

lines. In some texts, a graph is what we call a simple undirected graph, in the presence of parallel edges they speak of multigraphs. Sometimes edges whose endpoints coincide, so-called loops, are considered. However, unless otherwise stated, we do not use them. For a digraph G we sometimes consider the underlying undirected graph, i.e. the undirected graph G 0 on the same vertex set which contains an edge fv; wg for each edge .v; w/ of G (so jE.G 0 /j D jE.G/j). We also say that G is an orientation of G 0 . A subgraph of a graph G D .V .G/; E.G// is a graph H D .V .H /; E.H // with V .H / V .G/ and E.H / E.G/. We also say that G contains H . H is an induced subgraph of G if it is a subgraph of G and E.H / D ffx; yg 2 E.G/ W x; y 2 V .H /g or E.H / D f.x; y/ 2 E.G/ W x; y 2 V .H /g. Here H is the subgraph of G induced by V .H /. We also write H D GŒV .H /. A subgraph H of G is called spanning if V .H / D V .G/. If v 2 V .G/, we write G v for the subgraph of G induced by V .G/ n fvg. If e 2 E.G/, we define G e WD .V .G/; E.G/ n feg/. We also use this notation for deleting a set X of vertices or edges and write G X . Furthermore, the addition of : a new edge e is abbreviated by G C e WD .V .G/; E.G/ [ feg/. If G and H are two graphs, we denote by G C H the graph with V .G C H / D V .G/ [ V .H / and E.G C H / being the disjoint union of E.G/ and E.H / (parallel edges may arise). A family of graphs is called vertex-disjoint or edge-disjoint if their vertex sets or edge sets are pairwise disjoint, respectively. Two graphs G and H are called isomorphic if there are bijections ˆV W V .G/ ! V .H / and ˆE W E.G/ ! E.H / such that ˆE ..v; w// D .ˆV .v/; ˆV .w// for all .v; w/ 2 E.G/, or ˆE .fv; wg/ D fˆV .v/; ˆV .w/g for all fv; wg 2 E.G/ in the undirected case. We normally do not distinguish between isomorphic graphs; for example we say that G contains H if G has a subgraph isomorphic to H . Suppose we have an undirected graph G and X V .G/. By contracting (or shrinking) X we mean deleting the vertices in X and the edges in GŒX , adding a new vertex x and replacing each edge fv; wg with v 2 X , w … X by an edge fx; wg (parallel edges may arise). Similarly for digraphs. We often call the result G=X . For a graph G and X; Y V .G/ we define E.X; Y / WD ffx; yg 2 E.G/ W x 2 X n Y; y 2 Y n X g if G is undirected and E C .X; Y / WD f.x; y/ 2 E.G/ W x 2 X n Y; y 2 Y n X g if G is directed. For undirected graphs G and X V .G/ we define ı.X / WD E.X; V .G/ n X /. The set of neighbours of X is defined by .X / WD fv 2 V .G/ n X W E.X; fvg/ 6D ;g. For digraphs G and X V .G/ we define ı C .X / WD E C .X; V .G/ n X /, ı .X / WD ı C .V .G/ n X / and ı.X / WD ı C .X /[ı .X /. We use subscripts (e.g. ıG .X /) to specify the graph G if necessary. For singletons, i.e. one-element vertex sets fvg (v 2 V .G/) we write ı.v/ WD ı.fvg/, .v/ WD .fvg/, ı C .v/ WD ı C .fvg/ and ı .v/ WD ı .fvg/. The degree of a vertex v is jı.v/j, the number of edges incident to v. In the directed case, the in-degree is jı .v/j, the out-degree is jı C .v/j, and the degree is jı C .v/j C jı .v/j.

2.1

Basic Definitions

15

A vertex with degree zero is called isolated. A graph where all vertices have degree k is called k-regular. P For any graph, v2V .G/ jı.v/j D 2jE.G/j. In particular, the number of vertices P P with odd degree is even. In a digraph, v2V .G/ jı C .v/j D v2V .G/ jı .v/j. To prove these statements, please observe that each edge is counted twice on each side of the first equation and once on each side of the second equation. With just a little more effort we get the following useful statements: Lemma 2.1. For a digraph G and any two sets X; Y V .G/: (a) jı C .X /jCjı C .Y /j D jı C .X \Y /jCjı C .X [Y /jCjE C .X; Y /jCjE C .Y; X /j; (b) jı .X /jCjı .Y /j D jı .X \Y /jCjı .X [Y /jCjE C .X; Y /jCjE C .Y; X /j. For an undirected graph G and any two sets X; Y V .G/: (c) jı.X /j C jı.Y /j D jı.X \ Y /j C jı.X [ Y /j C 2jE.X; Y /j; (d) jı.X /j C jı.Y /j D jı.X n Y /j C jı.Y n X /j C 2jE.X \ Y; V .G/ n .X [ Y //j; (e) j.X /j C j.Y /j j.X \ Y /j C j.X [ Y /j. Proof: All parts can be proved by simple counting arguments. Let Z WD V .G/ n .X [ Y /. To prove (a), observe that jı C .X /jCjı C .Y /j D jE C .X; Z/jCjE C .X; Y nX /jC C jE .Y; Z/j C jE C .Y; X n Y /j D jE C .X [ Y; Z/j C jE C.X \ Y; Z/j C jE C.X; Y n X /j C jE C .Y; X n Y /j D jı C .X [ Y /j C jı C .X \ Y /j C jE C .X; Y /j C jE C .Y; X /j. (b) follows from (a) by reversing each edge (replace .v; w/ by .w; v/). (c) follows from (a) by replacing each edge fv; wg by a pair of oppositely directed edges .v; w/ and .w; v/. Substituting Y by V .G/ n Y in (c) yields (d). To show (e), observe that j.X /j C j.Y /j D j.X [ Y /j C j.X / \ .Y /j C j.X / \ Y j C j.Y / \ X j j.X [ Y /j C j.X \ Y /j. A function f W 2U ! R (where U is some finite set and 2U denotes its power set) is called submodular if f .X \ Y / C f .X [ Y / f .X / C f .Y / for all X; Y U ; supermodular if f .X \ Y / C f .X [ Y / f .X / C f .Y / for all X; Y U ; modular if f .X \ Y / C f .X [ Y / D f .X / C f .Y / for all X; Y U . So Lemma 2.1 implies that jı C j, jı j, jıj and jj are submodular. This will be useful later. A complete graph is a simple undirected graph where each pair of vertices is adjacent. We denote the complete graph on n vertices by Kn . The complement of a simple undirected graph G is the graph H for which V .G/ D V .H / and G C H is a complete graph. A matching in an undirected graph G is a set of pairwise disjoint edges (i.e. the endpoints are all different). A vertex cover in G is a set S V .G/ of vertices such that every edge of G is incident to at least one vertex in S . An edge cover in G is a set F E.G/ of edges such that every vertex of G is incident to at least one edge in F . A stable set in G is a set of pairwise non-adjacent vertices.

16

2 Graphs

A graph containing no edges is called empty. A clique is a set of pairwise adjacent vertices. Proposition 2.2. Let G be a graph and X V .G/. Then the following three statements are equivalent: (a) X is a vertex cover in G, (b) V .G/ n X is a stable set in G, (c) V .G/ n X is a clique in the complement of G.

If F is a family of sets or graphs, we say that F is a minimal element of F if F contains F but no proper subset/subgraph of F . Similarly, F is maximal in F if F 2 F and F is not a proper subset/subgraph of any element of F. When we speak of a minimum or maximum element, we mean one of minimum/maximum cardinality. For example, a minimal vertex cover is not necessarily a minimum vertex cover (see e.g. the graph in Figure 13.1), and a maximal matching is in general not maximum. The problems of finding a maximum matching, stable set or clique, or a minimum vertex cover or edge cover in an undirected graph will play important roles in later chapters. The line graph of a simple undirected graph G is the graph .E.G/; F /, where F D ffe1 ; e2 g W e1 ; e2 2 E.G/; je1 \ e2 j D 1g. Obviously, matchings in a graph G correspond to stable sets in the line graph of G. For the following notation, let G be a graph, directed or undirected. An edge progression W in G (from v1 to vkC1 ) is a sequence v1 ; e1 ; v2 ; : : : ; vk ; ek ; vkC1 such that k 0, and ei D .vi ; vi C1 / 2 E.G/ or ei D fvi ; vi C1 g 2 E.G/ for i D 1; : : : ; k. If in addition ei 6D ej for all 1 i < j k, W is called a walk in G. W is closed if v1 D vkC1 . A path is a graph P D .fv1 ; : : : ; vkC1 g; fe1 ; : : : ; ek g/ such that vi ¤ vj for 1 i < j k C 1 and the sequence v1 ; e1 ; v2 ; : : : ; vk ; ek ; vkC1 is a walk. P is also called a path from v1 to vkC1 or a v1 -vkC1 -path. v1 and vkC1 are the endpoints of P , v2 ; : : : ; vk are its internal vertices. By PŒx;y with x; y 2 V .P / we mean the (unique) subgraph of P which is an x-y-path. Evidently, there is an edge progression from a vertex v to another vertex w if and only if there is a v-w-path. A circuit or a cycle is a graph .fv1 ; : : : ; vk g; fe1 ; : : : ; ek g/ such that the sequence v1 ; e1 ; v2 ; : : : ; vk ; ek ; v1 is a (closed) walk with k 2 and vi ¤ vj for 1 i < j k. An easy induction argument shows that the edge set of a closed walk can be partitioned into edge sets of circuits. By an undirected path or an undirected circuit in a digraph, we mean a subgraph corresponding to a path or circuit, respectively, in the underlying undirected graph. The length of a path or circuit is the number of its edges. If it is a subgraph of G, we speak of a path or circuit in G. A spanning path in G is called a Hamiltonian path while a spanning circuit in G is called a Hamiltonian circuit or a tour. A graph containing a Hamiltonian circuit is a Hamiltonian graph.

2.2

Trees, Circuits, and Cuts

17

For two vertices v and w we write dist.v; w/ or distG .v; w/ for the length of a shortest v-w-path (the distance from v to w) in G. If there is no v-w-path at all, i.e. w is not reachable from v, we set dist.v; w/ WD 1. In the undirected case, dist.v; w/ D dist.w; v/ for all v; w 2 V .G/. We shall often have a P weight (or cost) function c W E.G/ ! R. Then for F E.G/ we write c.F / WD e2F c.e/ (and c.;/ D 0). This extends c to a modular function c W 2E.G/ ! R. Moreover, dist.G;c/ .v; w/ denotes the minimum c.E.P // over all v-w-paths P in G.

2.2 Trees, Circuits, and Cuts An undirected graph G is called connected if there is a v-w-path for all v; w 2 V .G/; otherwise G is disconnected. A digraph is called connected if the underlying undirected graph is connected. The maximal connected subgraphs of a graph are its connected components. Sometimes we identify the connected components with the vertex sets inducing them. A set of vertices X is called connected if the subgraph induced by X is connected. A vertex v with the property that G v has more connected components than G is called an articulation vertex. An edge e is called a bridge if G e has more connected components than G. An undirected graph without a circuit (as a subgraph) is called a forest. A connected forest is a tree. A vertex of degree at most 1 in a tree is called a leaf. A star is a tree where at most one vertex is not a leaf. In the following we shall give some equivalent characterizations of trees and their directed counterparts, arborescences. We need the following connectivity criterion: Proposition 2.3. (a) An undirected graph G is connected if and only if ı.X / 6D ; for all ; 6D X V .G/. (b) Let G be a digraph and r 2 V .G/. Then there exists an r-v-path for every v 2 V .G/ if and only if ı C .X / 6D ; for all X V .G/ with r 2 X . Proof: (a): If there is a set X V .G/ with r 2 X , v 2 V .G/ n X , and ı.X / D ;, there can be no r-v-path, so G is not connected. On the other hand, if G is not connected, there is no r-v-path for some r and v. Let R be the set of vertices reachable from r. We have r 2 R, v … R and ı.R/ D ;. (b) is proved analogously. Theorem 2.4. Let G be an undirected graph on n vertices. Then the following statements are equivalent: (a) (b) (c) (d)

G is a tree (i.e. is connected and has no circuits). G has n 1 edges and no circuits. G has n 1 edges and is connected. G is connected and every edge is a bridge.

18

2 Graphs

(e) G satisfies ı.X / 6D ; for all ; 6D X V .G/, but deleting any edge would destroy this property. (f) G is a forest, but the addition of an arbitrary edge would create a circuit. (g) G contains a unique path between any pair of vertices. Proof: (a))(g) follows from the fact that the union of two distinct paths with the same endpoints contains a circuit. (g))(e))(d) follows from Proposition 2.3(a). (d))(f) is trivial. (f))(b))(c): This follows from the fact that for forests with n vertices, m edges and p connected components n D m C p holds. (The proof is a trivial induction on m.) (c))(a): Let G be connected with n 1 edges. As long as there are any circuits in G, we destroy them by deleting an edge of the circuit. Suppose we have deleted k edges. The resulting graph G 0 is still connected and has no circuits. G 0 has m D n 1 k edges. So n D m C p D n 1 k C 1, implying k D 0. In particular, (d))(a) implies that a graph is connected if and only if it contains a spanning tree (a spanning subgraph which is a tree). A digraph is a branching if the underlying undirected graph is a forest and each vertex v has at most one entering edge. A connected branching is an arborescence. By Theorem 2.4 an arborescence with n vertices has n 1 edges, hence it has exactly one vertex r with ı .r/ D ;. This vertex is called its root; we also speak of an arborescence rooted at r. For a vertex v in a branching, the vertices w for which .v; w/ is an edge are called the children of v. For a child w of v, v is called the parent or predecessor of w. Vertices without children are called leaves. Theorem 2.5. Let G be a digraph on n vertices. Then the following statements are equivalent: G is an arborescence rooted at r (i.e. a connected branching with ı .r/ D ;). G is a branching with n 1 edges and ı .r/ D ;. G has n 1 edges and every vertex is reachable from r. Every vertex is reachable from r, but deleting any edge would destroy this property. (e) G satisfies ı C .X / 6D ; for all X V .G/ with r 2 X , but deleting any edge would destroy this property. (f) ı .r/ D ;, and there is a unique walk from r to v for each v 2 V .G/ n frg. (g) ı .r/ D ;, jı .v/j D 1 for all v 2 V .G/ n frg, and G contains no circuit. (a) (b) (c) (d)

Proof: (a))(b) and (c))(d) follow from Theorem 2.4. (b))(c): We have that jı .v/j D 1 for all v 2 V .G/ n frg. So for any v we have an r-v-path (start at v and always follow the entering edge until r is reached). (d),(e) is implied by Proposition 2.3(b). (d))(f): Any edge in ı .r/ could be deleted without destroying reachability from r. Suppose that, for some v 2 V .G/, there are two r-v-walks P and Q. Let e

2.2

Trees, Circuits, and Cuts

19

be the last edge of P that does not belong to Q. Then after deleting e, every vertex is still reachable from r. (f))(g): If every vertex is reachable from r and jı .v/j > 1 for some vertex v 2 V .G/ n frg, then we have two walks from r to v. If G contains a circuit C , let v 2 V .C /, consider the r-v-path P , and let x be the first vertex on P belonging to C . Then there are two walks from r to x: PŒr;x , and PŒr;x plus C . (g))(a): If jı .v/j 1, every undirected circuit is a (directed) circuit. A cut in an undirected graph G is an edge set of type ı.X / for some ; 6D X V .G/. In a digraph G, ı C .X / is a directed cut if ; 6D X V .G/ and ı .X / D ;, i.e. no edge enters the set X . We say that an edge set F E.G/ separates two vertices s and t if t is reachable from s in G but not in .V .G/; E.G/ n F /. An s-t-cut in an undirected graph is a cut ı.X / for some X V .G/ with s 2 X and t … X . In a digraph, an s-t-cut is an edge set ı C .X / with s 2 X and t … X . An r-cut in a digraph is an edge set ı C .X / for some X V .G/ with r 2 X . An undirected cut in a digraph is an edge set corresponding to a cut in the underlying undirected graph, i.e., ı.X / for some ; 6D X V .G/. Lemma 2.6. (Minty [1960]) Let G be a digraph and e 2 E.G/. Suppose e is coloured black, while all other edges are coloured red, black or green. Then exactly one of the following statements holds: (a) There is an undirected circuit containing e and only red and black edges such that all black edges have the same orientation. (b) There is an undirected cut containing e and only green and black edges such that all black edges have the same orientation. Proof: Let e D .x; y/. We label the vertices of G by the following procedure. First label y. In case v is already labelled and w is not, we label w if there is a black edge .v; w/, a red edge .v; w/ or a red edge .w; v/. In this case, we write pred.w/ WD v. When the labelling procedure stops, there are two possibilities: Case 1: x has been labelled. Then the vertices x; pred.x/; pred.pred.x//; : : : ; y form an undirected circuit with the property (a). Case 2: x has not been labelled. Then let R consist of all labelled vertices. Obviously, the undirected cut ı C .R/ [ ı .R/ has the property (b). Suppose that an undirected circuit C as in (a) and an undirected cut ı C .X / [ ı .X / as in (b) both exist. All edges in their (nonempty) intersection are black, they all have the same orientation with respect to C , and they all leave X or all enter X . This is a contradiction. A digraph is called strongly connected if there is a path from s to t and a path from t to s for all s; t 2 V .G/. The strongly connected components of a digraph are the maximal strongly connected subgraphs. Corollary 2.7. In a digraph G, each edge belongs either to a (directed) circuit or to a directed cut. Moreover the following statements are equivalent:

20

2 Graphs

(a) G is strongly connected. (b) G contains no directed cut. (c) G is connected and each edge of G belongs to a circuit. Proof: The first statement follows directly from Minty’s Lemma 2.6 by colouring all edges black. This also proves (b))(c). (a))(b) follows from Proposition 2.3(b). (c))(a): Let r 2 V .G/ be an arbitrary vertex. We prove that there is an r-vpath for each v 2 V .G/. Suppose this is not true, then by Proposition 2.3(b) there is some X V .G/ with r 2 X and ı C .X / D ;. Since G is connected, we have ı C .X / [ ı .X / 6D ; (by Proposition 2.3(a)), so let e 2 ı .X /. But then e cannot belong to a circuit since no edge leaves X . Corollary 2.7 and Theorem 2.5 imply that a digraph is strongly connected if and only if it contains for each vertex v a spanning arborescence rooted at v. A digraph is called acyclic if it contains no (directed) circuit. So by Corollary 2.7 a digraph is acyclic if and only if each edge belongs to a directed cut. Moreover, a digraph is acyclic if and only if its strongly connected components are the singletons. The vertices of an acyclic digraph can be ordered in a nice way: Definition 2.8. Let G be a digraph. A topological order of G is an order of the vertices V .G/ D fv1 ; : : : ; vn g such that for each edge .vi ; vj / 2 E.G/ we have i < j. Proposition 2.9. A digraph has a topological order if and only if it is acyclic. Proof: If a digraph has a circuit, it clearly cannot have a topological order. We show the converse by induction on the number of edges. If there are no edges, every order is topological. Otherwise let e 2 E.G/; by Corollary 2.7 e belongs to a directed cut ı C .X /. Then a topological order of GŒX followed by a topological order of G X (both exist by the induction hypothesis) is a topological order of G. Circuits and cuts also play an important role in algebraic graph theory. For a graph G we associate a vector space RE.G/ whose elements are vectors .xe /e2E.G/ with jE.G/j real components. Following Berge [1985] we shall now briefly discuss two linear subspaces which are particularly important. Let G be a digraph. We associate a vector .C / 2 f1; 0; 1gE.G/ with each undirected circuit C in G by setting .C /e D 0 for e … E.C /, and setting .C /e 2 f1; 1g for e 2 E.C / such that reorienting all edges e with .C /e D 1 results in a directed circuit. Similarly, we associate a vector .D/ 2 f1; 0; 1gE.G/ with each undirected cut D D ı.X / in G by setting .D/e D 0 for e … D, .D/e D 1 for e 2 ı .X / and .D/e D 1 for e 2 ı C .X /. Note that these vectors are properly defined only up to multiplication by 1. However, the subspaces of the vector space RE.G/ generated by the set of vectors associated with the undirected circuits and by the set of vectors associated with the undirected cuts in G are properly defined; they are called the cycle space and the cocycle space of G, respectively.

2.2

Trees, Circuits, and Cuts

21

Proposition 2.10. The cycle space and the cocycle space are orthogonal to each other. Proof: Let C be any undirected circuit and D D ı.X / be any undirected cut. We claim that the scalar product of .C / and .D/ is zero. Since reorienting any edge does not change the scalar product we may assume that D is a directed cut. But then the result follows from observing that any circuit enters a set X the same number of times as it leaves X . We shall now show that the sum of the dimensions of the cycle space and the cocycle space is jE.G/j, the dimension of the whole space. A set of undirected circuits (undirected cuts) is called a cycle basis (a cocycle basis) if the associated vectors form a basis of the cycle space (the cocycle space, respectively). Let G be a graph (directed or undirected) and T a maximal subgraph without an undirected circuit. For each e 2 E.G/ n E.T / we call the unique undirected circuit in T C e the fundamental circuit of e with respect to T . Moreover, for each e 2 E.T / there is a set X V .G/ with ıG .X / \ E.T / D feg (consider a component of T e); we call ıG .X / the fundamental cut of e with respect to T . Theorem 2.11. Let G be a digraph and T a maximal subgraph without an undirected circuit. The jE.G/ n E.T /j fundamental circuits with respect to T form a cycle basis of G, and the jE.T /j fundamental cuts with respect to T form a cocycle basis of G. Proof: The vectors associated with the fundamental circuits are linearly independent since each fundamental circuit contains an element not belonging to any other. The same holds for the fundamental cuts. Since the vector spaces are orthogonal to each other by Proposition 2.10, the sum of their dimensions cannot exceed jE.G/j D jE.G/ n E.T /j C jE.T /j. The fundamental cuts have a nice property which we shall exploit quite often and which we shall discuss now. Let T be a digraph whose underlying undirected graph is a tree. Consider the family F WD fCe W e 2 E.T /g, where for e D .x; y/ 2 E.T / we denote by Ce the connected component of T e containing y (so ı.Ce / is the fundamental cut of e with respect to T ). If T is an arborescence, then any two elements of F are either disjoint or one is a subset of the other. In general F is at least cross-free: Definition 2.12. A set system is a pair .U; F /, where U is a nonempty finite set and F a family of subsets of U . .U; F / is cross-free if for any two sets X; Y 2 F , at least one of the four sets X n Y , Y n X , X \ Y , U n .X [ Y / is empty. .U; F / is laminar if for any two sets X; Y 2 F, at least one of the three sets X n Y , Y n X , X \ Y is empty. In the literature set systems are also known as hypergraphs. See Figure 2.1(a) for an illustration of the laminar family ffag; fb; cg; fa; b; cg; fa; b; c; d g; ff g; ff; ggg. Another word used for laminar is nested.

22

2 Graphs

a

b

e

g

d

a

b

c

f

e

d

g f

a

b, c

Fig. 2.1.

Whether a set system .U; F / is laminar does not depend on U , so we sometimes simply say that F is a laminar family. However, whether a set system is cross-free can depend on the ground set U . If U contains an element that does not belong to any set of F , then F is cross-free if and only if it is laminar. Let r 2 U be arbitrary. It follows directly from the definition that a set system .U; F/ is cross-free if and only if F 0 WD fX 2 F W r 62 X g [ fU n X W X 2 F ; r 2 X g is laminar. Hence cross-free families are sometimes depicted similarly to laminar families: for example, Figure 2.2(a) shows the cross-free family ffb; c; d; e; f g; fcg; fa; b; cg; feg; fa; b; c; d; f g; fe; f gg; a square corresponds to the set containing all elements outside.

a

d

b

f

b a

b

c

e

d

f a

c

e

Fig. 2.2.

While oriented trees lead to cross-free families the converse is also true: every cross-free family can be represented by a tree in the following sense:

2.2

Trees, Circuits, and Cuts

23

Definition 2.13. Let T be a digraph such that the underlying undirected graph is a tree. Let U be a finite set and ' W U ! V .T /. Let F WD fSe W e 2 E.T /g, where for e D .x; y/ we define Se WD fs 2 U W '.s/ is in the same connected component of T e as yg: Then .T; '/ is called a tree-representation of .U; F /. See Figures 2.1(b) and 2.2(b) for examples. Proposition 2.14. Let .U; F / be a set system with a tree-representation .T; '/. Then .U; F / is cross-free. If T is an arborescence, then .U; F / is laminar. Moreover, every cross-free family has a tree-representation, and for laminar families, an arborescence can be chosen as T . Proof: If .T; '/ is a tree-representation of .U; F/ and e D .v; w/; f D .x; y/ 2 E.T /, we have an undirected v-x-path P in T (ignoring the orientations). There are four cases: If w; y … V .P / then Se \ Sf D ; (since T contains no circuit). If w … V .P / and y 2 V .P / then Se Sf . If y … V .P / and w 2 V .P / then Sf Se . If w; y 2 V .P / then Se [ Sf D U . Hence .U; F/ is cross-free. If T is an arborescence, the last case cannot occur (otherwise at least one vertex of P would have two entering edges), so F is laminar. : To prove the converse, let F first be a laminar family. We define V .T / WD F [ frg and E.T / WD f.X; Y / 2 F F W X Y 6D ; and there is no Z 2 F with X Z Y g [ f.r; X / W X D ; 2 F or X is a maximal element of F g : We set '.x/ WD X , where X is the minimal set in F containing x, and '.x/ WD r if no set in F contains x. Obviously, T is an arborescence rooted at r, and .T; '/ is a tree-representation of F. Now let F be a cross-free family of subsets of U . Let r 2 U . As noted above, F 0 WD fX 2 F W r 62 X g [ fU n X W X 2 F ; r 2 X g is laminar, so let .T; '/ be a tree-representation of .U; F 0 /. Now for an edge e 2 E.T / there are three cases: If Se 2 F and U n Se 2 F, we replace the edge e D .x; y/ by two edges .x; ´/ and .y; ´/, where ´ is a new vertex. If Se 62 F and U n Se 2 F , we replace the edge e D .x; y/ by .y; x/. If Se 2 F and U n Se 62 F , we do nothing. Let T 0 be the resulting graph. Then .T 0 ; '/ is a tree-representation of .U; F /. The above result is mentioned by Edmonds and Giles [1977] but was probably known earlier. Corollary 2.15. A laminar family of distinct subsets of U has at most 2jU j elements. A cross-free family of distinct subsets of U has at most 4jU j 2 elements.

24

2 Graphs

Proof: We first consider a laminar family F of distinct nonempty proper subsets of U . We prove that jF j 2jU j 2. Let .T; '/ be a tree-representation, where T is an arborescence whose number of vertices is as small as possible. For every w 2 V .T / we have either jı C .w/j 2 or there exists an x 2 U with '.x/ D w or both. (For the root this follows from U … F , for the leaves from ; … F, for all other vertices from the minimality of T .) j There k can be at most jU j vertices w with '.x/ D w for some x 2 U and at most jE.T /j /j vertices w with jı C .w/j 2. So jE.T /j C 1 D jV .T /j jU j C jE.T 2 2 and thus jF j D jE.T /j 2jU j 2. Now let .U; F / be a cross-free family with ;; U … F , and let r 2 U . Since F 0 WD fX 2 F W r 62 X g [ fU n X W X 2 F ; r 2 X g is laminar, we have jF 0 j 2jU j 2. Hence jF j 2jF 0 j 4jU j 4. The proof is concluded by taking ; and U as possible members of F into account.

2.3 Connectivity Connectivity is a very important concept in graph theory. For many problems it suffices to consider connected graphs, since otherwise we can solve the problem for each connected component separately. So it is a fundamental task to detect the connected components of a graph. The following simple algorithm finds a path from a specified vertex s to all other vertices that are reachable from s. It works for both directed and undirected graphs. In the undirected case it builds a maximal tree containing s; in the directed case it constructs a maximal arborescence rooted at s.

GRAPH SCANNING ALGORITHM Input:

A graph G (directed or undirected) and some vertex s.

Output:

The set R of vertices reachable from s, and a set T E.G/ such that .R; T / is an arborescence rooted at s, or a tree.

1

Set R WD fsg, Q WD fsg and T WD ;.

2

If Q D ; then stop, else choose a v 2 Q. Choose a w 2 V .G/ n R with e D .v; w/ 2 E.G/ or e D fv; wg 2 E.G/. If there is no such w then set Q WD Q n fvg and go to . 2 Set R WD R [ fwg, Q WD Q [ fwg and T WD T [ feg. Go to . 2

3 4

Proposition 2.16. The GRAPH SCANNING ALGORITHM works correctly. Proof: At any time, .R; T / is a tree or an arborescence rooted at s. Suppose at the end there is a vertex w 2 V .G/ n R that is reachable from s. Let P be an s-w-path,

2.3

Connectivity

25

and let fx; yg or .x; y/ be an edge of P with x 2 R and y … R. Since x has been added to R, it also has been added to Q at some time during the execution of the algorithm. The algorithm does not stop before removing x from Q. But this is done in 3 only if there is no edge fx; yg or .x; y/ with y … R. Since this is the first graph algorithm in this book we discuss some implementation issues. The first question is how the graph is given. There are several natural ways. For example, one can think of a matrix with a row for each vertex and a column for each edge. The incidence matrix of an undirected graph G is the matrix A D .av;e /v2V .G/; e2E.G/ where ( 1 if v 2 e av;e D : 0 if v 62 e The incidence matrix of a digraph G is the matrix A D .av;e /v2V .G/; e2E.G/ where 8 ˆ l.v/ C 1 (because the vertices are scanned in an order with nondecreasing l-values). Suppose that when the algorithm terminates there is a vertex w 2 V .G/ with distG .s; w/ < dist.R;T / .s; w/; let w have minimum distance from s in G with this property. Let P be a shortest s-w-path in G, and let e D .v; w/ or e D fv; wg be the last edge in P . We have distG .s; v/ D dist.R;T / .s; v/, but e does not belong to T . Moreover, l.w/ D dist.R;T / .s; w/ > distG .s; w/ D distG .s; v/ C 1 D dist.R;T / .s; v/ C 1 D l.v/ C 1. This inequality combined with the above observation proves that w did not belong to R when v was removed from Q. But this contradicts 3 because of edge e. This result will also follow from the correctness of DIJKSTRA’S ALGORITHM for the SHORTEST PATH PROBLEM, which can be thought of as a generalization of BFS to the case where we have nonnegative weights on the edges (see Section 7.1). We now show how to identify the strongly connected components of a digraph. Of course, this can easily be done by using n times DFS (or BFS). However, it is possible to find the strongly connected components by visiting every edge only twice:

STRONGLY CONNECTED COMPONENT ALGORITHM Input:

A digraph G.

Output:

A function comp W V .G/ ! N indicating the membership of the strongly connected components.

1

Set R WD ;. Set N WD 0.

2

For all v 2 V .G/ do: If v … R then VISIT1.v/.

3

Set R WD ;. Set K WD 0.

4

For i WD jV .G/j down to 1 do: If 1 .i / … R then set K WD K C 1 and VISIT2.

VISIT1.v/ 1

Set R WD R [ fvg.

2

For all w with .v; w/ 2 E.G/ do: If w … R then VISIT1.w/.

3

Set N WD N C 1,

.v/ WD N and

1

.N / WD v.

1

.i //.

28

2 Graphs

VISIT2.v/ 1

Set R WD R [ fvg.

2

For all w with .w; v/ 2 E.G/ do: If w … R then VISIT2.w/. Set comp.v/ WD K.

3

Figure 2.3 shows an example: The first DFS scans the vertices in the order a; g; b; d; e; f and produces the arborescence shown in the middle; the numbers are the -labels. Vertex c is the only one that is not reachable from a; it gets the highest label .c/ D 7. The second DFS starts with c but cannot reach any other vertex via a reverse edge. So it proceeds with vertex a because .a/ D 6. Now b, g and f can be reached. Finally e is reached from d . The strongly connected components are fcg, fa; b; f; gg and fd; eg. b

b

c a

a 6

g

5 f 4

e

c 7

c a g

g

d f

b

1

d 3

d f

e 2

e

Fig. 2.3.

In summary, one DFS is needed to find an appropriate numbering, while in the second DFS the reverse graph is considered and the vertices are processed in decreasing order with respect to this numbering. Each connected component of the second DFS-forest is an anti-arborescence, a graph arising from an arborescence by reversing every edge. We show that these anti-arborescences identify the strongly connected components. Theorem 2.19. The STRONGLY CONNECTED COMPONENT ALGORITHM identifies the strongly connected components correctly in linear time. Proof: The running time is obviously O.n C m/. Of course, vertices of the same strongly connected component are always in the same component of any DFSforest, so they get the same comp-value. We have to prove that two vertices u and v with comp.u/ D comp.v/ indeed lie in the same strongly connected component. Let r.u/ and r.v/ be the vertex reachable from u and v with the highest -label, respectively. Since comp.u/ D comp.v/, i.e. u and v lie in the same anti-arborescence of the second DFS-forest, r WD r.u/ D r.v/ is the root of this anti-arborescence. So r is reachable from both u and v.

2.3

Connectivity

29

Since r is reachable from u and .r/ .u/, r has not been added to R after u in the first DFS, and the first DFS-forest contains an r-u-path. In other words, u is reachable from r. Analogously, v is reachable from r. Altogether, u is reachable from v and vice versa, proving that indeed u and v belong to the same strongly connected component. It is interesting that this algorithm also solves another problem: finding a topological order of an acyclic digraph. Observe that contracting the strongly connected components of any digraph yields an acyclic digraph. By Proposition 2.9 this acyclic digraph has a topological order. In fact, such an order is given by the numbers comp.v/ computed by the STRONGLY CONNECTED COMPONENT ALGORITHM: Theorem 2.20. The STRONGLY CONNECTED COMPONENT ALGORITHM determines a topological order of the digraph resulting from contracting each strongly connected component of G. In particular, we can for any given digraph either find a topological order or decide that none exists in linear time. Proof: Let X and Y be two strongly connected components of a digraph G, and suppose the STRONGLY CONNECTED COMPONENT ALGORITHM computes comp.x/ D k1 for x 2 X and comp.y/ D k2 for y 2 Y with k1 < k2 . We claim C that EG .Y; X / D ;. Suppose that there is an edge .y; x/ 2 E.G/ with y 2 Y and x 2 X . All vertices in X are added to R in the second DFS before the first vertex of Y is added. In particular we have x 2 R and y … R when the edge .y; x/ is scanned in the second DFS. But this means that y is added to R before K is incremented, contradicting comp.y/ 6D comp.x/. Hence the comp-values computed by the STRONGLY CONNECTED COMPONENT A LGORITHM determine a topological order of the digraph resulting from contracting the strongly connected components. The second statement of the theorem now follows from Proposition 2.9 and the observation that a digraph is acyclic if and only if its strongly connected components are the singletons. A linear-time algorithm that identifies the strongly connected components was first given by Karzanov [1970] and Tarjan [1972]. The problem of finding a topological order (or deciding that none exists) was solved earlier (Kahn [1962], Knuth [1968]). Both BFS and DFS occur as subroutines in many other combinatorial algorithms. Some examples will appear in later chapters. Sometimes one is interested in higher connectivity. Let k 2. An undirected graph with more than k vertices and the property that it remains connected even if we delete any k 1 vertices, is called k-connected. A graph with at least two vertices is k-edge-connected if it remains connected after deleting any k 1 edges. So a connected graph with at least three vertices is 2-connected (2-edge-connected) if and only if it has no articulation vertex (no bridge, respectively). The largest k and l such that a graph G is k-connected and l-edge-connected are called the vertex-connectivity and edge-connectivity of G. Here we say that

30

2 Graphs

a graph is 1-connected (and 1-edge-connected) if it is connected. A disconnected graph has vertex-connectivity and edge-connectivity zero. The blocks of an undirected graph are its maximal connected subgraphs without articulation vertex. Thus each block is either a maximal 2-connected subgraph, or consists of a bridge or an isolated vertex. Two blocks have at most one vertex in common, and a vertex belonging to more than one block is an articulation vertex. The blocks of an undirected graph can be determined in linear time quite similarly to the STRONGLY CONNECTED COMPONENT ALGORITHM; see Exercise 20. Here we prove a nice structure theorem for 2-connected graphs. We construct graphs from a single vertex by sequentially adding ears: Definition 2.21. Let G be a graph (directed or undirected). An ear-decomposition of G is a sequence r; P1 ; : : : ; Pk with G D .frg; ;/ C P1 C C Pk , such that each Pi is either a path where exactly the endpoints belong to frg[V .P1 /[ [V .Pi 1 /, or a circuit where exactly one of its vertices belongs to frg [ V .P1 / [ [ V .Pi 1 / (i 2 f1; : : : ; kg). P1 ; : : : ; Pk are called ears. If k 1, P1 is a circuit of length at least three, and P2 ; : : : ; Pk are paths, then the ear-decomposition is called proper. Theorem 2.22. (Whitney [1932]) An undirected graph is 2-connected if and only if it has a proper ear-decomposition. Proof: Evidently a circuit of length at least three is 2-connected. Moreover, if G is 2-connected, then so is G C P , where P is an x-y-path, x; y 2 V .G/ and x 6D y: deleting any vertex does not destroy connectivity. We conclude that a graph with a proper ear-decomposition is 2-connected. To show the converse, let G be a 2-connected graph. Let G 0 be the maximal simple subgraph of G; evidently G 0 is also 2-connected. Hence G 0 cannot be a tree; i.e. it contains a circuit. Since it is simple, G 0 , and thus G, contains a circuit of length at least three. So let H be a maximal subgraph of G that has a proper eardecomposition; H exists by the above consideration. Suppose H is not spanning. Since G is connected, we then know that there exists an edge e D fx; yg 2 E.G/ with x 2 V .H / and y … V .H /. Let ´ be a vertex in V .H / n fxg. Since G x is connected, there exists a path P from y to ´ in G x. Let ´0 be the first vertex on this path, when traversed from y, that belongs to V .H /. Then PŒy;´0 C e can be added as an ear, contradicting the maximality of H . Thus H is spanning. Since each edge of E.G/ n E.H / can be added as an ear, we conclude that H D G. See Exercise 21 for similar characterizations of 2-edge-connected graphs and strongly connected digraphs.

2.4

Eulerian and Bipartite Graphs

31

2.4 Eulerian and Bipartite Graphs Euler’s work on the problem of traversing each of the seven bridges of Königsberg exactly once was the origin of graph theory. He showed that the problem had no solution by defining a graph, asking for a walk containing all edges, and observing that more than two vertices had odd degree. Definition 2.23. An Eulerian walk in a graph G is a closed walk containing every edge. An undirected graph G is called Eulerian if the degree of each vertex is even. A digraph G is Eulerian if jı .v/j D jı C .v/j for each v 2 V .G/. Although Euler neither proved sufficiency nor considered the case explicitly in which we ask for a closed walk, the following famous result is usually attributed to him: Theorem 2.24. (Euler [1736], Hierholzer [1873]) A connected (directed or undirected) graph has an Eulerian walk if and only if it is Eulerian. Proof: The necessity of the degree conditions is obvious, as a vertex appearing k times in an Eulerian walk (or k C 1 times if it is the first and the last vertex) must have in-degree k and out-degree k, or degree 2k in the undirected case. For the sufficiency, let W D v1 ; e1 ; v2 ; : : : ; vk ; ek ; vkC1 be a longest walk in G, i.e. one with maximum number of edges. In particular, W must contain all edges leaving vkC1 , which implies vkC1 D v1 by the degree conditions. So W is closed. Suppose that W does not contain all edges. As G is connected, we then conclude that there is an edge e 2 E.G/ for which e does not appear in W , but at least one of its endpoints appears in W , say vi . Then e can be combined with vi ; ei ; vi C1 ; : : : ; ek ; vkC1 D v1 ; e1 ; v2 ; : : : ; ei 1 ; vi to a walk which is longer than W . The algorithm accepts as input only connected Eulerian graphs. Note that one can check in linear time whether a given graph is connected (Theorem 2.17) and Eulerian (trivial). The algorithm first chooses an initial vertex, then calls a recursive procedure. We first describe it for undirected graphs:

EULER’S ALGORITHM Input:

An undirected connected Eulerian graph G.

Output:

An Eulerian walk W in G.

1

Choose v1 2 V .G/ arbitrarily. Return W WD EULER.G; v1 /.

EULER(G; v1 ) 1

Set W WD v1 and x WD v1 .

2

If ı.x/ D ; then go to . 4 Else let e 2 ı.x/, say e D fx; yg.

32

2 Graphs

3

Set W WD W; e; y and x WD y. Set E.G/ WD E.G/ n feg and go to . 2

4

Let v1 ; e1 ; v2 ; e2 ; : : : ; vk ; ek ; vkC1 be the sequence W . For i WD 2 to k do: Set Wi WD EULER.G; vi /. Set W WD W1 ; e1 ; W2 ; e2 ; : : : ; Wk ; ek ; vkC1 . Return W .

5

For digraphs, 2 has to be replaced by: 2

If ı C .x/ D ; then go to . 4 Else let e 2 ı C .x/, say e D .x; y/. We can analyze both versions (undirected and directed) simultaneously:

Theorem 2.25. EULER’S ALGORITHM works correctly. Its running time is O.mC n/, where n D jV .G/j and m D jE.G/j. Proof: We show that EULER.G; v1 /, if called for an Eulerian graph G and v 2 V .G/, returns an Eulerian walk in the connected component G1 of G that contains v1 . We use induction on jE.G/j, the case E.G/ D ; being trivial. Because of the degree conditions, vkC1 D x D v1 when 4 is executed. So at this stage W is a closed walk. Let G 0 be the graph G at this stage. G 0 is also Eulerian. For each edge e 2 E.G1 / \ E.G 0 / there exists a minimum i 2 f2; : : : ; kg such that e is in the same connected component of G 0 as vi (note that v1 D vkC1 is isolated in G 0 ). Then by the induction hypothesis e belongs to Wi . So the closed walk W composed in 5 is indeed an Eulerian walk in G1 . The running time is linear, because each edge is deleted immediately after being examined. EULER’S ALGORITHM will be used several times as a subroutine in later chapters. Sometimes one is interested in making a given graph Eulerian by adding or contracting edges. Let G be an undirected graph and F a family of unordered pairs : of V .G/ (edges or not). F is called an odd join if .V .G/; E.G/ [ F / is Eulerian. F is called an odd cover if the graph which results from G by contracting the vertex set of each connected component of .V .G/; F / is Eulerian. Both concepts are equivalent in the following sense. Theorem 2.26. (Aoshima and Iri [1977]) For any undirected graph we have: (a) Every odd join is an odd cover. (b) Every minimal odd cover is an odd join. Proof: Let G be an undirected graph. To prove (a), let F be an odd join. We build a graph G 0 by contracting the connected components of .V .G/; F / in G. Each of these connected components contains an even number of odd-degree vertices (with respect to F and thus with

2.4

Eulerian and Bipartite Graphs

33

respect to G, because F is an odd join). So the resulting graph has even degrees only. Thus F is an odd cover. To prove (b), let F be a minimal odd cover. Because of the minimality, .V .G/; F / is a forest. We have to show that jıF .v/j jıG .v/j .mod 2/ for each v 2 V .G/. So let v 2 V .G/. Let C1 ; : : : ; Ck be the connected components of .V .G/; F / v that contain a vertex w with fv; wg 2 F . Since F is a forest, k D jıF .v/j. As F is an odd cover, contracting X WD V .C1 / [ [ V .Ck / [ fvg in G yields a vertex of even degree, i.e. jıG .X /j is even. On the other hand, because of the minimality of F , F n ffv; wgg is not an odd cover (for any w with fv; wg 2 F ), so jıG .V .Ci //j is odd for i D 1; : : : ; k. Since k X

jıG .V .Ci //j D jıG .X /j C jıG .v/j

i D1

2jEG .fvg; V .G/ n X /j C 2

X

jEG .Ci ; Cj /j;

1i <j k

we conclude that k has the same parity as jıG .v/j.

We shall return to the problem of making a graph Eulerian in Section 12.2. A bipartition of an undirected graph G is a partition of the vertex set V .G/ D : A [ B such that the subgraphs induced by A and B are both empty. A graph is called bipartite if it has a bipartition. The simple bipartite graph G with V .G/ D : A [ B, jAj D n, jBj D m and E.G/ D ffa; bg W a 2 A; b 2 Bg is denoted : by Kn;m (the complete bipartite graph). When we write G D .A [ B; E.G//, we mean that GŒA and GŒB are both empty. Proposition 2.27. (König [1916]) An undirected graph is bipartite if and only if it contains no odd circuit (circuit of odd length). There is a linear-time algorithm which, given an undirected graph G, either finds a bipartition or an odd circuit. :

Proof: Suppose G is bipartite with bipartition V .G/ D A [ B, and the closed walk v1 ; e1 ; v2 ; : : : ; vk ; ek ; vkC1 defines some circuit in G. W.l.o.g. v1 2 A. But then v2 2 B, v3 2 A, and so on. We conclude that vi 2 A if and only if i is odd. But vkC1 D v1 2 A, so k must be even. To prove the sufficiency, we may assume that G is connected, since a graph is bipartite iff each connected component is (and the connected components can be determined in linear time; Proposition 2.17). We choose an arbitrary vertex s 2 V .G/ and apply BFS to .G; s/ in order to obtain the distances from s to v for all v 2 V .G/ (see Proposition 2.18). Let T be the resulting BFS-tree. Define A WD fv 2 V .G/ W distG .s; v/ is eveng and B WD V .G/ n A. If there is an edge e D fx; yg in GŒA or GŒB, the x-y-path in T together with e forms an odd circuit in G. If there is no such edge, we have a bipartition.

34

2 Graphs

2.5 Planarity We often draw graphs in the plane. A graph is called planar if it can be drawn such that no pair of edges intersect. To formalize this concept we need the following topological terms: Definition 2.28. A simple Jordan curve is the image of a continuous injective function ' W Œ0; 1 ! R2 ; its endpoints are '.0/ and '.1/. A closed Jordan curve is the image of a continuous function ' W Œ0; 1 ! R2 with '.0/ D '.1/ and './ 6D '. 0 / for 0 < 0 < 1. A polygonal arc is a simple Jordan curve which is the union of finitely many intervals (straight line segments). A polygon is a closed Jordan curve which is the union of finitely many intervals. Let R D R2 n J , where J is the union of finitely many intervals. We define the connected regions of R as equivalence classes where two points in R are equivalent if they can be joined by a polygonal arc within R. Definition 2.29. A planar embedding of a graph G consists of an injective mapping W V .G/ ! R2 and for each e D fx; yg 2 E.G/ a polygonal arc Je with endpoints .x/ and .y/, such that for each e D fx; yg 2 E.G/: 0 1 [ .Je n f .x/; .y/g/ \ @f .v/ W v 2 V .G/g [ Je0 A D ;: e 0 2E.G/nfeg

A graph is called planar if it has a planar embedding. Let G be a (planar) graph with some fixed planar embedding ˆ D . ; .Je /e2E.G/ /. After removing the points and polygonal arcs from the plane, the remainder, 0 1 [ R WD R2 n @f .v/ W v 2 V .G/g [ Je A ; e2E.G/

splits into open connected regions, called faces of ˆ. For example, K4 is obviously planar but it will turn out that K5 is not planar. Exercise 28 shows that restricting ourselves to polygonal arcs instead of arbitrary Jordan curves makes no substantial difference. We will show later that for simple graphs it is indeed sufficient to consider straight line segments only. Our aim is to characterize planar graphs. Following Thomassen [1981], we first prove the following topological fact, a version of the Jordan curve theorem: Theorem 2.30. If J is a polygon, then R2 n J splits into exactly two connected regions, each of which has J as its boundary. If J is a polygonal arc, then R2 n J has only one connected region. Proof: Let J be a polygon, p 2 R2 n J and q 2 J . Then there exists a polygonal arc in .R2 n J / [ fqg joining p and q: starting from p, one follows the straight

2.5

Planarity

35

line towards q until one gets close to J , then one proceeds within the vicinity of J . (We use the elementary topological fact that disjoint compact sets, in particular non-adjacent intervals of J , have a positive distance from each other.) We conclude that p is in the same connected region of R2 n J as some points arbitrarily close to q. J is the union of finitely many intervals; one or two of these intervals contain q. Let > 0 such that the ball with center q and radius intersects no other interval of J ; then clearly this ball intersects at most two connected regions. Since p 2 R2 n J and q 2 J were chosen arbitrarily, we conclude that there are at most two regions and each region has J as its boundary. Since the above also holds if J is a polygonal arc and q is an endpoint of J , R2 n J has only one connected region in this case. Returning to the case when J is a polygon, it remains to prove that R2 n J has more than one region. For any p 2 R2 n J and any angle ˛ we consider the ray l˛ starting at p with angle ˛. J \ l˛ is a set of points or closed intervals. Let cr.p; l˛ / be the number of these points or intervals that J enters from a different side of l˛ than to which it leaves (the number of times J “crosses” l˛ ; e.g. in Figure 2.4 we have cr.p; l˛ / D 2).

J

J

p

lα

J

Fig. 2.4.

Note that for any angle ˛, ˇ ˇ ˇ ˇ ˇ ˇ ˇ ˇ ˇ lim cr.p; l˛ / cr.p; l˛ /ˇ and ˇ lim cr.p; l˛C / cr.p; l˛ /ˇ ˇ!0; >0 ˇ ˇ!0; >0 ˇ are even integers: twice the number of points and intervals of J \ l˛ that J enters from the same side to which it leaves (left side and right side, respectively). Therefore g.p; ˛/ WD .cr.p; l˛ / mod 2/ is a continuous function in ˛, so it is constant and we denote it by g.p/. Clearly g.p/ is constant for points p on each straight line not intersecting J , so it is constant within each region. However, g.p/ 6D g.q/ for points p; q such that the straight line segment joining p and q intersects J exactly once. Hence there are indeed two regions. Exactly one of the faces, the outer face, is unbounded.

36

2 Graphs

Proposition 2.31. Let G be a 2-connected graph with a planar embedding ˆ. Then every face is bounded by a circuit, and every edge is on the boundary of exactly two faces. Moreover, the number of faces is jE.G/j jV .G/j C 2. Proof: By Theorem 2.30 both assertions are true if G is a circuit. For general 2connected graphs we use induction on the number of edges, using Theorem 2.22. Consider a proper ear-decomposition of G, and let P be the last ear, a path with endpoints x and y, say. Let G 0 be the graph before adding the last ear, and let ˆ0 be the restriction of ˆ to G 0 . S Let ˆ D . ; .Je /e2E.G/ /. Let F 0 be the face of ˆ0 containing e2E.P / Je n f .x/; .y/g. By induction, F 0 is bounded by a circuit C . C contains x and y, so C is the union of two x-y-paths Q1 ; Q2 in G 0 . Now we apply Theorem 2.30 to each of the circuits Q1 C P and Q2 C P . We conclude that [ : : Je F 0 [ f .x/; .y/g D F1 [ F2 [ e2E.P /

and F1 and F2 are two faces of G bounded by the circuits Q1 C P and Q2 C P , respectively. Hence G has one more face than G 0 . Using jE.G/nE.G 0 /j D jV .G/n V .G 0 /j C 1, this completes the induction step. This proof is due to Tutte. It also implies easily that the circuits bounding the finite faces constitute a cycle basis (Exercise 29). The last statement of Proposition 2.31 is known as Euler’s formula; it holds for general connected graphs: Theorem 2.32. (Euler [1758], Legendre [1794]) For any planar connected graph G with any embedding, the number of faces is jE.G/j jV .G/j C 2. Proof: We have already proved the statement for 2-connected graphs (Proposition 2.31). Moreover, the assertion is trivial if jV .G/j D 1 and follows from Theorem 2.30 if jE.G/j D 1. If jV .G/j D 2 and jE.G/j 2, then we can subdivide one edge e, thereby increasing the number of vertices and the number of edges by one and making the graph 2-connected, and apply Proposition 2.31. So we may now assume that G has an articulation vertex x; we proceed by induction on the number of vertices. Let ˆ be an embedding of G. Let C1 ; : : : ; Ck be the connected components of G x; and let ˆi be the restriction of ˆ to Gi WD GŒV .Ci / [ fxg for i D 1; : : : ; k. The set of inner (bounded) faces of ˆ is the disjoint union of the sets of inner faces of ˆi , i D 1; : : : ; k. By applying the induction hypothesis to .Gi ; ˆi /, i D 1; : : : ; k, we get that the total number of inner faces of .G; ˆ/ is k k X X .jE.Gi /jjV .Gi /jC1/ D jE.G/j jV .Gi /nfxgj D jE.G/jjV .G/jC1: i D1

i D1

Taking the outer face into account concludes the proof.

In particular, the number of faces is independent of the embedding. The average degree of a simple planar graph is less than 6:

2.5

Planarity

37

Corollary 2.33. Let G be a 2-connected simple planar graph whose minimum cirk cuit has length k (we also say that G has girth k). Then G has at most .n 2/ k2 edges. Any simple planar graph with n 3 vertices has at most 3n 6 edges. Proof: First assume that G is 2-connected. Let some embedding ˆ of G be given, and let r be the number of faces. By Euler’s formula (Theorem 2.32), r D jE.G/j jV .G/j C 2. By Proposition 2.31, each face is bounded by a circuit, i.e. by at least k edges, and each edge is on the boundary of exactly two faces. Hence kr 2jE.G/j. Combining the two results we get jE.G/j jV .G/j C 2 k2 jE.G/j, implying k jE.G/j .n 2/ k2 . If G is not 2-connected we add edges between non-adjacent vertices to make it 3 2-connected while preserving planarity. By the first part we have at most .n 2/ 32 edges, including the new ones. Now we show that certain graphs are non-planar: Corollary 2.34. Neither K5 nor K3;3 is planar. Proof: This follows directly from Corollary 2.33: K5 has five vertices but 10 > 4 3 5 6 edges; K3;3 is 2-connected, has girth 4 (as it is bipartite) and 9 > .6 2/ 42 edges.

Fig. 2.5.

Figure 2.5 shows these two graphs, which are the smallest non-planar graphs. We shall prove that every non-planar graph contains, in a certain sense, K5 or K3;3 . To make this precise we need the following notion: Definition 2.35. Let G and H be two undirected graphs. G is a minor of H if : : there exists a subgraph H 0 of H and a partition V .H 0 / D V1 [ [ Vk of its vertex set into connected subsets such that contracting each of V1 ; : : : ; Vk yields a graph which is isomorphic to G. In other words, G is a minor of H if it can be obtained from H by a series of operations of the following type: delete a vertex, delete an edge or contract an edge. Since neither of these operations destroys planarity, any minor of a planar graph is planar. Hence a graph which contains K5 or K3;3 as a minor cannot be

38

2 Graphs

planar. Kuratowski’s Theorem says that the converse is also true. We first consider 3-connected graphs and start with the following lemma (which is the heart of Tutte’s so-called wheel theorem): Lemma 2.36. (Tutte [1961], Thomassen [1980]) Let G be a 3-connected graph with at least five vertices. Then there exists an edge e such that G=e is also 3-connected. Proof: Suppose there is no such edge. Then for each edge e D fv; wg there exists a vertex x such that G fv; w; xg is disconnected, i.e. has a connected component C with jV .C /j < jV .G/j 3. Choose e, x and C such that jV .C /j is minimum. x has a neighbour y in C , because otherwise C is a connected component of G fv; wg (but G is 3-connected). By our assumption, G=fx; yg is not 3-connected, i.e. there exists a vertex ´ such that G fx; y; ´g is disconnected. Since fv; wg 2 E.G/, there exists a connected component D of Gfx; y; ´g which contains neither v nor w. But D contains a neighbour d of y, since otherwise D is a connected component of G fx; ´g (again contradicting the fact that G is 3-connected). So d 2 V .D/ \ V .C /, and thus D is a subgraph of C . Since y 2 V .C / n V .D/, we have a contradiction to the minimality of jV .C /j. Theorem 2.37. (Kuratowski [1930], Wagner [1937]) A 3-connected graph is planar if and only if it contains neither K5 nor K3;3 as a minor. Proof: As the necessity is evident (see above), we prove the sufficiency. Since K4 is obviously planar, we proceed by induction on the number of vertices: let G be a 3-connected graph with more than four vertices but no K5 or K3;3 minor. By Lemma 2.36, there exists an edge e D fv; wg such that G=e is 3-connected. Let ˆ D ; .Je0 /e0 2E.G=e/ be a planar embedding of G=e, which exists by induction. Let x be the vertex in G=e which arises by contracting e. Consider .G=e/ x with the restriction of ˆ as a planar embedding. Since .G=e/ x is 2-connected, every face is bounded by a circuit (Proposition 2.31). In particular, the face containing the point .x/ is bounded by a circuit C . Let y1 ; : : : ; yk 2 V .C / be the neighbours of v that are distinct from w, numbered in cyclic order, and partition C into edge-disjoint paths Pi , i D 1; : : : ; k, such that Pi is a yi -yi C1 -path (ykC1 WD y1 ). Suppose there exists an index i 2 f1; : : : ; kg such that .w/ fvg [ V .Pi /. Then a planar embedding of G can be constructed easily by modifying ˆ. We shall prove that all other cases are impossible. First, if w has three neighbours among y1 ; : : : ; yk , we have a K5 minor (Figure 2.6(a)). Next, if .w/ D fv; yi ; yj g for some i < j , then we must have i C 1 < j and .i; j / 6D .1; k/ (otherwise yi and yj would both lie on Pi or Pj ); see Figure 2.6(b). Otherwise there is a neighbour ´ of w in V .Pi / n fyi ; yi C1 g for some i and another neighbour ´0 … V .Pi / (Figure 2.6(c)). In both cases, there are four vertices y; ´; y 0 ; ´0 on C , in this cyclic order, with y; y 0 2 .v/ and ´; ´0 2 .w/. This implies that we have a K3;3 minor.

2.5

a

Planarity

39

c

b

Fig. 2.6.

The proof implies quite directly that every 3-connected simple planar graph has a planar embedding where each edge is embedded by a straight line and each face, except the outer face, is convex (Exercise 32(a)). The general case of Kuratowski’s Theorem can be reduced to the 3-connected case by gluing together planar embeddings of the maximal 3-connected subgraphs, or by the following lemma: Lemma 2.38. (Thomassen [1980]) Let G be a graph with at least five vertices which is not 3-connected and which contains neither K5 nor K3;3 as a minor. Then there exist two non-adjacent vertices v; w 2 V .G/ such that G C e, where e D fv; wg is a new edge, does not contain a K5 or K3;3 minor either. Proof: We use induction on jV .G/j. Let G be as above. Without loss of generality, G is simple. If G is disconnected, we can simply add an edge e joining two different connected components. So henceforth we assume that G is connected. Since G is not 3-connected, there exists a set X D fx; yg of two vertices such that G X is disconnected. (If G is not even 2-connected we may choose x to be an articulation vertex and y a neighbour of x.) Let C be a connected component of G X , G1 WD GŒV .C / [ X and G2 WD G V .C /. We first prove the following: Claim: Let v; w 2 V .G1 / be two vertices such that adding an edge e D fv; wg to G creates a K3;3 or K5 minor. Then at least one of G1 C e C f and G2 C f contains a K5 or K3;3 minor, where f is a new edge joining x and y. To prove this claim, let v; w 2 V .G1 /, e D fv; wg and suppose that there are pairwise disjoint connected vertex sets Z1 ; : : : ; Z t of G C e such that after contracting each of them we have a K5 (t D 5/ or K3;3 (t D 6) subgraph. Note that it is impossible that Zi V .G1 / n X and Zj V .G2 / n X for some i; j 2 f1; : : : ; tg: in this case the set of those Zk with Zk \ X 6D ; (there are at most two of these) separate Zi and Zj , contradicting the fact that both K5 and K3;3 are 3-connected. Hence there are two cases: If none of Z1 ; : : : ; Z t is a subset of V .G2 / n X , then G1 C e C f also contains a K5 or K3;3 minor: just consider Zi \ V .G1 / (i D 1; : : : ; t).

40

2 Graphs

Analogously, if none of Z1 ; : : : ; Z t is a subset of V .G1 / n X , then G2 C f contains a K5 or K3;3 minor (consider Zi \ V .G2 / (i D 1; : : : ; t)). The claim is proved. Now we first consider the case when G contains an articulation vertex x, and y is a neighbour of x. We choose a second neighbour ´ of x such that y and ´ are in different connected components of G x. W.l.o.g. say that ´ 2 V .G1 /. Suppose that the addition of e D fy; ´g creates a K5 or K3;3 minor. By the claim, at least one of G1 C e and G2 contains a K5 or K3;3 minor (an edge fx; yg is already present). But then G1 or G2 , and thus G, contains a K5 or K3;3 minor, contradicting our assumption. Hence we may assume that G is 2-connected. Recall that x; y 2 V .G/ were chosen such that G fx; yg is disconnected. If fx; yg … E.G/ we simply add an edge f D fx; yg. If this creates a K5 or K3;3 minor, the claim implies that G1 C f or G2 C f contains such a minor. Since there is an x-y-path in each of G1 ; G2 (otherwise we would have an articulation vertex of G), this implies that there is a K5 or K3;3 minor in G which is again a contradiction. Thus we can assume that f D fx; yg 2 E.G/. Suppose now that at least one of the graphs Gi (i 2 f1; 2g) is not planar. Then this Gi has at least five vertices. Since it does not contain a K5 or K3;3 minor (this would also be a minor of G), we conclude from Theorem 2.37 that Gi is not 3-connected. So we can apply the induction hypothesis to Gi . By the claim, if adding an edge within Gi does not introduce a K5 or K3;3 minor in Gi , it cannot introduce such a minor in G either. So we may assume that both G1 and G2 are planar; let ˆ1 and ˆ2 be planar embeddings. Let Fi be a face of ˆi with f on its boundary, and let ´i be another vertex on the boundary of Fi , ´i … fx; yg (i D 1; 2). We claim that adding an edge f´1 ; ´2 g (cf. Figure 2.7) does not introduce a K5 or K3;3 minor.

z1

z2

x

G1

f

G2

y

Fig. 2.7.

Suppose, on the contrary, that adding f´1 ; ´2 g and contracting some pairwise disjoint connected vertex sets Z1 ; : : : ; Z t would create a K5 (t D 5/ or K3;3 (t D 6) subgraph. First suppose that at most one of the sets Zi is a subset of V .G1 / n fx; yg. Then the graph G20 , arising from G2 by adding one vertex w and edges from w to x, y and ´2 , also contains a K5 or K3;3 minor. (Here w corresponds to the contracted set

2.6

Planar Duality

41

Zi V .G1 / n fx; yg.) This is a contradiction since there is a planar embedding of G20 : just supplement ˆ2 by placing w within F2 . So we may assume that Z1 ; Z2 V .G1 /nfx; yg. Analogously, we may assume that Z3 ; Z4 V .G2 / n fx; yg. W.l.o.g. we have ´1 … Z1 and ´2 … Z3 . Then we cannot have a K5 , because Z1 and Z3 are not adjacent. Moreover, the only possible common neighbours of Z1 and Z3 are Z5 and Z6 . Since in K3;3 two vertices are either adjacent or have three common neighbours, a K3;3 minor is also impossible. Theorem 2.37 and Lemma 2.38 yield Kuratowski’s Theorem: Theorem 2.39. (Kuratowski [1930], Wagner [1937]) An undirected graph is planar if and only if it contains neither K5 nor K3;3 as a minor. Indeed, Kuratowski proved a stronger version (Exercise 33). The proof can be turned into a polynomial-time algorithm quite easily (Exercise 32(b)). In fact, a linear-time algorithm exists: Theorem 2.40. (Hopcroft and Tarjan [1974]) There is a linear-time algorithm for finding a planar embedding of a given graph or deciding that it is not planar.

2.6 Planar Duality We shall now introduce an important duality concept. In this section, graphs may contain loops, i.e. edges whose endpoints coincide. In a planar embedding loops are of course represented by polygons instead of polygonal arcs. Note that Euler’s formula (Theorem 2.32) also holds for graphs with loops: this follows from the observation that subdividing a loop e (i.e. replacing e D fv; vg by two parallel edges fv; wg; fw; vg where w is a new vertex) and adjusting the embedding (replacing the polygon Je by two polygonal arcs whose union is Je ) increases the number of edges and vertices each by one but does not change the number of faces. Definition 2.41. Let G be a directed or undirected graph, possibly with loops, and let ˆ D . ; .Je /e2E.G/ / be a planar embedding of G. We define the planar dual G whose vertices are the faces of ˆ and whose edge set is fe W e 2 E.G/g, where e connects the faces that are adjacent to Je (if Je is adjacent to only one face, then e is a loop). In the directed case, say for e D .v; w/, we orient e D .F1 ; F2 / in such a way that F1 is the face “to the right” when traversing Je from .v/ to .w/. G is again planar. In fact, there obviously exists a planar embedding ; .Je /e 2E.G / of G such that .F / 2 F for all faces F of ˆ and, for each e 2 E.G/,

42

2 Graphs

0 Je \ @f .v/ W v 2 V .G/g [

[

1 Jf A D ;;

f 2E.G/nfeg

jJe \ Je j D 1, and if e is a loop then the face bounded by Je contains exactly one endpoint of e. Such an embedding is called a standard embedding of G .

a

b

Fig. 2.8.

The planar dual of a graph really depends on the embedding: consider the two embeddings of the same graph shown in Figure 2.8. The resulting planar duals are not isomorphic, since the second one has a vertex of degree four (corresponding to the outer face) while the first one is 3-regular. Proposition 2.42. Let G be an undirected connected planar graph with a fixed embedding. Let G be its planar dual with a standard embedding. Then .G / D G. Proof: Let ; .Je /e2E.G/ be a fixed embedding of G and ; .Je /e 2E.G / a standard embedding of G . Let F be a face of G . The boundary of F contains Je for at least one edge e , so F must contain .v/ for one endpoint v of e. So every face of G contains at least one vertex of G. By applying Euler’s formula (Theorem 2.32) to G and to G, we get that the number of faces of G is jE.G /j jV .G /j C 2 D jE.G/j .jE.G/j jV .G/j C 2/ C 2 D jV .G/j. Hence each face of G contains exactly one vertex of G. From this we conclude that the planar dual of G is isomorphic to G. The requirement that G is connected is essential here: note that G is always connected, even if G is disconnected. Theorem 2.43. Let G be a connected planar undirected graph with arbitrary embedding. The edge set of any circuit in G corresponds to a minimal cut in G , and any minimal cut in G corresponds to the edge set of a circuit in G . fixed planar embedding of G. Let C be Proof: Let ˆ D . ; .Je /e2E.G/ / be a S a circuit in G. By Theorem 2.30, R2 n e2E.C / Je splits into exactly two connected regions. Let A and B be the set of faces of ˆ in the inner and outer region,

Exercises

43

:

respectively. We have V .G / D A [ B and EG .A; B/ D fe W e 2 E.C /g. Since A and B form connected sets in G , this is indeed a minimal cut. Conversely, let ıG .A/ be a minimal cut in G. Let ˆ D . ; .Je /e2E.G / / be a standard embedding of G . Let a 2 A and b 2 V .G/ n A. Observe that there is no polygonal arc in 0 1 [ R WD R2 n @f .v/ W v 2 V .G /g [ Je A e2ıG .A/

which connects .a/ and .b/: the sequence of faces of G passed by such a polygonal arc would define an edge progression from a to b in G not using any edge of ıG .A/. So R consists of at least two connected regions. Then, obviously, the boundary of each region must contain a circuit. Hence F WD fe W e 2 ıG .A/g contains the edge set of a circuit C in G . We have fe W e 2 E.C /g fe W e 2 F g D ıG .A/, and, by the first part, fe W e 2 E.C /g is a minimal cut in .G / D G (cf. Proposition 2.42). We conclude that fe W e 2 E.C /g D ıG .A/. In particular, e is a loop if and only if e is a bridge, and vice versa. For digraphs the above proof yields: Corollary 2.44. Let G be a connected planar digraph with some fixed planar embedding. The edge set of any circuit in G corresponds to a minimal directed cut in G , and vice versa. Another interesting consequence of Theorem 2.43 is: Corollary 2.45. Let G be a connected undirected graph with arbitrary planar embedding. Then G is bipartite if and only if G is Eulerian, and G is Eulerian if and only if G is bipartite. Proof: Observe that a connected graph is Eulerian if and only if every minimal cut has even cardinality. By Theorem 2.43, G is bipartite if G is Eulerian, and G is Eulerian if G is bipartite. By Proposition 2.42, the converse is also true. An abstract dual of G is a graph G 0 for which there is a bijection W E.G/ ! E.G 0 / such that F is the edge set of a circuit iff .F / is a minimal cut in G 0 and vice versa. Theorem 2.43 shows that any planar dual is also an abstract dual. The converse is not true. However, Whitney [1933] proved that a graph has an abstract dual if and only if it is planar (Exercise 39). We shall return to this duality relation when dealing with matroids in Section 13.3.

Exercises 1. Let G be a simple undirected graph on n vertices which is isomorphic to its complement. Show that n mod 4 2 f0; 1g.

44

2 Graphs

2. Prove that every simple undirected graph G with jı.v/j 12 jV .G/j for all v 2 V .G/ is Hamiltonian. Hint: Consider a longest path in G and the neighbours of its endpoints. (Dirac [1952]) 3. Prove that any simple undirected graph G with jE.G/j > jV .G/j1 is 2 connected. 4. Let G be a simple undirected graph. Show that G or its complement is connected. 5. Prove that every simple undirected graph with more than one vertex contains two vertices that have the same degree. Prove that every tree (except a single vertex) contains at least two leaves. 6. Let T be a tree with k leaves. Show that T contains at most k 2 vertices of degree at least 3. 7. Prove that every tree T contains a vertex v such that no connected component /j of T v contains more than jV .T vertices. Can you find such a vertex in linear 2 time? 8. Let G be a connected undirected graph, and let .V .G/; F / be a forest in G. Prove that there is a spanning tree .V .G/; T / with F T E.G/. 9. Let .V; F1 / and .V; F2 / be two forests with jF1 j < jF2 j. Prove that there exists an edge e 2 F2 n F1 such that .V; F1 [ feg/ is a forest. 10. Let .V; F1 / and .V; F2 / be two branchings with 2jF1 j < jF2 j. Prove that there exists an edge e 2 F2 n F1 such that .V; F1 [ feg/ is a branching. 11. Prove that any cut in an undirected graph is the disjoint union of minimal cuts. 12. Let G be an undirected graph, C a circuit and D a cut. Show that jE.C / \ Dj is even. 13. Show that any undirected graph has a cut containing at least half of the edges. 14. Let .U; F / be a cross-free set system with jU j 2. Prove that F contains at most 4jU j 4 distinct elements. 15. Let G be a connected undirected graph. Show that there exists an orientation G 0 of G and a spanning arborescence T of G 0 such that the set of fundamental circuits with respect to T is precisely the set of directed circuits in G 0 . Hint: Consider a DFS-tree. (Camion [1968], Crestin [1969]) 16. Describe a linear-time algorithm for the following problem: Given an adjacency list of a graph G, compute an adjacency list of the maximal simple subgraph of G. Do not assume that parallel edges appear consecutively in the input. 17. Given a graph G (directed or undirected), show that there is a linear-time algorithm to find a circuit or decide that none exists. 18. Describe a simple linear-time algorithm that finds a topological order in a given acyclic digraph. (Do not use the STRONGLY CONNECTED COMPONENT ALGORITHM). 19. Let G be a connected undirected graph, s 2 V .G/ and T a DFS-tree resulting from running DFS on .G; s/. s is called the root of T . x is an ancestor of y in T if x lies on the (unique) s-y-path in T . x is the parent of y if the edge fx; yg lies

Exercises

45

on the s-y-path in T . y is a child (successor) of x if x is the parent (an ancestor) of y. Note that with this definition each vertex is an ancestor and a successor of itself. Every vertex except s has exactly one parent. Prove: (a) For any edge fv; wg 2 E.G/, v is an ancestor or a successor of w in T . (b) A vertex v is an articulation vertex of G if and only if either v D s and jıT .v/j > 1 or v 6D s and there is a child w of v such that no edge in G connects a proper ancestor of v (that is, excluding v) with a successor of w.

20. Use Exercise 19 to design a linear-time algorithm which finds the blocks of an undirected graph. It will be useful to compute numbers ˛.x/ WD minff .w/ W w D x or fw; yg 2 E.G/ n T for some successor y of xg

21.

22.

23. 24. 25.

26.

27.

recursively during the DFS. Here .R; T / is the DFS-tree (with root s), and the f -values represent the order in which the vertices are added to R (see the GRAPH SCANNING ALGORITHM). If for some vertex x 2 R n fsg we have ˛.x/ f .w/, where w is the parent of x, then w must be either the root or an articulation vertex. Prove: (a) An undirected graph is 2-edge-connected if and only if it has at least two vertices and an ear-decomposition. (b) A digraph is strongly connected if and only if it has an ear-decomposition. (c) The edges of an undirected graph G with at least two vertices can be oriented such that the resulting digraph is strongly connected if and only if G is 2-edge-connected. (Robbins [1939]) A tournament is a digraph such that the underlying undirected graph is a (simple) complete graph. Prove that every tournament contains a Hamiltonian path (Rédei [1934]). Prove that every strongly connected tournament is Hamiltonian (Camion [1959]). Let G be an undirected graph. Prove that there exists an orientation G 0 of G C 0 such that jjıG 0 .v/j jıG 0 .v/jj 1 for all v 2 V .G /. Prove that if a connected undirected simple graph is Eulerian then its line graph is Hamiltonian. What about the converse? Prove that any connected bipartite graph has a unique bipartition. Prove that any non-bipartite undirected graph contains an odd circuit as an induced subgraph. Prove that an undirected graph G is bipartite if and only if E.G/ can be partitioned into cuts. Prove that a strongly connected digraph whose underlying undirected graph is non-bipartite contains a (directed) circuit of odd length. Let G be an undirected graph. A tree-decomposition of G is a pair .T; '/, where T is a tree and ' W V .T / ! 2V .G/ satisfies the following conditions: for each e 2 E.G/ there exists a t 2 V .T / with e '.t/; for each v 2 V .G/ the set ft 2 V .T / W v 2 '.t/g is connected in T .

46

28.

29. 30. 31.

32.

33.

34.

2 Graphs

We say that the width of .T; '/ is maxt 2V .T / j'.t/j 1. The tree-width of a graph G is the minimum width of a tree-decomposition of G. This notion is due to Robertson and Seymour [1986]. Show that the simple graphs of tree-width at most 1 are the forests. Moreover, prove that the following statements are equivalent for an undirected graph G: (a) G has tree-width at most 2; (b) G does not contain K4 as a minor; (c) G can be obtained from an empty graph by successively adding bridges and doubling and subdividing edges. (Doubling an edge e D fv; wg 2 E.G/ means adding another edge with endpoints v and w; subdividing an edge e D fv; wg 2 E.G/ means adding a vertex x and replacing e by two edges fv; xg; fx; wg.) Note: Because of the construction in (c) such graphs are called series-parallel. Show that if a graph G has a planar embedding where the edges are embedded by arbitrary Jordan curves, then it also has a planar embedding with polygonal arcs only. Let G be a 2-connected graph with a planar embedding. Show that the set of circuits bounding the finite faces constitutes a cycle basis of G. Can you generalize Euler’s formula (Theorem 2.32) to disconnected graphs? Show that there are exactly five Platonic graphs (corresponding to the Platonic solids; cf. Exercise 11 of Chapter 4), i.e. 3-connected planar regular graphs whose faces are all bounded by the same number of edges. Hint: Use Euler’s formula (Theorem 2.32). Deduce from the proof of Kuratowski’s Theorem 2.39: (a) Every 3-connected simple planar graph has a planar embedding where each edge is embedded by a straight line and each face, except the outer face, is convex. (b) There is a polynomial-time algorithm for checking whether a given graph is planar. Given a graph G and an edge e D fv; wg 2 E.G/, we say that H results from : G by subdividing e if V .H / D V .G/ [ fxg and E.H / D .E.G/ n feg/ [ ffv; xg; fx; wgg. A graph resulting from G by successively subdividing edges is called a subdivision of G. (a) Trivially, if H contains a subdivision of G then G is a minor of H . Show that the converse is not true. (b) Prove that a graph containing a K3;3 or K5 minor also contains a subdivision of K3;3 or K5 . Hint: Consider what happens when contracting one edge. (c) Conclude that a graph is planar if and only if no subgraph is a subdivision of K3;3 or K5 . (Kuratowski [1930]) Prove that each of the following statements implies the other: (a) For every infinite sequence of graphs G1 ; G2 ; : : : there are two indices i < j such that Gi is a minor of Gj .

References

35.

36.

37. 38. 39.

47

(b) Let G be a class of graphs such that for each G 2 G and each minor H of G we have H 2 G (i.e. membership in G is a hereditary graph property). Then there exists a finite set X of graphs such that G consists of all graphs that do not contain any element of X as a minor. Note: The statements have been proved by Robertson and Seymour [2004]; they are a main result of their series of papers on graph minors. Theorem 2.39 and Exercise 27 give examples of forbidden minor characterizations as in (b). Let G be a planar graph with an embedding ˆ, and let C be a circuit of G bounding some face of ˆ. Prove that then there is an embedding ˆ0 of G such that C bounds the outer face. (a) Let G be disconnected with an arbitrary planar embedding, and let G be the planar dual with a standard embedding. Prove that .G / arises from G by successively applying the following operation, until the graph is connected: Choose two vertices x and y which belong to different connected components and which are adjacent to the same face; contract fx; yg. (b) Generalize Corollary 2.45 to arbitrary planar graphs. Hint: Use (a) and Theorem 2.26. Let G be a connected digraph with a fixed planar embedding, and let G be the planar dual with a standard embedding. How are G and .G / related? Prove that if a planar digraph is acyclic (strongly connected), then its planar dual is strongly connected (acyclic). What about the converse? (a) Show that if G has an abstract dual and H is a minor of G then H also has an abstract dual. (b) Show that neither K5 nor K3;3 has an abstract dual. (c) Conclude that a graph is planar if and only if it has an abstract dual. (Whitney [1933])

References General Literature: Berge, C. [1985]: Graphs. Second Edition. Elsevier, Amsterdam 1985 Bollobás, B. [1998]: Modern Graph Theory. Springer, New York 1998 Bondy, J.A. [1995]: Basic graph theory: paths and circuits. In: Handbook of Combinatorics; Vol. 1 (R.L. Graham, M. Grötschel, L. Lovász, eds.), Elsevier, Amsterdam 1995 Bondy, J.A., and Murty, U.S.R. [2008]: Graph Theory. Springer, New York 2008 Diestel, R. [2010]: Graph Theory. Fourth Edition. Springer, New York 2010 Wilson, R.J. [2010]: Introduction to Graph Theory. Fifth Edition. Addison-Wesley, Reading 2010

Cited References: Aoshima, K., and Iri, M. [1977]: Comments on F. Hadlock’s paper: finding a maximum cut of a planar graph in polynomial time. SIAM Journal on Computing 6 (1977), 86–87 Camion, P. [1959]: Chemins et circuits hamiltoniens des graphes complets. Comptes Rendus Hebdomadaires des Séances de l’Académie des Sciences (Paris) 249 (1959), 2151–2152

48

2 Graphs

Camion, P. [1968]: Modulaires unimodulaires. Journal of Combinatorial Theory A 4 (1968), 301–362 Dirac, G.A. [1952]: Some theorems on abstract graphs. Proceedings of the London Mathematical Society 2 (1952), 69–81 Edmonds, J., and Giles, R. [1977]: A min-max relation for submodular functions on graphs. In: Studies in Integer Programming; Annals of Discrete Mathematics 1 (P.L. Hammer, E.L. Johnson, B.H. Korte, G.L. Nemhauser, eds.), North-Holland, Amsterdam 1977, pp. 185–204 Euler, L. [1736]: Solutio problematis ad geometriam situs pertinentis. Commentarii Academiae Petropolitanae 8 (1736), 128–140 Euler, L. [1758]: Demonstratio nonnullarum insignium proprietatum quibus solida hedris planis inclusa sunt praedita. Novi Commentarii Academiae Petropolitanae 4 (1758), 140–160 Hierholzer, C. [1873]: Über die Möglichkeit, einen Linienzug ohne Wiederholung und ohne Unterbrechung zu umfahren. Mathematische Annalen 6 (1873), 30–32 Hopcroft, J.E., and Tarjan, R.E. [1974]: Efficient planarity testing. Journal of the ACM 21 (1974), 549–568 Kahn, A.B. [1962]: Topological sorting of large networks. Communications of the ACM 5 (1962), 558–562 Karzanov, A.V. [1970]: An efficient algorithm for finding all the bi-components of a graph. In: Trudy 3-˘ı Zimne˘ı Shkoly po Matematicheskomu Programmirovaniyu i Smezhnym Voprosam (Drogobych, 1970), Issue 2, Moscow Institute for Construction Engineering (MISI) Press, Moscow, 1970, pp. 343–347 [in Russian] Knuth, D.E. [1968]: The Art of Computer Programming; Vol. 1. Fundamental Algorithms. Addison-Wesley, Reading 1968 (third edition: 1997) König, D. [1916]: Über Graphen und Ihre Anwendung auf Determinantentheorie und Mengenlehre. Mathematische Annalen 77 (1916), 453–465 König, D. [1936]: Theorie der endlichen und unendlichen Graphen. Teubner, Leipzig 1936; reprint: Chelsea Publishing Co., New York 1950 Kuratowski, K. [1930]: Sur le problème des courbes gauches en topologie. Fundamenta Mathematicae 15 (1930), 271–283 Legendre, A.M. [1794]: Éléments de Géométrie. Firmin Didot, Paris 1794 Minty, G.J. [1960]: Monotone networks. Proceedings of the Royal Society of London A 257 (1960), 194–212 Moore, E.F. [1959]: The shortest path through a maze. Proceedings of the International Symposium on the Theory of Switching; Part II. Harvard University Press 1959, pp. 285–292 Rédei, L. [1934]: Ein kombinatorischer Satz. Acta Litt. Szeged 7 (1934), 39–43 Robbins, H.E. [1939]: A theorem on graphs with an application to a problem of traffic control. American Mathematical Monthly 46 (1939), 281–283 Robertson, N., and Seymour, P.D. [1986]: Graph minors II: algorithmic aspects of tree-width. Journal of Algorithms 7 (1986), 309–322 Robertson, N., and Seymour, P.D. [2004]: Graph minors XX: Wagner’s conjecture. Journal of Combinatorial Theory B 92 (2004), 325–357 Tarjan, R.E. [1972]: Depth first search and linear graph algorithms. SIAM Journal on Computing 1 (1972), 146–160 Thomassen, C. [1980]: Planarity and duality of finite and infinite graphs. Journal of Combinatorial Theory B 29 (1980), 244–271 Thomassen, C. [1981]: Kuratowski’s theorem. Journal of Graph Theory 5 (1981), 225–241 Tutte, W.T. [1961]: A theory of 3-connected graphs. Proceedings of the Koninklijke Nederlandse Akademie van Wetenschappen A 64 (1961), 441–455

References

49

Wagner, K. [1937]: Über eine Eigenschaft der ebenen Komplexe. Mathematische Annalen 114 (1937), 570–590 Whitney, H. [1932]: Non-separable and planar graphs. Transactions of the American Mathematical Society 34 (1932), 339–362 Whitney, H. [1933]: Planar graphs. Fundamenta Mathematicae 21 (1933), 73–84

•

3 Linear Programming

In this chapter we review the most important facts about Linear Programming. Although this chapter is self-contained, it cannot be considered to be a comprehensive treatment of the field. The reader unfamiliar with Linear Programming is referred to the textbooks mentioned at the end of this chapter. The general problem reads as follows:

LINEAR PROGRAMMING Instance:

A matrix A 2 Rmn and column vectors b 2 Rm ; c 2 Rn .

Task:

Find a column vector x 2 Rn such that Ax b and c > x is maximum, decide that fx 2 Rn W Ax bg is empty, or decide that for all ˛ 2 R there is an x 2 Rn with Ax b and c > x > ˛.

Here c > x denotes the scalar product of the vectors. The notion x y for vectors x and y (of equal size) means that the inequality holds in each component. If no sizes are specified, the matrices and vectors are always assumed to be compatible in size. We often omit indicating the transposition of column vectors and write e.g. cx for the scalar product. By 0 we denote the number zero as well as all-zero vectors and all-zero matrices (the order will always be clear from the context). A linear program (LP) is an instance of the above problem. We often write a linear program as maxfcx W Ax bg. A feasible solution of an LP maxfcx W Ax bg is a vector x with Ax b. A feasible solution attaining the maximum is called an optimum solution. As the problem formulation indicates, there are two possibilities when an LP has no solution: The problem can be infeasible (i.e. P WD fx 2 Rn W Ax bg D ;) or unbounded (i.e. for all ˛ 2 R there is an x 2 P with cx > ˛). If an LP is neither infeasible nor unbounded it has an optimum solution: Proposition 3.1. Let P D fx 2 Rn W Ax bg 6D ; and c 2 Rn with ı WD supfc > x W x 2 P g < 1. Then there exists a vector ´ 2 P with c > ´ D ı. Proof: Let U be a matrix whose columns are an orthonormal of the kernel basis of A, i.e. U > U D I , AU D 0, and rank.A0 / D n where A0 WD UA> . Let b 0 WD b0 . We show that for every y 2 P there exists a subsystem A00 x b 00 of A0 x b 0 such that A00 is nonsingular, y 0 WD .A00 /1 b 00 2 P , and c > y 0 c > y. As there are

B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__3, c Springer-Verlag Berlin Heidelberg 2012

51

52

3 Linear Programming

only finitely many such subsystems, one of these y 0 attains the maximum (c > y 0 D ı), and the assertion follows. So let y 2 P , and denote by k.y/ the rank of A00 for the maximal subsystem A00 x b 00 of A0 x b 0 with A00 y D b 00 . Suppose that k.y/ < n. We show how to find a y 0 2 P with c > y 0 c > y and k.y 0 / > k.y/. After at most n steps we have a vector y 0 with k.y 0 / D n as required. If U > y 6D 0, we set y 0 WD y U U > y. Since y C U U > c 2 P for all 2 R we have supfc > .y C U U > c/ W 2 Rg ı < 1 and hence c > U D 0 and c > y 0 D c > y. Moreover, Ay 0 D Ay AU U > y D Ay and U > y 0 D U > y U > U U > y D 0. Now suppose that U > y D 0. Let v 6D 0 with nA00 v D 0. Denote o by ˇi ai y ai x ˇi the i -th row of Ax b. Let WD min a v W ai v > 0 and i n o ˇi ai y WD max ai v W ai v < 0 , where min ; D 1 and max ; D 1. We have

0 , and at least one of and is finite (because A0 v 6D 0 but U > v D 0). For 2 R with we have A00 .y C v/ D A00 y C A00 v D A00 y D b 00 and A.yCv/ D AyCAv b, i.e. yCv 2 P . Thus, as supfc > x W x 2 P g < 1, we have < 1 if c > v > 0 and > 1 if c > v < 0. Moreover, if c > v 0 and < 1, we have ai .y C v/ D ˇi for some i . Analogously, if c > v 0 and > 1, we have ai .y C v/ D ˇi for some i . Thus in each case we have found a vector y 0 2 P with c > y 0 c > y and k.y 0 / k.y/ C 1.

This justifies the notation maxfc > x W Ax bg instead of supfc > x W Ax bg. Many combinatorial optimization problems can be formulated as LPs. To do this, we encode the feasible solutions as vectors in Rn for some n. In Section 3.5 we show that one can optimize a linear objective function over a finite set S of vectors by solving a linear program. Although the feasible set of this LP contains not only the vectors in S but also all their convex combinations, one can show that among the optimum solutions there is always an element of S . In Section 3.1 we compile some terminology and basic facts about polyhedra, the sets P D fx 2 Rn W Ax bg of feasible solutions of LPs. In Sections 3.2 and 3.3 we present the SIMPLEX ALGORITHM, which we also use to derive the Duality Theorem and related results (Section 3.4). LP duality is a most important concept which explicitly or implicitly appears in almost all areas of combinatorial optimization; we shall often refer to the results in Sections 3.4 and 3.5.

3.1 Polyhedra Linear Programming deals with maximizing or minimizing a linear objective function of finitely many variables subject to finitely many linear inequalities. So the set of feasible solutions is the intersection of finitely many halfspaces. Such a set is called a polyhedron:

3.1

Polyhedra

53

Definition 3.2. A polyhedron in Rn is a set of type P D fx 2 Rn W Ax bg for some matrix A 2 Rmn and some vector b 2 Rm . If A and b are rational, then P is a rational polyhedron. A bounded polyhedron is also called a polytope. We denote by rank.A/ the rank of a matrix A. The dimension dim X of a nonempty set X Rn is defined to be n maxfrank.A/ W A is an n n-matrix with Ax D Ay for all x; y 2 X g: A polyhedron P Rn is called full-dimensional if dim P D n. Equivalently, a polyhedron is full-dimensional if and only if there is a point in its interior. For most of this chapter it makes no difference whether we are in the rational or real space. We need the following standard terminology: Definition 3.3. Let P WD fx W Ax bg be a nonempty polyhedron. If c is a nonzero vector for which ı WD maxfcx W x 2 P g is finite, then fx W cx D ıg is called a supporting hyperplane of P . A face of P is P itself or the intersection of P with a supporting hyperplane of P . A point x for which fxg is a face is called a vertex of P , and also a basic solution of the system Ax b. Proposition 3.4. Let P D fx W Ax bg be a polyhedron and F P . Then the following statements are equivalent: (a) F is a face of P . (b) There exists a vector c such that ı WD maxfcx W x 2 P g is finite and F D fx 2 P W cx D ıg. (c) F D fx 2 P W A0 x D b 0 g 6D ; for some subsystem A0 x b 0 of Ax b. Proof: (a) and (b) are obviously equivalent. (c))(b): If F D fx 2 P W A0 x D b 0 g is nonempty, let c be the sum of the rows of A0 , and let ı be the sum of the components of b 0 . Then obviously cx ı for all x 2 P and F D fx 2 P W cx D ıg. (b))(c): Assume that c is a vector, ı WD maxfcx W x 2 P g is finite and F D fx 2 P W cx D ıg. Let A0 x b 0 be the maximal subsystem of Ax b such that A0 x D b 0 for all x 2 F . Let A00 x b 00 be the rest of the system Ax b. We first observe that for each inequality ai00 x ˇi00 of A00 x b 00 (i D 1; : : : ; k) P there is a point xi 2 F such that ai00 xi < ˇi00 . Let x WD k1 kiD1 xi be the center of gravity of these points (if k D 0, we can choose an arbitrary x 2 F ); we have x 2 F and ai00 x < ˇi00 for all i . We have to prove that A0 y D b 0 cannot hold for any y 2 P nF . So let y 2 P nF . We have cy < ı. Now consider ´ WD x C .x y/ for some small > 0; in ˇ 00 a00 x particular let be smaller than a00i .x iy/ for all i 2 f1; : : : ; kg with ai00 x > ai00 y. i

We have c´ > ı and thus ´ … P . So there is an inequality ax ˇ of Ax b such that a´ > ˇ. Thus ax > ay. The inequality ax ˇ cannot belong to A00 x ˇ ax b 00 , since otherwise we have a´ D ax Ca.x y/ < ax C a.x y/ a.x y/ D ˇ

54

3 Linear Programming

(by the choice of ). Hence the inequality ax ˇ belongs to A0 x b 0 . Since ay D a.x C 1 .x ´// < ˇ, this completes the proof. As a trivial but important corollary we remark: Corollary 3.5. If maxfcx W x 2 P g is bounded for a nonempty polyhedron P and a vector c, then the set of points where the maximum is attained is a face of P . The relation “is a face of ” is transitive: Corollary 3.6. Let P be a polyhedron and F a face of P . Then F is again a polyhedron. Furthermore, a set F 0 F is a face of P if and only if it is a face of F . The maximal faces distinct from P are particularly important: Definition 3.7. Let P be a polyhedron. A facet of P is a maximal face distinct from P . An inequality cx ı is facet-defining for P if cx ı for all x 2 P and fx 2 P W cx D ıg is a facet of P . Proposition 3.8. Let P fx 2 Rn W Ax D bg be a nonempty polyhedron of dimension n rank.A/. Let A0 x b 0 be a minimal inequality system such that P D fx W Ax D b; A0 x b 0 g. Then each inequality of A0 x b 0 is facet-defining for P , and each facet of P is defined by an inequality of A0 x b 0 . Proof: If P D fx 2 Rn W Ax D bg, then there are no facets and the statement is trivial. So let A0 x b 0 be a minimal inequality system with P D fx W Ax D b; A0 x b 0 g, let a0 x ˇ 0 be one of its inequalities and A00 x b 00 be the rest of the system A0 x b 0 . Let y be a vector with Ay D b, A00 y b 00 and a0 y > ˇ 0 (such a vector y exists as the inequality a0 x ˇ 0 is not redundant). Let x 2 P such that A0 x < b 0 (such a vector must exist because dim P D n rank.A/). 0 a0 x 0 0 00 00 Consider ´ WD x C aˇ0 ya 0 x .y x/. We have a ´ D ˇ , A ´ < b , and, since 0

0

a x 0 0 0 < aˇ0 ya 0 x < 1, ´ 2 P . Therefore F WD fx 2 P W a x D ˇ g 6D 0 and F 6D P (as x 2 P n F ). We conclude that F is a facet of P . By Proposition 3.4 each facet is defined by an inequality of A0 x b 0 .

The other important class of faces (beside facets) are minimal faces (i.e. faces not containing any other face). Here we have: Proposition 3.9. (Hoffman and Kruskal [1956]) Let P D fx W Ax bg be a polyhedron. A nonempty subset F P is a minimal face of P if and only if F D fx W A0 x D b 0 g for some subsystem A0 x b 0 of Ax b. Proof: If F is a minimal face of P , by Proposition 3.4 there is a subsystem A0 x b 0 of Ax b such that F D fx 2 P W A0 x D b 0 g. We choose A0 x b 0 maximal. Let A00 x b 00 be a minimal subsystem of Ax b such that F D fx W A0 x D b 0 ; A00 x b 00 g. We claim that A00 x b 00 does not contain any inequality.

3.1

Polyhedra

55

Suppose, on the contrary, that a00 x ˇ 00 is an inequality of A00 x b 00 . Since it is not redundant for the description of F , Proposition 3.8 implies that F 0 WD fx W A0 x D b 0 ; A00 x b 00 ; a00 x D ˇ 00 g is a facet of F . By Corollary 3.6 F 0 is also a face of P , contradicting the assumption that F is a minimal face of P . Now let ; 6D F D fx W A0 x D b 0 g P for some subsystem A0 x b 0 of Ax b. Obviously F has no faces except itself. By Proposition 3.4, F is a face of P . It follows by Corollary 3.6 that F is a minimal face of P . Corollary 3.5 and Proposition 3.9 imply that LINEAR PROGRAMMING can be solved in finite time by solving the linear equation system A0 x D b 0 for each subsystem A0 x b 0 of Ax b. A more intelligent way is the SIMPLEX ALGORITHM which is described in the next section. Another consequence of Proposition 3.9 is: Corollary 3.10. Let P D fx 2 Rn W Ax bg be a polyhedron. Then all minimal faces of P have dimension nrank.A/. The minimal faces of polytopes are vertices. This is why polyhedra fx 2 Rn W Ax bg with rank.A/ D n are called pointed: their minimal faces are points. Let us close this section with some remarks on polyhedral cones. Definition 3.11. A (convex) cone is a set C Rn for which x; y 2 C and ; 0 implies x C y 2 C . A cone C is said to be generated by x1 ; : : : ; xk if x1 ; : : : ; xk 2 C and for any x 2 C there are numbers 1 ; : : : ; k 0 with P x D kiD1 i xi . A cone is called finitely generated if some finite set of vectors generates it. A polyhedral cone is a polyhedron of type fx W Ax 0g. It is immediately clear that polyhedral cones are indeed cones. We shall now show that polyhedral cones are finitely generated. I always denotes an identity matrix. Lemma 3.12. (Minkowski [1896]) Let C D fx 2 Rn W Ax 0g be a polyhedral 0 cone. Then C is generated by a subset of the set of solutions A to the 0systems My D b , where M consists of n linearly independent rows of I and b D ˙ej for some unit vector ej . Proof: Let A be an m n-matrix. Consider My D b 0 where M A the systems 0 consists of n linearly independent rows of I and b D ˙ej for some unit vector ej . Let y1 ; : : : ; y t be those solutions of these equality systems that belong to C . We claim that C is generated by y1 ; : : : ; y t . First suppose C D fx W Ax D 0g, i.e. C is a linear subspace. Write C D fx W A0 x D 0g where A0 consists of a maximal of linearly independent rows of A. Let 0set I 0 consist of some rows of I such that A is a nonsingular square matrix. Then C 0 I is generated by the solutions of

56

3 Linear Programming

0 A 0 x D ; b I0

for b D ˙ej , j D 1; : : : ; dim C .

For the general case we use induction on the dimension of C . If C is not a linear subspace, then there is a vector ´ 2 C such that ´ … C . Then there is a row a of A such that a´ < 0. 0 Let A0 consist of any maximal set of rows of A such that (i) the rows of Aa are linearly independent, and (ii) there exists a vector ´ 2 C with A0 ´ D 0 and a´ < 0. Let y be any vector with A0 y D 0 and ay D 1. We claim that y 2 C . Let ´ satisfy (ii), i.e., ´ 2 C , A0 ´ D 0 and a´ < 0. Let B be the set of rows b of A with by > 0. Each b 2 B must be linearly independent of a and A0 : otherwise b D cA0 C ıa for a vector c and a number ı, but then 0 b´ D cA0 ´ C ıa´ D ıa´, hence ı 0, contradicting 0 < by D cA0 y C ıay D ı. b´ Suppose that B is nonempty. Let WD minf by W b 2 Bg. We have 0. Then 0 0 0 0 0 ´ WD ´ y 2 C , A ´ D A ´ A y D 0, a´0 D a´ ay < 0, and there is a b 0 2 B with b 0 ´0 D 0. This contradicts the maximality of A0 . So B D ;, i.e., y 2 C. Hence by construction there is an index s 2 f1; : : : ; tg such that A0 ys D 0 and ays D 1. Now letn an arbitrary ´ 2 C be given.o Let a1 ; : : : ; am be the rows of A and WD min aaiy´s W i D 1; : : : ; m; ai ys < 0 . We have 0. Let k be an index i

where the minimum is attained. Consider ´0 WD ´ ys . By the definition of we have aj ´0 D aj ´ aaky´s aj ys for j D 1; : : : ; m, and hence ´0 2 C 0 WD fx 2 k C W ak x D 0g. C 0 is a cone whose dimension is one less than that of C (because ak ys P < 0 and ys 2 C ). By induction, C 0 is generated by a subset of y1 ; : : : ; y t , so 0 ´ D ti D1 i yi for some 1 ; : : : ; t 0. By setting 0s P WD s C (observe that 0) and 0i WD i (i 6D s), we obtain ´ D ´0 C ys D ti D1 0i yi . Thus any polyhedral cone is finitely generated. We shall show the converse at the end of Section 3.4.

3.2 The Simplex Algorithm The oldest and best-known algorithm for L INEAR PROGRAMMING is Dantzig’s [1951] simplex method. We first assume that the polyhedron has a vertex, and that some vertex is given as input. Later we shall show how general LPs can be solved with this method. For a set J of row indices we write AJ for the submatrix of A consisting of the rows in J only, and bJ for the subvector of b consisting of the components with indices in J . We abbreviate ai WD Afi g and ˇi WD bfi g .

3.2

The Simplex Algorithm

57

SIMPLEX ALGORITHM Input: Output:

A matrix A 2 Rmn and column vectors b 2 Rm ; c 2 Rn . A vertex x of P WD fx 2 Rn W Ax bg. A vertex x of P attaining maxfcx W x 2 P g or a vector w 2 Rn with Aw 0 and cw > 0 (i.e. the LP is unbounded).

1

Choose a set of n row indices J such that AJ is nonsingular and AJ x D bJ .

2

Compute c .AJ /1 and add zeros in order to obtain a vector y with c D yA such that all entries of y outside J are zero. If y 0 then stop. Return x and y. Choose the minimum index i with yi < 0. Let w be the column of .AJ /1 with index i , so AJ nfi g w D 0 and ai w D 1. If Aw 0 then stop. Return w. ˇj aj x W j 2 f1; : : : ; mg; aj w > 0 , Let WD min aj w and let j be the smallest row index attaining this minimum. Set J WD .J n fi g/ [ fj g and x WD x C w. Go to . 2

3

4 5

Step 1 relies on Proposition 3.9 and can be implemented with GAUSSIAN ELIMINATION (Section 4.3). The selection rules for i and j in 3 and 4 (often called pivot rule) are due to Bland [1977]. If one just chose an arbitrary i with yi < 0 and an arbitrary j attaining the minimum in 4 the algorithm would run into cyclic repetitions for some instances. Bland’s pivot rule is not the only one that avoids cycling; another one (the so-called lexicographic rule) was proved to avoid cycling already by Dantzig, Orden and Wolfe [1955]. Before proving the correctness of the SIMPLEX ALGORITHM, let us make the following observation (sometimes known as “weak duality”): Proposition 3.13. Let x and y be feasible solutions of the LPs maxfcx W Ax bg

and

(3.1)

minfyb W y A D c ; y 0g;

(3.2)

>

>

respectively. Then cx yb. Proof: cx D .yA/x D y.Ax/ yb.

Theorem 3.14. (Dantzig [1951], Dantzig, Orden and Wolfe [1955], Bland [1977]) The SIMPLEX ALGORITHM terminates after at most m iterations. If it returns n x and y in , 2 these vectors are optimum solutions of the LPs (3.1) and (3.2), respectively, with cx D yb. If the algorithm returns w in 3 then cw > 0 and the LP (3.1) is unbounded.

58

3 Linear Programming

Proof: We first prove that the following conditions hold at any stage of the algorithm: (a) (b) (c) (d) (e)

x 2 P; AJ x D bJ ; AJ is nonsingular; cw > 0; 0.

(a) and (b) hold initially. 2 and 3 guarantee cw D yAw D yi > 0. By , 4 x 2 P implies 0. (c) follows from the fact that AJ nfi g w D 0 and aj w > 0. It remains to show that 5 preserves (a) and (b). We show that if x 2 P , then also x C w 2 P . For a row index k we have two cases: If ak w 0 then (using 0) ak .x C w/ ak x ˇk . Otherwise ˇkaawk x and hence ak .x C w/ ak x C ak w ˇkaawk x D ˇk . (Indeed, is k k chosen in 4 to be the largest number such that x C w 2 P .) ˇ a x To show (b), note that after 4 we have AJ nfi g w D 0 and D ja wj , so j ˇ a x

AJ nfi g .x C w/ D AJ nfi g x D bJ nfi g and aj .x C w/ D aj x C aj w jaj wj D ˇj . Therefore after , 5 AJ x D bJ holds again. So we indeed have (a)–(e) at any stage. If the algorithm returns x and y in , 2 x and y are feasible solutions of (3.1) and (3.2), respectively. x is a vertex of P by (a), (b) and (c). Moreover, cx D yAx D yb since the components of y are zero outside J . This proves the optimality of x and y by Proposition 3.13. If the algorithm stops in , 3 the LP (3.1) is indeed unbounded because in this case x C w 2 P for all 0, and cw > 0 by (d). We finally show that the algorithm terminates. Let J .k/ and x .k/ be the set J and the vector x in iteration k of the SIMPLEX ALGORITHM, respectively. If the algorithm did not terminate after m n iterations, there are iterations k < l with .k/ .l/ .k/ J D J . By (b) and (c), x D x .l/ . By (d) and (e), cx never decreases, and it strictly increases if > 0. Hence is zero in all the iterations k; k C 1; : : : ; l 1, and x .k/ D x .kC1/ D D x .l/ . Let h be the highest index leaving J in one of the iterations k; : : : ; l 1, say in iteration p. Index h must also have been added to J in some iteration q 2 fk; : : : ; l 1g. Now let y 0 be the vector y at iteration p, and let w 0 be the vector w at iteration q. We have y 0 Aw 0 D cw 0 > 0. So let r be an index for which yr0 ar w 0 > 0. Since yr0 6D 0, index r belongs to J .p/ . If r > h, index r would also belong to J .q/ and J .qC1/ , implying ar w 0 D 0. So r h. But by the choice of i in iteration p we have yr0 < 0 iff r D h, and by the choice of j in iteration q we have ar w 0 > 0 iff r D h (recall that D 0 and ar x .q/ D ar x .p/ D ˇr as r 2 J .p/ ). This is a contradiction. Klee and Minty [1972] and Avis and Chvátal [1978] found examples where the SIMPLEX ALGORITHM (with Bland’s rule) needs 2n iterations on LPs with n variables and 2n constraints, proving that it is not a polynomial-time algorithm. It is not

3.2

The Simplex Algorithm

59

known whether there is a pivot rule that leads to a polynomial-time algorithm. However, Borgwardt [1982] showed that the average running time (for random instances in a certain natural probabilistic model) can be bounded by a polynomial. Spielman and Teng [2004] introduced a so-called smoothed analysis: for each input they consider the expected running time with respect to small random perturbations of the input. The maximum of all these expectations is polynomially bounded. Kelner and Spielman [2006] proposed a randomized polynomial-time algorithm for L INEAR PROGRAMMING that is similar to the SIMPLEX A LGORITHM . The SIMPLEX ALGORITHM is also quite fast in practice if implemented skilfully; see Section 3.3. We now show how to solve general linear programs with the SIMPLEX ALGORITHM. More precisely, we show how to find an initial vertex. Since there are polyhedra that do not have vertices at all, we put a given LP into a different form first. Let maxfcx W Ax bg be an LP. We substitute x by y ´ and write it equivalently in the form y y c c max W A A b; y; ´ 0 : ´ ´ So w.l.o.g. we assume that our LP has the form maxfcx W A0 x b 0 ; A00 x b 00 ; x 0g

(3.3)

with b 0 0 and b 00 < 0. We first run the SIMPLEX ALGORITHM on the instance minf.1lA00 /x C 1ly W A0 x b 0 ; A00 x C y b 00 ; x; y 0g; (3.4) where 1l denotes a vector whose entries are all 1. Since xy D 0 defines a vertex, this is possible. The LP is obviously not unbounded x since the minimum must be at least 1lb 00 . For any feasible solution x of (3.3), b 00 A is an optimum solution of 00 x (3.4) of value 1lb 00 . Hence if the minimum of (3.4) is greater than 1lb 00 , then (3.3) is infeasible. In the contrary case, let yx be an optimum vertex of (3.4) of value 1lb 00 . We claim that x is a vertex of the polyhedron defined by (3.3). To see this, first observe that A00 x C y D b 00 . Let n and m be the dimensions of x and y, respectively; then by Proposition 3.9 there is a set S of n C m inequalities of (3.4) satisfied with equality, such that the submatrix corresponding to these n C m inequalities is nonsingular. Let S 0 be the inequalities of A0 x b 0 and of x 0 that belong to S . Let S 00 consist of those inequalities of A00 x b 00 for which the corresponding inequalities of A00 x C y b 00 and y 0 both belong to S . Obviously jS 0 [ S 00 j jS j m D n, and the inequalities of S 0 [ S 00 are linearly independent and satisfied by x with equality. Hence x satisfies n linearly independent inequalities of (3.3) with equality; thus x is indeed a vertex. Therefore we can start the SIMPLEX ALGORITHM with (3.3) and x.

60

3 Linear Programming

3.3 Implementation of the Simplex Algorithm The previous description of the SIMPLEX ALGORITHM is simple but not suitable for an efficient implementation. As we will see, it is not necessary to solve a linear equation system in each iteration. To motivate the main idea, we start with a proposition (which is actually not needed later): for LPs of the form maxfcx W Ax D b; x 0g, vertices can be represented not only by subsets of rows but also by subsets of columns. For a matrix A and a set J of column indices we denote by AJ the submatrix consisting of the columns in J only. Consequently, AIJ denotes the submatrix of A with rows in I and columns in J . Sometimes the order of the rows and columns is important: if J D .j1 ; : : : ; jk / is a vector of row (column) indices, we denote by AJ (AJ ) the matrix whose i -th row (column) is the ji -th row (column) of A (i D 1; : : : ; k). Proposition 3.15. Let P WD fx W Ax D b; x 0g, where A is a matrix and b is a vector. Then x is a vertex of P if and only if x 2 P and the columns of A corresponding to positive entries of x are linearly independent. 0 0 0 Proof: Let A be an m n-matrix. Let X WD I A I and b WD b . Let N WD f1; : : : ; ng and M WD fnC1; : : : ; nCmg. For an index set J N [M with jJ j D n N \JN JN let JN WD .N [ M / n J . Then XJN is nonsingular iff XM \J is nonsingular iff XM is nonsingular. If x is a vertex of P , then – by Proposition 3.9 – there exists a set J N [ M such that jJ j D n, XJN is nonsingular, and XJN x D bJ0 . Then the components of JN x corresponding to N \ J are zero. Moreover, XM is nonsingular, and hence the N columns of AN \J are linearly independent. Conversely, let x 2 P , and let the set of columns of A corresponding to positive entries of x be linearly independent. By adding suitable unit column vectors to these B columns we obtain a nonsingular submatrix XM with xi D 0 for i 2 N n B. Then N N 0 XBN is nonsingular and XBN x D bBN . Hence, by Proposition 3.9, x is a vertex of P . ˚ Corollary 3.16. Let yx 2 P WD xy W Ax C y D b; x 0; y 0 . Then yx is a vertex of P if and only if the columns of .A I / corresponding to positive components of xy are linearly independent. Moreover, x is a vertex of fx W Ax b; x x 0g if and only if . bAx / is a vertex of P . We will now analyze the behaviour of the SIMPLEX ALGORITHM when applied to an LP of the form maxfcx W Ax b; x 0g. 0 0 Theorem 3.17. Let A 2 Rmn , b 2 Rm , and c 2 Rn . Let A0 WD I A , b WD b and cN WD .c > ; 0/. Let B 2 f1; : : : ; n C mgm such that .A I /B is nonsingular. Let J f1; : : : ; n C mg be the set of the remaining n indices. Let QB WD ..A I /B /1 . Then:

3.3

Implementation of the Simplex Algorithm

61

(a) A0J is nonsingular. (b) .b 0 A0 x/J D 0 and .b 0 A0 x/B D QB b and c > x D cNB QB b, where x WD .A0J /1 bJ0 . (c) Let y be the vector with yB D 0 and y > A0 D c > . Then y > D cNB QB .A I / c. N (d) Let i 2 J . Let w be the vector with A0i w D 1 and A0J nfi g w D 0. Then 0 AB w D QB .A I /i . (e) Define ! QB .A I / QB b : TB WD cNB QB .A I / cN c > x Given B and TB , we can compute B 0 and TB 0 in O.m.n C m// time, where B 0 arises from B by replacing j by i , and i and j are given as in – 2 4 of the SIMPLEX ALGORITHM (applied to A0 , b 0 , c, and index set J ). TB is called the simplex tableau with respect to the basis B. N nJ

Proof: (a): Let N WD f1; : : : ; ng. As .A I /B is nonsingular, also .A0 /J nN is nonsingular, and thus A0J is nonsingular. (b): The first statement follows directly from A0J x D bJ0 . Then b D Ax C I.b Ax/ D .A I /.b 0 A0 x/ D .A I /B .b 0 A0 x/B and c > x D c.b N 0 A0 x/ D B 0 0 B cN .b A x/B D cN QB b. (c): This follows from .cNB QB .A I / c/ N B D cNB QB .A I /B cNB D 0 and .cNB QB .A I / c/A N 0 D cNB QB .A I /A0 c > .I / D c > . 0 (d): This follows from 0 D .A I /A0 w D .A I /B .AB w/C.A I /J nfi g .A0J nfi g w/C i 0 B 0 i .A I / .Ai w/ D .A I / .AB w/ .A I / . (e): By (c), y as in 2 of the SIMPLEX ALGORITHM is given by the last row of TB . If y 0, we stop (x and y are optimal). Otherwise i is the first index with yi < 0, found in O.n C m/ time. If the i -th column of TB has no positive entry, we stop (the LP is unbounded, and w is given by (d)). Otherwise, by (b) and (d), we have that in 4 of the SIMPLEX ALGORITHM is given by .QB b/j i D min W j 2 f1; : : : ; mg; .QB .A I / /j > 0 ; .QB .A I /i /j and among the indices attaining this minimum, j is the one for which the j -th component of B is minimum. So we can compute j in O.m/ time by considering the i -th and the last column of TB . This yields B 0 . We can compute the updated tableau TB 0 as follows: Divide the j -th row by the entry in row j and column i . Then add a suitable multiple of the j -th row to all other rows, such that the i -th column has zeros only outside row j . Note that these row operations do not destroy the property that the tableau has the form Q.A I / Qb v.A I / cN vb

62

3 Linear Programming

for some nonsingular matrix Q and some vector v, and in addition we have 0 0 Q.A I /B D I and .v.A I / c/ N B D 0. Since there is only one choice for Q 0 and v, namely Q D QB 0 and v D cNB QB 0 , the updated tableau TB 0 is computed correctly by the above operations in O.m.n C m// time. To start the SIMPLEX ALGORITHM we consider an LP of the form maxfcx W A0 x b 0 ; A00 x b 00 ; x 0g 0

00 n

with A0 2 Rm n , A00 2 Rm ALGORITHM on the instance

, b 0 0 and b 00 < 0. We first run the SIMPLEX

minf.1lA00 /x C 1ly W A0 x b 0 ; A00 x C y b 00 ; x; y 0g; starting with the tableau

0

1 A0 0 I 0 b 0 @ A00 I 0 I b 00 A ; 1lA00 1l 0 0 0

(3.5)

corresponding to the basic solution x D 0, y D 0. Then we run the iterations of the SIMPLEX ALGORITHM as in Theorem 3.17(e). If the algorithm terminates with optimum value 1lb, we modify the final simplex tableau as follows. Multiply some rows by 1 such that none of the columns n C m00 Cm0 C1; : : : ; nCm00 Cm0 Cm00 (the fourth section in (3.5)) is a unit vector, delete the fourth section of the tableau (i.e. columns nCm00 Cm0 C1; : : : ; nCm00 Cm0 Cm00 ), and replace the last row by .c; 0; 0; 0/. Then add suitable multiples of the other rows to the last row in order to get zeros at m0 Cm00 places corresponding to columns with distinct unit vectors; these will form our basis. The result is the simplex tableau with respect to the original LP and this basis. Therefore we can continue running the iterations of the SIMPLEX ALGORITHM as in Theorem 3.17(e). In fact, one can often do even more efficiently. Suppose we want to solve an LP minfcx W Ax b; x 0g with a very large number of inequalities which are implicitly given in a way that allows us to solve the following problem efficiently: Given a vector x 0, decide if Ax b and find a violated inequality otherwise. We apply the SIMPLEX ALGORITHM to the dual LP maxfyb W yA c; y 0g D maxfby W A> y c; y 0g. Let bN WD .b > ; 0/. For a basis B we set QB WD ..A> I /B /1 and store only the right-hand part of the simplex tableau ! QB QB c : bN B QB b > x N To perform an iteration, The last row of the full simplex tableau is bN B QB .A> I / b. we must check if bN B QB 0 and bN B QB A> b 0, and find a negative component if one exists. This reduces to solving the above problem for x D .bN B QB /> . Then we generate the corresponding column of the full simplex tableau, but only for the

3.4

Duality

63

current iteration. After updating the reduced tableau we can delete it again. This technique is known under the names revised simplex and column generation. We will see applications later.

3.4 Duality Theorem 3.14 shows that the LPs (3.1) and (3.2) are related. This motivates the following definition: Definition 3.18. Given a linear program maxfcx W Ax bg, we define the dual LP to be the linear program minfyb W yA D c; y 0g. In this case, the original LP maxfcx W Ax bg is often called the primal LP. Proposition 3.19. The dual of the dual of an LP is (equivalent to) the original LP. Proof: Let the primal LP maxfcx W Ax bg be given. Its dual is minfyb W yA D c; y 0g, or equivalently 8 0 > 1 0 19 A c = < max by W @A> A y @c A : ; : 0 I (Each equality constraint has been split up into two inequality constraints.) So the dual of the dual is 8 9 0 1 ´ < = min ´c ´0 c W A A I @´0 A D b; ´; ´0 ; w 0 : ; w which is equivalent to minfcx W Ax w D b; w 0g (where we have substituted x for ´0 ´). By eliminating the slack variables w we see that this is equivalent to the primal LP. We now obtain the most important theorem in LP theory, the Duality Theorem: Theorem 3.20. (von Neumann [1947], Gale, Kuhn and Tucker [1951]) If the polyhedra P WD fx W Ax bg and D WD fy W yA D c; y 0g are both nonempty, then maxfcx W x 2 P g D minfyb W y 2 Dg. Proof: If D is nonempty, it has a vertex y. We run the SIMPLEX ALGORITHM for minfyb W y 2 Dg and y. By Proposition 3.13, the existence of some x 2 P guarantees that minfyb W y 2 Dg is not unbounded. Thus by Theorem 3.14, the

64

3 Linear Programming

SIMPLEX ALGORITHM returns optimum solutions y and ´ of the LP minfyb W y 2 Dg and its dual. However, the dual is maxfcx W x 2 P g by Proposition 3.19. We have yb D c´, as required. We can say even more about the relation between the optimum solutions of the primal and dual LP: Corollary 3.21. Let maxfcx W Ax bg and minfyb W yA D c; y 0g be a primal-dual pair of LPs. Let x and y be feasible solutions, i.e. Ax b, yA D c and y 0. Then the following statements are equivalent: (a) x and y are both optimum solutions. (b) cx D yb. (c) y.b Ax/ D 0. Proof: The Duality Theorem 3.20 immediately implies the equivalence of (a) and (b). The equivalence of (b) and (c) follows from y.b Ax/ D yb yAx D yb cx. The property (c) of optimum solutions is often called complementary slackness. It can also be formulated as follows: a point x 2 P D fx W Ax bg is an optimum solution of maxfcx W x 2 P g if and only if c is a nonnegative combination of those rows of A which correspond to inequalities of Ax b that are satisfied by x with equality. It also implies: Corollary 3.22. Let P D fx W Ax bg be a polyhedron and ; 6D Z P . Then the set of vectors c for which each ´ 2 Z is an optimum solution of maxfcx W x 2 P g is the cone generated by the rows of A0 , where A0 x b 0 is the maximal subsystem of Ax b with A0 ´ D b 0 for all ´ 2 Z. Proof: There is a ´ 2 conv.Z/ that satisfies all other inequalities of Ax b strictly. Let c be a vector for which each element of Z, and hence also ´, is an optimum solution of maxfcx W x 2 P g. Then by Corollary 3.21 there exists an y 0 with c D yA0 , i.e. c is a nonnegative linear combination of the rows of A0 . Conversely, for a row a0 x ˇ 0 of A0 x b 0 and ´ 2 Z we have a0 ´ D ˇ 0 D maxfa0 x W x 2 P g. Let us write Corollary 3.21 in another form: Corollary 3.23. Let minfcx W Ax b; x 0g and maxfyb W yA c; y 0g be a primal-dual pair of LPs. Let x and y be feasible solutions, i.e. Ax b, yA c and x; y 0. Then the following statements are equivalent: (a) x and y are both optimum solutions. (b) cx D yb. (c) .c yA/x D 0 and y.b Ax/ D 0. Proof: The˚ equivalence of (a) and (b) is obtained by applying the Duality Theorem b 3.20 to max .c/x W A . I x 0

3.4

Duality

65

To prove that (b) and (c) are equivalent, observe that we have y.b Ax/ 0 .c yA/x for any feasible solutions x and y, and that y.b Ax/ D .c yA/x iff yb D cx. The two conditions in (c) are sometimes called primal and dual complementary slackness conditions. The Duality Theorem has many applications in combinatorial optimization. One reason for its importance is that the optimality of a solution can be proved by giving a feasible solution of the dual LP with the same objective value. We shall show now how to prove that an LP is unbounded or infeasible: Theorem 3.24. There exists a vector x with Ax b if and only if yb 0 for each vector y 0 for which yA D 0. Proof: If there is a vector x with Ax b, then yb yAx D 0 for each y 0 with yA D 0. Consider the LP minf1lw W Ax w b; w 0g:

(3.6)

Writing it in standard form we have x A I x b max 0 1l W : w 0 I w 0 The dual of this LP is > y y 0 A 0 D ; y; ´ 0 ; min b 0 W I I ´ 1l ´ or, equivalently, minfyb W yA D 0; 0 y 1lg:

(3.7)

Since both (3.6) and (3.7) have a solution (x D 0, w D jbj, y D 0), we can apply Theorem 3.20. So the optimum values of (3.6) and (3.7) are the same. Since the system Ax b has a solution iff the optimum value of (3.6) is zero, the proof is complete. So the fact that a linear inequality system Ax b has no solution can be proved by giving a vector y 0 with yA D 0 and yb < 0. We mention two equivalent formulations of Theorem 3.24: Corollary 3.25. There is a vector x 0 with Ax b if and only if yb 0 for each vector y 0 with yA 0. A Proof: Apply Theorem 3.24 to the system I x b0 .

66

3 Linear Programming

Corollary 3.26. (Farkas [1894]) There is a vector x 0 with Ax D b if and only if yb 0 for each vector y with yA 0. A b Proof: Apply Corollary 3.25 to the system A x b , x 0. Corollary 3.26 is usually known as Farkas’ Lemma. The above results in turn imply the Duality Theorem 3.20 which is interesting since they have quite easy direct proofs (in fact they were known before the SIMPLEX ALGORITHM); see Exercises 11 and 12. We have seen how to prove that an LP is infeasible. How can we prove that an LP is unbounded? The next theorem answers this question. Theorem 3.27. If an LP is unbounded, then its dual LP is infeasible. If an LP has an optimum solution, then its dual also has an optimum solution. Proof: The first statement follows immediately from Proposition 3.13. To prove the second statement, suppose that the (primal) LP maxfcx W Ax bg has an optimum solution x , but the dual minfyb W yA D c; y 0g is infeasible (it cannot be unbounded due to the first statement). In other words, there is no y 0 with A> y D c, and we apply Farkas’ Lemma (Corollary 3.26) to get a vector ´ with ´A> 0 and ´c < 0. But then x ´ is feasible for the primal, because A.x ´/ D Ax A´ b. The observation c.x ´/ > cx therefore contradicts the optimality of x . So there are four cases for a primal-dual pair of LPs: either both have an optimum solution (in which case the optimum values are the same), or one is infeasible and the other one is unbounded, or both are infeasible. We also note: Corollary 3.28. A feasible LP maxfcx W Ax bg is bounded if and only if c belongs to the cone generated by the rows of A. Proof: The LP is bounded iff its dual is feasible, i.e. there is a y 0 with yA D c. Farkas’ Lemma also enables us to prove that each finitely generated cone is polyhedral: Theorem 3.29. (Minkowski [1896], Weyl [1935]) A cone is polyhedral if and only if it is finitely generated. Proof: The only-if direction is given by Lemma 3.12. So consider the cone C generated by a1 ; : : : ; a t . We have to show that C is polyhedral. Let A be the matrix whose rows are a1 ; : : : ; a t . By Lemma 3.12, the cone D WD fx W Ax 0g is generated by some vectors b1 ; : : : ; bs . Let B be the matrix whose rows are b1 ; : : : ; bs . We prove that C D fx W Bx 0g. As bj ai D ai bj 0 for all i and j , we have C fx W Bx 0g. Now suppose there is a vector w … C with Bw 0. w 62 C means that there is no v 0 such

3.5

Convex Hulls and Polytopes

67

that A> v D w. By Farkas’ Lemma (Corollary 3.26) this means that there is a vector y with yw < 0 and Ay 0. So y 2 D. Since D is generated by b1 ; : : : ; bs we have y D ´B for some ´ 0. But then 0 < yw D ´Bw 0, a contradiction.

3.5 Convex Hulls and Polytopes In this section we collect some more facts on polytopes. In particular, we show that polytopes are precisely those sets that are the convex hull of a finite number of points. We start by recalling some basic definitions: Definition 3.30. Given vectorsPx1 ; : : : ; xk 2 Rn and 1 ; : : : ; k 0 with Pk k i D1 i D 1, we call x D i D1 i xi a convex combination of x1 ; : : : ; xk . n A set X R is convex if x C .1 /y 2 X for all x; y 2 X and 2 Œ0; 1. The convex hull conv.X / of a set X is defined as the set of all convex combinations of points in X . An extreme point of a set X is an element x 2 X with x … conv.X n fxg/. So a set X is convex if and only if all convex combinations of points in X are again in X . The convex hull of a set X is the smallest convex set containing X . Moreover, the intersection of convex sets is convex. Hence polyhedra are convex. Now we prove the “finite basis theorem for polytopes”, a fundamental result which seems to be obvious but is not trivial to prove directly: Theorem 3.31. (Minkowski [1896], Steinitz [1916], Weyl [1935]) A set P is a polytope if and only if it is the convex hull of a finite set of points. Proof: (Schrijver [1986]) Let P D fx 2 Rn W Ax bg be a nonempty polytope. Obviously, x x P D xW 2 C ; where C D 2 RnC1 W 0; Ax b 0 : 1 C is a polyhedral 3.29 it is generated by finitely many nonzero xcone, so by x Theorem vectors, say by 11 ; : : : ; kk . Since P is bounded, all i are nonzero; w.l.o.g. all i are 1. So x 2 P if and only if x1 x x D 1 C C k k 1 1 1 for some 1 ; : : : ; k 0. In other words, P is the convex hull of x1 ; : : : ; xk . Now let P be the convex hull of x1 ; : : : ;xk 2 Rn . Then x 2 P if and only if x . 1 / 2 C , where C is the cone generated by x11 ; : : : ; x1k . By Theorem 3.29, C is polyhedral, so x C D W Ax C b 0 : We conclude that P D fx 2 Rn W Ax C b 0g.

68

3 Linear Programming

Corollary 3.32. A polytope is the convex hull of its vertices. Proof: Let P be a polytope. By Theorem 3.31, the convex hull of its vertices is a polytope Q. Obviously Q P . Suppose there is a point ´ 2 P n Q. Then there is a vector c with c´ > maxfcx W x 2 Qg. The supporting hyperplane fx W cx D maxfcy W y 2 P gg of P defines a face of P containing no vertex. This is impossible by Corollary 3.10. The previous two and the following result are the starting point of polyhedral combinatorics; they will be used very often in this book. For a given ground set E and a subset X E, the incidence vector of X (with respect to E) is defined as the vector x 2 f0; 1gE with xe D 1 for e 2 X and xe D 0 for e 2 E n X . Corollary 3.33. Let .E; F / be a set system, P the convex hull of the incidence vectors of the elements of F , and c W E ! R. Then maxfcx W x 2 P g D maxfc.X / W X 2 Fg. Proof: Since maxfcx W x 2 P g maxfc.X / W X 2 F g is trivial, let x be an optimum solution of maxfcx W x 2 P g (note that P is a polytope by Theorem 3.31). By definition of P , x is a convex combination of incidence vectors y1 ; : : : ; yk P P of elements of F : x D kiD1 i yi for some 1 ; : : : ; k 0 with kiD1 i D 1. Pk Since cx D i D1 i cyi , we have cyi cx for at least one i 2 f1; : : : ; kg. This yi is the incidence vector of a set Y 2 F with c.Y / D cyi cx.

Exercises 1. Let H be a hypergraph, F V .H /, Pand x; y W F ! R. The task is to find x; y W V .H / n F ! R such that e2E.H / .maxv2e x.v/ minv2e x.v/ C maxv2e y.v/ minv2e y.v// is minimum. Show that this can be formulated as an LP. Note: This is a relaxation of a placement problem in VLSI design. Here H is called the netlist, and its vertices correspond to modules that need to placed on the chip. Some (those in F ) are pre-placed in advance. The main difficulty (ignored in this relaxation) is that modules must not overlap. 2. A set of vectors x1 ; : : : ; xk is called affinely independent if there is no 2 P Rk n f0g with > 1l D 0 and kiD1 i xi D 0. Let ; 6D X Rn . Show that the maximum cardinality of an affinely independent set of elements of X equals dim X C 1. 3. Let P; Q 2 Rn be polyhedra. Prove that the closure of conv.P [ Q/ is a polyhedron. Show polyhedra P and Q for which conv.P [ Q/ is not a polyhedron. 4. Show that the problem to compute the largest ball that is a subset of a given polyhedron can be formulated as a linear program. 5. Let P be a polyhedron. Prove that the dimension of any facet of P is one less than the dimension of P .

Exercises

69

6. Let F be a minimal face of a polyhedron fx W Ax bg. Prove that then Ax D Ay for all x; y 2 F . 7. Let A 2 Rmn , b 2 Rm , c 2 Rn , and u 2 Zn . Consider the LP maxfcx W Ax b; 0 x ug. Prove: if this LP has an optimum solution, then it has an optimum solution with at most m components that are not integers. 8. Formulate the dual of the LP formulation (1.1) of the JOB ASSIGNMENT PROBLEM. Show how to solve the primal and the dual LP in the case when there are only two jobs (by a simple algorithm). 9. Let G be a digraph, c W E.G/ ! RC , E1 ; E2 E.G/, and s; t 2 V .G/. Consider the following linear program X

min

c.e/ye

e2E.G/

ye ´ t ´s ye ye

s.t.

´w ´v D1 0 0

.e D .v; w/ 2 E.G// .e 2 E1 / .e 2 E2 /:

Prove that there is an optimum solution .y; ´/ and s 2 X V .G/ n ftg with ye D 1 for e 2 ı C .X /, ye D 1 for e 2 ı .X / n E1 , and ye D 0 for all other edges e. Hint: Consider the complementary slackness conditions for the edges entering or leaving fv 2 V .G/ W ´v ´s g. 10. Let Ax b be a linear inequality system in n variables. By multiplying each row by a positive constant we may assume that the first column of A is a vector with entries 0, 1 and 1 only. So we can write Ax b equivalently as ai0 x 0 bi x1 C aj0 x 0 bj

x1 C ak0 x 0 bk

.i D 1; : : : ; m1 /; .j D m1 C 1; : : : ; m2 /; .k D m2 C 1; : : : ; m/;

0 where x 0 D .x2 ; : : : ; xn / and a10 ; : : : ; am are the rows of A without the first entry. Then one can eliminate x1 : Prove that Ax b has a solution if and only if the system

aj0 x 0

ai0 x 0 bi

bj bk ak0 x 0

.i D 1; : : : ; m1 /; .j D m1 C 1; : : : ; m2 ; k D m2 C 1; : : : ; m/

has a solution. Show that this technique, when iterated, leads to an algorithm for solving a linear inequality system Ax b (or proving infeasibility). Note: This method is known as Fourier-Motzkin elimination because it was proposed by Fourier and studied by Motzkin [1936]. One can prove that it is not a polynomial-time algorithm.

70

3 Linear Programming

11. Use Fourier-Motzkin elimination (Exercise 10) to prove Theorem 3.24 directly. (Kuhn [1956]) 12. Show that Theorem 3.24 implies the Duality Theorem 3.20. 13. Prove the decomposition theorem for polyhedra: Any polyhedron P can be written as P D fx C c W x 2 X; c 2 C g, where X is a polytope and C is a polyhedral cone. (Motzkin [1936]) 14. Let P be a rational polyhedron and F a face of P . Show that fc W c´ D max fcx W x 2 P g for all ´ 2 F g is a rational polyhedral cone. 15. Prove Carathéodory’s theorem: If X Rn and y 2 conv.X /, then there are x1 ; : : : ; xnC1 2 X such that y 2 conv.fx1 ; : : : ; xnC1 g/. (Carathéodory [1911]) 16. Prove the following extension of Carathéodory’s theorem (Exercise 15): If X Rn and y; ´ 2 conv.X /, then there are x1 ; : : : ; xn 2 X such that y 2 conv.f´; x1 ; : : : ; xn g/. 17. Prove that the extreme points of a polyhedron are precisely its vertices. 18. Let P be a nonempty polytope. Consider the graph G.P / whose vertices are the vertices of P and whose edges correspond to the 1-dimensional faces of P . Let x be any vertex of P , and c a vector with c > x < maxfc > ´ W ´ 2 P g. Prove that then there is a neighbour y of x in G.P / with c > x < c > y. 19. Use Exercise 18 to prove that G.P / is n-connected for any n-dimensional polytope P (n 1). 20. Let P Rn be a polytope (not necessarily rational) and y … P . Prove that there exists a rational vector c with maxfcx W x 2 P g < cy. Show that the statement does not hold for general polyhedra. 21. Let X Rn be a nonempty convex set, XN the closure of X , and y … X . Prove: (a) There is a unique point in XN that has minimum distance to y. (b) There exists a vector a 2 Rn n f0g with a> x a> y for all x 2 X . (c) If y … XN , then there exists a vector a 2 Rn with a> x < a> y for all x 2 X . (d) If X is bounded and y … XN , then there exists a vector a 2 Qn with a> x < a> y for all x 2 X . (e) A closed convex set is the intersection of all closed half-spaces containing it.

References General Literature: Bertsimas, D., and Tsitsiklis, J.N. [1997]: Introduction to Linear Optimization. Athena Scientific, Belmont 1997

References

71

Chvátal, V. [1983]: Linear Programming. Freeman, New York 1983 Matoušek, J., and Gärtner, B. [2007]: Understanding and Using Linear Programming. Springer, Berlin 2007 Padberg, M. [1999]: Linear Optimization and Extensions. Second Edition. Springer, Berlin 1999 Schrijver, A. [1986]: Theory of Linear and Integer Programming. Wiley, Chichester 1986

Cited References: Avis, D., and Chvátal, V. [1978]: Notes on Bland’s pivoting rule. Mathematical Programming Study 8 (1978), 24–34 Bland, R.G. [1977]: New finite pivoting rules for the simplex method. Mathematics of Operations Research 2 (1977), 103–107 Borgwardt, K.-H. [1982]: The average number of pivot steps required by the simplex method is polynomial. Zeitschrift für Operations Research 26 (1982), 157–177 Carathéodory, C. [1911]: Über den Variabilitätsbereich der Fourierschen Konstanten von positiven harmonischen Funktionen. Rendiconto del Circolo Matematico di Palermo 32 (1911), 193–217 Dantzig, G.B. [1951]: Maximization of a linear function of variables subject to linear inequalities. In: Activity Analysis of Production and Allocation (T.C. Koopmans, ed.), Wiley, New York 1951, pp. 359–373 Dantzig, G.B., Orden, A., and Wolfe, P. [1955]: The generalized simplex method for minimizing a linear form under linear inequality restraints. Pacific Journal of Mathematics 5 (1955), 183–195 Farkas, G. [1894]: A Fourier-féle mechanikai elv alkalmazásai. Mathematikai és Természettudományi Értesitö 12 (1894), 457–472 Gale, D., Kuhn, H.W., and Tucker, A.W. [1951]: Linear programming and the theory of games. In: Activity Analysis of Production and Allocation (T.C. Koopmans, ed.), Wiley, New York 1951, pp. 317–329 Hoffman, A.J., and Kruskal, J.B. [1956]: Integral boundary points of convex polyhedra. In: Linear Inequalities and Related Systems; Annals of Mathematical Study 38 (H.W. Kuhn, A.W. Tucker, eds.), Princeton University Press, Princeton 1956, pp. 223–246 Kelner, J.A., and Spielman, D.A. [2006]: A randomized polynomial-time simplex algorithm for linear programming. Proceedings of the 38th Annual ACM Symposium on Theory of Computing (2006), 51–60 Klee, V., and Minty, G.J. [1972]: How good is the simplex algorithm? In: Inequalities III (O. Shisha, ed.), Academic Press, New York 1972, pp. 159–175 Kuhn, H.W. [1956]: Solvability and consistency for linear equations and inequalities. The American Mathematical Monthly 63 (1956), 217–232 Minkowski, H. [1896]: Geometrie der Zahlen. Teubner, Leipzig 1896 Motzkin, T.S. [1936]: Beiträge zur Theorie der linearen Ungleichungen (Dissertation). Azriel, Jerusalem 1936 von Neumann, J. [1947]: Discussion of a maximum problem. Working paper. Published in: John von Neumann, Collected Works; Vol. VI (A.H. Taub, ed.), Pergamon Press, Oxford 1963, pp. 27–28 Spielman, D.A., and Teng, S.-H. [2004]: Smoothed analysis of algorithms: why the simplex algorithm usually takes polynomial time. Journal of the ACM 51 (2004), 385–463 Steinitz, E. [1916]: Bedingt konvergente Reihen und konvexe Systeme. Journal für die reine und angewandte Mathematik 146 (1916), 1–52 Weyl, H. [1935]: Elementare Theorie der konvexen Polyeder. Commentarii Mathematici Helvetici 7 (1935), 290–306

•

4 Linear Programming Algorithms

Three types of algorithms for L INEAR PROGRAMMING had the most impact: the SIMPLEX ALGORITHM (see Section 3.2), interior point algorithms, and the ELLIPSOID M ETHOD . Each of these has a disadvantage: In contrast to the other two, so far no variant of the SIMPLEX ALGORITHM has been shown to have a polynomial running time. In Sections 4.4 and 4.5 we present the E LLIPSOID METHOD and prove that it leads to a polynomial-time algorithm for LINEAR PROGRAMMING. However, the ELLIPSOID METHOD is too inefficient to be used in practice. Interior point algorithms and, despite its exponential worst-case running time, the SIMPLEX ALGORITHM are far more efficient, and they are both used in practice to solve LPs. In fact, both the ELLIPSOID METHOD and interior point algorithms can be used for more general convex optimization problems, e.g. for so-called semidefinite programs. An advantage of the SIMPLEX ALGORITHM and the ELLIPSOID METHOD is that they do not require the LP to be given explicitly. It suffices to have an oracle (a subroutine) which decides whether a given vector is feasible and, if not, returns a violated constraint. We shall discuss this in detail with respect to the E LLIPSOID METHOD in Section 4.6, because it implies that many combinatorial optimization problems can be solved in polynomial time; for some problems this is in fact the only known way to show polynomial solvability. This is the reason why we discuss the ELLIPSOID METHOD but not interior point algorithms in this book. A prerequisite for polynomial-time algorithms is that there exists an optimum solution that has a binary representation whose length is bounded by a polynomial in the input size. We prove in Section 4.1 that this condition holds for L INEAR PROGRAMMING. In Sections 4.2 and 4.3 we review some basic algorithms needed later, including the well-known Gaussian elimination method for solving systems of equations.

4.1 Size of Vertices and Faces Instances of LINEAR PROGRAMMING are vectors and matrices. Since no strongly polynomial-time algorithm for LINEAR PROGRAMMING is known we have to restrict attention to rational instances when analyzing the running time of algorithms. We assume that all numbers are coded in binary. To estimate the size (number of bits) of this representation we define size.n/ WD 1 C dlog.jnj C 1/e for B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__4, c Springer-Verlag Berlin Heidelberg 2012

73

74

4 Linear Programming Algorithms

integers n 2 Z and size.r/ WD size.p/ C size.q/ for rational numbers r D pq , where p; q are relatively prime integers (i.e. their greatest common divisor is 1). For vectors x D .x1 ; : : : ; xn / 2 Qn we store the components and have size.x/ WD n C size.x1 / C : : P : C size.xn /. For a matrix A 2 Qmn with entries aij we have size.A/ WD mn C i;j size.aij /. Of course these precise values are a somewhat random choice, but remember that we are not really interested in constant factors. For polynomial-time algorithms it is important that the sizes of numbers do not increase too much by elementary arithmetic operations. We note: Proposition 4.1. If r1 ; : : : ; rn are rational numbers, then size.r1 rn / size.r1 / C C size.rn /I size.r1 C C rn / 2.size.r1 / C C size.rn //: Proof: For integers s1 ; : : : ; sn we obviously have size.s1 sn / size.s1 /C C size.sn / and size.s1 C C sn / size.s1 / C C size.sn /. Let now ri D pqii , where pi and qi are nonzero integers (i D 1; : : : ; n). Then size.r1 rn / size.p1 pn / C size.q1 qn / size.r1 / C C size.rn /. For the second statement, observe that the denominator q1 qn has size at most size.q1 / C C size.qn /. The numerator is the sum of the numbers q1 qi 1 pi qi C1 qn (i D 1; : : : ; n), so its absolute value is at most .jp1 j C C jpn j/jq1 qn j. Therefore the size of the numerator is at most size.r1 / C C size.rn /. The first part of this proposition also implies that we can often assume w.l.o.g. that all numbers in a problem instance are integers, since otherwise we can multiply each of them with the product of all denominators. For addition and inner product of vectors we have: Proposition 4.2. If x; y 2 Qn are rational vectors, then size.x C y/ 2.size.x/ C size.y//I size.x > y/ 2.size.x/ C size.y//: P Proof: UsingP Proposition 4.1 wePhave size.x C y/ D n C niD1 size.xi C n n yi / n C 2 i D1 size.x Pni / C 2 i D1 size.y Pn i / D 2.size.x/ C Pnsize.y// 3n > and size.x 2 y/ D size x y size.x y / 2 i i i D1 i i i D1 i D1 size.xi / C P 2 niD1 size.yi / D 2.size.x/ C size.y// 4n. Even under more complicated operations the numbers involved do not grow fast. Recall that the determinant of a matrix A D .aij /1i;j n is defined by det A WD

X 2Sn

sgn./

n Y i D1

ai;.i / ;

(4.1)

4.1

Size of Vertices and Faces

75

where Sn is the set of all permutations of f1; : : : ; ng and sgn./ is the sign of the permutation (defined to be 1 if can be obtained from the identity map by an even number of transpositions, and 1 otherwise). Proposition 4.3. For any rational square matrix A we have size.det A/ 2size.A/. p

Proof: We write aij D q ij with relatively prime integers pij ; qij . Now let ij Q det AD pq where p and q are relatively prime integers. Then jdet Aj i;j .jpij j C Q 1/ and jqj i;j jqij j. We obtain size.q/ size.A/ and, using jpj D jdet Ajjqj Q i;j .jpij j C 1/jqij j, size.p/

X .size.pij / C 1 C size.qij // D size.A/: i;j

With this observation we can prove: Theorem 4.4. Suppose the rational LP maxfcx W Ax bg has an optimum solution. Then it also has an optimum solution x with size.x/ 4n.size.A/ C size.b//, with components of size at most 4.size.A/ C size.b//. If b D ei or b D ei for some unit vector ei , then there is a nonsingular submatrix A0 of A and an optimum solution x with size.x/ 4nsize.A0 /. Proof: By Corollary 3.5, the maximum is attained in a face F of fx W Ax bg. Let F 0 F be a minimal face. By Proposition 3.9, F 0 D fx W A0 x D b 0 g for some subsystem A0 x b 0 of Ax b. W.l.o.g., we may assume that the rows of A0 are linearly independent. We then take a maximal set of linear independent columns (call this matrix A00 ) and set all other components to zero. Then x D .A00 /1 b 0 , filled up with zeros, is an optimum solution to our LP. By Cramer’s rule the entries of x A000 are given by xj D det , where A000 arises from A00 by replacing the j -th column det A00 0 by b . By Proposition 4.3 we obtain size.x/ n C 2n.size.A000 / C size.A00 // 4n.size.A00 / C size.b 0 //. If b D ˙ei then j det.A000 /j is the absolute value of a subdeterminant of A00 . The encoding length of the faces of a polytope given by its vertices can be estimated as follows: Lemma 4.5. Let P Rn be a rational polytope and T 2 N such that size.x/ T for each vertex x. Then P D fx W Ax bg for some inequality system Ax b, each of whose inequalities ax ˇ satisfies size.a/ C size.ˇ/ 75n2 T . Proof: First assume that P is full-dimensional. Let F D fx 2 P W ax D ˇg be a facet of P , where P fx W ax ˇg. Let y1 ; : : : ; y t be the vertices of F (by Proposition 3.6 they are also vertices of P ). Let c be the solution of M c D e1 , where M is a t n-matrix whose i -th

76

4 Linear Programming Algorithms

row is yi y1 (i D 2; : : : ; t) and whose first row is some unit vector that is linearly independent of the other rows. Observe that rank.M / D n (because dim F D n1). So we have c > D a for some 2 R n f0g. By Theorem 4.4 size.c/ 4nsize.M 0 /, where M 0 is a nonsingular n nsubmatrix of M . By Proposition 4.2 we have size.M 0 / 4nT and size.c > y1 / 2.size.c/ C size.y1 //. So the inequality c > x ı (or c > x ı if < 0), where ı WD c > y1 D ˇ, satisfies size.c/ C size.ı/ 3size.c/ C 2T 48n2 T C 2T 50n2 T . Collecting these inequalities for all facets F yields a description of P . If P D ;, the assertion is trivial, so we now assume that P is neither fulldimensional nor empty. Let V be the set of vertices of P . For s D .s1 ; : : : ; sn / 2 f1; 1gn let Ps be the convex hull of V [ fx C si ei W x 2 V; i D 1; : : : ; ng. Each Ps is a full-dimensional polytope (Theorem 3.31), and the size of any of its vertices is at most T Cn (cf. Corollary 3.32). By the above, Ps can be described byT inequalities of size at most 50n2 .T C n/ 75n2 T (note that T 2n). Since P D s2f1;1gn Ps , this completes the proof.

4.2 Continued Fractions When we say that the numbers occurring in a certain algorithm do not grow too fast, we often assume that for each rational pq the numerator p and the denominator q are relatively prime. This assumption causes no problem if we can easily find the greatest common divisor of two natural numbers. This is accomplished by one of the oldest algorithms:

EUCLIDEAN ALGORITHM Input:

Two natural numbers p and q.

Output:

The greatest common divisor d of p and q, i.e. prime integers.

p d

and

q d

are relatively

1

While p > 0 and q > 0 do: If p < q then set q WD q b pq cp else set p WD p b pq cq.

2

Return d WD maxfp; qg.

Theorem 4.6. The EUCLIDEAN ALGORITHM works correctly. The number of iterations is at most size.p/ C size.q/. Proof: The correctness follows from the fact that the set of common divisors of p and q does not change throughout the algorithm, until one of the numbers becomes zero. One of p or q is reduced by at least a factor of two in each iteration, hence there are at most log p C log q C 1 iterations. Since no number occurring in an intermediate step is greater than p and q, we have a polynomial-time algorithm.

4.2

Continued Fractions

77

A similar algorithm is the so-called CONTINUED FRACTION EXPANSION. This can be used to approximate any number by a rational number whose denominator is 1 not too large. For any positive real number x we define x0 WD x and xi C1 WD xi bx ic for i D 1; 2; : : :, until xk 2 N for some k. Then we have x D x0 D bx0 cC

1 1 D bx0 cC x1 bx1 c C

1 x2

D bx0 cC

1 bx1 c C

1 bx2 cC x1

D

3

We claim that this sequence is finite if and only if x is rational. One direction follows immediately from the observation that xi C1 is rational if and only if xi is rational. The other direction is also easy: If x D pq , the above procedure is equivalent to the E UCLIDEAN ALGORITHM applied to p and q. This also shows that for a given rational number pq with p; q > 0 the (finite) sequence x1 ; x2 ; : : : ; xk as above can be computed in polynomial time. The following algorithm is almost identical to the EUCLIDEAN ALGORITHM except for the computation of the numbers gi and hi ; we shall prove that the sequence ghii converges to x. i 2N

CONTINUED FRACTION EXPANSION Input: Output:

Natural numbers p and q (let x WD pq ). The sequence xi D pqii with x0 D i D0;1;:::

p q

and xi C1 WD

1 xi bxi c .

Set i WD 0, p0 WD p and q0 WD q. Set g2 WD 0, g1 WD 1, h2 WD 1, and h1 WD 0. While qi 6D 0 do: Set ai WD b pqii c. Set gi WD ai gi 1 C gi 2 . Set hi WD ai hi 1 C hi 2 . Set qi C1 WD pi ai qi . Set pi C1 WD qi . Set i WD i C 1.

1 2

We claim that the sequence ghii yields good approximations of x. Before we can prove this, we need some preliminary observations: Proposition 4.7. The following statements hold for all iterations i in the above algorithm: (a) ai 1 (except possibly for i D 0) and hi hi 1 . (b) gi 1 hi gi hi 1 D .1/i . pi gi 1 C qi gi 2 (c) D x. pi hi 1 C qi hi 2 (d) ghi x if i is even and ghi x if i is odd. i

i

78

4 Linear Programming Algorithms

Proof: (a) is obvious. (b) is easily shown by induction: For i D 0 we have gi 1 hi gi hi 1 D g1 h0 D 1, and for i 1 we have gi 1 hi gi hi 1 D gi 1 .ai hi 1 C hi 2 / hi 1 .ai gi 1 C gi 2 / D gi 1 hi 2 hi 1 gi 2 : (c) is also proved by induction: For i D 0 we have pi 1 C 0 pi gi 1 C qi gi 2 D x: D pi hi 1 C qi hi 2 0 C qi 1 For i 1 we have qi 1 .ai 1 gi 2 C gi 3 / C .pi 1 ai 1 qi 1 /gi 2 pi gi 1 C qi gi 2 D pi hi 1 C qi hi 2 qi 1 .ai 1 hi 2 C hi 3 / C .pi 1 ai 1 qi 1 /hi 2 qi 1 gi 3 C pi 1 gi 2 D : qi 1 hi 3 C pi 1 hi 2 We finally prove (d). We note gh2 D 0 < x < 1 D gh1 and proceed by 2 1 induction. The induction step follows easily from the fact that the function f .˛/ WD ˛gi 1 Cgi 2 is monotone for ˛ > 0, and f . pq i / D x by (c). ˛h Ch i 1

i 2

i

Theorem 4.8. (Khintchine [1956]) Given a rational number ˛ and a natural number n, a rational number ˇ with denominator at most n such that j˛ ˇj is minimum can be found in polynomial time (polynomial in size.n/ C size.˛/). Proof: We run the CONTINUED FRACTION EXPANSION with x WD ˛. If the algorithm stops with qi D 0 and hi 1 n, we can set ˇ D ghi 1 D ˛ by i 1 Proposition 4.7(c). Otherwise let i be the last index with hi n, and let t be the maximum integer such that thi C hi 1 n (cf. Proposition 4.7(a)). Since ai C1 hi C hi 1 D hi C1 > n, we have t < ai C1 . We claim that gi tgi C gi 1 y WD or ´ WD hi thi C hi 1 is an optimum solution. Both numbers have denominators at most n. If i is even, then y x < ´ by Proposition 4.7(d). Similarly, if i is odd, we have y x > ´. We show that any rational number pq between y and ´ has denominator greater than n. Observe that jhi gi 1 hi 1 gi j 1 j´ yj D D hi .thi C hi 1 / hi .thi C hi 1 / (using Proposition 4.7(b)). On the other hand, ˇ ˇ ˇ ˇ ˇ ˇ 1 1 hi 1 C .t C 1/hi p ˇˇ ˇˇ p ˇ C D ; j´ yj D ˇ´ ˇ C ˇ y ˇˇ q q .thi C hi 1 /q hi q qhi .thi C hi 1 / so q hi 1 C .t C 1/hi > n.

The above proof is from the book of Grötschel, Lovász and Schrijver [1988], which also contains important generalizations.

4.3

Gaussian Elimination

79

4.3 Gaussian Elimination The most important algorithm in linear algebra is the so-called Gaussian elimination. It has been applied by Gauss but was known much earlier (see Schrijver [1986] for historical notes). Gaussian elimination is used to determine the rank of a matrix, to compute the determinant and to solve a system of linear equations. It occurs very often as a subroutine in linear programming algorithms; e.g. in 1 of the SIMPLEX ALGORITHM. Given a matrix A 2 Qmn , our algorithm for Gaussian Elimination works with an extended matrix Z D .B C / 2 Qm.nCm/ ; initially B D A and C D I . The algorithm transforms B to the form I0 R0 by the following elementary operations: permuting rows and columns, adding a multiple of one row to another row, and (in the final step) multiplying rows by nonzero constants. At each iteration C is modified accordingly, such that the property C AQ D B is maintained throughout where AQ results from A by permuting rows and columns. The first part of the algorithm, consisting of 2 and , 3 transforms B to an upper triangular matrix. Consider for example the matrix Z after two iterations; it has the form 0 1 ´11 6D 0 ´12 ´13 ´1n 1 0 0 0 B 0 ´22 6D 0 ´23 ´2n ´2;nC1 1 0 0C B C B 0 0 ´33 ´3n ´3;nC1 ´3;nC2 1 0 0 C B C B 0 C B C: B I C B C @ 0A 0 0 ´m3 ´mn ´m;nC1 ´m;nC2 0 0 1 i3 If ´33 6D 0, then the next step just consists of subtracting ´´33 times the third row from the i -th row, for i D 4; : : : ; m. If ´33 D 0 we first exchange the third row and/or the third column with another one. Note that if we exchange two rows, we have to exchange also the two corresponding columns of C in order to maintain the property C AQ D B. To have AQ available at each point we store the permutations of the rows and columns in variables row.i /, i D 1; : : : ; m and col.j /, j D 1; : : : ; n. Then AQ D .Arow.i /;col.j //i 2f1;:::;mg;j 2f1;:::;ng . The second part of the algorithm, consisting of 4 and , 5 is simpler since no rows or columns are exchanged anymore.

GAUSSIAN ELIMINATION Input:

A matrix A D .aij / 2 Qmn .

Output:

Its rank r, a maximal nonsingular submatrix A0 D.arow.i /;col.j //i;j 2f1;:::;rg of A, its determinant d D det A0 , and its inverse .A0 /1 D.´i;nCj /i;j 2f1;:::;rg .

80

4 Linear Programming Algorithms

1

Set r WD 0 and d WD 1. Set ´ij WD aij , row.i / WD i and col.j / WD j (i D 1; : : : ; m, j D 1; : : : ; n). Set ´i;nCj WD 0 and ´i;nCi WD 1 for 1 i; j m, i 6D j .

2

Let p 2 fr C 1; : : : ; mg and q 2 fr C 1; : : : ; ng with ´pq 6D 0. If no such p and q exist, then go to . 4 Set r WD r C 1. If p 6D r then exchange ´pj and ´rj (j D 1; : : : ; n C m), exchange ´i;nCp and ´i;nCr (i D 1; : : : ; m), and exchange row.p/ and row.r/. If q 6D r then exchange ´i q and ´i r (i D 1; : : : ; m), and exchange col.q/ and col.r/. Set d WD d ´rr . For i WD r C 1 to m do: ir Set ˛ WD ´´rr . For j WD r to n C r do: ´ij WD ´ij ˛´rj . Go to . 2 For k WD r down to 2 do: For i WD 1 to k 1 do: ik Set ˛ WD ´´kk . For j WD k to n C r do ´ij WD ´ij ˛´kj .

3

4

5

For k WD 1 to r do: Set ˛ WD ´ 1 . kk For j WD 1 to n C r do ´kj WD ˛´kj .

Theorem 4.9. GAUSSIAN ELIMINATION works correctly and terminates after O.mnr/ steps. Proof: First observe that each time before 2 we have ´i i 6D 0 for i 2 f1; : : : ; rg and ´ij D 0 for all j 2 f1; : : : ; rg and i 2 fj C 1; : : : ; mg. Hence det .´ij /i;j 2f1;2;:::;rg D ´11 ´22 ´rr D d 6D 0: Since adding a multiple of one row to another row of a square matrix does not change the value of the determinant (this well-known fact follows directly from the definition (4.1)) we have det .´ij /i;j 2f1;2;:::;rg D det .arow.i /;col.j //i;j 2f1;2;:::;rg at any stage before , 5 and hence the determinant d is computed correctly. A0 is a nonsingular r r-submatrix of A. Since .´ij /i 2f1;:::;mg;j 2f1;:::;ng has rank r at termination andPthe operations did not change the rank, A has also rank r. Moreover, jmD1 ´i;nCj arow.j /;col.k/ D ´i k for all i 2 f1; : : : ; mg and k 2 f1; : : : ; ng (i.e. C AQ D B in our above notation) holds throughout. (Note that for j D r C 1; : : : ; m we have at any stage ´j;nCj D 1 and ´i;nCj D 0 for i 6D j .) Since .´ij /i;j 2f1;2;:::;rg is the unit matrix at termination this implies that .A0 /1 is

4.3

Gaussian Elimination

81

also computed correctly. The number of steps is obviously O.rmn C r 2 .n C r// D O.mnr/. In order to prove that GAUSSIAN ELIMINATION is a polynomial-time algorithm we have to guarantee that all numbers that occur are polynomially bounded by the input size. This is not trivial but can be shown: Theorem 4.10. (Edmonds [1967]) GAUSSIAN ELIMINATION is a polynomialtime algorithm. Each number occurring in the course of the algorithm can be stored with O.m.m C n/size.A// bits. Proof: We first show that in 2 and 3 all numbers are 0, 1, or quotients of subdeterminants of A. First observe that entries ´ij with i r or j r are not modified anymore. Entries ´ij with j > n C r are 0 (if j 6D n C i ) or 1 (if j D n C i ). Furthermore, we have for all s 2 fr C 1; : : : ; mg and t 2 fr C 1; : : : ; n C mg det .´ij /i 2f1;2;:::;r;sg;j 2f1;2;:::;r;t g ´st D : det .´ij /i;j 2f1;2;:::;rg (This follows from evaluating the determinant det .´ij /i 2f1;2;:::;r;sg;j 2f1;2;:::;r;t g along the last row because ´sj D 0 for all s 2 fr C1; : : : ; mg and all j 2 f1; : : : ; rg.) We have already observed in the proof of Theorem 4.9 that det .´ij /i;j 2f1;2;:::;rg D det .arow.i /;col.j //i;j 2f1;2;:::;rg ; because adding a multiple of one row to another row of a square matrix does not change the value of the determinant. By the same argument we have det .´ij /i 2f1;2;:::;r;sg;j 2f1;2;:::;r;t g D det .arow.i /;col.j //i 2f1;2;:::;r;sg;j 2f1;2;:::;r;t g for s 2 fr C 1; : : : ; mg and t 2 fr C 1; : : : ; ng. Furthermore, det .´ij /i 2f9;2;:::;r;sg;j 2f1;2;:::;r;nCt g D det .arow.i /;col.j //i 2f1;2;:::;r;sgnft g;j 2f1;2;:::;rg for all s 2 fr C 1; : : : ; mg and t 2 f1; : : : ; rg, which is checked by evaluating the left-hand side determinant (after ) 1 along column n C t. We conclude that at any stage in 2 and 3 all numbers ´ij are 0, 1, or quotients of subdeterminants of A. Hence, by Proposition 4.3, each number occurring in 2 and 3 can be stored with O.size.A// bits. Finally observe that 4 is equivalent to applying 2 and 3 again, choosing p and q appropriately (reversing the order of the first r rows and columns). Hence each number occurring in 4 can be stored with O size .´ij /i 2f1;:::;mg;j 2f1;:::;mCng bits, which is O.m.m C n/size.A//. The easiest way to keep the representations of the numbers ´ij small enough is to guarantee that the numerator and denominator of each of these numbers are relatively prime at any stage. This can be accomplished by applying the EUCLIDEAN ALGORITHM after each computation. This gives an overall polynomial running time.

82

4 Linear Programming Algorithms

In fact, we can easily implement GAUSSIAN ELIMINATION to be a strongly polynomial-time algorithm (Exercise 4). So we can check in polynomial time whether a set of vectors is linearly independent, and we can compute the determinant and the inverse of a nonsingular matrix in polynomial time (exchanging two rows or columns changes just the sign of the determinant). Moreover we get: Corollary 4.11. Given a matrix A 2 Qmn and a vector b 2 Qm we can in polynomial time find a vector x 2 Qn with Ax D b or decide that no such vector exists. Proof: We compute a maximal nonsingular submatrix A0 D.arow.i /;col.j / /i;j 2f1;:::;rg 1 of A and its inverse .A0 /P D .´i;nCj /i;j 2f1;:::;rg by GAUSSIAN ELIMINATION. r Then we set xcol.j / WD kD1 ´j;nCk brow.k/ for j D 1; : : : ; r and xk WD 0 for k … fcol.1/; : : : ; col.r/g. We obtain for i D 1; : : : r: n X

arow.i /;j xj D

j D1

r X

arow.i /;col.j /xcol.j /

j D1

D

r X

arow.i /;col.j /

j D1

D

r X

r X

´j;nCk brow.k/

kD1

brow.k/

kD1

r X

arow.i /;col.j /´j;nCk

j D1

D brow.i / : Since the other rows of A with indices not in frow.1/; : : : ; row.r/g are linear combinations of these, either x satisfies Ax D b or no vector satisfies this system of equations.

4.4 The Ellipsoid Method In this section we describe the so-called ellipsoid method, developed by Iudin and Nemirovskii [1976] and Shor [1977] for nonlinear optimization. Khachiyan [1979] observed that it can be modified in order to solve LPs in polynomial time. Most of our presentation is based on (Grötschel, Lovász and Schrijver [1981]), (Bland, Goldfarb and Todd [1981]) and the book of Grötschel, Lovász and Schrijver [1988], which is also recommended for further study. The idea of the ellipsoid method is very roughly the following. We look for either a feasible or an optimum solution of an LP. We start with an ellipsoid which we know a priori to contain the solutions (e.g. a large ball). At each iteration k, we check if the center xk of the current ellipsoid is a feasible solution. Otherwise, we take a hyperplane containing xk such that all the solutions lie on one side of this hyperplane. Now we have a half-ellipsoid which contains all solutions. We take the smallest ellipsoid completely containing this half-ellipsoid and continue.

4.4

The Ellipsoid Method

83

Definition 4.12. An ellipsoid is a set E.A; x/ D f´ 2 Rn W .´ x/> A1 .´ x/ 1g for some symmetric positive definite n n-matrix A. Note that B.x; r/ WD E.r 2 I; x/ (with I being the n n unit matrix) is the n-dimensional Euclidean ball with center x and radius r. The volume of an ellipsoid E.A; x/ is known to be p volume .E.A; x// D det A volume .B.0; 1// (see Exercise 7). Given an ellipsoid E.A; x/ and a hyperplane f´ W a´ D axg, the smallest ellipsoid E.A0 ; x 0 / containing the half-ellipsoid E 0 D f´ 2 E.A; x/ W a´ axg is called the Löwner-John ellipsoid of E 0 (see Figure 4.1). It can be computed by the following formulas: 2 n2 0 > A bb ; A D 2 n 1 nC1 1 x0 D x C b; nC1 1 bD p Aa: a> Aa

{z : az = ax }

x

E ( A, x) E(A , x )

Fig. 4.1.

84

4 Linear Programming Algorithms

One difficulty of the ellipsoid method is caused by the square root in the computation of b. Because we have to tolerate rounding errors, it is necessary to increase the radius of the next ellipsoid a little bit. Here is an algorithmic scheme that takes care of this problem:

ELLIPSOID METHOD Input: Output: 1

2 3

4

A number n 2 N, n 2. A number N 2 N. x0 2 Qn and R 2 QC , R 2. An ellipsoid E.AN ; xN /.

Set p WD d6N C log.9n3 /e. Set A0 WD R2 I , where I is the n n unit matrix. Set k WD 0. Choose any ak 2 Qn n f0g. 1 Ak ak : Set bk WD q > ak Ak ak 1 bk . Set xkC1 W xkC1 WD xk C n C1 2 2n C 3 2 > bk bk . Ak Set AkC1 W AkC1 WD 2n2 nC1 (Here W means computing the entries up to p binary digits behind the point, taking care that AkC1 is symmetric). Set k WD k C 1. If k < N then go to 2 else stop.

So in each of the N iterations an approximation E.AkC1 ; xkC1 / of the smallest ellipsoid containing E.Ak ; xk / \ f´ W ak ´ ak xk g is computed. Two main issues, how to obtain the ak and how to choose N , will be addressed in the next section. But let us first prove some lemmas. Let jjxjj denote the Euclidean norm of vector x, while jjAjj WD maxfjjAxjj W jjxjj D 1g shall denote the norm of the matrix A. For symmetric matrices, jjAjj is the maximum absolute value of an eigenvalue and jjAjj D maxfx > Ax W jjxjj D 1g. The first lemma says that each Ek WD E.Ak ; xk / is indeed an ellipsoid. Furthermore, the absolute values of the numbers involved remain smaller than R2 2N C 2size.x0 / . Therefore each iteration of the ELLIPSOID METHOD consists of O.n2 / computational steps, each involving numbers with O.p C size.ak / C size.R/ C size.x0 // bits. Lemma 4.13. (Grötschel, Lovász and Schrijver [1981]) Let k 2 f0; 1; : : : ; N g. Then Ak is positive definite, and we have jjxk jj jjx0 jj C R2k ;

jjAk jj R2 2k ;

and

2 k jjA1 k jj R 4 :

Proof: We use induction on k. For k D 0 all the statements are obvious. Assume that they are true for some k 0. By a straightforward computation one verifies

4.4

that .AkC1 /1

The Ellipsoid Method

ak ak> 2n2 2 1 Ak C : D 2n2 C 3 n 1 ak> Ak ak

85

(4.2)

So .AkC1 /1 is the sum of a positive definite and a positive semidefinite matrix; thus it is positive definite. Hence AkC1 is also positive definite. Note that for positive semidefinite matrices A and B we have jjAjj jjA C Bjj. Therefore ˇˇ ˇˇ ˇˇ 2n2 C 3 2n2 C 3 ˇˇˇˇ 2 11 2 k > ˇˇ A jjAkC1 jj D b R 2 : b jjAk jj k k k ˇˇ ˇ ˇ 2 2 2n nC1 2n 8 Since the n n all-one matrix has norm n, the matrix AkC1 AkC1 , each of whose entries has absolute value at most 2p , has norm at most n2p . We conclude jjAkC1 jj jjAkC1 jj C jjAkC1 AkC1 jj

11 2 k R 2 C n2p R2 2kC1 8

(here we used the very rough estimate 2p n1 ). It is well-known from linear algebra that for any symmetric positive definite n n-matrix A there exists a symmetric positive definite matrix B with A D BB. Writing Ak D BB with B D B > we obtain v s u > 2 u a A ak p .Bak /> Ak .Bak / jjAk ak jj k k jjbk jj D q D t > D jjAk jj R2k1 : > .Bak / .Bak / ak Ak ak ak> Ak ak

Using this (and again the induction hypothesis) we get 1 jjbk jj C jjxkC1 xkC1 jj nC1 p 1 R2k1 C n2p jjx0 jj C R2kC1 : jjx0 jj C R2k C nC1

jjxkC1 jj jjxk jj C

Using (4.2) and jjak ak> jj D ak> ak we compute 2 ˇˇ 1 ˇˇ ˇˇ 1 ˇˇ ak> ak ˇˇA ˇˇ C 2 ˇˇ 2n ˇˇ.A / kC1 k 2n2 C 3 n 1 ak> Ak ak

(4.3)

! ˇˇ 1 ˇˇ ak> BA1 Bak 2n2 2 k ˇˇA ˇˇ C D k 2n2 C 3 n 1 ak> BBak ˇˇ 1 ˇˇ ˇˇ ˇˇ ˇˇ ˇˇ 2n2 ˇˇA ˇˇ C 2 ˇˇA1 ˇˇ < n C 1 ˇˇA1 ˇˇ k k k 2 2n C 3 n1 n1 3R2 4k :

Let be the smallest eigenvalue of AkC1 , and let v be a corresponding eigenvector with jjvjj D 1. Then – writing AkC1 D C C for a symmetric matrix C – we have

86

4 Linear Programming Algorithms

D v > AkC1 v D v > AkC1 v C v > .AkC1 AkC1 /v v> C C v C v > .AkC1 AkC1 /v 1 v > C AkC1 Cv ˇˇ1 ˇˇ 1 ˇˇ.AkC1 /1 ˇˇ jjAkC1 AkC1 jj > R2 4k n2p R2 4.kC1/ ; 3

D

where we used 2p

1 k 4 . 3n

Since > 0, AkC1 is positive definite. Furthermore,

ˇˇ ˇˇ ˇˇ.AkC1 /1 ˇˇ D 1 R2 4kC1 :

Next we show that in each iteration the ellipsoid contains the intersection of E0 and the previous half-ellipsoid: Lemma 4.14. For k D 0; : : : ; N 1 we have EkC1 fx 2 Ek \ E0 W ak x ak xk g. Proof: Let x 2 Ek \ E0 with ak x ak xk . We first compute (using (4.2)) /> .AkC1 /1 .x xkC1 / .x xkC1 > 2 ak ak> 1 2 1 2n 1 x x b b A x x C D k k k k k 2n2 C3 nC1 n1 ak> Ak ak nC1

D

D

ak ak> 2n2 2 > 1 > .x x .x x / A .x x / C / .x xk / k k k k 2n2 C 3 n1 ak> Ak ak 2 bk> ak ak> bk 1 > 1 bk Ak bk C C .n C 1/2 n 1 ak> Ak ak ! 2.x xk /> 2 ak ak> bk 1 Ak b k C nC1 n 1 ak> Ak ak ak a> 2 2n2 .x xk /> > k .x xk / C .x xk /> A1 k .x xk / C 2 2n C 3 n1 ak Ak ak ! 2 .x xk /> ak 2 2 1 : 1C 1C q .n C 1/2 n1 nC1 n1 a> A a k

k k

Since x 2 Ek , we have .x xk /> A1 k .x xk / 1. By abbreviating t WD

a> .xxk / qk > ak Ak ak

we obtain

/> .AkC1 /1 .xxkC1 / .xxkC1

2 2 2 2n2 1 1 C t t : C 2n2 C 3 n1 n2 1 n 1

> 1 Since bk> A1 k bk D 1 and bk Ak .x xk / D t, we have

4.4

The Ellipsoid Method

87

1 .x xk /> A1 k .x xk / 2 D .x xk tbk /> A1 k .x xk tbk / C t t 2;

because A1 is positive definite. So (using ak x ak xk ) we have 0 t 1 and k obtain 2n4 .x xkC1 : /> .AkC1 /1 .x xkC1 / 2n4 C n2 3 It remains to estimate the rounding error ˇ ˇ Z WD ˇ.x xkC1 /> .AkC1 /1 .x xkC1 / .x xkC1 /> .AkC1 /1 .x xkC1 /ˇ ˇ ˇ ˇ.x xkC1 /> .AkC1 /1 .xkC1 xkC1 /ˇ ˇ ˇ C ˇ.xkC1 xkC1 /> .AkC1 /1 .x xkC1 /ˇ ˇ ˇ C ˇ.x x /> .AkC1 /1 .A /1 .x x /ˇ kC1

kC1 jjx xkC1 jj jj.AkC1 / jj jjxkC1 xkC1 jj CjjxkC1 xkC1 jj jj.AkC1 /1 jj jjx xkC1 jj

kC1

1

Cjjx xkC1 jj2 jj.AkC1 /1 jj jj.AkC1 /1 jj jjAkC1 AkC1 jj:

Using Lemma 4.13 and x 2 E0 we get jjx xp kC1 jj jjx x0 jj C jjxkC1 x0 jj R C R2N and jjx xkC1 jj jjx xkC1 jj C n2p R2N C1 . We also use (4.3) and obtain p Z 2.R2N C1 /.R2 4N /. n2p / C .R2 4N C1 /.R2 4N /.3R2 4N 1 /.n2p / p D 4R1 23N n2p C 3R2 26N n2p 26N n2p 1 ; 9n2 by definition of p. Altogether we have .x xkC1 /> .AkC1 /1 .x xkC1 /

1 2n4 C 2 1: 2n4 C n2 3 9n

The volumes of the ellipsoids decrease by a constant factor in each iteration: Lemma 4.15. For k D 0; : : : ; N 1 we have

volume .EkC1 / volume .Ek /

1

< e 5n .

Proof: (Grötschel, Lovász and Schrijver [1988]) We write s s s det AkC1 det AkC1 det AkC1 volume .EkC1 / D D volume .Ek / det Ak det Ak det AkC1

88

4 Linear Programming Algorithms

and estimate the two factors independently. First observe that n 2 det AkC1 2 ak ak> Ak 2n C 3 : D det I det Ak 2n2 n C 1 ak> Ak ak The matrix

> ak ak Ak > ak Ak ak

has rank one and 1 as its only nonzero eigenvalue (eigenvector

ak ). Since the determinant is the product of the eigenvalues, we conclude that n 2 det AkC1 2 3 2 1 2n C 3 < e 2n e n D e 2n ; 1 D 2 det Ak 2n nC1 n1 n < e 2 for n 2. where we used 1 C x e x for all x and nC1 For the second estimation we use (4.3) and the well-known fact that det B jjBjjn for any matrix B: det AkC1 D det I C .AkC1 /1 .AkC1 AkC1 / det AkC1 ˇˇ ˇˇn ˇˇI C .AkC1 /1 .AkC1 AkC1 /ˇˇ n jjI jj C jj.AkC1 /1 jj jjAkC1 AkC1 jj n 1 C .R2 4kC1 /.n2p / n 1 1C 10n2 1

e 10n 2

(we used 2p 10n43 4N 10nR 3 4kC1 ). We conclude that s s det AkC1 volume .EkC1 / det AkC1 1 1 1 D e 4n e 20n D e 5n : volume .Ek / det Ak det AkC1

4.5 Khachiyan’s Theorem In this section we shall prove Khachiyan’s theorem: the E LLIPSOID METHOD can be applied to LINEAR PROGRAMMING in order to obtain a polynomial-time algorithm. Let us first prove that it suffices to have an algorithm for checking feasibility of linear inequality systems: Proposition 4.16. Suppose there is a polynomial-time algorithm for the following problem: “Given a matrix A 2 Qmn and a vector b 2 Qm , decide if fx W Ax bg is empty.” Then there is a polynomial-time algorithm for LINEAR PROGRAMMING which finds an optimum basic solution if there exists one.

4.5

Khachiyan’s Theorem

89

Proof: Let an LP maxfcx W Ax bg be given. We first check if the primal and dual LPs are both feasible. If at least one of them is infeasible, we are done by Theorem 3.27. Otherwise, by Corollary 3.21, it is sufficient to find an element of f.x; y/ W Ax b; yA D c; y 0; cx D ybg. We show (by induction on k) that a solution of a feasible system of k inequalities and l equalities can be found by k calls to the subroutine checking emptiness of polyhedra plus additional polynomial-time work. For k D 0 a solution can be found easily by GAUSSIAN ELIMINATION (Corollary 4.11). Now let k > 0. Let ax ˇ be an inequality of the system. By a call to the subroutine we check whether the system becomes infeasible by replacing ax ˇ by ax D ˇ. If so, the inequality is redundant and can be removed (cf. Proposition 3.8). If not, we replace it by the equality. In both cases we reduced the number of inequalities by one, so we are done by induction. If there exists an optimum basic solution, the above procedure generates one, because the final equality system contains a maximal feasible subsystem of Ax D b. Before we can apply the ELLIPSOID METHOD, we have to take care that the polyhedron is bounded and full-dimensional: Proposition 4.17. (Khachiyan [1979], Gács and Lovász [1981]) Let A 2 Qmn and b 2 Qm . The system Ax b has a solution if and only if the system Ax b C 1l;

R1l x R1l

has a solution, where 1l is the all-one vector, 1 D 2n24.size.A/Csize.b// and R D 1 C 24.size.A/Csize.b// . If Ax b has a solution, then volume .fx 2 Rn W Ax b C 1l; R1l x R1lg/

2 n2size.A/

n

.

Proof: The box constraints R1l x R1l do not change the solvability by Theorem 4.4. Now suppose that Ax b has no solution. By Theorem 3.24 (a version of Farkas’ Lemma), there is a vector y 0 with yA D 0 and yb D 1. By applying Theorem 4.4 to minf1ly W y 0; A> y D 0; b > y D 1g we conclude that y can be chosen such that its components are of absolute value less than 24.size.A/Csize.b// . Therefore y.b C 1l/ < 1 C .n C 1/24.size.A/Csize.b// 0. Again by Theorem 3.24, this proves that Ax b C 1l has no solution. For the second statement, if x 2 Rn with Ax b has components of absolute value at most R 1 (cf. Theorem 4.4), then fx 2 Rn W Ax b C 1l; R1l x R1lg contains all points ´ with jj´ xjj1 n2size.A/ . Note that the construction of this proposition increases the size of the system of inequalities by at most a factor of O.m C n/. Theorem 4.18. (Khachiyan [1979]) There exists a polynomial-time algorithm for LINEAR PROGRAMMING (with rational input), and this algorithm finds an optimum basic solution if there exists one.

90

4 Linear Programming Algorithms

Proof: By Proposition 4.16 it suffices to check feasibility of a system Ax b. We transform the system as in Proposition 4.17 in order to obtain a polytope P which is either empty or has volume at least

2 n2size.A/

n

.

We run the ELLIPSOID METHOD with x0 D 0, R D n 1 C 24.size.A/Csize.b// , N D d10n2 .2 log n C 5.size.A/ C size.b///e. Each time in 2 we check whether xk 2 P . If yes, we are done. Otherwise we take a violated inequality ax ˇ of the system Ax b and set ak WD a. We claim that if the algorithm does not find an xk 2 P before iteration N , then P must be empty. To see this, we first observe that P Ek for all k: for k D 0 this is clear by the construction of P and R; the induction step is Lemma 4.14. So we have P EN . By Lemma 4.15, we have, abbreviating s WD size.A/ C size.b/, N

N

volume .EN / volume .E0 /e 5n .2R/n e 5n n 4n 10ns < 2n 1 C 24s n e < n2n 25ns : On the other hand, P 6D ; implies n 1 2 n D D n2n 25ns ; volume .P / n2s n2 25s which is a contradiction.

If we estimate the running time for solving an LP maxfcx W Ax bg with the above method, we get the bound O..n C m/9 .size.A/ C size.b/ C size.c//2 / (Exercise 9), which is polynomial but completely useless for practical purposes. In practice, either the SIMPLEX ALGORITHM or interior point algorithms are used. Karmarkar [1984] was the first to describe a polynomial-time interior point algorithm for LINEAR PROGRAMMING. We shall not go into the details here. A strongly polynomial-time algorithm for LINEAR PROGRAMMING is not known. However, Tardos [1986] showed that there is an algorithm for solving maxfcx W Ax bg with a running time that polynomially depends on size.A/ only. For many combinatorial optimization problems, where A is a 0-1-matrix, this gives a strongly polynomial-time algorithm. Tardos’ result was extended by Frank and Tardos [1987].

4.6 Separation and Optimization The above method (in particular Proposition 4.16) requires that the polyhedron be given explicitly by a list of inequalities. However, a closer look shows that this is not really necessary. It is sufficient to have a subroutine which – given a vector x – decides if x 2 P or otherwise returns a separating hyperplane, i.e. a vector a such that ax > maxfay W y 2 P g. We shall prove this for full-dimensional polytopes;

4.6

Separation and Optimization

91

for the general (more complicated) case we refer to Grötschel, Lovász and Schrijver [1988] (or Padberg [1995]). The results in this section are due to Grötschel, Lovász and Schrijver [1981] and independently to Karp and Papadimitriou [1982] and Padberg and Rao [1981]. With the results of this section one can solve certain linear programs in polynomial time although the polytope has an exponential number of facets. Many examples will be discussed later in this book; see e.g. Corollary 12.22 or Theorem 20.34. By considering the dual LP one can also deal with linear programs with a huge number of variables. Let P Rn be a full-dimensional polytope, or more generally, a fulldimensional bounded convex set. We assume that we know the dimension n and two balls B.x0 ; r/ and B.x0 ; R/ such that B.x0 ; r/ P B.x0 ; R/. But we do not assume that we know a linear inequality system defining P . In fact, this would not make sense if we want to solve linear programs with an exponential number of constraints in polynomial time, or even optimize linear objective functions over nonlinearly constrained convex sets. Below we shall prove that, under some reasonable assumptions, we can optimize a linear function over a polyhedron P in polynomial time (independent of the number of constraints) if we have a so-called separation oracle: a subroutine for the following problem:

SEPARATION PROBLEM Instance:

A convex set P Rn . A vector y 2 Qn .

Task:

Either decide that y 2 P or find a vector d 2 Qn such that dx < dy for all x 2 P .

Note that such a vector d exists if P is a rational polyhedron or a compact convex set (cf. Exercise 21 of Chapter 3). Given a convex set P by such a separation oracle, we look for an oracle algorithm using this as a black box. In an oracle algorithm we may ask the oracle at any time and we get a correct answer in one step. We can regard this concept as a subroutine whose running time we do not take into account. (In Chapter 15 we shall give a formal definition.) Indeed, it often suffices to have an oracle which solves the SEPARATION PROBLEM approximately. More precisely we assume an oracle for the following problem:

WEAK SEPARATION PROBLEM Instance: Task:

A convex set P Rn , a vector c 2 Qn and a number > 0. A vector y 2 Qn . Either find a vector y 0 2 P with cy cy 0 C or find a vector d 2 Qn such that dx < dy for all x 2 P .

Using a weak separation oracle we first solve linear programs approximately:

92

4 Linear Programming Algorithms

WEAK OPTIMIZATION PROBLEM Instance:

A number n 2 N. A vector c 2 Qn . A number > 0. A convex set P Rn given by an oracle for the WEAK SEPARATION PROBLEM for P , c and 2 .

Task:

Find a vector y 2 P with cy supfcx W x 2 P g .

Note that the above two definitions differ from the ones given e.g. in Grötschel, Lovász and Schrijver [1981]. However, they are basically equivalent, and we shall need the above form again in Section 18.3. The following variant of the ELLIPSOID METHOD solves the WEAK OPTIMIZATION PROBLEM for bounded full-dimensional convex sets:

GRÖTSCHEL-L OVÁSZ-SCHRIJVER ALGORITHM Input:

Output:

A number n 2 N, n 2. A vector c 2 Qn . A number 0 < 1. A convex set P Rn given by an oracle for the WEAK SEPARATION PROBLEM for P , c and 2 . x0 2 Qn and r; R 2 QC such that B.x0 ; r/ P B.x0 ; R/. A vector y 2 P with cy supfcx W x 2 P g .

1

Set R WD maxfR; l 2g,2r mWD minfr; 1g and WD maxfjjcjj; 1g. 2 Set N WD 5n ln 6Rr . Set y WD x0 .

2

Run the ELLIPSOID METHOD, with ak in 2 being computed as follows: Run the oracle for the WEAK SEPARATION PROBLEM with y D xk . If it returns a y 0 2 P with cy cy 0 C 2 then: If cy 0 > cy then set y WD y 0 . Set ak WD c. If it returns a d 2 Qn with dx < dy for all x 2 P then: Set ak WD d .

Theorem 4.19. The GRÖTSCHEL-LOVÁSZ-SCHRIJVER ALGORITHM correctly solves the WEAK OPTIMIZATION PROBLEM for bounded full-dimensional convex sets. Its running time is bounded by O n6 ˛ 2 C n4 ˛f .size.c/; size./; nsize.x0 / C n3 ˛/ ; 2

where ˛ D log Rr and f .size.c/; size./; size.y// is an upper bound of the running time of the oracle for the WEAK SEPARATION PROBLEM for P with input c; ; y. Proof: (Grötschel, Lovász and Schrijver [1981]) The running time in each of the N D O.n2 ˛/ iterations of the E LLIPSOID METHOD is O.n2 .n2 ˛ C size.R/ C size.x0 / C q// plus one oracle call, where q is the size of the output of the oracle. As size.y/ n.size.x0 / C size.R/ C N / by Lemma 4.13, the overall running time is O.n4 ˛.n2 ˛ C size.x0 / C f .size.c/; size./; nsize.x0 / C n3 ˛///, as stated.

4.6

Separation and Optimization

93

By Lemma 4.14, we have n o EN : x 2 P W cx cy C 2 Let ´ 2 P with c´ supfcx W x 2 P g 6 . We may assume that c´ > cy C 2 ; otherwise we are done.

r x0 U

r

z

cy∗

{x : cx

2}

{x : cx

cx0 }

Fig. 4.2.

Consider the convex hull U of ´ and the .n1/-dimensional ball B.x0 ; r/\fx W cx D cx0 g (see Figure 4.2). We have U P and hence U 0 WD fx 2 U W cx cy C 2 g is contained in EN . The volume of U 0 is c´ cy 2 n c´ cx0 c´ cy 2 n n1 c´ cx0 D Vn1 r ; njjcjj c´ cx0

volume .U 0 / D volume .U /

where Vn denotes the volume of the n-dimensional unit ball. Since volume .U 0 / volume .EN /, and Lemma 4.15 yields N

N

volume .EN / e 5n volume .E0 / D e 5n Vn Rn ; we have 1 Vn .c´ cx0 /n1 njjcjj n N2 5n R : c´ cy e 2 Vn1 r n1

Since c´ cx0 jjcjj jj´ x0 jj jjcjjR we obtain 1 2 nVn Rn1 n N2 N2 R 5n < 2jjcjje c´ cy jjcjje 5n R n1 2 Vn1 r r 3

and hence cy c´ 56 supfcx W x 2 P g .

94

4 Linear Programming Algorithms

Of course we are usually interested in the exact optimum. For this we restrict ourselves to rational full-dimensional polytopes. We need some assumption on the size of the vertices of the polytope. Lemma 4.20. Let n 2 N, let P Rn be a rational polytope, and let x0 2 Qn be a point in the interior of P . Let T 2 N such that size.x0 / log T and size.x/ log T for all vertices x of P . Then B.x0 ; r/ P B.x0 ; R/, where 2 r WD n1 T 379n and R WD 2nT . Moreover, let K WD 4T 2nC1 . Let c 2 Zn , and define c 0 WD K n c C .1; K; : : : ; n1 K /. Then maxfc 0 x W x 2 P g is attained by a unique vector x , for all other vertices y of P we have c 0 .x y/ > T 2n , and x is also an optimum solution of maxfcx W x 2 P g. Proof: For any vertex x of P we have jjxjj nT and jjx0 jj nT , so jjx x0 jj 2nT and x 2 B.x0 ; R/. To show that B.x0 ; r/ P , let F D fx 2 P W ax D ˇg be a facet of P , where by Lemma 4.5 we may assume that size.a/ C size.ˇ/ < 75n2 log T . Suppose there is a point y 2 F with jjy x0 jj < r. Then jax0 ˇj D jax0 ayj jjajj jjy x0 jj < n2size.a/ r T 304n

2

But on the other hand the size of ax0 ˇ can by estimated by size.ax0 ˇ/ 4.size.a/ C size.x0 / C size.ˇ// 300n2 log T C 4 log T 304n2 log T: 2

Since ax0 6D ˇ (x0 is in the interior of P ), this implies jax0 ˇj T 304n , a contradiction. To prove the last statements, let x be a vertex of P maximizing c 0 x, and let y be another vertex of P . By the assumption on the size of the vertices of P we may write x y D ˛1 ´, where ˛ 2 f1; 2; : : : ; T 2n 1g and ´ is an integral vector whose components have absolute value at most K2 . Then ! n X 1 0 n i 1 K c´ C K ´i : 0 c .x y/ D ˛ i D1

Pn

Since K n > i D1 K i 1 j´i j, we must have c´ 0 and hence cx cy. So x indeed maximizes cx over P . Moreover, since ´ 6D 0, we obtain c 0 .x y/ as required.

1 > T 2n ; ˛

Theorem 4.21. Let n 2 N and c 2 Qn . Let P Rn be a rational polytope, and let x0 2 Qn be a point in the interior of P . Let T 2 N such that size.x0 / log T and size.x/ log T for all vertices x of P .

4.6

Separation and Optimization

95

Given n, c, x0 , T and a polynomial-time oracle for the SEPARATION PROBfor P , a vertex x of P attaining maxfc > x W x 2 P g can be found in time polynomial in n, log T and size.c/. LEM

Proof: (Grötschel, Lovász and Schrijver [1981]) We first use the GRÖTSCHELLOVÁSZ-SCHRIJVER ALGORITHM to solve the WEAK OPTIMIZATION PROBLEM; we set c 0 , r and R according to Lemma 4.20 and WD 8nT 12nC3 . (We first have to make c integral by multiplying with the product of its denominators; this increases its size by at most a factor 2n.) The GRÖTSCHEL-LOVÁSZ-SCHRIJVER ALGORITHM returns a vector y 2 P with c 0 y c 0 x , where x is an optimum of maxfc 0 x W x 2 P g. By 6 2 solution 4 Theorem time is O n ˛ C n ˛f .size.c 0 /; size./; nsize.x0 /C 4.19 the 6running 3 2 4 n ˛/ D O n ˛ C n ˛f .size.c 0 /; 6n log T; n log T C n3 ˛/ , where ˛ D 2

0

2

0

jj;1g log.16n5 T 400n 2size.c / / D O.n2 log T C size.c 0 // and f log R maxfjjc r is a polynomial upper bound of the running time of the oracle for the SEPARATION PROBLEM for P . Since size.c 0 / 6n2 log T C2size.c/, we have an overall running time that is polynomial in n, log T and size.c/. We claim that jjx yjj 2T1 2 . To see this, write y as a convex combination of the vertices x ; x1 ; : : : ; xk of P :

y D 0 x C

k X

i xi ;

i 0;

i D1

k X

i D 1:

i D0

Now – using Lemma 4.20 – c 0 .x y/ D

k X

k X i c 0 x xi > i T 2n D .1 0 /T 2n ;

i D1

i D1

so 1 0 < T 2n . We conclude that

jjy x jj

k X

i jjxi x jj .1 0 /2R < 4nT 2nC1

i D1

1 : 2T 2

So when rounding each entry of y to the next rational number with denominator at most T , we obtain x . The rounding can be done in polynomial time by Theorem 4.8. We have proved that, under certain assumptions, optimizing over a polytope can be done whenever there is a separation oracle. We close this chapter by noting that the converse is also true. We need the concept of polarity: If X Rn , we define the polar of X to be the set X ı WD fy 2 Rn W y > x 1 for all x 2 X g: When applied to full-dimensional polytopes, this operation has some nice properties:

96

4 Linear Programming Algorithms

Theorem 4.22. Let P be a polytope in Rn with 0 in the interior. Then: (a) P ı is a polytope with 0 in the interior; (b) .P ı /ı D P ; (c) x is a vertex of P if and only if x > y 1 is a facet-defining inequality of P ı . Proof: (a): Let P be the convex hull of x1 ; : : : ; xk (cf. Theorem 3.31). By definition, P ı D fy 2 Rn W y > xi 1 for all i 2 f1; : : : ; kgg, i.e. P ı is a polyhedron and the facet-defining inequalities of P ı are given by vertices of P . Moreover, 0 is in the interior of P ı because 0 satisfies all of the finitely many inequalities strictly. Suppose P ı is unbounded, i.e. there exists a w 2 Rn n f0g with ˛w 2 P ı for all ˛ > 0. Then ˛wx 1 for all ˛ > 0 and all x 2 P , so wx 0 for all x 2 P . But then 0 cannot be in the interior of P . (b): Trivially, P .P ı /ı . To show the converse, suppose that ´ 2 .P ı /ı n P . Then there is an inequality c > x ı satisfied by all x 2 P but not by ´. We have ı > 0 since 0 is in the interior of P . Then 1ı c 2 P ı but 1ı c > ´ > 1, contradicting the assumption that ´ 2 .P ı /ı . (c): We have already seen in (a) that the facet-defining inequalities of P ı are given by vertices of P . Conversely, if x1 ; : : : ; xk are the vertices of P , then PN WD conv.f 21 x1 ; x2 ; : : : ; xk g/ 6D P , and 0 is in the interior of PN . Now (b) implies PN ı 6D P ı . Hence fy 2 Rn W y > x1 2; y > xi 1.i D 2; : : : ; k/g D PN ı 6D P ı D fy 2 Rn W y > xi 1.i D 1; : : : ; k/g. We conclude that x1> y 1 is a facet-defining inequality of P ı . Now we can prove: Theorem 4.23. Let n 2 N and y 2 Qn . Let P Rn be a rational polytope, and let x0 2 Qn be a point in the interior of P . Let T 2 N such that size.x0 / log T and size.x/ log T for all vertices x of P . Given n, y, x0 , T and an oracle which for any given c 2 Qn returns a vertex x of P attaining maxfc > x W x 2 P g, we can solve the SEPARATION PROBLEM for P and y in time polynomial in n, log T and size.y/. Indeed, in the case y … P we can find a facet-defining inequality of P that is violated by y. Proof: Consider Q WD fx x0 W x 2 P g and its polar Qı . If x1 ; : : : ; xk are the vertices of P , we have Qı D f´ 2 Rn W ´> .xi x0 / 1 for all i 2 f1; : : : ; kgg: By Theorem 4.4 we have size.´/ 4n.4n log T C3n/ 28n2 log T for all vertices ´ of Qı . Observe that the SEPARATION PROBLEM for P and y is equivalent to the SEPARATION PROBLEM for Q and y x0 . Since by Theorem 4.22 Q D .Q ı /ı D fx W ´x 1 for all ´ 2 Qı g; the SEPARATION PROBLEM for Q and y x0 is equivalent to solving maxf.y x0 /> x W x 2 Qı g. Since each vertex of Q ı corresponds to a facet-defining

Exercises

97

inequality of Q (and thus of P ), it remains to show how to find a vertex attaining maxf.y x0 /> x W x 2 Q ı g. To do this, we apply Theorem 4.21 to Q ı . By Theorem 4.22, Qı is fulldimensional with 0 in the interior. We have shown above that the size of the vertices of Qı is at most 28n2 log T . So it remains to show that we can solve the SEPARATION PROBLEM for Q ı in polynomial time. However, this reduces to the optimization problem for Q which can be solved using the oracle for optimizing over P . We finally mention that a new algorithm which is faster than the E LLIPSOID METHOD and also implies the equivalence of optimization and separation has been proposed by Vaidya [1996]. However, this algorithm does not seem to be of practical use either.

Exercises

1. Let A be a nonsingular rational n n-matrix. Prove that size.A1 / 4n2 size.A/. 2. Let n 2, c 2 Rn and y1 ; : : : ; yk 2 f1; 0; 1gn such that 0 < c > yi C1 1 > 2 c yi for i D 1; : : : ; k 1. Prove that then k 3n log n. Hint: Consider the linear program maxfy1> x W yk> x D 1; .yi 2yi C1 /> x 0 .i D 1; : : : ; k 1/g and recall the proof of Theorem 4.4. (M. Goemans) 3. Consider the numbers hi in the CONTINUED FRACTION EXPANSION. Prove that hi Fi C1 for all i , where Fi is the i -th Fibonacci number (F1 D F2 D 1 and Fn D Fn1 C Fn2 for n 3). Observe that p !n p !n ! 1 1C 5 1 5 : Fn D p 2 2 5 Conclude that the number of iterations of the CONTINUED FRACTION EXPANSION is O.log q/. (Grötschel, Lovász and Schrijver [1988]) 4. Show that GAUSSIAN ELIMINATION can be made a strongly polynomial-time algorithm. Hint: First assume that A is integral. Recall the proof of Theorem 4.10 and observe that we can choose d as the common denominator of the entries. (Edmonds [1967]) 5. Let x1 ; : : : ; xk 2 Rl , d WD 1 C dimfx1 ; : : : ; xk g, 1 ; : : : ; k 2 RC with Pk Pk i D1 i D 1, and x WD i D1 i xi . Show how to compute numbers P 1 ; : : : ; k 2 RC , at most d of which are nonzero, such that kiD1 i D 1 and Pk x D i D1 i xi (cf. Exercise 15 of Chapter 3). Show that all computations can be performed in O..k C l/3 / time.

98

4 Linear Programming Algorithms

Hint: Run G ELIMINATION with the matrix A 2 R.lC1/k whose i -th AUSSIAN column is x1i . If d < k, let w 2 Rk be the vector with wcol.i / WD ´i;d C1 (i D 1; : : : ; d ), wcol.d C1/ WD 1 and wcol.i / WD 0 (i D d C 2; : : : ; k); observe that Aw D0. Add a multiple of w to , eliminate at least one vector and iterate. > 6. Let A D ˛b bC 2 Rnn be a symmetric positive semidefinite matrix with 1 ˛ 0 ˛ > 0 and b 2 Rn1 . Let A0 WD 0 C 1 bb > and U WD 1 ˛ b . Prove that 0 I

˛

A D U > A0 U and C ˛1 bb > is positive semidefinite. Iterate and conclude that for any positive semidefinite matrix A there is a matrix U with A D U > U , and such a matrix can be computed with arbitrary precision in O.n3 / steps (some of which consist of computing approximate square roots). Note: This is called Cholesky factorization. It cannot be computed exactly as U can be irrational. 7. Let A be a symmetric positive definite n n-matrix. Let v1 ; : : : ; vn be n orthogonal eigenvectors of A, with corresponding eigenvalues 1 ; : : : ; n . W.l.o.g. jjvi jj D 1 for i D 1; : : : ; n. Prove that then n p o p E.A; 0/ D 1 1 v1 C C n n vn W 2 Rn ; jjjj 1 :

8. 9. 10. 11.

12.

(The eigenvectors correspond to thep axes of symmetry of the ellipsoid.) Conclude that volume .E.A; 0// D det A volume .B.0; 1//. Let E.A; x/ Rn be an ellipsoid and a 2 Rn , and let E.A0 ; x 0 // be as defined on page 83. Prove that f´ 2 E.A; x/ W a´ axg E.A0 ; x 0 /. Prove that the algorithm of Theorem 4.18 solves a linear program maxfcx W Ax bg in O..n C m/9 .size.A/ C size.b/ C size.c//2 / time. Show that the assumption that P is bounded can be omitted in Theorem 4.21. One can detect if the LP is unbounded and otherwise find an optimum solution. Let P R3 be a 3-dimensional polytope with 0 in its interior. Consider again the graph G.P / whose vertices are the vertices of P and whose edges correspond to the 1-dimensional faces of P (cf. Exercises 18 and 19 of Chapter 3). Show that G.P ı / is the planar dual of G.P /. Note: Steinitz [1922] proved that for every simple 3-connected planar graph G there is a 3-dimensional polytope P with G D G.P /. Let G be a simple connected undirected graph. Show that the LP X min xvw eDfv;wg2E.G/

s.t.

X

w2S

xvw

˙1 4

jS j2 C 12 jS j

.v 2 V .G/; S V .G/ n fvg/

xuw xuv C xvw

.u; v; w 2 V .G//

xvw 0

.v; w 2 V .G//

xvv D 0

.v 2 V .G//

References

99

can be solved in time polynomial in jV .G/j. Note: This can be regarded as a relaxation of the OPTIMAL LINEAR ARRANGEMENT PROBLEM ; cf. Exercise 8 of Chapter 19. 13. Prove that the polar of a polyhedron is always a polyhedron. For which polyhedra P is .P ı /ı D P ?

References General Literature: Grötschel, M., Lovász, L., and Schrijver, A. [1988]: Geometric Algorithms and Combinatorial Optimization. Springer, Berlin 1988 Padberg, M. [1999]: Linear Optimization and Extensions. Second edition. Springer, Berlin 1999 Schrijver, A. [1986]: Theory of Linear and Integer Programming. Wiley, Chichester 1986

Cited References: Bland, R.G., Goldfarb, D., and Todd, M.J. [1981]: The ellipsoid method: a survey. Operations Research 29 (1981), 1039–1091 Edmonds, J. [1967]: Systems of distinct representatives and linear algebra. Journal of Research of the National Bureau of Standards B 71 (1967), 241–245 Frank, A., and Tardos, É. [1987]: An application of simultaneous Diophantine approximation in combinatorial optimization. Combinatorica 7 (1987), 49–65 Gács, P., and Lovász, L. [1981]: Khachiyan’s algorithm for linear programming. Mathematical Programming Study 14 (1981), 61–68 Grötschel, M., Lovász, L., and Schrijver, A. [1981]: The ellipsoid method and its consequences in combinatorial optimization. Combinatorica 1 (1981), 169–197 Iudin, D.B., and Nemirovskii, A.S. [1976]: Informational complexity and effective methods of solution for convex extremal problems. Ekonomika i Matematicheskie Metody 12 (1976), 357–369 [in Russian] Karmarkar, N. [1984]: A new polynomial-time algorithm for linear programming. Combinatorica 4 (1984), 373–395 Karp, R.M., and Papadimitriou, C.H. [1982]: On linear characterizations of combinatorial optimization problems. SIAM Journal on Computing 11 (1982), 620–632 Khachiyan, L.G. [1979]: A polynomial algorithm in linear programming [in Russian]. Doklady Akademii Nauk SSSR 244 (1979) 1093–1096. English translation: Soviet Mathematics Doklady 20 (1979), 191–194 Khintchine, A. [1956]: Kettenbrüche. Teubner, Leipzig 1956 Padberg, M.W., and Rao, M.R. [1981]: The Russian method for linear programming III: Bounded integer programming. Research Report 81-39, New York University 1981 Shor, N.Z. [1977]: Cut-off method with space extension in convex programming problems. Cybernetics 13 (1977), 94–96 Steinitz, E. [1922]: Polyeder und Raumeinteilungen. Enzyklopädie der Mathematischen Wissenschaften, Band 3 (1922), 1–139 Tardos, É. [1986]: A strongly polynomial algorithm to solve combinatorial linear programs. Operations Research 34 (1986), 250–256 Vaidya, P.M. [1996]: A new algorithm for minimizing convex functions over convex sets. Mathematical Programming 73 (1996), 291–341

•

5 Integer Programming

In this chapter, we consider linear programs with integrality constraints:

INTEGER PROGRAMMING Instance:

A matrix A 2 Zmn and vectors b 2 Zm ; c 2 Zn .

Task:

Find a vector x 2 Zn such that Ax b and cx is maximum, decide that fx 2 Zn W Ax bg D ;, or decide that supfcx W x 2 Zn ; Ax bg D 1.

We do not consider mixed integer programs, i.e. linear programs with integrality constraints for only a subset of the variables. Most of the theory of linear and integer programming can be extended to mixed integer programming in a natural way.

PI P

Fig. 5.1.

Virtually all combinatorial optimization problems can be formulated as integer programs. The set of feasible solutions can be written as fx W Ax b; x 2 Zn g for some matrix A and some vector b. The set P WD fx 2 Rn W Ax bg is a polyhedron, so let us define by PI D fx W Ax bgI the convex hull of the integral vectors in P . We call PI the integer hull of P . Obviously PI P . B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__5, c Springer-Verlag Berlin Heidelberg 2012

101

102

5 Integer Programming

If P is bounded, then PI is also a polytope by Theorem 3.31 (see Figure 5.1). Meyer [1974] proved: Theorem 5.1. For any rational polyhedron P , its integer hull PI is a rational polyhedron. Proof: Let P D fx W Ax bg. By Lemma 3.12 the rational polyhedral cone C WD f.x; / W x 2 Rn ; 0; Ax b 0g is generated by a finite set of rational vectors. We may assume that .x1 ; 1/; : : : ; .xk ; 1/; .y1 ; 0/; : : : ; .yl ; 0/ generate C , where x1 ; : : : ; xk are rational and y1 ; : : : ; yl are integral (by multiplying the elements of a finite set of generators by suitable positive scalars). Consider the polytope ( k l k X X X Q WD i xi C i yi W i 0 .i D 1; : : : ; k/; i D 1; i D1

i D1

i D1

)

0 i 1 .i D 1; : : : ; l/ : Note that Q P . Let ´1 ; : : : ; ´m be the integral points in Q. By Theorem 3.29 the cone C 0 generated by .y1 ; 0/; : : : ; .yl ; 0/; .´1 ; 1/; : : : ; .´m ; 1/ is polyhedral, i.e. can be written as f.x; / W M x C d 0g for a rational matrix M and a rational vector d . We claim that PI D fx W M x d g. P To show “”, let x 2 P \ Zn . We have .x; 1/ 2 C , i.e. x D kiD1 i xi C Pl Pk i D1 i yi for some 1 ; : : : ; k 0 with i D1 i D 1 and 1 ; : : : ; l 0. Then Pl c WD b cy is integral, and hence x c is integral. Moreover, x c D i i i D1 Pk Pl i D1 i xi C i D1 .i bi c/yi 2 Q, and hence x c D ´i for some i . Thus .x; 1/ D .c; 0/ C .x c; 1/ 2 C 0 and hence M x C d 0. To show “”, let x be a vector satisfying M x d , i.e. .x; 1/ 2 C 0 . Then x D Pl Pm Pm i D1 i yi C i D1 i ´i for some 1 ; : : : ; l ; 1 ; : : : ; m 0 with i D1 i D i 1. W.l.o.g. assume l 1 and 1 > 0. Let 0i WD l for i D 1; : : : ; l. Then 1 .´1 C yi ; 1/ 2 C for all i D 1; : : : ; l and > 0 and hence xD

l X 1 0 bi c C 1 0i ´1 C b0i cyi l i D1

C

l m X X 1 0 i b0i c ´1 C .b0i c C 1/yi C i ´i l i D1

is a convex combination of integral points in P .

i D2

This does in general not hold for irrational polyhedra; see Exercise 1. Due to Theorem 5.1 we can write an instance of I NTEGER PROGRAMMING as maxfc > x W x 2 PI g where P D fx W Ax bg.

5.1

The Integer Hull of a Polyhedron

103

We prove a generalization of Meyer’s Theorem 5.1 in Section 5.1 (Theorem 5.8). After some preparation in Section 5.2 we study conditions under which polyhedra are integral (i.e. P D PI ) in Sections 5.3 and 5.4. Note that in this case the integer linear program is equivalent to its LP relaxation (arising by omitting the integrality constraints), and can hence be solved in polynomial time. We shall encounter this situation for several combinatorial optimization problems in later chapters. In general, however, INTEGER PROGRAMMING is much harder than L INEAR PROGRAMMING, and polynomial-time algorithms are not known. This is indeed not surprising since we can formulate many apparently hard problems as integer programs. Nevertheless we discuss a general method for finding the integer hull by successively cutting off parts of P n PI in Section 5.5. Although it does not yield a polynomial-time algorithm it is a useful technique in some cases. Finally Section 5.6 contains an efficient way of approximating the optimal value of an integer linear program.

5.1 The Integer Hull of a Polyhedron As linear programs, integer programs can be infeasible or unbounded. It is not easy to decide whether PI D ; for a polyhedron P . But if an integer program is feasible we can decide whether it is bounded by simply considering the LP relaxation. Proposition 5.2. Let P D fx W Ax bg be some rational polyhedron whose integer hull is nonempty, and let c be some vector (not necessarily rational). Then max fcx W x 2 P g is bounded if and only if max fcx W x 2 PI g is bounded. Proof: Suppose max fcx W x 2 P g is unbounded. Then Corollary 3.28 says that the system yA D c; y 0 has no solution. By Corollary 3.26 there is a vector ´ with c´ < 0 and A´ 0. Then the LP minfc´ W A´ 0; 1l ´ 1lg is feasible. Let ´ be an optimum basic solution of this LP. ´ is rational as it is a vertex of a rational polytope. Multiply ´ by a suitable natural number to obtain an integral vector w with Aw 0 and cw < 0. Let v 2 PI be some integral vector. Then v kw 2 PI for all k 2 N, and thus max fcx W x 2 PI g is unbounded. The other direction is trivial. Definition 5.3. Let A be an integral matrix. A subdeterminant of A is det B for some square submatrix B of A (defined by arbitrary row and column indices). We write „.A/ for the maximum absolute value of the subdeterminants of A. Lemma 5.4. Let C D fx W Ax 0g be a polyhedral cone, where A is an integral matrix. Then C is generated by a finite set of integral vectors, each having components with absolute value at most „.A/. Proof: By Lemma 3.12, C is generated by some of the vectors y1 ; : : : ; y t , such that for each i , yi is the solution to a system My D b 0 where M consists of n

104

5 Integer Programming

0 linearly independent rows of A I and b D ˙ej for some unit vector ej . Set ´i WD j det M jyi . By Cramer’s rule, ´i is integral with jj´i jj1 „.A/. Since this holds for each i , the set f´1 ; : : : ; ´ t g has the required properties. A similar lemma will be used in the next section: Lemma 5.5. Each rational polyhedral cone C is generated by a finite set of integral vectors fa1 ; : : : ; a t g such that each integral vector in C is a nonnegative integral combination of a1 ; : : : ; a t . (Such a set is called a Hilbert basis for C .) Proof: Let C be generated by the integral vectors b1 ; : : : ; bk . Let a1 ; : : : ; a t be all integral vectors in the polytope f1 b1 C : : : C k bk W 0 i 1 .i D 1; : : : ; k/g We show that fa1 ; : : : ; a t g is a Hilbert basis for C . They indeed generate C , because b1 ; : : : ; bk occur among the a1 ; : : : ; a t . For any integral vector x 2 C there are 1 ; : : : ; k 0 with x D 1 b1 C : : : C k bk D b1 cb1 C : : : C bk cbk C .1 b1 c/b1 C : : : C .k bk c/bk ; so x is a nonnegative integral combination of a1 ; : : : ; a t .

An important basic fact in integer programming is that optimum integral and fractional solutions are not too far away from each other: Theorem 5.6. (Cook et al. [1986]) Let A be an integral mn-matrix and b 2 Rm , c 2 Rn arbitrary vectors. Let P WD fx W Ax bg and suppose that PI 6D ;. (a) Suppose y is an optimum solution of max fcx W x 2 P g. Then there exists an optimum integral solution ´ of max fcx W x 2 PI g with jj´ yjj1 n „.A/. (b) Suppose y is a feasible integral solution of max fcx W x 2 PI g, but not an optimal one. Then there exists a feasible integral solution ´ 2 PI with c´ > cy and jj´ yjj1 n „.A/. Proof: The proof is almost the same for both parts. Let first y 2 P arbitrary. Let ´ 2 P \ Zn be (a) an optimum solution of max fcx W x 2 PI g (note that PI D fx W Ax bbcgI is a polyhedron by Theorem 5.1, and thus the maximum is attained) or (b) a vector with c´ > cy. We split Ax b into two subsystems A1 x b1 , A2 x b2 such that A1 ´ A1 y and A2 ´ < A2 y. Then ´ y belongs to the polyhedral cone C WD fx W A1 x 0; A2 x 0g. C is generated by some vectors xi (i D 1; : : : ; s). By Lemma 5.4, we may assume that xi is integral and jjxi jj1 „.A/ for all i . Ps Since ´ y 2 C , there are nonnegative numbers 1 ; : : : ; s with ´ y D i D1 i xi . We may assume that at most n of the i are nonzero.

5.1

The Integer Hull of a Polyhedron

105

For D .1 ; : : : ; s / with 0 i i (i D 1; : : : ; s) we define ´ WD ´

s X

i xi D y C

i D1

s X .i i /xi i D1

and observe that ´ 2 P : the first representation of ´ implies A1 ´ A1 ´ b1 ; the second one implies A2 ´ A2 y b2 . Case 1: There is some i 2 f1; : : : ; sg with i 1 and cxi > 0. Let ´ WD y C xi . We have c´ > cy, showing that this case cannot occur in case (a). In case (b), when y is integral, ´ is an integral solution of Ax b such that c´ > cy and jj´ yjj1 D jjxi jj1 „.A/. Case 2: For all i 2 f1; : : : ; sg, i 1 implies cxi 0. Let ´ WD ´bc D ´

s X

bi c xi :

i D1

´ is an integral vector of P with c´ c´ and jj´ yjj1

s X

.i bi c/ jjxi jj1 n „.A/:

i D1

Hence in both (a) and (b) this vector ´ does the job.

As a corollary we can bound the size of optimum solutions of integer programming problems: Corollary 5.7. If P D fx 2 Qn W Ax bg is a rational polyhedron and maxfcx W x 2 PI g has an optimum solution, then it also has an optimum integral solution x with size.x/ 13n.size.A/ C size.b//. Proof: By Proposition 5.2 and Theorem 4.4, maxfcx W x 2 P g has an optimum solution y with size.y/ 4n.size.A/ C size.b//. By Theorem 5.6(a) there is an optimum solution x of maxfcx W x 2 PI g with jjx yjj1 n „.A/. By Propositions 4.1 and 4.3 we have size.x/ 2size.y/ C 2nsize.n „.A// 8n.size.A/ C size.b// C 2n log n C 4nsize.A/ 13n.size.A/ C size.b//: Theorem 5.6(b) implies the following: given any feasible solution of an integer program, optimality of a vector x can be checked simply by testing x C y for a finite set of vectors y that depend on the matrix A only. Such a finite test set (whose existence has been proved first by Graver [1975]) enables us to prove a fundamental theorem on integer programming:

106

5 Integer Programming

Theorem 5.8. (Wolsey [1981], Cook et al. [1986]) For each integral mn-matrix A there exists an integral matrix M whose entries have absolute value at most n2n „.A/n , such that for each vector b 2 Qm there exists a rational vector d with fx W Ax bgI D fx W M x d g: Proof: We may assume A ¤ 0. Let C be the cone generated by the rows of A. Let L WD f´ 2 Zn W jj´jj1 n„.A/g: For each K L, consider the cone CK WD C \ fy W ´y 0 for all ´ 2 Kg: By the proof of Theorem 3.29 and Lemma 5.4, CK D fy W Uy 0g for some integral matrix U (whose rows are generators of fx W Ax 0g and elements of K) whose entries have absolute value at most n„.A/. Hence, again by Lemma 5.4, there is a finite set G.K/ of integral vectors generating CK , each having components with absolute value at most „.U / SnŠ.n„.A//n n2n „.A/n . Let M be the matrix with rows KL G.K/. Since C; D C , we may assume that the rows of A are also rows of M . Now let b be some fixed vector. If Ax b has no solution, we can complete b to a vector d arbitrarily and have fx W M x d g fx W Ax bg D ;. If Ax b contains a solution, but no integral solution, we set b 0 WD b A0 1l, where A0 arises from A by taking the absolute value of each entry. Then Ax b 0 has no solution, since any such solution yields an integral solution of Ax b by rounding. Again, we complete b 0 to d arbitrarily. Now we may assume that Ax b has an integral solution. For y 2 C we define ıy WD max fyx W Ax b; x integralg (by Corollary 3.28 this maximum is bounded for y 2 C ). It suffices to show that 8 9 < = [ G.K/ : (5.1) fx W Ax bgI D x W yx ıy for each y 2 : ; KL

Here “” is trivial. To show the converse, let c be any vector for which max fcx W Ax b; x integralg is bounded, and let x be a vector attaining this maximum. We show that cx cx for all x satisfying the inequalities on the right-hand side of (5.1). By Proposition 5.2 the LP max fcx W Ax bg is bounded, so by Corollary 3.28 we have c 2 C . N so Let KN WD f´ 2 L W A.x C ´/ bg. By definition c´ 0 for all ´ 2 K, N c 2 CKN . Thus there are nonnegative numbers y (y 2 G.K// such that

5.2

c D

X

Unimodular Transformations

107

y y:

N y2G.K/

Next we claim that x is an optimum solution for max fyx W Ax b; x integralg N the contrary assumption would, by Theorem 5.6(b), yield a for each y 2 G.K/: N vector ´ 2 K with y´ > 0, which is impossible since y 2 CKN . We conclude that 0 1 X X X y ıy D y yx D @ y y A x D cx : N y2G.K/

N y2G.K/

N y2G.K/

Thus the inequality cx cx is a nonnegative linear combination of the inequalities N Hence (5.1) is proved. yx ıy for y 2 G.K/. See Lasserre [2004] for a similar result.

5.2 Unimodular Transformations In this section we shall prove two lemmas for later use. A square matrix is called unimodular if it is integral and has determinant 1 or 1. Three types of unimodular matrices will be of particular interest: For n 2 N, p 2 f1; : : : ; ng and q 2 f1; : : : ; ng n fpg consider the matrices .aij /i;j 2f1;:::;ng defined in one of the following ways: 8 8 ˆ ˆ if i D j 6D p ˇ. Then clearly (f) is violated, since max fax W x 2 P g (which is finite by Proposition 5.2) is not attained by any integral vector. (b))(d) is also trivial since the intersection of a supporting hyperplane with P is a face of P . (d))(e) and (c))(b) are trivial. (e))(c): Let P D fx W Ax bg. We may assume that A and b are integral. Let F D fx W A0 x D b 0 g be a minimal face of P , where A0 x b 0 is a subsystem of Ax b (we use Proposition 3.9). If A0 x D b 0 has no integral solution, then – by Lemma 5.11 – there exists a rational vector y such that c WD yA0 is integral but ı WD yb 0 is not an integer. Adding integers to components of y does not destroy this property (A0 and b 0 are integral), so we may assume that all components of y are positive. Observe that H WD fx W cx D ıg is a rational hyperplane which contains no integral vectors. We finally show that H is a supporting hyperplane by proving that H \ P D F . Since F H is trivial, it remains to show that H \ P F . But for x 2 H \ P we have yA0 x D cx D ı D yb 0 , so y.A0 x b 0 / D 0. Since y > 0 and A0 x b 0 , this implies A0 x D b 0 , so x 2 F . (f))(g) is trivial, so we finally show (g))(e). Let H D fx W cx D ıg be a rational supporting hyperplane of P , so maxfcx W x 2 P g D ı. Suppose H

110

5 Integer Programming

contains no integral vectors. Then – by Lemma 5.11 – there exists a number such that c is integral but ı … Z. Then maxf.j jc/x W x 2 P g D j j maxfcx W x 2 P g D j jı … Z;

contradicting our assumption.

See also Gomory [1963], Fulkerson [1971] and Chvátal [1973] for earlier partial results. By (a),(b) and Corollary 3.6 every face of an integral polyhedron is integral. The equivalence of (f) and (g) of Theorem 5.13 motivated Edmonds and Giles to define TDI-systems: Definition 5.14. (Edmonds and Giles [1977]) A system Ax b of linear inequalities is called totally dual integral (TDI) if the minimum in the LP duality equation max fcx W Ax bg D min fyb W yA D c; y 0g has an integral optimum solution y for each integral vector c for which the minimum is finite. With this definition we get an easy corollary of (g))(a) of Theorem 5.13: Corollary 5.15. Let Ax b be a TDI-system where A is rational and b is integral. Then the polyhedron fx W Ax bg is integral. But total dual integrality is not a property of polyhedra (cf. Exercise 8). In general, a TDI-system contains more inequalities than necessary for describing the polyhedron. Adding valid inequalities does not destroy total dual integrality: Proposition 5.16. If Ax b is TDI and ax ˇ is a valid inequality for fx W Ax bg, then the system Ax b; ax ˇ is also TDI. Proof: Let c be an integral vector such that min fyb C ˇ W yA C a D c; y 0; 0g is finite. Since ax ˇ is valid for fx W Ax bg, min fyb W yA D c; y 0g D max fcx W Ax bg D max fcx W Ax b; ax ˇg D min fyb C ˇ W yA C a D c; y 0; 0g: The first minimum is attained by some integral vector y , so y D y ; D 0 is an integral optimum solution for the second minimum. Theorem 5.17. (Giles and Pulleyblank [1979]) For each rational polyhedron P there exists a rational TDI-system Ax b with A integral and P D fx W Ax bg. Here b can be chosen to be integral if and only if P is integral.

5.3

Total Dual Integrality

111

Proof: Let P D fx W C x d g with C and d integral. W.l.o.g., P 6D ;. For each minimal face F of P let KF WD fc W c´ D max fcx W x 2 P g for all ´ 2 F g: By Corollary 3.22 and Theorem 3.29, KF is a rational polyhedral cone. By Lemma 5.5 there exists an integral Hilbert basis a1 ; : : : ; a t generating KF . Let S F be the system of inequalities a1 x max fa1 x W x 2 P g ; : : : ; a t x max fa t x W x 2 P g: Let Ax b be the collection of all these systems SF (for all minimal faces F ). Note that if P is integral then b is integral. Moreover, P fx W Ax bg. Let c be an integral vector for which max fcx W x 2 P g is finite. The set of vectors attaining this maximum is a face of P , so let F be a minimal face such that c´ D max fcx W x 2 P g for all ´ 2 F . Let SF be the system a1 x ˇ1 ; : : : ; a t x ˇ t . Then c D 1 a1 C C t a t for some nonnegative integers 1 ; : : : ; t . We add N Dc zero components to 1 ; : : : ; t in order to get an integral vector N 0 with A N N N D .A´/ N N and thus cx D .A/x D .Ax/ b D .A/´ D c´ for all x with Ax b and all ´ 2 F . Applying this for each row c of C yields C x d for all x with Ax b; and thus P D fx W Ax bg. Moreover, for general c we conclude that N is an optimum solution of the dual LP min fyb W y 0; yA D cg. Hence Ax b is TDI. If P is integral, we have chosen b to be integral. Conversely, if b can be chosen integral, by Corollary 5.15 P must be integral. Indeed, for full-dimensional rational polyhedra there is a unique minimal TDIsystem describing it (Schrijver [1981]). For later use, we prove that each “face” of a TDI-system is again TDI: Theorem 5.18. (Cook [1983]) Let Ax b; ax ˇ be a TDI-system, where a is integral. Then the system Ax b; ax D ˇ is also TDI. Proof: (Schrijver [1986]) Let c be an integral vector such that max fcx W Ax b; ax D ˇg D min fyb C . /ˇ W y; ; 0; yA C . /a D cg

(5.2)

is finite. Let x ; y ; ; attain these optima. We set c 0 WD c Cd ea and observe that max fc 0 x W Ax b; ax ˇg D min fyb Cˇ W y; 0; yACa D c 0 g (5.3) is finite, because x WD x is feasible for the maximum and y WD y ; WD C d e is feasible for the minimum. Since Ax b; ax ˇ is TDI, the minimum in (5.3) has an integral optimum Q We finally set y WD y; solution y; Q . Q WD Q and WD d e and claim that .y; ; / is an integral optimum solution for the minimum in (5.2).

112

5 Integer Programming

Obviously .y; ; / is feasible for the minimum in (5.2). Furthermore, Q d eˇ yb C . /ˇ D yb Q C ˇ y b C . C d e /ˇ d eˇ Q is an since .y ; C d e / is feasible for the minimum in (5.3), and .y; Q / optimum solution. We conclude that yb C . /ˇ y b C . /ˇ; proving that .y; ; / is an integral optimum solution for the minimum in (5.2). The following statements are straightforward consequences of the definition of TDI-systems: A system Ax D b; x 0 is TDI if min fyb W yA cg has an integral optimum solution y for each integral vector c for which the minimum is finite. A system Ax b; x 0 is TDI if min fyb W yA c; y 0g has an integral optimum solution y for each integral vector c for which the minimum is finite. One may ask whether there are matrices A such that Ax b; x 0 is TDI for each integral vector b. It will turn out that these matrices are exactly the totally unimodular matrices.

5.4 Totally Unimodular Matrices Definition 5.19. A matrix A is totally unimodular if each subdeterminant of A is 0, C1, or 1. In particular, each entry of a totally unimodular matrix must be 0, C1, or 1. The main result of this section is: Theorem 5.20. (Hoffman and Kruskal [1956]) An integral matrix A is totally unimodular if and only if the polyhedron fx W Ax b; x 0g is integral for each integral vector b. Proof: Let A be an m n-matrix and P WD fx W Ax b; x 0g. Observe that the minimal faces of P are vertices. To prove necessity, suppose that A is totally unimodular. Let b be some integral vector and xa vertex of solution of A0 x D b 0 for some subsystem P . x is the 0 0 0 A b A x b of I x 0 , with A being a nonsingular n n-matrix. Since A is totally unimodular, j det A0 j D 1, so by Cramer’s rule x D .A0 /1 b 0 is integral. We now prove sufficiency. Suppose that the vertices of P are integral for each integral vector b. Let A0 be some nonsingular kk-submatrix of A. We have to show j det A0 j D 1. W.l.o.g., A0 contains the elements of the first k rows and columns of A. Consider the integral m m-matrix B consisting of the first k and the last m k columns of .A I / (see Figure 5.2). Obviously, j det Bj D j det A0 j.

5.4 n− k

k

k

A

Totally Unimodular Matrices

k

m − k

I

0

113

(A I) m − k

0

0

I

0

z

z

Fig. 5.2.

To prove j det Bj D 1, we shall prove that B 1 is integral. Since det B det B 1 D 1, this implies that j det Bj D 1, and we are done. Let i 2 f1; : : : ; mg; we prove that B 1 ei is integral. Choose an integral vector y such that ´ WD y C B 1 ei 0. Then b WD B´ D By C ei is integral. We add zero components to ´ in order to obtain ´0 with A I ´0 D B´ D b: Now ´00 , consisting of the first n components of ´0 , belongs to P . Furthermore, n linearly independent constraints are satisfied with equality, namely the first k and the last n k inequalities of A b ´00 : I 0 Hence ´00 is a vertex of P . By our assumption ´00 is integral. But then ´0 must also be integral: its first n components are the components of ´00 , and the last m components are the slack variables b A´00 (and A and b are integral). So ´ is also integral, and hence B 1 ei D ´ y is integral. The above proof is due to Veinott and Dantzig [1968]. Corollary 5.21. An integral matrix A is totally unimodular if and only if for all integral vectors b and c both optima in the LP duality equation max fcx W Ax b; x 0g D min fyb W y 0; yA cg are attained by integral vectors (if they are finite).

114

5 Integer Programming

Proof: This follows from the Hoffman-Kruskal Theorem 5.20 by using the fact that the transpose of a totally unimodular matrix is also totally unimodular. Let us reformulate these statements in terms of total dual integrality: Corollary 5.22. An integral matrix A is totally unimodular if and only if the system Ax b; x 0 is TDI for each vector b. Proof: If A (and thus A> ) is totally unimodular, then by the Hoffman-Kruskal Theorem min fyb W yA c; y 0g is attained by an integral vector for each vector b and each integral vector c for which the minimum is finite. In other words, the system Ax b; x 0 is TDI for each vector b. To show the converse, suppose Ax b; x 0 is TDI for each integral vector b. Then by Corollary 5.15, the polyhedron fx W Ax b; x 0g is integral for each integral vector b. By Theorem 5.20 this means that A is totally unimodular. This is not the only way how total unimodularity can be used to prove that a certain system is TDI. The following lemma contains another proof technique; this will be used several times later (Theorems 6.14, 19.17 and 14.12). Lemma 5.23. Let Ax b; x 0 be an inequality system, where A 2 Rmn and b 2 Rm . Suppose that for each c 2 Zn for which minfyb W yA c; y 0g has an optimum solution, it has one y such that the rows of A corresponding to nonzero components of y form a totally unimodular matrix. Then Ax b; x 0 is TDI. Proof: Let c 2 Zn , and let y be an optimum solution of minfyb W yA c; y 0g such that the rows of A corresponding to nonzero components of y form a totally unimodular matrix A0 . We claim that minfyb W yA c; y 0g D minfyb 0 W yA0 c; y 0g;

(5.4)

where b 0 consists of the components of b corresponding to the rows of A0 . To see the inequality “” of (5.4), observe that the LP on the right-hand side arises from the LP on the left-hand side by setting some variables to zero. The inequality “” follows from the fact that y without zero components is a feasible solution for the LP on the right-hand side. Since A0 is totally unimodular, the second minimum in (5.4) has an integral optimum solution (by the Hoffman-Kruskal Theorem 5.20). By filling this solution with zeros we obtain an integral optimum solution to the first minimum in (5.4), completing the proof. A very useful criterion for total unimodularity is the following: Theorem 5.24. (Ghouila-Houri [1962]) A matrix A D .aij / 2 Zmn is totally : unimodular if and only if for every R f1; : : : ; mg there is a partition R D R1 [ R2 such that

5.4

X i 2R1

aij

X

Totally Unimodular Matrices

115

aij 2 f1; 0; 1g

i 2R2

for all j D 1; : : : ; n. Proof: Let A be totally unimodular, and let R f1; : : :; mg. Let dr WD 1 for A> r 2 R and dr WD 0 for r 2 f1; : : : ; mg n R. The matrix A> is also totally I

unimodular, so by Theorem 5.20 the polytope

1 1 x W xA dA ; xA dA ; x d; x 0 2 2 is integral. Moreover it is nonempty because it contains 12 d . So it has an integral vertex, say ´. Setting R1 WD fr 2 R W ´r D 0g and R2 WD fr 2 R W ´r D 1g we obtain 0 1 X X @ aij aij A D .d 2´/A 2 f1; 0; 1gn; i 2R1

i 2R2

1j n

as required. We now prove the converse. By induction on k we prove that every k ksubmatrix has determinant 0, 1 or 1. For k D 1 this is directly implied by the criterion for jRj D 1. Now let k > 1, and let B D .bij /i;j 2f1;:::;kg be a nonsingular k k-submatrix B0 0 of A. By Cramer’s rule, each entry of B 1 is det det B , where B arises from B by replacing a column by a unit vector. By the induction hypothesis, det B 0 2 f1; 0; 1g. So B WD .det B/B 1 is a matrix with entries 1; 0; 1 only. Let b1 be the first row of B . We have b1 B D .det B/e1 , where e1 is the first unit vector. Let R WD fi W b1i 6D 0g. Then for j D 2; : : : ; k we have 0 D .b1 B/j D P i 2R b1i bij , so jfi 2 R W bij 6D 0gj is even. : P By the hypothesis there is a partition R D R [ R2 with Pi 2R1 bij 1 P for all j . SoP for j D 2; : : : ; k we have i 2R1 bij Pi 2R2 bij 2 f1; 0; 1g P b D 0. If also b i 2R2 ij i 2R1 i1 i 2R2 bi1 D 0, then the sum of the rows in R1 equals the sum of the rows in R2 , contradicting the assumption that B is nonsingular R 6D ;). P (becauseP So i 2R1 bi1 i 2R2 bi1 2 f1; 1g and we have yB 2 fe1 ; e1 g, where 8 ˆ if i 2 R1 jE.B 0 /j we have

6.2

Minimum Weight Arborescences

139

c 0 .E.B// > c 0 .E.B 0 // (and branchings with n 1 edges are exactly the spanning arborescences). Given an instance .G; c/ of the MAXIMUM WEIGHT BRANCHING PROBLEM, : let G 0 WD .V .G/ [ frg; E.G/ [ f.r; v/ W v 2 V .G/g/. Let c 0 .e/ WD c.e/ for e 2 E.G/ and c.e/ WD 0 for e 2 E.G 0 / n E.G/. Then the instance .G 0 ; r; c 0 / of the MINIMUM WEIGHT ROOTED ARBORESCENCE PROBLEM is equivalent. Finally, given an instance .G; r; c/ of the MINIMUM WEIGHT ROOTED : ARBORESCENCE PROBLEM, let G 0 WD .V .G/ [ fsg; E.G/ [ f.s; r/g/ and c..s; r// WD 0. Then the instance .G 0 ; c/ of the MINIMUM WEIGHT ARBORESCENCE PROBLEM is equivalent. In the rest of this section we shall deal with the M AXIMUM WEIGHT BRANCHPROBLEM only. This problem is not as easy as its undirected version, the M AXIMUM WEIGHT FOREST PROBLEM . For example any maximal forest is maximum, but the bold edges in Figure 6.1 form a maximal branching which is not maximum. ING

Fig. 6.1.

Recall that a branching is a graph B with jıB .x/j 1 for all x 2 V .B/, such that the underlying undirected graph is a forest. Equivalently, a branching is an acyclic digraph B with jıB .x/j 1 for all x 2 V .B/; see Theorem 2.5(g): Proposition 6.10. Let B be a digraph with jıB .x/j 1 for all x 2 V .B/. Then B contains a circuit if and only if the underlying undirected graph contains a circuit. Now let G be a digraph and c W E.G/ ! RC . We can ignore negative weights since such edges will never appear in an optimum branching. A first idea towards an algorithm could be to take the best entering edge for each vertex. Of course the resulting graph may contain circuits. Since a branching cannot contain circuits, we must delete at least one edge of each circuit. The following lemma says that one is enough. Lemma 6.11. (Karp [1972]) Let B0 be a maximum weight subgraph of G with jıB0 .v/j 1 for all v 2 V .B0 /. Then there exists an optimum branching B of G such that for each circuit C in B0 , jE.C / n E.B/j D 1. Proof: Let B be an optimum branching of G containing as many edges of B0 as possible. Let C be some circuit in B0 . Let E.C /nE.B/ D f.a1 ; b1 /; : : : ; .ak ; bk /g;

140

6 Spanning Trees and Arborescences a1

b1

C a2

b3

a3

b2

Fig. 6.2.

suppose that k 2 and a1 ; b1 ; a2 ; b2 ; a3 ; : : : ; bk lie in this order on C (see Figure 6.2). We claim that B contains a bi -bi 1 -path for each i D 1; : : : ; k (b0 WD bk ). This, however, is a contradiction because these paths form a closed edge progression in B, and a branching cannot have a closed edge progression. Let i 2 f1; : : : ; kg. It remains to show that B contains a bi -bi 1 -path. Consider B 0 with V .B 0 / D V .G/ and E.B 0 / WD f.x; y/ 2 E.B/ W y 6D bi g [ f.ai ; bi /g. B 0 cannot be a branching since it would be optimum and contain more edges of B0 than B. So (by Proposition 6.10) B 0 contains a circuit, i.e. B contains a bi -ai path P . Since k 2, P is not completely on C , so let e be the last edge of P not belonging to C . Obviously e D .x; bi 1 / for some x, so P (and thus B) contains a bi -bi 1 -path. The main idea of Edmonds’ [1967] algorithm is to find first B0 as above, and then contract every circuit of B0 in G. If we choose the weights of the resulting graph G1 correctly, any optimum branching in G1 will correspond to an optimum branching in G.

EDMONDS’ BRANCHING ALGORITHM Input:

A digraph G, weights c W E.G/ ! RC .

Output:

A maximum weight branching B of G.

1

Set i WD 0, G0 WD G, and c0 WD c.

2

Let Bi be a maximum weight subgraph of Gi with jıBi .v/j 1 for all v 2 V .Bi /. If Bi contains no circuit then set B WD Bi and go to . 5

3

6.2

4

5

Minimum Weight Arborescences

141

. Contract these circuits: Let C be the set of circuits in BiS Let V .Gi C1 / WD C [ .V .Gi / n C 2C V .C //. 0 For e D .v; w/ 2 E.Gi / let e 0 D .v 0 ; w 0 / and ˆi C1 .e S/ WD e, where v 0 D C if v 2 V .C / for C 2 C, and v 0 D v if v … CS2C V .C /, and w 0 D C if w 2 V .C / for C 2 C, and w 0 D w if w … C 2C V .C /. Let E.Gi C1 / WD fe 0 D .v 0 ; w 0 / W e 2 E.Gi /; v 0 6D w 0 g (parallel edges may arise). For e D .v; w/ 2 E.Gi / with e 0 D .v 0 ; w 0 / 2 E.Gi C1 / set ci C1 .e 0 / WD ci .e/ if w 0 … C, and ci C1 .e 0 / WD ci .e/ ci .˛.e; C // C ci .eC / if w 0 D C 2 C, where ˛.e; C / 2 ıC .w/ and eC is some cheapest edge of C . Set i WD i C 1 and go to . 2 While i > 0 do: Set B 0 WD .V .Gi 1 /; fˆi .e/ W e 2 E.B/g/. For each circuit C of Bi 1 do: If there is an edge e 2 ıB0 .V .C // then set E.B 0 / WD E.B 0 / [ .E.C / n f˛.e; C /g/ else set E.B 0 / WD E.B 0 / [ .E.C / n feC g/. Set B WD B 0 and i WD i 1.

This algorithm was also discovered independently by Chu and Liu [1965] and Bock [1971]. Theorem 6.12. (Edmonds [1967]) EDMONDS’ BRANCHING ALGORITHM works correctly. Proof: We show that in , 5 B is always an optimum branching of Gi . This is trivial for the first time we reach . 5 So we have to show that one iteration of 5 transforms an optimum branching B of Gi into an optimum branching B 0 of Gi 1 . Let Bi1 be any branching of Gi 1 such that jE.C / n E.Bi1 /j D 1 for each circuit C of Bi 1 . Let Bi result from Bi1 by contracting the circuits of Bi 1 . Bi is a branching of Gi . Furthermore we have X .ci 1 .E.C // ci 1 .eC //: ci 1 .Bi1 / ci .Bi / C C W circuit of Bi 1

By the induction hypothesis, B is an optimum branching of Gi , so we have ci .B/ ci .Bi /. We conclude that X

ci 1 .Bi1 / ci .B/ C

.ci 1 .E.C // ci 1 .eC //

C W circuit of Bi 1

D ci 1 .B 0 /: This, together with Lemma 6.11, implies that B 0 is an optimum branching of Gi 1 .

142

6 Spanning Trees and Arborescences

This proof is due to Karp [1972]. Edmonds’ original proof was based on a linear programming formulation (see Corollary 6.15). The running time of EDMONDS’ BRANCHING ALGORITHM is easily seen to be O.mn/, where m D jE.G/j and n D jV .G/j: there are at most n iterations (i.e. i n at any stage of the algorithm), and each iteration can be implemented in O.m/ time. The best known bound has been obtained by Gabow et al. [1986] using a Fibonacci heap: their branching algorithm runs in O.m C n log n/ time.

6.3 Polyhedral Descriptions A polyhedral description of the M INIMUM SPANNING TREE PROBLEM is as follows: Theorem 6.13. (Edmonds [1970]) Given a connected undirected graph G, n WD jV .G/j, the polytope P WD 9 8 = < X X xe D n 1; xe jX j 1 for ; 6D X V .G/ x 2 Œ0; 1E.G/ W ; : e2E.G/

e2E.GŒX/

is integral. Its vertices are exactly the incidence vectors of spanning trees of G. (P is called the spanning tree polytope of G.) Proof: Let T be a spanning tree of G, and let x be the incidence vector of E.T /. Obviously (by Theorem 2.4), x 2 P . Furthermore, since x 2 f0; 1gE.G/ , it must be a vertex of P . On the other hand let x be an integral vertex of P . Then x is the incidence vector of the edge set of some subgraph H with n 1 edges and no circuit. Again by Theorem 2.4 this implies that H is a spanning tree. So it suffices to show that P is integral (recall Theorem 5.13). Let c W E.G/ ! R, and let T be the tree produced by KRUSKAL’S ALGORITHM when applied to .G; c/ (ties are broken arbitrarily when sorting the edges). Denote E.T / D ff1 ; : : : ; fn1 g, where the fi were taken in this order by the algorithm. In particular, c.f1 / c.fn1 /. Let Xk V .G/ be the connected component of .V .G/; ff1 ; : : : ; fk g/ containing fk (k D 1; : : : ; n 1). Let x be the incidence vector of E.T /. We show that x is an optimum solution to the LP X min c.e/xe e2E.G/

s.t.

X

e2E.G/ X

xe D n 1 xe jX j 1

.; 6D X V .G//

xe 0

.e 2 E.G//:

e2E.GŒX/

6.3

Polyhedral Descriptions

143

We introduce a dual variable ´X for each ; 6D X V .G/ and one additional dual variable ´V .G/ for the equality constraint. Then the dual LP is X max .jX j 1/´X ;6DXV .G/

s.t.

X

´X c.e/

.e 2 E.G//

´X 0

.; 6D X V .G//:

eXV .G/

Note that the dual variable ´V .G/ is not forced to be nonnegative. For k D 1; : : : ; n 2 let ´X WD c.fl / c.fk /, where l is the first index greater than k k for which fl \ Xk 6D ;. Let ´V .G/ WD c.fn1 /, and let ´X WD 0 for all X 62 fX1 ; : : : ; Xn1 g. For each e D fv; wg we have that X ´X D c.fi /; eXV .G/

where i is the smallest index such that v; w 2 Xi . Moreover c.fi / c.e/ since v and w are in different connected components of .V .G/; ff1 ; : : : ; fi 1 g/. Hence ´ is a feasible dual solution. Moreover xe > 0, i.e. e 2 E.T /, implies X ´X D c.e/; eXV .G/ > 0 i.e. the corresponding dual constraint is satisfied with equality. Finally, ´X implies that T ŒX is connected, so the corresponding primal constraint is satisfied with equality. In other words, the primal and dual complementary slackness conditions are satisfied, thus (by Corollary 3.23) x and ´ are optimum solutions for the primal and dual LP, respectively.

Indeed, we have proved that the inequality system in Theorem 6.13 is TDI. We remark that the above is also an alternative proof of the correctness of KRUSKAL’S ALGORITHM (Theorem 6.4). Another description of the spanning tree polytope is the subject of Exercise 19. There is also a polynomial-size LP formulation; see Exercise 20. P P If we replace the constraint e2E.G/ xe D n 1 by e2E.G/ xe n 1, we obtain the convex hull of the incidence vectors of all forests in G (Exercise 21). A generalization of these results is Edmonds’ characterization of the matroid polytope (Theorem 13.21). We now turn to a polyhedral description of the MINIMUM WEIGHT ROOTED ARBORESCENCE PROBLEM. First we prove a classical result of Fulkerson. Recall that an r-cut is a set of edges ı C .S / for some S V .G/ with r 2 S . Theorem 6.14. (Fulkerson [1974]) Let G be a digraph with weights c W E.G/ ! ZC , and r 2 V .G/ such that G contains a spanning arborescence rooted at r. Then

144

6 Spanning Trees and Arborescences

the minimum weight of a spanning arborescence rooted at r equals the maximum number t of r-cuts C1 ; : : : ; C t (repetitions allowed) such that no edge e is contained in more than c.e/ of these cuts. Proof: Let A be the matrix whose columns are indexed by the edges and whose rows are all incidence vectors of r-cuts. Consider the LP minfcx W Ax 1l; x 0g; and its dual maxf1ly W yA c; y 0g: Then (by part (e) of Theorem 2.5) we have to show that for any nonnegative integral c, both the primal and dual LP have integral optimum solutions. By Corollary 5.15 it suffices to show that the system Ax 1l; x 0 is TDI. We use Lemma 5.23. Since the dual LP is feasible if and only if c is nonnegative, let c W E.G/ ! ZC . Let y be an optimum solution of maxf1ly W yA c; y 0g for which X yı .X/ jX j2 (6.1) ;6DXV .G/nfrg

is as large as possible. We claim that F WD fX W yı .X/ > 0g is laminar. To see this, suppose X; Y 2 F with X \ Y 6D ;, X n Y 6D ; and Y n X 6D ; (Figure 6.3). Let WD minfyı .X/ ; yı .Y / g. Set yı0 .X/ WD yı .X/ , yı0 .Y / WD yı .Y / , yı0 .X\Y / WD yı .X\Y / C , yı0 .X[Y / WD yı .X[Y / C , and y 0 .S / WD y.S / for all other r-cuts S . Observe that y 0 A yA, so y 0 is a feasible dual solution. Since 1ly D 1ly 0 , it is also optimum and contradicts the choice of y, because (6.1) is larger for y 0 . (For any numbers a > b c > d > 0 with a C d D b C c we have a2 C d 2 > b 2 C c 2 .) X

Y

r

Fig. 6.3.

Now let A0 be the submatrix of A consisting of the rows corresponding to the elements of F . A0 is the one-way cut-incidence matrix of a laminar family (to be precise, we must consider the graph resulting from G by reversing each edge). So by Theorem 5.28 A0 is totally unimodular, as required. The above proof also yields the promised polyhedral description:

6.4

Packing Spanning Trees and Arborescences

145

Corollary 6.15. (Edmonds [1967]) Let G be a digraph with weights c W E.G/ ! RC , and r 2 V .G/ such that G contains a spanning arborescence rooted at r. Then the LP 8 9 < = X min cx W x 0; xe 1 for all X V .G/ with r 2 X : ; C e2ı .X/

has an integral optimum solution (which is the incidence vector of a minimum weight spanning arborescence rooted at r, plus possibly some edges of zero weight). For a description of the convex hull of the incidence vectors of all branchings or spanning arborescences rooted at r, see Exercises 22 and 23.

6.4 Packing Spanning Trees and Arborescences If we are looking for more than one spanning tree or arborescence, classical theorems of Tutte, Nash-Williams and Edmonds are of help. We first give a proof of Tutte’s Theorem on packing spanning trees which is essentially due to Mader (see Diestel [1997]) and which uses the following lemma: Lemma 6.16. Let G be an undirected graph, and let F D .F1 ; : : : ; Fk / be a ktuple of edge-disjoint forests in G such that jE.F /j is maximum, where E.F / WD Sk i D1 E.Fi /. Let e 2 E.G/ n E.F /. Then there exists a set X V .G/ with e X such that Fi ŒX is connected for each i 2 f1; : : : ; kg. Proof: For two k-tuples F 0 D .F10 ; : : : ; Fk0 / and F 00 D .F100 ; : : : ; Fk00 / of edgedisjoint forests we say that F 00 arises from F 0 by exchanging e 0 for e 00 if Fj00 D :

.Fj0 n e 0 / [ e 00 for some j and Fi00 D Fi0 for all i 6D j . Let F be the set of all k-tuples of edge-disjoint forests arising from F by a sequence of such exchanges. T 0 Let E WD E.G/ n E.F / and G WD .V .G/; E/. We have F 2 F and thus 0 F 2F e 2 E. Let X be the vertex set of the connected component of G containing e. We shall prove that Fi ŒX is connected for each i . Claim: For any F 0 D .F10 ; : : : ; Fk0 / 2 F and any eN D fv; wg 2 E.GŒX /nE.F 0 / there exists a v-w-path in Fi0 ŒX for all i 2 f1; : : : ; kg. To prove this, let i 2 f1; : : : ; kg be fixed. Since F 0 2 F and jE.F 0 /j D jE.F /j is maximum, Fi0 C eN contains a circuit C . Now for all e 0 2 E.C / n feg N we have Fe00 2 F , where Fe00 arises from F 0 by exchanging e 0 for e. N This shows that E.C / E, and so C eN is a v-w-path in Fi0 ŒX . This proves the claim. Since GŒX is connected, it suffices to prove that for each eN D fv; wg 2 E.GŒX / and each i there is a v-w-path in Fi ŒX . So let eN D fv; wg 2 E.GŒX /. Since eN 2 E, there is some F 0 D .F10 ; : : : ; Fk0 / 2 F with eN 62 E.F 0 /. By the claim there is a v-w-path in Fi0 ŒX for each i . Now there is a sequence F D F .0/ ; F .1/ : : : ; F .s/ D F 0 of elements of F such that F .rC1/ arises from F .r/ by exchanging one edge (r D 0; : : : ; s 1). It suffices

146

6 Spanning Trees and Arborescences

to show that the existence of a v-w-path in Fi.rC1/ ŒX implies the existence of a v-w-path in Fi.r/ ŒX (r D 0; : : : ; s 1). .rC1/ .r/ To see this, suppose that Fi arises from Fi by exchanging er for erC1 , .rC1/ and let P be the v-w-path in Fi ŒX . If P does not contain erC1 D fx; yg, it is .r/ also a path in Fi ŒX . Otherwise erC1 2 E.GŒX /, and we consider the x-y-path .r/ Q in Fi ŒX which exists by the claim. Since .E.P / n ferC1 g/ [ E.Q/ contains a .r/ v-w-path in Fi ŒX , the proof is complete. Now we can prove Tutte’s theorem on disjoint spanning trees. A multicut in an undirected graph G is a set of edges ı.X1 ; : : : ; Xp / WD ı.X1 /[ [ı.Xp / for some : : : partition V .G/ D X1 [ X2 [ [ Xp of the vertex set into nonempty subsets. For p D 3 we also speak of 3-cuts. Observe that cuts are multicuts with p D 2. Theorem 6.17. (Tutte [1961], Nash-Williams [1961]) An undirected graph G contains k edge-disjoint spanning trees if and only if jı.X1 ; : : : ; Xp /j k.p 1/ for every multicut ı.X1 ; : : : ; Xp /. Proof: To prove necessity, let T1 ; : : : ; Tk be edge-disjoint spanning trees in G, and let ı.X1 ; : : : ; Xp / be a multicut. Contracting each of the vertex subsets X1 ; : : : ; Xp yields a graph G 0 whose vertices are X1 ; : : : ; Xp and whose edges correspond to the edges of the multicut. T1 ; : : : ; Tk correspond to edge-disjoint connected subgraphs T10 ; : : : ; Tk0 in G 0 . Each of the T10 ; : : : ; Tk0 has at least p 1 edges, so G 0 (and thus the multicut) has at least k.p 1/ edges. To prove sufficiency we use induction on jV .G/j. For n WD jV .G/j 2 the statement is true. Now assume n > 2, and suppose that jı.X1; : : : ; Xp /j k.p 1/ for every multicut ı.X1 ; : : : ; Xp /. In particular (consider the partition into singletons) G has at least k.n1/ edges. Moreover, the condition is preserved when contracting vertex sets, so by the induction hypothesis G=X contains k edge-disjoint spanning trees for each X V .G/ with jX j 2. Let F D .F1 ; : : : ; Fk / be a k-tuple of edge-disjoint forests in G such that S jE.F /j is maximum, where again E.F / WD kiD1 E.Fi /. We claim that each Fi is a spanning tree. Otherwise jE.F /j < k.n 1/, so there is an edge e 2 E.G/ n E.F /. By Lemma 6.16 there is an X V .G/ with e X such that Fi ŒX is connected for each i . Since jX j 2, G=X contains k edge-disjoint spanning trees F10 ; : : : ; Fk0 . Now Fi0 together with Fi ŒX forms a spanning tree in G for each i , and all these k spanning trees are edge-disjoint. We now turn to the corresponding problem in digraphs, packing spanning arborescences: Theorem 6.18. (Edmonds [1973]) Let G be a digraph and r 2 V .G/. Then the maximum number of edge-disjoint spanning arborescences rooted at r equals the minimum cardinality of an r-cut.

6.4

Packing Spanning Trees and Arborescences

147

Proof: Let k be the minimum cardinality of an r-cut. Obviously there are at most k edge-disjoint spanning arborescences rooted at r. We prove the existence of k edge-disjoint spanning arborescences rooted at r by induction on k. The case k D 0 is trivial. If we can find one spanning arborescence A rooted at r such that ˇ C ˇ min ˇıG .S / n E.A/ˇ k 1; (6.2) r2SV .G/

then we are done by induction. Suppose we have already found some arborescence A rooted at r (but not necessarily spanning) such that (6.2) holds. Let R V .G/ be the set of vertices covered by A. Initially, R D frg; if R D V .G/, we are done. If R 6D V .G/, we call a set X V .G/ critical if (a) r 2 X ; (b) X [ R 6D V .G/; C (c) jıG .X / n E.A/j D k 1.

R x

r e X

y

Fig. 6.4.

If there is no critical vertex set, we can augment A by any edge leaving R. Otherwise let X be a maximal critical set, and let e D .x; y/ be an edge such that x 2 R n X and y 2 V .G/ n .R [ X / (see Figure 6.4). Such an edge must exist because C C C jıGE.A/ .R [ X /j D jıG .R [ X /j k > k 1 D jıGE.A/ .X /j:

We now add e to A. Obviously A C e is an arborescence rooted at r. We have to show that (6.2) continues to hold. C Suppose there is some Y such that r 2 Y V .G/ and jıG .Y / n E.A C e/j < C k 1. Then x 2 Y , y … Y , and jıG .Y / n E.A/j D k 1. Now Lemma 2.1(a) implies C C k 1 C k 1 D jıGE.A/ .X /j C jıGE.A/ .Y /j C C .X [ Y /j C jıGE.A/ .X \ Y /j jıGE.A/

k1Ck1 ;

148

6 Spanning Trees and Arborescences

because r 2 X \ Y and y 2 V .G/ n .X [ Y /. So equality must hold throughout, in C particular jıGE.A/ .X [ Y /j D k 1. Since y 2 V .G/ n .X [ Y [ R/ we conclude that X [ Y is critical. But since x 2 Y n X , this contradicts the maximality of X . This proof is due to Lovász [1976]. Fujishige [2010] generalized this result to packing arborescences with given (but not necessarily identical) roots, spanning given subsets of vertices. A common generalization of Theorems 6.17 and 6.18 was found by Frank [1981]. A good characterization (see Chapter 15 for an explanation of this term) of the problem of packing spanning arborescences with arbitrary roots is given by the following theorem, which we cite without proof: Theorem 6.19. (Frank [1979]) A digraph G contains k edge-disjoint spanning arborescences if and only if p X

jı .Xi /j k.p 1/

i D1

for every collection of pairwise disjoint nonempty subsets X1 ; : : : ; Xp V .G/. Another question is how many forests are needed to cover a graph. This is answered by the following theorem: Theorem 6.20. (Nash-Williams [1964]) The edge set of an undirected graph G is the union of k forests if and only if jE.GŒX /j k.jX j 1/ for all ; 6D X V .G/. Proof: The necessity is clear since no forest can contain more than jX j 1 edges within a vertex set X . To prove the sufficiency, assume that jE.GŒX /j k.jX j1/ for all ; 6D X V .G/, and letˇ F D .F1 ; : ˇ: : ; Fk / be a k-tuple of edge-disjoint ˇS ˇ forests in G such that jE.F /j D ˇ kiD1 E.Fi /ˇ is maximum. We claim that E.F / D E.G/. To see this, suppose there is an edge e 2 E.G/ n E.F /. By Lemma 6.16 there exists a set X V .G/ with e X such that Fi ŒX is connected for each i . In particular, ˇ ˇ k ˇ ˇ : [ ˇ ˇ jE.GŒX /j ˇfeg [ E.Fi ŒX /ˇ 1 C k.jX j 1/; ˇ ˇ i D1

contradicting the assumption.

Exercise 29 gives a directed version. A generalization of Theorems 6.17 and 6.20 to matroids can be found in Exercise 19 of Chapter 13.

Exercises 1. Prove Cayley’s Theorem 6.2 by showing that the following defines a oneto-one correspondence between the spanning trees in Kn and the vectors in

Exercises

2. 3.

4.

5.

6.

7.

8.

9.

10.

149

f1; : : : ; ngn2 : For a tree T with V .T / D f1; : : : ; ng, n 3, let v be the leaf with the smallest index and let a1 be the neighbour of v. We recursively define a.T / WD .a1 ; : : : ; an2 /, where .a2 ; : : : ; an2 / D a.T v/. (Prüfer [1918]) Prove that there are exactly .n C 1/n1 branchings B with V .B/ D f1; : : : ; ng. Let pn be the probability that vertex 1 is a leaf in T if T is chosen randomly among all trees with vertex set f1; : : : ; ng (with uniform distribution). What is limn!1 pn ? Let .V; T1 / and .V; T2 / be two trees on the same vertex set V . Prove that for any edge e 2 T1 there is an edge f 2 T2 such that both .V; .T1 n feg/ [ ff g/ and .V; .T2 n ff g/ [ feg/ are trees. Let .G; c/ be an instance of the MINIMUM SPANNING TREE PROBLEM where G is connected and c.e/ 6D c.e 0 / for any two distinct edges e and e 0 . Prove that then there is exactly one optimum solution. Given an undirected graph G with weights c W E.G/ ! R and a vertex v 2 V .G/, we ask for a minimum weight spanning tree in G where v is not a leaf. Can you solve this problem in polynomial time? We want to determine the set of edges e in an undirected graph G with weights c W E.G/ ! R for which there exists a minimum weight spanning tree in G containing e (in other words, we are looking for the union of all minimum weight spanning trees in G). Show how this problem can be solved in O.mn/ time. Given an undirected graph G with arbitrary weights c W E.G/ ! R, we ask for a minimum weight connected spanning subgraph. Can you solve this problem efficiently? Consider the following algorithm (sometimes called WORST-OUT-GREEDY ALGORITHM, see Section 13.4). Examine the edges in order of non-increasing weights. Delete an edge unless it is a bridge. Does this algorithm solve the M INIMUM SPANNING T REE PROBLEM ? Consider the following “colouring” algorithm. Initially all edges are uncoloured. Then apply the following rules in arbitrary order until all edges are coloured: Blue rule: Select a cut containing no blue edge. Among the uncoloured edges in the cut, select one of minimum cost and colour it blue. Red rule: Select a circuit containing no red edge. Among the uncoloured edges in the circuit, select one of maximum cost and colour it red. Show that one of the rules is always applicable as long as there are uncoloured edges left. Moreover, show that the algorithm maintains the “colour invariant”: there always exists an optimum spanning tree containing all blue edges but no red edge. (So the algorithm solves the MINIMUM SPANNING TREE PROBLEM optimally.) Observe that KRUSKAL’S ALGORITHM and PRIM’S ALGORITHM are special cases. (Tarjan [1983])

150

6 Spanning Trees and Arborescences

11. Suppose we wish to find a spanning tree T in an undirected graph such that the maximum weight of an edge in T is as small as possible. How can this be done? 12. Is it true that the maximum length of a path in a branching implementing a Fibonacci heap is O.log n/, where n is the number of elements? 13. Show that two Fibonacci heaps with n1 and n2 elements can be merged in O.log.n1 C n2 // time. The resulting Fibonacci heap shall contain all n1 C n2 elements. 14. For a finite set V R2 , the Vorono˘ı diagram consists of the regions Pv WD x 2 R2 W jjx vjj2 D min jjx wjj2 w2V

for v 2 V . The Delaunay triangulation of V is the graph .V; ffv; wg V; v 6D w; jPv \ Pw j > 1g/ :

15.

16.

17.

18.

A minimum spanning tree for V is a tree T with V .T / D V whose length P fv;wg2E.T / jjv wjj2 is minimum. Prove that every minimum spanning tree is a subgraph of the Delaunay triangulation. Note: Using the fact that the Delaunay triangulation can be computed in O.n log n/ time (where n D jV j; see e.g. Fortune [1987], Knuth [1992]), this implies an O.n log n/ algorithm for the M INIMUM SPANNING TREE PROBLEM for point sets in the plane. (Shamos and Hoey [1975]; see also Zhou, Shenoy and Nicholls [2002]) Can you decide in linear time whether a digraph contains a spanning arborescence? Hint: To find a possible root, start at an arbitrary vertex and traverse edges backwards as long as possible. When encountering a circuit, contract it. Can you find a maximum cardinality branching in a given digraph in linear time? Hint: First find the strongly connected components. The MINIMUM WEIGHT ROOTED ARBORESCENCE PROBLEM can be reduced to the MAXIMUM WEIGHT BRANCHING PROBLEM by Proposition 6.9. However, it can also be solved directly by a modified version of EDMONDS’ BRANCHING ALGORITHM. Show how. Prove that the spanning tree polytope of an undirected graph G (see Theorem 6.13) with n WD jV .G/j is in general a proper subset of the polytope 8 9 < = X X x 2 Œ0; 1E.G/ W xe D n 1; xe 1 for ; X V .G/ : : ; e2E.G/

e2ı.X/

Hint: To prove that this polytope is not integral, consider the graph shown in Figure 6.5 (the numbers are edge weights). (Magnanti and Wolsey [1995])

Exercises 1

151

0 0

1

0

1

Fig. 6.5.

19. In Exercise 18 we saw that cut constraints do not suffice to describe the spanning tree polytope. However, if we consider multicuts instead, we obtain a complete description: Prove that the spanning tree polytope of an undirected graph G with n WD jV .G/j consists of all vectors x 2 Œ0; 1E.G/ with X X xe D n 1 and xe k 1 for all multicuts C D ı.X1 ; : : : ; Xk /: e2E.G/

e2C

(Magnanti and Wolsey [1995])

20. Let G be an undirected graph and n WD jV .G/j. Prove that the following linear inequality system with O.n3 / variables and constraints describes a polytope whose orthogonal projection onto the x-variables yields the spanning tree polytope of G: xe 0 (e 2 E.G/), ´u;v;w 0 (fu; vg 2 E.G/; w 2 V .G/nfu; vg), P u;v;w C ´v;u;w (e D fu; vg 2 E.G/, e2E.G/ xe D n 1, xe D ´P w 2 V .G/ n fu; vg), and xe C fu;vg2ı.v/nfeg ´u;v;w D 1 (v 2 V .G/, e D fv; wg 2 ı.v/). Note: See Conforti, Cornuéjols and Zambelli [2010] for a survey of such extended formulations of combinatorial LPs. 21. Prove that the convex hull of the incidence vectors of all forests in an undirected graph G is the polytope 8 9 < = X P WD x 2 Œ0; 1E.G/ W xe jX j 1 for ; 6D X V .G/ : : ; e2E.GŒX/

P Note: This statement implies Theorem 6.13 since e2E.GŒX/ xe D jV .G/j 1 is a supporting hyperplane. Moreover, it is a special case of Theorem 13.21.

22. Prove that the convex hull of the incidence vectors of all branchings in a digraph G is the set of all vectors x 2 Œ0; 1E.G/ with X X xe jX j 1 for ; 6D X V .G/ and xe 1 for v 2 V .G/: e2E.GŒX/

e2ı .v/

Note: This is a special case of Theorem 14.13.

23. Let G be a digraph and r 2 V .G/. Prove that the polytopes

152

6 Spanning Trees and Arborescences

( x 2 Œ0; 1E.G/ W xe D 0 .e 2 ı .r//;

X

xe D 1 .v 2 V .G/ n frg/;

e2ı .v/

X

)

xe jX j 1 for ; 6D X V .G/

e2E.GŒX/

and ( x 2 Œ0; 1E.G/ W xe D 0 .e 2 ı .r//;

X

xe D 1 .v 2 V .G/ n frg/;

e2ı .v/

X

)

xe 1 for r 2 X V .G/

e2ı C .X/

24. 25.

26.

27.

28.

29.

are both equal to the convex hull of the incidence vectors of all spanning arborescences rooted at r. Prove that every 2k-edge-connected graph contains k pairwise edge-disjoint spanning trees. Let G be a digraph and r 2 V .G/. Prove that G is the disjoint union of k spanning arborescences rooted at r if and only if the underlying undirected graph is the disjoint union of k spanning trees and jı .x/j D k for all x 2 V .G/ n frg. (Edmonds) Let G be a digraph and r 2 V .G/. Suppose that G contains k edge-disjoint paths from r to every other vertex, but removing any edge destroys this property. Prove that every vertex of G except r has exactly k entering edges. Hint: Use Theorem 6.18. Prove the statement of Exercise 26 without using Theorem 6.18. Formulate and prove a vertex-disjoint version. Hint: If a vertex v has more than k entering edges, take k edge-disjoint rv-paths. Show that an edge entering v that is not used by these paths can be deleted. Give a polynomial-time algorithm for finding a maximum set of edge-disjoint spanning arborescences (rooted at r) in a digraph G. Note: The most efficient algorithm is due to Gabow [1995]; see also (Gabow and Manu [1998]). Prove that the edges of a digraph G can be covered by k branchings if and only if the following two conditions hold: (a) jı .v/j k for all v 2 V .G/; (b) jE.GŒX /j k.jX j 1/ for all X V .G/. Hint: Use Theorem 6.18. (Frank [1979])

References

153

References General Literature: Ahuja, R.K., Magnanti, T.L., and Orlin, J.B. [1993]: Network Flows. Prentice-Hall, Englewood Cliffs 1993, Chapter 13 Balakrishnan, V.K. [1995]: Network Optimization. Chapman and Hall, London 1995, Chapter 1 Cormen, T.H., Leiserson, C.E., Rivest, R.L., and Stein, C. [2001]: Introduction to Algorithms. Second Edition. MIT Press, Cambridge 2001, Chapter 23 Gondran, M., and Minoux, M. [1984]: Graphs and Algorithms. Wiley, Chichester 1984, Chapter 4 Magnanti, T.L., and Wolsey, L.A. [1995]: Optimal trees. In: Handbooks in Operations Research and Management Science; Volume 7: Network Models (M.O. Ball, T.L. Magnanti, C.L. Monma, G.L. Nemhauser, eds.), Elsevier, Amsterdam 1995, pp. 503–616 Schrijver, A. [2003]: Combinatorial Optimization: Polyhedra and Efficiency. Springer, Berlin 2003, Chapters 50–53 Tarjan, R.E. [1983]: Data Structures and Network Algorithms. SIAM, Philadelphia 1983, Chapter 6 Wu, B.Y., and Chao, K.-M. [2004]: Spanning Trees and Optimization Problems. Chapman & Hall/CRC, Boca Raton 2004

Cited References: Bock, F.C. [1971]: An algorithm to construct a minimum directed spanning tree in a directed network. In: Avi-Itzhak, B. (Ed.): Developments in Operations Research, Volume I. Gordon and Breach, New York 1971, pp. 29–44 Boruvka, O. [1926a]: O jistém problému minimálním. Práca Moravské P˘rírodov˘edecké Spolne˘cnosti 3 (1926), 37–58 [in Czech] Boruvka, O. [1926b]: P˘ríspev˘ek k ˘re˘sení otázky ekonomické stavby. Elektrovodních sítí. Elektrotechnicky Obzor 15 (1926), 153–154 [in Czech] Cayley, A. [1889]: A theorem on trees. Quarterly Journal on Mathematics 23 (1889), 376–378 Chazelle, B. [2000]: A minimum spanning tree algorithm with inverse-Ackermann type complexity. Journal of the ACM 47 (2000), 1028–1047 Cheriton, D., and Tarjan, R.E. [1976]: Finding minimum spanning trees. SIAM Journal on Computing 5 (1976), 724–742 Chu, Y., and Liu, T. [1965]: On the shortest arborescence of a directed graph. Scientia Sinica 4 (1965), 1396–1400; Mathematical Review 33, # 1245 Conforti, M., Cornuéjols, G., and Zambelli, G. [2010]: Extended formulations in combinatorial optimization. 4OR 8 (2010), 1–48 Diestel, R. [1997]: Graph Theory. Springer, New York 1997 Dijkstra, E.W. [1959]: A note on two problems in connexion with graphs. Numerische Mathematik 1 (1959), 269–271 Dixon, B., Rauch, M., and Tarjan, R.E. [1992]: Verification and sensitivity analysis of minimum spanning trees in linear time. SIAM Journal on Computing 21 (1992), 1184–1192 Edmonds, J. [1967]: Optimum branchings. Journal of Research of the National Bureau of Standards B 71 (1967), 233–240

154

6 Spanning Trees and Arborescences

Edmonds, J. [1970]: Submodular functions, matroids and certain polyhedra. In: Combinatorial Structures and Their Applications; Proceedings of the Calgary International Conference on Combinatorial Structures and Their Applications 1969 (R. Guy, H. Hanani, N. Sauer, J. Schönheim, eds.), Gordon and Breach, New York 1970, pp. 69–87 Edmonds, J. [1973]: Edge-disjoint branchings. In: Combinatorial Algorithms (R. Rustin, ed.), Algorithmic Press, New York 1973, pp. 91–96 Fortune, S. [1987]: A sweepline algorithm for Voronoi diagrams. Algorithmica 2 (1987), 153–174 Frank, A. [1981]: On disjoint trees and arborescences. In: Algebraic Methods in Graph Theory; Colloquia Mathematica Societatis János Bolyai 25 (L. Lovász, V.T. Sós, eds.), North-Holland, Amsterdam 1981, pp. 159–169 Frank, A. [1979]: Covering branchings. Acta Scientiarum Mathematicarum (Szeged) 41 (1979), 77–82 Fredman, M.L., and Tarjan, R.E. [1987]: Fibonacci heaps and their uses in improved network optimization problems. Journal of the ACM 34 (1987), 596–615 Fredman, M.L., and Willard, D.E. [1994]: Trans-dichotomous algorithms for minimum spanning trees and shortest paths. Journal of Computer and System Sciences 48 (1994), 533–551 Fujishige, S. [2010]: A note on disjoint arborescences. Combinatorica 30 (2010), 247–252 Fulkerson, D.R. [1974]: Packing rooted directed cuts in a weighted directed graph. Mathematical Programming 6 (1974), 1–13 Gabow, H.N. [1995]: A matroid approach to finding edge connectivity and packing arborescences. Journal of Computer and System Sciences 50 (1995), 259–273 Gabow, H.N., Galil, Z., and Spencer, T. [1989]: Efficient implementation of graph algorithms using contraction. Journal of the ACM 36 (1989), 540–572 Gabow, H.N., Galil, Z., Spencer, T., and Tarjan, R.E. [1986]: Efficient algorithms for finding minimum spanning trees in undirected and directed graphs. Combinatorica 6 (1986), 109–122 Gabow, H.N., and Manu, K.S. [1998]: Packing algorithms for arborescences (and spanning trees) in capacitated graphs. Mathematical Programming B 82 (1998), 83–109 Jarník, V. [1930]: O jistém problému minimálním. Práca Moravské P˘rírodov˘edecké Spole˘cnosti 6 (1930), 57–63 Karger, D., Klein, P.N., and Tarjan, R.E. [1995]: A randomized linear-time algorithm to find minimum spanning trees. Journal of the ACM 42 (1995), 321–328 Karp, R.M. [1972]: A simple derivation of Edmonds’ algorithm for optimum branchings. Networks 1 (1972), 265–272 King, V. [1997]: A simpler minimum spanning tree verification algorithm. Algorithmica 18 (1997), 263–270 Knuth, D.E. [1992]: Axioms and hulls; LNCS 606. Springer, Berlin 1992 Korte, B., and Nešetˇril, J. [2001]: Vojt˘ech Jarník’s work in combinatorial optimization. Discrete Mathematics 235 (2001), 1–17 Kruskal, J.B. [1956]: On the shortest spanning subtree of a graph and the travelling salesman problem. Proceedings of the AMS 7 (1956), 48–50 Lovász, L. [1976]: On two minimax theorems in graph. Journal of Combinatorial Theory B 21 (1976), 96–103 Nash-Williams, C.S.J.A. [1961]: Edge-disjoint spanning trees of finite graphs. Journal of the London Mathematical Society 36 (1961), 445–450 Nash-Williams, C.S.J.A. [1964]: Decompositions of finite graphs into forests. Journal of the London Mathematical Society 39 (1964), 12

References

155

Nešetˇril, J., Milková, E., and Nešetˇrilová, H. [2001]: Otakar Boruvka on minimum spanning tree problem. Translation of both the 1926 papers, comments, history. Discrete Mathematics 233 (2001), 3–36 Pettie, S., and Ramachandran, V. [2002]: An optimal minimum spanning tree algorithm. Journal of the ACM 49 (2002), 16–34 Prim, R.C. [1957]: Shortest connection networks and some generalizations. Bell System Technical Journal 36 (1957), 1389–1401 Prüfer, H. [1918]: Neuer Beweis eines Satzes über Permutationen. Arch. Math. Phys. 27 (1918), 742–744 Shamos, M.I., and Hoey, D. [1975]: Closest-point problems. Proceedings of the 16th Annual IEEE Symposium on Foundations of Computer Science (1975), 151–162 Sylvester, J.J. [1857]: On the change of systems of independent variables. Quarterly Journal of Mathematics 1 (1857), 42–56 Tarjan, R.E. [1975]: Efficiency of a good but not linear set union algorithm. Journal of the ACM 22 (1975), 215–225 Tutte, W.T. [1961]: On the problem of decomposing a graph into n connected factor. Journal of the London Mathematical Society 36 (1961), 221–230 Zhou, H., Shenoy, N., and Nicholls, W. [2002]: Efficient minimum spanning tree construction without Delaunay triangulation. Information Processing Letters 81 (2002), 271–276

•

7 Shortest Paths

One of the best-known combinatorial optimization problems is to find a shortest path between two specified vertices of a directed or undirected graph:

SHORTEST PATH PROBLEM Instance: Task:

A graph G (directed or undirected), weights c W E.G/ ! R and two vertices s; t 2 V .G/. Find a shortest s-t-path P , i.e. one of minimum weight c.E.P //, or decide that t is not reachable from s.

Obviously this problem has many practical applications. Like the MINIMUM SPANNING TREE PROBLEM it also often appears as a subproblem when one deals with more difficult combinatorial optimization problems. In fact, the problem is not easy to solve if we allow arbitrary weights. For example, if all weights are 1 then the s-t-paths of weight 1 jV .G/j are precisely the Hamiltonian s-t-paths. Deciding whether such a path exists is a difficult problem (see Exercise 17(b) of Chapter 15). The problem becomes much easier if we restrict ourselves to nonnegative weights or at least exclude negative circuits: Definition 7.1. Let G be a (directed or undirected) graph with weights cWE.G/ ! R. c is called conservative if there is no circuit of negative total weight. We shall present algorithms for the SHORTEST PATH PROBLEM in digraphs in Section 7.1. The first one allows nonnegative weights only while the second algorithm can deal with arbitrary conservative weights. The algorithms of Section 7.1 in fact compute a shortest s-v-path for all v 2 V .G/ without using significantly more running time. Sometimes one is interested in the distance for every pair of vertices; Section 7.2 shows how to deal with this problem. Since negative circuits cause problems we also show how to detect them. If none exists, a circuit of minimum total weight can be computed quite easily. Another interesting problem asks for a circuit whose mean weight is minimum. As we shall see in Section 7.3, the directed version of this problem can also be solved efficiently by similar techniques. Finding shortest paths in undirected graphs is more difficult unless the edge weights are nonnegative. Undirected edges of nonnegative weights can be replaced B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__7, c Springer-Verlag Berlin Heidelberg 2012

157

158

7 Shortest Paths

equivalently by a pair of oppositely directed edges of the same weight; this reduces the undirected problem to a directed one. However, this construction does not work for edges of negative weight since it would introduce negative circuits. We shall return to the problem of finding shortest paths in undirected graphs with conservative weights in Section 12.2 (Corollary 12.13). Henceforth we work with a digraph G. Without loss of generality we may assume that G is connected and simple; among parallel edges we have to consider only the one with least weight.

7.1 Shortest Paths From One Source All shortest path algorithms we present are based on the following observation, sometimes called Bellman’s principle of optimality, which is indeed the core of dynamic programming: Proposition 7.2. Let G be a digraph with conservative weights c W E.G/ ! R, let k 2 N, and let s and w be two vertices. Let P be a shortest one among all s-w-paths with at most k edges, and let e D .v; w/ be its final edge. Then PŒs;v (i.e. P without the edge e) is a shortest one among all s-v-paths with at most k 1 edges. Proof: Suppose Q is a shorter s-v-path than PŒs;v , and jE.Q/j k 1. Then c.E.Q// C c.e/ < c.E.P //. If Q does not contain w, then Q C e is a shorter s-w-path than P , otherwise QŒs;w has length c.E.QŒs;w// D c.E.Q// C c.e/ c.E.QŒw;v C e// < c.E.P // c.E.QŒw;v C e// c.E.P //, because QŒw;v C e is a circuit and c is conservative. In both cases we have a contradiction to the assumption that P is a shortest s-w-path with at most k edges. The same result holds for undirected graphs with nonnegative weights and also for acyclic digraphs with arbitrary weights. It yields the recursion formulas dist.s; s/ D 0 and dist.s; w/ D minfdist.s; v/ C c..v; w// W .v; w/ 2 E.G/g for w 2 V .G/nfsg which immediately solve the SHORTEST PATH PROBLEM for acyclic digraphs (Exercise 7). Proposition 7.2 is also the reason why most algorithms compute the shortest paths from s to all other vertices. If one computes a shortest s-t-path P , one has already computed a shortest s-v-path for each vertex v on P . Since we cannot know in advance which vertices belong to P , it is only natural to compute shortest s-vpaths for all v. We can store these s-v-paths very efficiently by just storing the final edge of each path. We first consider nonnegative edge weights, i.e. c W E.G/ ! RC . The SHORTEST PATH PROBLEM can be solved by BFS if all weights are 1 (Proposition 2.18). For weights c W E.G/ ! N one could replace an edge e by a path of length c.e/ and again use BFS. However, this might introduce an exponential number P of edges; recall that the input size is ‚ n log m C m log n C e2E.G/ log c.e/ , where n D jV .G/j and m D jE.G/j.

7.1

Shortest Paths From One Source

159

A much better idea is to use the following algorithm, due to Dijkstra [1959]. It is quite similar to PRIM’S ALGORITHM for the MINIMUM SPANNING TREE PROBLEM (Section 6.1).

DIJKSTRA’S ALGORITHM Input:

A digraph G, weights c W E.G/ ! RC and a vertex s 2 V .G/.

Output:

Shortest paths from s to all v 2 V .G/ and their lengths. More precisely, we get the outputs l.v/ and p.v/ for all v 2 V .G/nfsg. l.v/ is the length of a shortest s-v-path, which consists of a shortest sp.v/-path together with the edge .p.v/; v/. If v is not reachable from s, then l.v/ D 1 and p.v/ is undefined.

2

Set l.s/ WD 0. Set l.v/ WD 1 for all v 2 V .G/ n fsg. Set R WD ;. Find a vertex v 2 V .G/ n R such that l.v/ D min

3

Set R WD R [ fvg.

4

For all w 2 V .G/ n R such that .v; w/ 2 E.G/ do: If l.w/ > l.v/ C c..v; w// then set l.w/ WD l.v/ C c..v; w// and p.w/ WD v. If R 6D V .G/ then go to . 2

1

5

w2V .G/nR

l.w/.

Theorem 7.3. (Dijkstra [1959]) DIJKSTRA’S ALGORITHM works correctly. Proof: We prove that the following statements hold at any stage of the algorithm: (a) For each v 2 V .G/ n fsg with l.v/ < 1 we have p.v/ 2 R, l.p.v// C c..p.v/; v// D l.v/, and the sequence v; p.v/; p.p.v//; : : : contains s. (b) For all v 2 R: l.v/ D dist.G;c/ .s; v/. The statements trivially hold after . 1 l.w/ is decreased to l.v/ C c..v; w// and p.w/ is set to v in 4 only if v 2 R and w … R. As the sequence v; p.v/; p.p.v//; : : : contains s but no vertex outside R, in particular not w, (a) is preserved by . 4 (b) is trivial for v D s. Suppose that v 2 V .G/ n fsg is added to R in , 3 and there is an s-v-path P in G that is shorter than l.v/. Let y be the first vertex on P that belongs to .V .G/ n R/ [ fvg, and let x be the predecessor of y on P . Since x 2 R, we have by 4 and the induction hypothesis: l.y/ l.x/ C c..x; y// D dist.G;c/ .s; x/ C c..x; y// c.E.PŒs;y // c.E.P // < l.v/; contradicting the choice of v in . 2

The running time is obviously O.n2 /. Using a Fibonacci heap we can do better:

160

7 Shortest Paths

Theorem 7.4. (Fredman and Tarjan [1987]) DIJKSTRA’S ALGORITHM implemented with a Fibonacci heap runs in O.m C n log n/ time, where n D jV .G/j and m D jE.G/j. Proof: We apply Theorem 6.7 to maintain the set f.v; l.v// W v 2 V .G/ n R; l.v/ < 1g. Then 2 and 3 are one DELETEMIN-operation, while the update of l.w/ in 4 is an INSERT -operation if l.w/ was infinite and a DECREASEKEYoperation otherwise. This is the best known strongly polynomial running time for the SHORTEST PATH PROBLEM with nonnegative weights. (On different computational models, Fredman and Willard [1994], Thorup [2000] and Raman [1997] achieved slightly better running times.) If the weights are integers within a fixed range there is a simple linear-time algorithm (Exercise running times of O.m log log cmax / (Johnson [1982]) p3). In general, and O m C n log cmax (Ahuja et al. [1990]) are possible for weights c W E.G/ ! f0; : : : ; cmax g. This has been improved by Thorup [2004] to O.m C n log log cmax / and O.m C n log log n/, but even the latter bound applies to integral edge weights only, and the algorithm is not strongly polynomial. For general nonnegative weights, Orlin et al. [2010] described an O.m log.2 C nk=m//-time algorithm, where k is the number of distinct edge weights. For planar digraphs there is a linear-time algorithm due to Henzinger et al. [1997]. Finally we mention that Thorup [1999] found a linear-time algorithm for finding a shortest path in an undirected graph with nonnegative integral weights. See also Pettie and Ramachandran [2005]; this paper also contains more references. We now turn to an algorithm for general conservative weights:

MOORE-BELLMAN-FORD ALGORITHM Input:

A digraph G, weights c W E.G/ ! R, and a vertex s 2 V .G/.

Output:

A negative circuit C in G, or shortest paths from s to all v 2 V .G/ and their lengths. More precisely, in the second case we get the outputs l.v/ and p.v/ for all v 2 V .G/ n fsg. l.v/ is the length of a shortest s-v-path, which consists of a shortest s-p.v/-path together with the edge .p.v/; v/. If v is not reachable from s, then l.v/ D 1 and p.v/ is undefined.

1

Set l.s/ WD 0 and l.v/ WD 1 for all v 2 V .G/ n fsg. Let n WD jV .G/j.

2

For i WD 1 to n 1 do: For each edge .v; w/ 2 E.G/ do: If l.w/ > l.v/ C c..v; w// then set l.w/ WD l.v/ C c..v; w// and p.w/ WD v. If there is an edge .v; w/ 2 E.G/ with l.w/ > l.v/ C c..v; w// then set xn WD w, xn1 WD v, and xni 1 WD p.xni / for i D 1; : : : ; n 1, and output any circuit C in .V .G/; f.xi 1 ; xi / W i D 1; : : : ; ng/.

3

7.1

Shortest Paths From One Source

161

Theorem 7.5. (Moore [1959], Bellman [1958], Ford [1956]) The MOORE-BELLMAN -FORD A LGORITHM works correctly. Its running time is O.nm/. Proof: The O.nm/ running time is obvious. At any stage of the algorithm, for v 2 V .G/, let k.v/ be the iteration in which l.v/ was decreased to its present value, and k.v/ WD 0 if l.v/ has not been changed after . 1 Let F WD f.p.y/; y/ W y 2 V .G/; k.y/ > 0g, and F 0 WD f.v; w/ 2 E.G/ W l.w/ > l.v/Cc..v; w//g. We claim that the following statements always hold: (a) l.y/ l.x/ C c..x; y// and k.x/ k.y/ 1 for all .x; y/ 2 F ; (b) If F [ F 0 contains a circuit C , then C has negative total weight. To prove (a), observe that l.y/ D l.x/ C c..x; y// and k.x/ k.y/ 1 when p.y/ is set to x, and l.x/ is never increased, and k.x/ is never decreased. 0 P a circuit C in .V .G/; F [ F /. By (a) we have P To prove (b), consider .v;w/2E.C / c..v; w// D .v;w/2E.C / .c..v; w// C l.v/ l.w// 0. This proves (b) except in the case that E.C / F . If at some stage a circuit C in .V .G/; F / is created by setting p.y/ WD x, then we had just before the insertion .x; y/ 2 F 0 , and hence C is a negative circuit. If the algorithm finds an edge .v; w/ 2 F 0 in , 3 then k.v/ D n 1, and thus k.xi / i for i D n 2; : : : ; 1. Hence the sequence x0 ; : : : ; xn is well-defined, and it must contain a repetition. Hence 3 indeed finds a circuit C , which has negative total weight due to (b). If theP algorithm ends with l.w/ P l.v/ C c..v; w// for all .v; w/ 2 E.G/, then we have .v;w/2E.C / c..v; w// D .v;w/2E.C / .c..v; w// C l.v/ l.w// 0 for every circuit C in GŒR, where R WD fv 2 V .G/ W l.v/ < 1g. Hence GŒR contains no negative circuit. Then (b) implies that .R; F / is acyclic. Moreover, x 2 R n fsg implies p.x/ 2 R, so .R; F / is an arborescence rooted at s. By (a), l.x/ is at least the length of the s-x-path in .R; F / for any x 2 R (at any stage of the algorithm). We claim that after k iterations of the algorithm, l.x/ is at most the length of a shortest s-x-path with at most k edges. This statement is easily proved by induction: Let P be a shortest s-x-path with at most k edges and let .w; x/ be the last edge of P . Then, by applying Proposition 7.2 to GŒR, PŒs;w must be a shortest s-wpath with at most k 1 edges, and by the induction hypothesis we have l.w/ c.E.PŒs;w // after k 1 iterations. But in the k-th iteration edge .w; x/ is also examined, after which l.x/ l.w/ C c..w; x// c.E.P //. Since no path has more than n1 edges, the above claim implies the correctness of the algorithm. Note that if c is conservative, .R; F / is an arborescence containing a shortest path from s to each vertex that is reachable from s. This is sometimes called a shortest paths tree. This algorithm is still the fastest known strongly polynomial-time algorithm for the SHORTEST PATH PROBLEM in digraphs with conservative p weights. A scaling algorithm due to Goldberg [1995] has a running time of O nm log.jcmin j C 2/

162

7 Shortest Paths

if the edge weights are integral and at least cmin . For planar digraphs, Mozes and Wulff-Nilsen [2010] described an O.n log2 n= log log n/-time algorithm. If G contains negative circuits, no polynomial-time algorithm for the SHORTEST PATH PROBLEM is known (the problem becomes NP-hard; see Exercise 17(b) of Chapter 15). The main difficulty is that Proposition 7.2 does not hold for general weights. It is not clear how to construct a path instead of an arbitrary edge progression. If there are no negative circuits, any shortest edge progression is a path, plus possibly some circuits of zero weight that can be deleted. In view of this it is also an important question how to prove that there are no negative circuits. The following concept due to Edmonds and Karp [1972] is useful: Definition 7.6. Let G be a digraph with weights c W E.G/ ! R, and let W V .G/ ! R. Then for any .x; y/ 2 E.G/ we define the reduced cost of .x; y/ with respect to by c ..x; y// WD c..x; y// C .x/ .y/. If c .e/ 0 for all e 2 E.G/, is called a feasible potential. Theorem 7.7. Let G be a digraph with weights c W E.G/ ! R. There exists a feasible potential of .G; c/ if and only if c is conservative. Given a digraph G with weights c W E.G/ ! R, we can find in O.nm/ time either a feasible potential or a negative circuit. Proof: If is a feasible potential, we have for each circuit C : X X 0 c .e/ D .c.e/ C .x/ .y// D e2E.C /

eD.x;y/2E.C /

X

c.e/

e2E.C /

(the potentials cancel). So c is conservative. To find either a negative circuit or a feasible potential, we add a new vertex s and edges .s; v/ of zero cost for all v 2 V .G/. Then we run the MOORE-BELLMANFORD ALGORITHM. The output is either a negative circuit (which of course cannot contain s) or numbers l.v/ < 1 for all v 2 V .G/ constituting a feasible potential. This can be regarded as a special form of LP duality; see Exercise 9. In practice there are more efficient methods to detect negative circuits; see Cherkassky and Goldberg [1999].

7.2 Shortest Paths Between All Pairs of Vertices Suppose we now want to find a shortest s-t-path for all ordered pairs of vertices .s; t/ in a digraph:

ALL PAIRS SHORTEST PATHS PROBLEM Instance:

A digraph G and conservative weights c W E.G/ ! R.

Task:

Find numbers lst and vertices pst for all s; t 2 V .G/ with s 6D t, such that lst is the length of a shortest s-t-path, and .pst ; t/ is the final edge of such a path (if it exists).

7.2

Shortest Paths Between All Pairs of Vertices

163

Of course we could run the MOORE-BELLMAN-FORD ALGORITHM n times, once for each choice of s. This immediately gives us an O.n2 m/-algorithm. However, one can do better, as was observed by Bazaraa and Langley [1974] and Johnson [1977]: Theorem 7.8. The ALL PAIRS SHORTEST PATHS PROBLEM can be solved in O.mn C n2 log n/ time, where n D jV .G/j and m D jE.G/j. Proof: Let .G; c/ be an instance. First we compute a feasible potential , which is possible in O.nm/ time by Corollary 7.7. Then for each s 2 V .G/ we do a single-source shortest path computation from s using the reduced costs c instead of c. For any vertex t the resulting s-t-path is also a shortest path with respect to c, because the length of any s-t-path changes by .s/ .t/, a constant. Since the reduced costs are nonnegative, we can use DIJKSTRA’S ALGORITHM each time. So, by Theorem 7.4, the total running time is O.mn C n.m C n log n//. The same idea will be used again in Chapter 9 (in the proof of Theorem 9.13). Pettie [2004] showed how to improve the running time to O.mn C n2 log log n/; this is the best known time bound. For dense graphs with nonnegative weights, Chan’s [2010] bound of O.n3 log3 log n= log2 n/ is slightly better. If all edge weights are small positive integers, this can be improved using fast matrix multiplication; see e.g. Zwick [2002]. The solution of the ALL PAIRS SHORTEST PATHS PROBLEM also enables us to compute the metric closure: Definition 7.9. Given a graph G (directed or undirected) with conservative N c/, weights c W E.G/ ! R. The metric closure of .G; c/ is the pair .G; N where N G is the simple graph on V .G/ that, for x; y 2 V .G/ with x 6D y, contains an edge e D fx; yg (or e D .x; y/ if G is directed) with weight c.e/ N D dist.G;c/ .x; y/ if and only if y is reachable from x in G. Corollary 7.10. Let G be a digraph with conservative weights c W E.G/ ! R, or an undirected graph with nonnegative weights c W E.G/ ! RC . Then the metric closure of .G; c/ can be computed in O.mn C n2 log n/ time. Proof: If G is undirected, we replace each edge by a pair of oppositely directed edges. Then we solve the resulting instance of the ALL PAIRS SHORTEST PATHS PROBLEM. The rest of the section is devoted to the FLOYD-WARSHALL ALGORITHM, another O.n3 /-algorithm for the ALL PAIRS SHORTEST PATHS PROBLEM. The main advantage of the FLOYD-WARSHALL ALGORITHM is its simplicity. We assume w.l.o.g. that the vertices are numbered 1; : : : ; n.

164

7 Shortest Paths

FLOYD-WARSHALL ALGORITHM Input: Output:

A digraph G with V .G/ D f1; : : : ; ng and conservative weights c W E.G/ ! R. Matrices .lij /1i;j n and .pij /1i;j n where lij is the length of a shortest path from i to j , and .pij ; j / is the final edge of such a path (if it exists).

1

Set lij WD c..i; j // for all .i; j / 2 E.G/. Set lij WD 1 for all .i; j / 2 .V .G/ V .G// n E.G/ with i 6D j . Set li i WD 0 for all i . Set pij WD i for all i; j 2 V .G/.

2

For j WD 1 to n do: For i WD 1 to n do: If i 6D j then: For k WD 1 to n do: If k 6D j then: If li k > lij C ljk then set li k WD lij C ljk and pi k WD pjk .

Theorem 7.11. (Floyd [1962], Warshall [1962]) The FLOYD-WARSHALL ALGORITHM works correctly. Its running time is O.n3 /. Proof: The running time is obvious. Claim: After the algorithm has run through the outer loop for j D 1; 2; : : : ; j0 , the variable li k contains the length of a shortest i -k-path with intermediate vertices v 2 f1; : : : ; j0 g only (for all i and k), and .pi k ; k/ is the final edge of such a path. This statement will be shown by induction for j0 D 0; : : : ; n. For j0 D 0 it is true by , 1 and for j0 D n it implies the correctness of the algorithm. Suppose the claim holds for some j0 2 f0; : : : ; n 1g. We have to show that it still holds for j0 C 1. For any i and k, during processing the outer loop for j D j0 C 1, li k (containing by the induction hypothesis the length of a shortest i -k-path with intermediate vertices v 2 f1; : : : ; j0 g only) is replaced by li;j0 C1 C lj0 C1;k if this value is smaller. It remains to show that the corresponding i -.j0 C 1/-path P and the .j0 C 1/-k-path Q have no inner vertex in common. Suppose that there is an inner vertex belonging to both P and Q. By shortcutting a maximal closed walk in P C Q (which by our assumption has nonnegative weight because it is the union of circuits) we get an i -k-path R with intermediate vertices v 2 f1; : : : ; j0 g only. R is no longer than li;j0 C1 C lj0 C1;k (and in particular shorter than the li k before processing the outer loop for j D j0 C 1/. This contradicts the induction hypothesis since R has intermediate vertices v 2 f1; : : : ; j0 g only. Like the MOORE-BELLMAN-FORD ALGORITHM, the FLOYD-WARSHALL ALGORITHM can also be used to detect the existence of negative circuits (see Exercise 13 and Hougardy [2010]). The ALL PAIRS SHORTEST PATHS PROBLEM in undirected graphs with arbitrary conservative weights is more difficult; see Theorem 12.14.

7.3

Minimum Mean Cycles

165

7.3 Minimum Mean Cycles We can easily find a circuit of minimum total weight in a digraph with conservative weights, using the above shortest path algorithms (see Exercise 14). Another problem asks for a circuit whose mean weight is minimum:

DIRECTED MINIMUM MEAN CYCLE PROBLEM Instance:

A digraph G, weights c W E.G/ ! R.

Task:

Find a circuit C whose mean weight that G is acyclic.

c.E.C // jE.C /j

is minimum, or decide

In this section we show how to solve this problem with dynamic programming, quite similar to the shortest path algorithms. We could assume that G is strongly connected, since otherwise we can identify the strongly connected components in linear time (Theorem 2.19) and solve the problem for each strongly connected component separately. But for the following min-max theorem it suffices to assume that there is a vertex s from which all vertices are reachable. We consider not only paths, but arbitrary edge progressions (where vertices and edges may be repeated). Theorem 7.12. (Karp [1978]) Let G be a digraph with weights c W E.G/ ! R. Let s 2 V .G/ such that each vertex is reachable from s. For x 2 V .G/ and k 2 ZC let ( k ) X c..vi 1 ; vi // W v0 D s; vk D x; .vi 1 ; vi / 2 E.G/ for all i Fk .x/ WD min i D1

be the minimum weight of an edge progression of length k from s to x (and 1 if there is none). Let .G; c/ be the minimum mean weight of a circuit in G (and .G; c/ D 1 if G is acyclic). Then .G; c/ D

min

max

x2V .G/ 0kn1 Fk .x/ 1 do: For e D .p; vi / 2 ıG .vi / with p 2 fv1 ; : : : ; vi 1 g do: f 0 Set ˇ WD minfˇ.vi /; uf .e/g. Augment f along e by ˇ 0 . Set ˇ.vi / WD ˇ.vi / ˇ 0 and ˇ.p/ WD ˇ.p/ C ˇ 0 . Set i WD i 1. Go to . 2

6

7

Theorem 8.22. FUJISHIGE’S ALGORITHM correctly solves the MAXIMUM FLOW PROBLEM for simple digraphs G and integral capacities u W E.G/ ! ZC in O.mn log umax / time, where n WD jV .G/j, m WD jE.G/j and umax WD maxfu.e/ W e 2 E.G/g. Proof: Let us call an iteration a sequence of steps ending with 4 or . 7 In – 2 , 5 v1 ; : : : ; vi is always an order of a subset of vertices such that b.vj /

186

8 Network Flows

D uf .E C .fv1 ; : : : ; vj 1 g; fvjP g// ˛ for j D 2; : : : ; i . In 6 the flow f is augmented with the invariant v2V .G/ ˇ.v/ D ˛, and by the above the result is an s-t-flow whose value is ˛ units larger. Thus after at most n 1 iterations, ˛ will be decreased for the first time. When C we decrease ˛ to ˛ 0 D b ˛2 c ˛3 in , .fv1 ; : : : ; vi g/ in Gf 4 we have an s-t-cut ıG f C of capacity less than ˛.jV .G/ji / because b.v/ D uf .E .fv1 ; : : : ; vi g; fvg// < ˛ for all v 2 V .G/ n fv1 ; : : : ; vi g. By Lemma 8.3(b), a maximum s-t-flow in Gf has value less than ˛.n i / < 3˛ 0 n. Hence after less than 3n iterations, ˛ will be decreased again. If ˛ is decreased from 1 to 0, we have an s-t-cut of capacity 0 in Gf , so f is maximum. As ˛ is decreased at most 1 C log umax times before it reaches 0, and each iteration takes O.m/ time, the overall running time is O.mn log umax /. Such a scaling technique is useful in many contexts and will reappear in Chapter 9. Fujishige [2003] also described a variant of his algorithm without scaling, where vi in 5 is chosen as a vertex attaining maxfb.v/ W v 2 V .G/ n fv1 ; : : : ; vi 1 gg. The resulting order is called MA order and will reappear in Section 8.7. The running time of this variant is slightly higher than the above and not strongly polynomial either (Shioura [2004]). See Exercise 24.

8.5 The Goldberg-Tarjan Algorithm In this section we shall describe the PUSH-Rp ELABEL A LGORITHM due to Goldberg and Tarjan [1988]. We shall derive an O.n2 m/ bound for the running time. Sophisticated implementations using dynamic trees (seeSleator and Tarjan 2 [1983]) result in network flow algorithms with running time O nm log nm (Gold np berg and Tarjan [1988]) and O nm log m log umax C 2 , where umax is the maximum (integral) edge capacity (Ahuja, Orlin and Tarjan [1989]). The best known bounds today are O nm log2Cm=.n log n/ n (King, Rao and Tarjan [1994]) and 2 n O minfm1=2 ; n2=3 gm log log umax m (Goldberg and Rao [1998]). By definition and Theorem 8.5, a flow f is a maximum s-t-flow if and only if the following conditions hold: exf .v/ D 0 for all v 2 V .G/ n fs; tg; There is no f -augmenting path. In the algorithms discussed so far, the first condition is always satisfied, and the algorithms stop when the second condition is satisfied. The PUSH-RELABEL ALGORITHM starts with an f satisfying the second condition and maintains it throughout. Naturally it stops when the first condition is satisfied as well. So f will not be an

8.5

The Goldberg-Tarjan Algorithm

187

s-t-flow during the algorithm (except at termination), but an s-t-preflow (cf. Definition 8.19). Definition 8.23. Let .G; u; s; t/ be a network and f an s-t-preflow. A distance labeling is a function W V .G/ ! ZC such that .t/ D 0, .s/ D n WD jV .G/j $

and .v/ .w/ C 1 for all .v; w/ 2 E.Gf /. An edge e D .v; w/ 2 E.G/ is called admissible if e 2 E.Gf / and .v/ D .w/ C 1. If is a distance labeling, .v/ (for v ¤ s) must be a lower bound on the distance to t (number of edges in a shortest v-t-path) in Gf . The PUSH-RELABEL ALGORITHM to be described below always works with an s-t-preflow f and a distance labeling . It starts with the preflow that is equal to the capacity on each edge leaving s and zero on all other edges. The initial distance labeling is .s/ D n and .v/ D 0 for all v 2 V .G/ n fsg. Then the algorithm performs the update operations P USH (updating f ) and RELABEL (updating ) in any order.

PUSH-RELABEL ALGORITHM Input:

A network .G; u; s; t/.

Output:

A maximum s-t-flow f .

1 2 3

Set f .e/ WD u.e/ for each e 2 ı C .s/. Set f .e/ WD 0 for each e 2 E.G/ n ı C .s/. Set .s/ WD n WD jV .G/j and .v/ WD 0 for all v 2 V .G/ n fsg. While there exists an active vertex do: Let v be an active vertex. C If no e 2 ıG .v/ is admissible f then RELABEL(v), C else let e 2 ıG .v/ be an admissible edge and PUSH(e). f

PUSH(e) 1

Set WD minfexf .v/; uf .e/g, where v is the tail of e.

2

Augment f along e by .

RELABEL(v) 1

Set

C .v/g. .v/ WD minf .w/ C 1 W .v; w/ 2 ıG f

Proposition 8.24. During the execution of the PUSH-RELABEL ALGORITHM f is always an s-t-preflow and is always a distance labeling with respect to f . For each v 2 V .G/, .v/ is strictly increased by every RELABEL.v/.

188

8 Network Flows

Proof: We have to show that the procedures PUSH and RELABEL preserve these properties. It is clear that after a PUSH operation, f is still an s-t-preflow. A RELABEL operation does not even change f . If RELABEL.v/ is called and was a distance labeling before, then .v/ is C strictly increased (as no e 2 ıG .v/ was admissible), and remains a distance f labeling. We finally show that after a PUSH operation, is still a distance labeling with respect to the new preflow. We have to check .a/ .b/ C 1 for all new edges .a; b/ in Gf . But if we apply PUSH(e) for some e D .v; w/, the only possible new edge in Gf is the reverse edge of e, and here we have .w/ D .v/ 1, since e is admissible. Lemma 8.25. If f is an s-t-preflow and f , then:

is a distance labeling with respect to

(a) s is reachable from any active vertex v in Gf . (b) If w is reachable from v in Gf for some v; w 2 V .G/, then .v/ (c) t is not reachable from s in Gf .

.w/Cn1.

Proof: (a): Let v be an active vertex, and let R be the set of vertices reachable from v in Gf . Then f .e/ D 0 for all e 2 ıG .R/. So X w2R

exf .w/ D

X

f .e/

e2ıG .R/

X

f .e/ 0:

C e2ıG .R/

But v is active, meaning exf .v/ > 0, and therefore there must exist a vertex w 2 R with exf .w/ < 0. Since f is an s-t-preflow, this vertex must be s. (b): Suppose there is a v-w-path in Gf , say with vertices v D v0 ; v1 ; : : : ; vk D w. Since is a distance labeling with respect to f , .vi / .vi C1 / C 1 for i D 0; : : : ; k 1. So .v/ .w/ C k. Note that k n 1. (c): follows from (b) as .s/ D n and .t/ D 0. Part (c) helps us to prove the following: Theorem 8.26. When the algorithm terminates, f is a maximum s-t-flow. Proof: f is an s-t-flow because there are no active vertices. Lemma 8.25(c) implies that there is no augmenting path. Then by Theorem 8.5 we know that f is maximum. The question now is how many PUSH and RELABEL operations are performed. Lemma 8.27. (a) For each v 2 V .G/, .v/ never decreases, and .v/ 2n 1 at any stage of the algorithm. (b) No The total increase of P vertex is relabelled more than 2n 1 times. 2 .v/ during the algorithm is at most 2n n. v2V .G/

8.5

The Goldberg-Tarjan Algorithm

189

Proof: Recall from Proposition 8.24 that .v/ is strictly increased by every RELABEL.v/. Moreover, we only change .v/ by RELABEL.v/ if v is active. By Lemma 8.25(a) and (b), .v/ .s/ C n 1 D 2n 1. This implies (a) and (b). We shall now analyse the number of PUSH operations. We distinguish between saturating pushes (where uf .e/ D 0 after the push) and nonsaturating pushes. As usual we denote m WD jE.G/j (and n WD jV .G/j). Lemma 8.28. The number of saturating pushes is at most 2mn. Proof: After each saturating push from v to w, another such push cannot occur until .w/ increases by at least 2, a push from w to v occurs, and .v/ increases by at least 2. Together with Lemma 8.27(a), this proves that there are at most n $

saturating pushes on each edge .v; w/ 2 E.G/.

The number of nonsaturating pushes can be in the order of n2 m in general (Exercise 25). By choosing an active vertex v with .v/ maximum in 3 we can prove a better bound. We may assume n m n2 . Lemma 8.29. If we always choose v to be an active vertex with .v/ maximum in PUSH-RELABEL ALGORITHM, the number of nonsaturating pushes is at 3 of thep most 8n2 m. Proof: Call a phase the time between two consecutive changes of WD maxf .v/ W v activeg. As can increase only by relabeling, its total increase is less than 2n2 . As D 0 initially, it decreases less than 2n2 times, and the number of phases is less than 4n2 . p Call a phase cheap if it contains at most m nonsaturating pushes and expensive p otherwise. Clearly there are at most 4n2 m nonsaturating pushes in cheap phases. Let X ˆ WD jfw 2 V .G/ W .w/ .v/gj: v2V .G/Wv active Initially ˆ n2 . A relabeling step may increase ˆ by at most n. A saturating push may increase ˆ by at most n. A nonsaturating push does not increase ˆ. Since ˆ D 0 at termination, the total decrease of ˆ is at most n2 Cn.2n2 n/Cn.2mn/ 4mn2 . Now consider the nonsaturating pushes in an expensive phase. Each of them pushes flow along an edge .v; w/ with .v/ D D .w/ C 1, deactivating v and possibly activating w. As the phase ends by deactivating the last active vertex v with .v/ D or by relabeling, the set of verticesp w with .w/ D remains constant during the phase, and it contains more than m vertices as the phase is expensive. Hence each p nonsaturating push in an expensive phase decreases ˆ by at least m. Thus the total p 2 p number of nonsaturating pushes in expensive phases is at most 4mn D 4n2 m. m

190

8 Network Flows

This proof is due to Cheriyan and Mehlhorn [1999]. We finally get: Theorem 8.30. (Goldberg and Tarjan [1988], Cheriyan and Maheshwari [1989], Tunçel [1994]) The PUSH-RELABEL ALGORITHM solves p the MAXIMUM FLOW PROBLEM correctly and can be implemented to run in O.n2 m/ time. Proof: The correctness follows from Theorem 8.26. As in Lemma 8.29 we always choose v in 3 to be an active vertex with .v/ maximum. To make this easy we keep track of doubly-linked lists L0 ; : : : ; L2n1 , where Li contains the active vertices v with .v/ D i . These lists can be updated during each PUSH and RELABEL operation in constant time. We can then start by scanning Li for i D 0. When a vertex is relabelled, we increase i accordingly. When we find a list Li for the current i empty (after deactivating the last active vertex at that level), we decrease i until Li is nonempty. As we increase i at most 2n2 times by Lemma 8.27(b), we also decrease i at most 2n2 times. As a second data structure, we store a doubly-linked list Av containing the admissible edges leaving v for each vertex v. They can also be updated in each PUSH operation in constant time, and in each RELABEL operation in time proportional to the total number of edges incident to the relabelled vertex. So RELABEL.v/ takes a total of O.jıG .v/j/ time, and by Lemma 8.27(b) the overall time for relabelling is O.mn/. Each PUSH takes constant p time, and by Lemma 8.28 and Lemma 8.29 the total number of pushes is O.n2 m/.

8.6 Gomory-Hu Trees Any algorithm for the MAXIMUM FLOW PROBLEM also implies a solution to the following problem:

MINIMUM CAPACITY CUT PROBLEM Instance:

A network .G; u; s; t/.

Task:

An s-t-cut in G with minimum capacity.

Proposition 8.31. The MINIMUM CAPACITY CUT PROBLEM can be solved in pthe same running time as the MAXIMUM FLOW PROBLEM, in particular in O.n2 m/ time. Proof: For a network .G; u; s; t/ we compute a maximum s-t-flow f and define X to be the set of all vertices reachable from s in Gf . X can be computed with the GRAPH SCANNING ALGORITHM in linear time (Proposition 2.17). By Lemma p8.3 C and Theorem 8.5, ıG .X / constitutes a minimum capacity s-t-cut. The O.n2 m/ running time follows from Theorem 8.30 (and is not best possible). In this section we consider the problem of finding a minimum capacity s-tcut for each pair of vertices s; t in an undirected graph G with capacities u W E.G/!RC .

8.6

Gomory-Hu Trees

191

This problem can be reduced to the above one: For all pairs s; t 2 V .G/ we solve the MINIMUM CAPACITY CUT PROBLEM for .G 0 ; u0 ; s; t/, where .G 0 ; u0 / arises from .G; u/ by replacing each undirected edge fv; wg by two oppositely directed 0 edges .v; w/ and .w; v/ with u0 ..v; w// D u ..w; v// D u.fv; wg/. In this way we obtain minimum s-t-cuts for all s; t after n2 flow computations. This section is devoted to the elegant method of Gomory and Hu [1961], which requires only n 1 flow computations. We shall see some applications in Sections 12.3 and 20.3. Definition 8.32. Let G be an undirected graph and u W E.G/ ! RC a capacity function. For two vertices s; t 2 V .G/ we denote by st their local edgeconnectivity, i.e. the minimum capacity of a cut separating s and t. The edge-connectivity of a graph is obviously the minimum local edgeconnectivity with respect to unit capacities. Lemma 8.33. For all vertices i; j; k 2 V .G/ we have i k minfij ; jk g. Proof: Let ı.A/ be a cut with i 2 A, k 2 V .G/ n A and u.ı.A// D i k . If j 2 A then ı.A/ separates j and k, so u.ı.A// jk . If j 2 V .G/nA then ı.A/ separates i and j , so u.ı.A// ij . We conclude that i k D u.ı.A// minfij ; jk g. Indeed, this condition is not only necessary but also sufficient for numbers .ij /1i;j n with ij D j i to be local edge-connectivities of some graph (Exercise 31). Definition 8.34. Let G be an undirected graph and u W E.G/ ! RC a capacity function. A tree T is called a Gomory-Hu tree for .G; u/ if V .T / D V .G/ and st D

min

e2E.Pst /

u.ıG .Ce // for all s; t 2 V .G/;

where Pst is the (unique) s-t-path in T and, for e 2 E.T /, Ce and V .G/ n Ce are the connected components of T e (i.e. ıG .Ce / is the fundamental cut of e with respect to T ). We shall see that every undirected graph possesses a Gomory-Hu tree. This implies that for any undirected graph G there is a list of n 1 cuts such that for each pair s; t 2 V .G/ a minimum s-t-cut belongs to the list. This is not true for digraphs: for each n 2 N, Jelinek and Mayeda [1963] constructed a digraph G with n vertices and capacities u W E.G/ ! RC such that the set fminfu.ı C .X // W s 2 X V .G/nftgg W s; t 2 V .G/; s 6D tg contains .nC2/.n1/=2 different numbers. In general, a Gomory-Hu tree cannot be chosen as a subgraph of G. For example, consider G D K3;3 and u 1. Here st D 3 for all s; t 2 V .G/. It is easy to see that the Gomory-Hu trees for .G; u/ are exactly the stars with five edges. The main idea of the algorithm for constructing a Gomory-Hu tree is as follows. First we choose any s; t 2 V .G/ and find some minimum s-t-cut, say ı.A/. Let B WD V .G/ n A. Then we contract A (or B) to a single vertex, choose any

192

8 Network Flows

s 0 ; t 0 2 B (or s 0 ; t 0 2 A, respectively) and look for a minimum s 0 -t 0 -cut in the contracted graph G 0 . We continue this process, always choosing a pair s 0 ; t 0 of vertices not separated by any cut obtained so far. At each step, we contract – for each cut E.A0 ; B 0 / obtained so far – A0 or B 0 , depending on which part does not contain s 0 and t 0 . Eventually each pair of vertices is separated. We have obtained a total of n 1 cuts. The crucial observation is that a minimum s 0 -t 0 -cut in the contracted graph G 0 is also a minimum s 0 -t 0 -cut in G. This is the subject of the following lemma. Note that when contracting a set A of vertices in .G; u/, the capacity of each edge in G 0 is the capacity of the corresponding edge in G. Lemma 8.35. Let G be an undirected graph and u W E.G/ ! RC a capacity function. Let s; t 2 V .G/, and let ı.A/ be a minimum s-t-cut in .G; u/. Let now s 0 ; t 0 2 V .G/ n A, and let .G 0 ; u0 / arise from .G; u/ by contracting A to a single vertex. Then for any minimum s 0 -t 0 -cut ı.K [ fAg/ in .G 0 ; u0 /, ı.K [ A/ is a minimum s 0 -t 0 -cut in .G; u/. Proof: Let s; t; A; s 0 ; t 0 ; G 0 ; u0 be as above. W.l.o.g. s 2 A. It suffices to prove that there is a minimum s 0 -t 0 -cut ı.A0 / in .G; u/ such that A A0 . So let ı.C / be any minimum s 0 -t 0 -cut in .G; u/. W.l.o.g. s 2 C . A

V (G) \ A

t V (G) \ C C s

s

Fig. 8.3.

Since u.ı.// is submodular (cf. Lemma 2.1(c)), we have u.ı.A// C u.ı.C // u.ı.A \ C // C u.ı.A [ C //. But ı.A \ C / is an s-t-cut, so u.ı.A \ C // st D u.ı.A//. Therefore u.ı.A [ C // u.ı.C // D s 0 t 0 proving that ı.A [ C / is a minimum s 0 -t 0 -cut. (See Figure 8.3.) Now we describe the algorithm which constructs a Gomory-Hu tree. Note that the vertices of the intermediate trees T will be vertex sets of the original graph;

8.6

Gomory-Hu Trees

193

indeed they form a partition of V .G/. At the beginning, the only vertex of T is V .G/. In each iteration, a vertex of T containing at least two vertices of G is chosen and split into two.

GOMORY-HU ALGORITHM Input:

An undirected graph G and a capacity function u W E.G/ ! RC .

Output:

A Gomory-Hu tree T for .G; u/.

1

Set V .T / WD fV .G/g and E.T / WD ;.

2

Choose some X 2 V .T / with jX j 2. If no such X exists then go to . 6

3

Choose s; t 2 X with s 6D t. S For each connected component C of T X do: Let SC WD Y 2V .C / Y . Let .G 0 ; u0 / arise from .G; u/ by contracting SC to a single vertex vC for each connected component C of T X . (So V .G 0 / D X [ fvC W C is a connected component of T X g.) 0 0 WD V .G 0 / n A Find a minimum s-t-cut1ı.A0 / in .G 0 ; u0 /. Let B0 0 1. [ [ SC A [ .A0 \ X / and B WD @ SC A [ .B 0 \ X /. Set A WD @

4

vC 2A0 nX

5

6

vC 2B 0 nX

Set V .T / WD .V .T / n fX g/ [ fA \ X; B \ X g. For each edge e D fX; Y g 2 E.T / incident to the vertex X do: If Y A then set e 0 WD fA \ X; Y g else set e 0 WD fB \ X; Y g. Set E.T / WD .E.T / n feg/ [ fe 0 g and w.e 0 / WD w.e/. Set E.T / WD E.T / [ ffA \ X; B \ X gg. Set w.fA \ X; B \ X g/ WD u0 .ıG 0 .A0 //. Go to . 2 Replace all fxg 2 V .T / by x and all ffxg; fygg 2 E.T / by fx; yg. Stop.

Figure 8.4 illustrates the modification of T in . 5 To prove the correctness of this algorithm, we first show the following lemma: Lemma 8.36. Each time at the end of 4 we have :

(a) A [ B D V .G/ (b) E.A; B/ is a minimum s-t-cut in .G; u/. Proof: The elements of V .T / are always nonempty subsets of V .G/, indeed V .T / constitutes a partition of V .G/. From this, (a) follows easily. We now prove (b). The claim is trivial for the first iteration (since here G 0 D G). We show that the property is preserved in each iteration. Let C1 ; : : : ; Ck be the connected components of T X . Let us contract them one by one; for i D 0; : : : ; k let .Gi ; ui / arise from .G; u/ by contracting each of SC1 ; : : : ; SCi to a single vertex. So .Gk ; uk / is the graph which is denoted by .G 0 ; u0 / in 3 of the algorithm.

194

8 Network Flows

a

X

b

A∩X

B∩X

Fig. 8.4.

Claim: For any minimum s-t-cut ı.Ai / in .Gi ; ui /, ı.Ai 1 / is a minimum s-t-cut in .Gi 1 ; ui 1 /, where ( .Ai n fvCi g/ [ SCi if vCi 2 Ai Ai 1 WD : Ai if vCi … Ai Applying this claim successively for k; k 1; : : : ; 1 implies (b). To prove the claim, let ı.Ai / be a minimum s-t-cut in .Gi ; ui /. By our assumption that (b) is true for the previous iterations, ı.SCi / is a minimum si -ti -cut in .G; u/ for some appropriate si ; ti 2 V .G/. Furthermore, s; t 2 V .G/ n SCi . So applying Lemma 8.35 completes the proof. Lemma 8.37. At any stage of the algorithm (until 6 is reached) for all e 2 E.T / 0 0 11 [ w.e/ D u @ıG @ Z AA ; Z2Ce

8.6

Gomory-Hu Trees

195

where Ce and V .T / n Ce are the connected components of T e. Moreover for all e D fP; Qg 2 E.T / there are vertices p 2 P and q 2 Q with pq D w.e/. Proof: Both statements are trivial at the beginning of the algorithm when T contains no edges; we show that they are never violated. So let X be the vertex of T chosen in 2 in some iteration of the algorithm. Let s; t; A0 ; B 0 ; A; B be as determined in 3 and 4 next. W.l.o.g. assume s 2 A0 . Edges of T not incident to X are not affected by . 5 For the new edge fA \ X; B \ X g, w.e/ is clearly set correctly, and we have st D w.e/, s 2 A \ X , t 2 B \ X. So let us consider an edge e D fX; Y g that is replaced by e 0 in . 5 We assume w.l.o.g. Y A, so e 0 D fA \ X; Y g. Assuming that the assertions were true for e 0 we claim that they remain true for e . This is trivial for the first assertion, because S 0 w.e/ D w.e / and u ıG Z does not change. Z2Ce To show the second statement, we assume that there are p 2 X; q 2 Y with pq D w.e/. If p 2 A \ X then we are done. So henceforth assume that p 2 B \ X (see Figure 8.5).

q

Y

s

t

p

B∩X

A∩X

Fig. 8.5.

We claim that sq D pq . Since pq D w.e/ D w.e 0 / and s 2 A \ X , this will conclude the proof. By Lemma 8.33, sq minfst ; tp ; pq g: Since by Lemma 8.36(b) E.A; B/ is a minimum s-t-cut, and since s; q 2 A, we may conclude from Lemma 8.35 that sq does not change if we contract B. Since t; p 2 B, this means that adding an edge ft; pg with arbitrary high capacity does not change sq . Hence sq minfst ; pq g: Now observe that st pq because the minimum s-t-cut E.A; B/ also separates p and q. So we have

196

8 Network Flows

sq pq : To prove equality, observe that w.e/ is the capacity of a cut separating X and Y , and thus s and q. Hence sq w.e/ D pq :

This completes the proof.

Theorem 8.38. (Gomory and Hu [1961]) The GOMORY-HU ALGORITHM works correctly. Every pundirected graph possesses a Gomory-Hu tree, and such a tree is found in O.n3 m/ time. Proof: The complexity of the algorithm is clearly determined by n 1 times the complexity of finding a minimum s-t-cut, since everything p else can be implemented in O.n3 / time. By Proposition 8.31 we obtain the O.n3 m/ bound. We prove that the output T of the algorithm is a Gomory-Hu tree for .G; u/. It should be clear that T is a tree with V .T / D V .G/. Now let s; t 2 V .G/. Let Pst be the (unique) s-t-path in T and, for e 2 E.T /, let Ce and V .G/ n Ce be the connected components of T e. Since ı.Ce / is an s-t-cut for each e 2 E.Pst /, st

min

e2E.Pst /

u.ı.Ce //:

On the other hand, a repeated application of Lemma 8.33 yields st

min

fv;wg2E.Pst /

vw :

Hence applying Lemma 8.37 to the situation before execution of 6 (where each vertex X of T is a singleton) yields st

min

e2E.Pst /

u.ı.Ce //;

so equality holds.

A similar algorithm for the same task (which might be easier to implement) was suggested by Gusfield [1990]. For digraphs, Cheung, Lau and Leung [2011] showed how to compute the minimum cardinality of an s-t-cut for all pairs s; t 2 V .G/ in O.m2:38 / time.

8.7 The Minimum Capacity of a Cut in an Undirected Graph If we are only interested in a minimum capacity cut in an undirected graph G with capacities u W E.G/ ! RC , there is a simpler method using n 1 flow computations: just compute a minimum s-t-cut for some fixed vertex s and each t 2 V .G/ n fsg. However, there are more efficient algorithms.

8.7

The Minimum Capacity of a Cut in an Undirected Graph

197

2

Hao and Orlin [1994] found an O.nm log nm /-algorithm for determining a minimum capacity cut. They use a modified version of the PUSH-RELABEL ALGORITHM . If we just want to compute the edge-connectivity of the graph (i.e. unit capacities), the currently fastest algorithm is due to Gabow [1995] with running time n O.mC2 n log .G/ /, where .G/ is the edge-connectivity (observe that 2m n). Gabow’s algorithm uses matroid intersection techniques. We remark that the M AXIMUM FLOW PROBLEM in undirected graphs with unit capacities can also be solved faster than in general (Karger and Levine [1998]). Nagamochi and Ibaraki [1992] found a completely different algorithm to determine a minimum capacity cut in an undirected graph. Their algorithm does not use max-flow computations at all. In this section we present this algorithm in a simplified form due to Stoer and Wagner [1997] and independently to Frank [1994]. We start with an easy definition. Definition 8.39. Given an undirected graph G with capacities u W E.G/ ! RC , we call an order v1 ; : : : ; vn of the vertices an MA (maximum adjacency) order if for all i 2 f2; : : : ; ng: X X u.e/ D max u.e/: e2E.fv1 ;:::;vi 1 g;fvi g/

j 2fi;:::;ng

e2E.fv1 ;:::;vi 1 g;fvj g/

Proposition 8.40. Given an undirected graph G with capacities u W E.G/ ! RC , an MA order can be found in O.m C n log n/ time. Proof: Consider the following algorithm. First set ˛.v/ WD 0 for all v 2 V .G/. Then for i WD 1 to n do the following: choose vi from among V .G/ n fv1 ; : : : ; vi 1 g such P that it has maximum ˛-value (breaking ties arbitrarily), and set ˛.v/ WD ˛.v/C e2E.fvi g;fvg/ u.e/ for all v 2 V .G/ n fv1 ; : : : ; vi g. The correctness of this algorithm is obvious. By implementing it with a Fibonacci heap, storing each vertex v with key ˛.v/ until it is selected, we get a running time of O.m C n log n/ by Theorem 6.7 as there are n INSERT-, n DELETEMIN - and (at most) m DECREASEKEY -operations. Lemma 8.41. (Stoer and Wagner [1997], Frank [1994]) Let G be an undirected graph with n WD jV .G/j 2, capacities u W E.G/ ! RC and an MA order v1 ; : : : ; vn . Then X u.e/: vn1 vn D e2ı.vn /

Proof: Of course we only have to show “”. We shall use induction on jV .G/j C jE.G/j. For jV .G/j < 3 the statement is trivial. We may assume that there is no edge e D fvn1 ; vn g 2 E.G/, because otherwise we would delete it (both left-hand side and right-hand side decrease by u.e/) and apply the induction hypothesis. Denote the right-hand side by R. Of course v1 ; : : : ; vn1 is an MA order in G vn . So by induction,

198

8 Network Flows

n Gv vn2 vn1 D

X

X

u.e/

e2E.fvn1 g;fv1 ;:::;vn2 g/

u.e/ D R:

e2E.fvn g;fv1 ;:::;vn2 g/

Here the inequality holds because v1 ; : : : ; vn was an MA order for G. The last equalGvn ity is true because fvn1 ; vn g … E.G/. So G vn2 vn1 vn2 vn1 R. On the other hand v1 ; : : : ; vn2 ; vn is an MA order in G vn1 . So by induction, X n1 u.e/ D R; Gv vn2 vn D e2E.fvn g;fv1 ;:::;vn2 g/ Gvn1 again because fvn1 ; vn g … E.G/. So G vn2 vn vn2 vn D R. Now by Lemma 8.33 vn1 vn minfvn1 vn2 ; vn2 vn g R. P Note that the existence of two vertices x; y with xy D e2ı.x/ u.e/ was already shown by Mader [1972], and follows easily from the existence of a GomoryHu tree (Exercise 33).

Theorem 8.42. (Nagamochi and Ibaraki [1992], Stoer and Wagner [1997]) A minimum capacity cut in an undirected graph with nonnegative capacities can be found in O.mn C n2 log n/ time. Proof: We may assume that the given graph G is simple since we can unite parallel edges. Denote by .G/ the minimum capacity of a cut in G. The algorithm proceeds as follows: Let G0 WD G. In the i -th step (i D 1; : : : ; n1) choose vertices x; y 2 V .Gi 1 / with X i 1 D G u.e/: xy e2ıGi 1 .x/

By Proposition 8.40 and Lemma 8.41 this can be done in O.m C n log n/ time. Set G i WD xyi 1 , ´i WD x, and let Gi result from Gi 1 by contracting fx; yg. Observe that .Gi 1 / D minf.Gi /; i g; (8.1) because a minimum cut in Gi 1 either separates x and y (in this case its capacity is i ) or does not (in this case contracting fx; yg does not change anything). After arriving at Gn1 which has only one vertex, we choose a k 2 f1; : : : ; n1g for which k is minimum. We claim that ı.X / is a minimum capacity cut in G, where X is the vertex set in G whose contraction resulted in the vertex ´k of Gk1 . But this is easy to see, since by (8.1) .G/ D minf1 ; : : : ; n1 g D k and k is the capacity of the cut ı.X /. A randomized contraction algorithm for finding a minimum cut (with high probability) is discussed in Exercise 37. Moreover, we mention that the vertexconnectivity of a graph can be computed by O.n2 / flow computations in a graph with unit capacities (Exercise 38).

Exercises

199

In this section we have shown how to minimize f .X / WD u.ı.X // over ; 6D X V .G/. Note that this f W 2V .G/ ! RC is submodular and symmetric (i.e. f .A/ D f .V .G/ n A/ for all A). The algorithm presented here has been generalized by Queyranne [1998] to minimize general symmetric submodular functions; see Section 14.5. The problem of finding a maximum cut is much harder and will be discussed in Section 16.2.

Exercises 1. Let .G; u; s; t/ be a network, and let ı C .X / and ı C .Y / be minimum s-t-cuts in .G; u/. Show that ı C .X \ Y / and ı C .X [ Y / are also minimum s-t-cuts in .G; u/. 2. Show that in case of irrational capacities, the FORD-FULKERSON ALGORITHM may not terminate at all. Hint: Consider the following network (Figure 8.6): x1

y1

x2

y2

s

t x3

y3

x4

y4

Fig. 8.6.

All lines represent edges in both directions. All edges have capacity S D except

1 1

u..x1 ; y1 // D 1; u..x2 ; y2 // D ; u..x3 ; y3 // D u..x4 ; y4 // D 2 p

n nC1 where D 51 C nC2 . 2 . Note that D (Ford and Fulkerson [1962]) 3. Let G be a digraph and M the incidence matrix of G. Prove that for all c; l; u 2 ZE.G/ with l u: o n max cx W x 2 ZE.G/ ; l x u; M x D 0 D

o n E.G/ min y 0 u y 00 l W y 0 ; y 00 2 ZC ; ´M C y 0 y 00 D c for some ´ 2 ZV .G/ : Show how this implies Theorem 8.6 and Corollary 8.7.

200

8 Network Flows

4. Prove Hoffman’s circulation theorem: Given a digraph G and lower and upper capacities l; u W E.G/ ! RC with l.e/ u.e/ for all e 2 E.G/, there is circulation f with l.e/ f .e/ u.e/ for all e 2 E.G/ if and only if X X l.e/ u.e/ for all X V .G/: e2ı .X/

e2ı C .X/

Note: Hoffman’s circulation theorem in turn quite easily implies the Max-FlowMin-Cut Theorem. (Hoffman [1960]) 5. Consider a network .G; u; s; t/, a maximum s-t-flow f and the residual graph Gf . Form a digraph H from Gf by contracting the set S of vertices reachable from s to a vertex vS , contracting the set T of vertices from which t is reachable to a vertex vT , and contracting each strongly connected component X of Gf .S [ T / to a vertex vX . Observe that H is acyclic. Prove that there is C a one-to-one correspondence between the sets X V .G/ for which ıG .X / is C a minimum s-t-cut in .G; u/ and the sets Y V .H / for which ıH .Y / is a directed vT -vS -cut in H (i.e. a directed cut in H separating vT and vS ). Note: This statement also holds for Gf without any contraction instead of H . However, we shall use the statement in the above form in Section 20.4. (Picard and Queyranne [1980]) 0 6. Let G be a digraph and c; cP W E.G/ ! R. We Plook for a set X V .G/ with s 2 X and t … X such that e2ı C .X/ c.e/ e2ı .X/ c 0 .e/ is minimum. (a) Show how to reduce this problem to the MINIMUM CAPACITY CUT PROBLEM. (b) Now consider the special case where c D c 0 . Can you solve this problem in linear time? 7. Let G be an acyclic digraph with mappings ; ; c W E.G/ ! RC , and a number C 2 RC . We look for a mapping x W E.G/ ! RC such that .e/ x.e/ P .e/ for all e 2 E.G/ and e2E.G/ ..e/x.e//c.e/ C . Among the feasible solutions we want to minimize the length (with respect to x) of the longest path in G. The meaning behind the above is the following. The edges correspond to jobs, .e/ and .e/ stand for the minimum and maximum completion time of job e, and c.e/ is the cost of reducing the completion time of job e by one unit. If there are two jobs e D .i; j / and e 0 D .j; k/, job e has to be finished before job e 0 can be processed. We have a fixed budget C and want to minimize the total completion time. Show how to solve this problem using network flow techniques. (This application is known as PERT, program evaluation and review technique, or CPM, critical path method. The problem is also known as the budget version of the time-cost tradeoff problem.) Hint: Introduce one source s and one sink t. Start with x D and successively reduce the length of the longest s-t-path (with respect to x) at the minimum possible cost. Use Exercise 8 of Chapter 7, Exercise 9 of Chapter 3, and Exercise 6. (Phillips and Dessouky [1977])

Exercises

201

8. Let .G; c; s; t/ be a network such that G is planar even when an edge e D .s; t/ is added. Consider the following algorithm. Start with the flow f 0 and let G 0 WD Gf . At each step consider the boundary B of a face of G 0 C e containing e (with respect to some fixed planar embedding). Augment f along B e. Let G 0 consist of the forward edges of Gf only and iterate as long as t is reachable from s in G 0 . Prove that this algorithm computes a maximum s-t-flow. Use Theorem 2.40 to show that it can be implemented to run in O.n2 / time. (Ford and Fulkerson [1956], Hu [1969]) Note: This problem can be solved in O.n/ time. For general planar networks an O.n log n/-algorithm exists; see Weihe [1997] and Borradaile and Klein [2009]. 9. Show that the directed edge-disjoint version of Menger’s Theorem 8.9 also follows directly from Theorem 6.18. 10. Let G be an undirected graph. Prove that one can compute an orientation G 0 of G in linear time such that for each v; w 2 V .G/ the following holds: if G has two edge-disjoint v-w-paths, then G 0 has a (directed) v-w-path. Hint: Use DFS. (Tarjan [1972]) 11. Let G be a digraph with conservative weights c W E.G/ ! R and two vertices s; t 2 V .G/ such that t is reachable from s. Suppose that for every edge e 2 E.G/ we have dist.Ge;c/ .s; t/ D dist.G;c/ .s; t/. Prove that then there are two edge-disjoint shortest s-t-paths in .G; c/. 12. Consider an undirected graph G with edge-connectivity k 2 N and (not necessarily distinct) vertices v0 ; v1 ; : : : ; vk 2 V .G/. Prove that there are pairwise edge-disjoint paths P1 ; : : : ; Pk such that Pi is a v0 -vi -path (i D 1; : : : ; k). 13. Let G be a graph (directed or undirected), x; y; ´ three vertices, and ˛; ˇ 2 N with ˛ xy , ˇ x´ and ˛ C ˇ maxfxy ; x´ g. Prove that there are ˛ xy-paths and ˇ x-´-paths such that these ˛ C ˇ paths are pairwise edge-disjoint. 14. Let G be a digraph that contains k edge-disjoint s-t-paths for any two vertices s and t (such a graph is called strongly k-edge-connected). Let H be any digraph with V .H / D V .G/ and jE.H /j D k. Prove that the instance .G; H / of the DIRECTED EDGE-DISJOINT PATHS PROBLEM has a solution. (Mader [1981] and Shiloach [1979]) 15. Let G be a digraph with at least k edges. Prove: G contains k edge-disjoint s-t-paths for any two vertices s and t if and only if for any k distinct edges e1 D .x1 ; y1 /; : : : ; ek D .xk ; yk /, G fe1 ; : : : ; ek g contains k edge-disjoint spanning arborescences T1 ; : : : ; Tk such that Ti is rooted at yi (i D 1; : : : ; k). Note: This generalizes Exercise 14. Hint: Use Theorem 6.18. (Su [1997])

202

8 Network Flows

16. Let G be a digraph with capacities c W E.G/ ! RC and r 2 V .G/. Can one determine an r-cut with minimum capacity in polynomial time? Can one determine a directed cut with minimum capacity in polynomial time (or decide that G is strongly connected)? Note: The answer to the first question solves the SEPARATION PROBLEM for the MINIMUM WEIGHT ROOTED ARBORESCENCE PROBLEM; see Corollary 6.15. 17. An airline wants to conduct a given set of scheduled flights with as few airplanes as possible. All available airplanes are of the same type. For each flight we know the departure time and the flight time. We also know, for any pair of flights i and j , how much time an airplane needs after finishing flight i until it can begin flight j (this time will depend in particular on where i ends and where j begins). Show how to compute efficiently a feasible schedule with as few airplanes as possible. 18. Prove that the value of a blocking s-t-flow in a network .G; u; s; t/ with an 1 acyclic digraph G is at least jV .G/j times the value of a maximum s-t-flow. Show that this bound is sharp up to a constant factor. 19. Show how to find a blocking flow in an acyclic network in O.nm/ time by successively augmenting along a path of non-saturated edges and using DEPTHFIRST SEARCH to find such a path. Show how to obtain a running time of O.m/ if all edges that are not incident to s or t have capacity 1. 20. Let .G; u; s; t/ be a network with u.e/ D 1 for all edges e 2 E.G/ that are not incident to s or t. (a) Show that then a maximum s-t-flow can be computed in O.mn2=3 / time. (b) Let in addition G have the property that for each v 2 V .G/ n fs; tg we have C jı .v/j D 1 or jıp .v/j D 1. Show that then a maximum s-t-flow can be computed in O.m n/ time. Hint: Consider DINIC’S ALGORITHM and the p situation when no augmenting path has length less than dn2=3 e in (a) and d ne in (b). Bound the number of remaining iterations and use the second part of Exercise 19. (Karzanov [1973], Even and Tarjan [1975]) 21. An s-t-preflow f is called maximum if exf .t/ is maximum. (a) Show that for any maximum preflow f there exists a maximum flow f 0 with f 0 .e/ f .e/ for all e 2 E.G/. (b) Show how a maximum preflow can be converted into a maximum flow in O.nm/ time. 22. Let .G; u; s; t/ be a network such that G t is an arborescence. Show how to find a maximum s-t-flow in linear time. Hint: Use DFS. 23. Let .G; u; s; t/ be a network such that the underlying undirected graph of G fs; tg is a forest. Show how to find a maximum s-t-flow in linear time. (Vygen [2002]) 24. Consider a modified version of FUJISHIGE’S ALGORITHM where in 5 we choose vi 2 V .G/ n fv1 ; : : : ; vi 1 g such that b.vi / is maximum, step 4 is

Exercises

25. 26.

27.

28.

29.

30.

31.

32.

203

replaced by stopping if b.v/ D 0 for all v 2 V .G/ n fv1 ; : : : ; vi g, and in the beginning of 6 we set ˇ.t/ WD minji D2 b.j /. Then X and ˛ are not needed anymore. (a) Show that this variant of the algorithm works correctly. (b) Let ˛k be the number minji D2 b.j / in iteration k (or zero if the algorithm stops before iteration k). Show that minkC2n ˛ 12 ˛k for all k. Conclude lDkC1 l that the number of iterations is O.n log umax /. (c) Show how to implement one iteration in O.m C n log n/ time. Prove that the PUSH-RELABEL ALGORITHM performs O.n2 m/ nonsaturating pushes, independent of the choice of v in . 3 Let .G; u; s; t/ be a network, f an s-t-preflow, and a distance labeling with respect to f with .v/ 2n for v 2 V .G/. Define 0 .v/ WD minfdistGf .v; t/; n C distGf .v; s/; 2ng for v 2 V .G/. Show that 0 is a distance labeling with respect to f , and 0 . Note: Replacing by 0 from time to time, e.g. after every n RELABEL operations, improves the performance of the PUSH-RELABEL ALGORITHM in practice. Given an acyclic digraph G with weights c W E.G/ ! RC , find a maximum weight directed cut in G. Show how this problem can be reduced to the MINIMUM CAPACITY CUT PROBLEM . Hint: Use Exercise 6. Let G be an acyclic digraph with weights c W E.G/ ! RC . We look for the maximum weight edge set F E.G/ such that no path in G contains more than one edge of F . Show that this problem is equivalent to looking for the maximum weight directed cut in G (and thus can be solved in O.n3 / time by Exercise 27). Let G be a digraph and p W V .G/ ! R. Show how to find a set X V .G/ with ı C .X / D ; such that p.X / is maximum. Note: This was used to model open-pit mining, where p.v/ is the (possibly negative) profit of mining v, and an edge .v; w/ models the constraint that we cannot mine v unless we mine w. Given an undirected graph G with capacities u W E.G/ ! RC and a set T V .G/ with jT j 2. PWe look for a set X V .G/ with T \ X 6D ; and T nX 6D ; such that e2ı.X/ u.e/ is minimum. Show how to solve this problem in O.n4 / time, where n D jV .G/j. Let ij , 1 i; j n, be nonnegative numbers with ij D j i and i k minfij ; jk g for any three distinct indices i; j; k 2 f1; : : : ; ng. Show that there exists a graph G with V .G/ D f1; : : : ; ng and capacities u W E.G/ ! RC such that the local edge-connectivities are precisely the ij . Hint: Consider a maximum weight spanning tree in .Kn ; c/, where c.fi; j g/ WD ij . (Gomory and Hu [1961]) Let G be an undirected graph with capacities u W E.G/ ! RC , and let T V .G/ with jT j even. A T -cut in G is a cut ı.X / with jX \ T j odd. Construct a

204

33.

34.

35.

36.

37.

8 Network Flows

polynomial time algorithm for finding a T -cut of minimum capacity in .G; u/. Hint: Use a Gomory-Hu tree. (A solution of this exercise can be found in Section 12.3.) Let G be a simple undirected graph with at least two vertices. Suppose the degree of each vertex of G is at least k. Prove that there are two vertices s and t such that at least k edge-disjoint s-t-paths exist. What if there is exactly one vertex with degree less than k? Hint: Consider a Gomory-Hu tree for G. Consider the problem of determining the edge-connectivity .G/ of an undirected graph (with unit capacities). Section 8.7 shows how to solve this problem in O.mn/ time, provided that we can find an MA order of an undirected graph with unit capacities in O.m C n/ time. How can this be done? G Let G be an undirected graph with an MA order v1 ; : : : ; vn . Let uv denote the maximum number of internally disjoint u-v-paths in G. Prove vGn1 vn D jE.fvn g; fv1 ; : : : ; vn1 g/j (the vertex-disjoint counterpart of Lemma 8.41). G Hint: Prove by induction that vjijvi D jE.fvj g; fv1 ; : : : ; vi g/j, where Gij D GŒfv1 ; : : : ; vi g [ fvj g. To do this, assume w.l.o.g. that fvj ; vi g … E.G/, choose a minimal set Z fv1 ; : : : ; vi 1 g separating vj and vi (Menger’s Theorem 8.10), and let h i be the maximum number such that vh … Z and vh is adjacent to vi or vj . (Frank [unpublished]) An undirected graph is called chordal if it has no circuit of length at least four as an induced subgraph. An order v1 ; : : : ; vn of an undirected graph G is called simplicial if fvi ; vj g; fvi ; vk g 2 E.G/ implies fvj ; vk g 2 E.G/ for i < j < k. (a) Prove that a graph with a simplicial order must be chordal. (b) Let G be a chordal graph, and let v1 ; : : : ; vn be an MA order. Prove that vn ; vn1 ; : : : ; v1 is a simplicial order. Hint: Use Exercise 35 and Menger’s Theorem 8.10. Note: The fact that a graph is chordal if and only if it has a simplicial order is due to Rose [1970]. Let G be an undirected graph with capacities u W E.G/ ! RC . Let ; 6D A

V .G/ such that ı.A/ is a minimum capacity cut in G. (a) Show that u.ı.A// n2 u.E.G//. (Hint: Consider the trivial cuts ı.x/, x 2 V .G/.) (b) Assume w.l.o.g. that u.ı.A// > 0 and consider the following procedure. We randomly choose an edge and contract it; each edge e is chosen with u.e/ probability u.E.G// . We repeat this operation until there are only two vertices. Prove that the probability that we never contract an edge of ı.A/ is at 2 least .n1/n . (c) Conclude that running the randomized algorithm in (b) k n2 times yields ı.A/ with probability at least 1 e 2k . (Such an algorithm with a positive probability of a correct answer is called a Monte Carlo algorithm.) (Karger and Stein [1996]; see also Karger [2000])

References

205

38. Show how the vertex-connectivity of an undirected graph can be determined in O.n2:5 m/ time. Hint: Recall the proof of Menger’s Theorem and use Exercise 20. Note: Faster algorithms were proposed by Henzinger, Rao and Gabow [2000], and by Gabow [2006]. 39. Let G be a connected undirected graph with capacities u W E.G/ ! RC . We are looking for a minimum capacity 3-cut, i.e. an edge set whose deletion splits G into at least three connected components. Let n WD jV .G/j 4. Let ı.X1 /; ı.X2 /; : : : be a list of the cuts ordered by nondecreasing capacities: u.ı.X1 // u.ı.X2 // . Assume that we know the first 2n 2 elements of this list (note: they can be computed in polynomial time by a method of Vazirani and Yannakakis [1992]). (a) Show that for some indices i; j 2 f1; : : : ; 2n 2g all sets Xi n Xj , Xj n Xi , Xi \ Xj and V .G/ n .Xi [ Xj / are nonempty. (b) Show that there is a 3-cut of capacity at most 32 u.ı.X2n2 /. (c) For each i D 1; : : : ; 2n 2 consider ı.Xi / plus a minimum capacity cut of G Xi , and also ı.Xi / plus a minimum capacity cut of GŒXi . This yields a list of at most 4n 4 3-cuts. Prove that one of them is optimum. (Nagamochi and Ibaraki [2000]) Note: This was generalized to k-cuts (for any fixed k) by Kamidoi, Yoshida and Nagamochi [2007]; see also Thorup [2008]. The problem of finding the optimum 3-cut separating three given vertices is much harder; see Dahlhaus et al. [1994] and Cheung, Cunningham and Tang [2006]. 40. Let G be an undirected graph with capacities u W E.G/ ! ZC . (a) Show that if ı.X / and ı.Y / are two minimum capacity cuts with X \Y 6D ; and X [ Y 6D V .G/, then ı.X n Y / \ ı.Y n X / D ;. (b) Suppose that the minimum capacity of a cut is odd. Show that then the family of vertex sets X for which ı.X / is a minimum capacity cut is crossfree, and hence there are at most n 1 minimum capacity cuts. Note: Dinitz, Karzanov and Lomonosov [1976] showed that there are at most n2 minimum capacity cuts in general. They can be described by a socalled cactus representation, generalizing tree-representations. See also Frank [2011].

References General Literature: Ahuja, R.K., Magnanti, T.L., and Orlin, J.B. [1993]: Network Flows. Prentice-Hall, Englewood Cliffs 1993 Cook, W.J., Cunningham, W.H., Pulleyblank, W.R., and Schrijver, A. [1998]: Combinatorial Optimization. Wiley, New York 1998, Chapter 3 Cormen, T.H., Leiserson, C.E., Rivest, R.L., and Stein, C. [2001]: Introduction to Algorithms. Second Edition. MIT Press, Cambridge 2001, Chapter 26

206

8 Network Flows

Ford, L.R., and Fulkerson, D.R. [1962]: Flows in Networks. Princeton University Press, Princeton 1962 Frank, A. [1995]: Connectivity and network flows. In: Handbook of Combinatorics; Vol. 1 (R.L. Graham, M. Grötschel, L. Lovász, eds.), Elsevier, Amsterdam, 1995 Frank, A. [2011]: Connections in Combinatorial Optimization. Oxford University Press, Oxford 2011 Goldberg, A.V., Tardos, É., and Tarjan, R.E. [1990]: Network flow algorithms. In: Paths, Flows, and VLSI-Layout (B. Korte, L. Lovász, H.J. Prömel, A. Schrijver, eds.), Springer, Berlin 1990, pp. 101–164 Gondran, M., and Minoux, M. [1984]: Graphs and Algorithms. Wiley, Chichester 1984, Chapter 5 Jungnickel, D. [2007]: Graphs, Networks and Algorithms. Third Edition. Springer, Berlin 2007 Phillips, D.T., and Garcia-Diaz, A. [1981]: Fundamentals of Network Analysis. Prentice-Hall, Englewood Cliffs 1981 Ruhe, G. [1991]: Algorithmic Aspects of Flows in Networks. Kluwer Academic Publishers, Dordrecht 1991 Schrijver, A. [2003]: Combinatorial Optimization: Polyhedra and Efficiency. Springer, Berlin 2003, Chapters 9,10,13–15 Tarjan, R.E. [1983]: Data Structures and Network Algorithms. SIAM, Philadelphia 1983, Chapter 8 Thulasiraman, K., and Swamy, M.N.S. [1992]: Graphs: Theory and Algorithms. Wiley, New York 1992, Chapter 12

Cited References: Ahuja, R.K., Orlin, J.B., and Tarjan, R.E. [1989]: Improved time bounds for the maximum flow problem. SIAM Journal on Computing 18 (1989), 939–954 Borradaile, G. and Klein, P. [2009]: An O.n log n/ algorithm for maximum st-flow in a directed planar graph. Journal of the ACM 56 (2009), Article 9 Cheriyan, J., and Maheshwari, S.N. [1989]: Analysis of preflow push algorithms for maximum network flow. SIAM Journal on Computing 18 (1989), 1057–1086 Cheriyan, J., and Mehlhorn, K. [1999]: An analysis of the highest-level selection rule in the preflow-push max-flow algorithm. Information Processing Letters 69 (1999), 239–242 Cherkassky, B.V. [1977]: Algorithm of construction of maximal flow in networks with comp plexity of O.V 2 E/ operations. Mathematical Methods of Solution of Economical Problems 7 (1977), 112–125 [in Russian] Cheung, K.K.H., Cunningham, W.H., and Tang, L. [2006]: Optimal 3-terminal cuts and linear programming. Mathematical Programming 106 (2006), 1–23 Cheung, H.Y., Lau, L.C., and Leung, K.M. [2011]: Graph connectivities, network coding, and expander graphs. Proceedings of the 52nd Annual IEEE Symposium on Foundations of Computer Science (2011), 190–199 Dahlhaus, E., Johnson, D.S., Papadimitriou, C.H., Seymour, P.D., and Yannakakis, M. [1994]: The complexity of multiterminal cuts. SIAM Journal on Computing 23 (1994), 864–894 Dantzig, G.B., and Fulkerson, D.R. [1956]: On the max-flow min-cut theorem of networks. In: Linear Inequalities and Related Systems (H.W. Kuhn, A.W. Tucker, eds.), Princeton University Press, Princeton 1956, pp. 215–221

References

207

Dinic, E.A. [1970]: Algorithm for solution of a problem of maximum flow in a network with power estimation. Soviet Mathematics Doklady 11 (1970), 1277–1280 Dinitz, E.A., Karzanov, A.V., and Lomonosov, M.V. [1976]: On the structure of the system of minimum edge cuts of a graph. Issledovaniya po Diskretno˘ı Optimizatsii (A.A. Fridman, ed.), Nauka, Moscow, 1976, pp. 290–306 [in Russian] Edmonds, J., and Karp, R.M. [1972]: Theoretical improvements in algorithmic efficiency for network flow problems. Journal of the ACM 19 (1972), 248–264 Elias, P., Feinstein, A., and Shannon, C.E. [1956]: Note on maximum flow through a network. IRE Transactions on Information Theory, IT-2 (1956), 117–119 Even, S., and Tarjan, R.E. [1975]: Network flow and testing graph connectivity. SIAM Journal on Computing 4 (1975), 507–518 Ford, L.R., and Fulkerson, D.R. [1956]: Maximal Flow Through a Network. Canadian Journal of Mathematics 8 (1956), 399–404 Ford, L.R., and Fulkerson, D.R. [1957]: A simple algorithm for finding maximal network flows and an application to the Hitchcock problem. Canadian Journal of Mathematics 9 (1957), 210–218 Frank, A. [1994]: On the edge-connectivity algorithm of Nagamochi and Ibaraki. Laboratoire Artemis, IMAG, Université J. Fourier, Grenoble, 1994 Fujishige, S. [2003]: A maximum flow algorithm using MA ordering. Operations Research Letters 31 (2003), 176–178 Gabow, H.N. [1995]: A matroid approach to finding edge connectivity and packing arborescences. Journal of Computer and System Sciences 50 (1995), 259–273 Gabow, H.N. [2006]: Using expander graphs to find vertex-connectivity. Journal of the ACM 53 (2006), 800–844 5 2 Galil, Z. [1980]: An O.V 3 E 3 / algorithm for the maximal flow problem. Acta Informatica 14 (1980), 221–242 Galil, Z., and Namaad, A. [1980]: An O.EV log2 V / algorithm for the maximal flow problem. Journal of Computer and System Sciences 21 (1980), 203–217 Gallai, T. [1958]: Maximum-minimum Sätze über Graphen. Acta Mathematica Academiae Scientiarum Hungaricae 9 (1958), 395–434 Goldberg, A.V., and Rao, S. [1998]: Beyond the flow decomposition barrier. Journal of the ACM 45 (1998), 783–797 Goldberg, A.V., and Tarjan, R.E. [1988]: A new approach to the maximum flow problem. Journal of the ACM 35 (1988), 921–940 Gomory, R.E., and Hu, T.C. [1961]: Multi-terminal network flows. Journal of SIAM 9 (1961), 551–570 Gusfield, D. [1990]: Very simple methods for all pairs network flow analysis. SIAM Journal on Computing 19 (1990), 143–155 Hao, J., and Orlin, J.B. [1994]: A faster algorithm for finding the minimum cut in a directed graph. Journal of Algorithms 17 (1994), 409–423 Henzinger, M.R., Rao, S., and Gabow, H.N. [2000]: Computing vertex connectivity: new bounds from old techniques. Journal of Algorithms 34 (2000), 222–250 Hoffman, A.J. [1960]: Some recent applications of the theory of linear inequalities to extremal combinatorial analysis. In: Combinatorial Analysis (R.E. Bellman, M. Hall, eds.), AMS, Providence 1960, pp. 113–128 Hu, T.C. [1969]: Integer Programming and Network Flows. Addison-Wesley, Reading 1969 Jelinek, F., and Mayeda, W. [1963]: On the maximum number of different entries in the terminal capacity matrix of oriented communication nets. IEEE Transactions on Circuit Theory 10 (1963), 307–308

208

8 Network Flows

Kamidoi, Y., Yoshida, N., and Nagamochi, H. [2007]: A deterministic algorithm for finding all minimum k-way cuts. SIAM Journal on Computing 36 (2007), 1329–1341 Karger, D.R. [2000]: Minimum cuts in near-linear time. Journal of the ACM 47 (2000), 46–76 Karger, D.R., and Levine, M.S. [1998]: Finding maximum flows in undirected graphs seems easier than bipartite matching. Proceedings of the 30th Annual ACM Symposium on Theory of Computing (1998), 69–78 Karger, D.R., and Stein, C. [1996]: A new approach to the minimum cut problem. Journal of the ACM 43 (1996), 601–640 Karzanov, A.V. [1973]: On finding a maximum flow in a network with special structure and some applications. In: Matematicheskie Voprosy Upravleniya Proizvodstvom 5 (L.A. Lyusternik, ed.), Moscow State University Press, Moscow, 1973, pp. 81–94 [in Russian] Karzanov, A.V. [1974]: Determining a maximal flow in a network by the method of preflows. Soviet Mathematics Doklady 15 (1974), 434–437 King, V., Rao, S., and Tarjan, R.E. [1994]: A faster deterministic maximum flow algorithm. Journal of Algorithms 17 (1994), 447–474 Mader, W. [1972]: Über minimal n-fach zusammenhängende, unendliche Graphen und ein Extremalproblem. Arch. Math. 23 (1972), 553–560 Mader, W. [1981]: On a property of n edge-connected digraphs. Combinatorica 1 (1981), 385–386 Malhotra, V.M., Kumar, M.P., and Maheshwari, S.N. [1978]: An O.jV j3 / algorithm for finding maximum flows in networks. Information Processing Letters 7 (1978), 277–278 Menger, K. [1927]: Zur allgemeinen Kurventheorie. Fundamenta Mathematicae 10 (1927), 96–115 Nagamochi, H., and Ibaraki, T. [1992]: Computing edge-connectivity in multigraphs and capacitated graphs. SIAM Journal on Discrete Mathematics 5 (1992), 54–66 Nagamochi, H., and Ibaraki, T. [2000]: A fast algorithm for computing minimum 3-way and 4-way cuts. Mathematical Programming 88 (2000), 507–520 Phillips, S., and Dessouky, M.I. [1977]: Solving the project time/cost tradeoff problem using the minimal cut concept. Management Science 24 (1977), 393–400 Picard, J., and Queyranne, M. [1980]: On the structure of all minimum cuts in a network and applications. Mathematical Programming Study 13 (1980), 8–16 Queyranne, M. [1998]: Minimizing symmetric submodular functions. Mathematical Programming B 82 (1998), 3–12 Rose, D.J. [1970]: Triangulated graphs and the elimination process. Journal of Mathematical Analysis and Applications 32 (1970), 597–609 Shiloach, Y. [1978]: An O.nI log2 I / maximum-flow algorithm. Technical Report STANCS-78-802, Computer Science Department, Stanford University, 1978 Shiloach, Y. [1979]: Edge-disjoint branching in directed multigraphs. Information Processing Letters 8 (1979), 24–27 Shioura, A. [2004]: The MA ordering max-flow algorithm is not strongly polynomial for directed networks. Operations Research Letters 32 (2004), 31–35 Sleator, D.D. [1980]: An O.nm log n/ algorithm for maximum network flow. Technical Report STAN-CS-80-831, Computer Science Department, Stanford University, 1978 Sleator, D.D., and Tarjan, R.E. [1983]: A data structure for dynamic trees. Journal of Computer and System Sciences 26 (1983), 362–391 Su, X.Y. [1997]: Some generalizations of Menger’s theorem concerning arc-connected digraphs. Discrete Mathematics 175 (1997), 293–296 Stoer, M., and Wagner, F. [1997]: A simple min cut algorithm. Journal of the ACM 44 (1997), 585–591

References

209

Tarjan, R.E. [1972]: Depth first search and linear graph algorithms. SIAM Journal on Computing 1 (1972), 146–160 Thorup, M. [2008]: Minimum k-way cuts via deterministic greedy tree packing. Proceedings of the 40th Annual ACM Symposium on Theory of Computing (2008), 159–165 Tunçel, L. [1994]: On the complexity preflow-push algorithms for maximum flow problems. Algorithmica 11 (1994), 353–359 Vazirani, V.V., and Yannakakis, M. [1992]: Suboptimal cuts: their enumeration, weight, and number. In: Automata, Languages and Programming; Proceedings of the 19th ICALP conference; LNCS 623 (W. Kuich, ed.), Springer, Berlin 1992, pp. 366–377 Vygen, J. [2002]: On dual minimum cost flow algorithms. Mathematical Methods of Operations Research 56 (2002), 101–126 Weihe, K. [1997]: Maximum .s; t/-flows in planar networks in O.jV j log jV j/ time. Journal of Computer and System Sciences 55 (1997), 454–475 Whitney, H. [1932]: Congruent graphs and the connectivity of graphs. American Journal of Mathematics 54 (1932), 150–168

•

9 Minimum Cost Flows

In this chapter we show how we can take edge costs into account. For example, in our application of the MAXIMUM FLOW PROBLEM to the JOB ASSIGNMENT PROBLEM mentioned in the introduction of Chapter 8 one could introduce edge costs to model that the employees have different salaries; our goal is to meet a deadline when all jobs must be finished at a minimum cost. Of course, there are many more applications. A second generalization, allowing several sources and sinks, is more due to technical reasons. We introduce the general problem and an important special case in Section 9.1. In Section 9.2 we prove optimality criteria that are the basis of the minimum cost flow algorithms presented in Sections 9.3, 9.4, 9.5 and 9.6. Most of these use algorithms of Chapter 7 for finding a minimum mean cycle or a shortest path as a subroutine. Section 9.7 concludes this chapter with an application to time-dependent flows.

9.1 Problem Formulation We are again given a digraph G with capacities u W E.G/ ! RC , but in addition numbers c W E.G/ ! R indicating the cost of each edge. Furthermore, we allow several sources and sinks: Definition 9.1. Given P a digraph G, capacities u W E.G/ ! RC , and numbers b W V .G/ ! R with v2V .G/ b.v/ D 0, a b-flow P in .G; u/ is a function P f W E.G/ ! RC with f .e/ u.e/ for all e 2 E.G/ and e2ı C .v/ f .e/ e2ı .v/ f .e/ D b.v/ for all v 2 V .G/. Thus a b-flow with b 0 is a circulation. b.v/ is called the balance of vertex v. jb.v/j is sometimes called the supply (if b.v/ > 0) or the demand (if b.v/ < 0) of v. Vertices v with b.v/ > 0 are called sources, those with b.v/ < 0 sinks. Theorem 9.2. (Gale [1957]) LetPG be a digraph with capacities u W E.G/ ! RC , and let b W V .G/ ! R with v2V .G/ b.v/ D 0. There exists a b-flow if and only if X X u.e/ b.v/ for all X V .G/: e2ı C .X/

v2X

B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__9, c Springer-Verlag Berlin Heidelberg 2012

211

212

9 Minimum Cost Flows

p We can find one or decide that none exists in O.n2 m/ time, where n WD jV .G/j and m WD jE.G/j. Proof: Let G 0 result from G by adding two vertices s and t and edges .s; v/, .v; t/ with capacities u..s; v// P WD maxf0; b.v/g and P u..v; t// WD maxf0; b.v/g for all v 2 V .G/. Let B WD v2V .G/ u..s; v// D v2V .G/ u..v; t//. Then the b-flows in .G; u/ are precisely the restrictions of the s-t-flows with value B in .G 0 ; u/ to E.G/. By the Max-Flow-Min-Cut Theorem 8.6, an s-t-flow of value P B exists in .G 0 ; u/ if and only if e2ı C .fsg[X/ u.e/ B for every X V .G/. P G0 P P Note that e2ı C .fsg[X/ u.e/ D e2ı C .X/ u.e/ C B C v2X .maxf0; b.v/g G P G 0P maxf0; b.v/g/ D e2ı C .X/ u.e/ C B v2X b.v/, implying the first claim. G We can find a b-flow or decide that none exists by solving the MAXIMUM FLOW PROBLEM in .G 0 ; u; s; t/. The running time follows from Theorem 8.30. The problem that we study in this chapter is to find a minimum cost b-flow:

MINIMUM COST FLOW PROBLEM Instance: Task:

A digraph P G, capacities u W E.G/ ! RC , numbers b W V .G/ ! R with v2V .G/ b.v/ D 0, and weights c W E.G/ ! R. P Find a b-flow f whose cost c.f / WD e2E.G/ f .e/c.e/ is minimum (or decide that none exists).

Sometimes one also allows infinite capacities. In this case an instance can be unbounded, but this can be checked in advance easily; see Exercise 5. Note that (in contrast to many other problems, e.g. the MAXIMUM FLOW PROBLEM) we cannot assume without loss of generality that the input graph is simple when considering the MINIMUM COST FLOW PROBLEM. The MINIMUM COST FLOW PROBLEM is quite general and has a couple of interesting special cases. The uncapacitated case (u 1) is sometimes called the transshipment problem. An even more restricted problem, also known as the transportation problem, has been formulated quite early by Hitchcock [1941] and others:

HITCHCOCK PROBLEM

:

Instance:

A digraph G with V .G/ D A [ B and E.G/ A B. Supplies b.v/ P 0 for v 2 A and demands b.v/ 0 for v 2 B with v2V .G/ b.v/ D 0. Weights c W E.G/ ! R.

Task:

Find a b-flow f in .G; 1/ of minimum cost (or decide that none exists).

In the HITCHCOCK PROBLEM it causes no loss of generality to assume that c is nonnegative: Adding a constant ˛ P to each weight increases the cost of each b-flow by the same amount, namely by ˛ v2A b.v/. Often only the special case where c is nonnegative and E.G/ D A B is considered.

9.1

Problem Formulation

213

Obviously, any instance of the HITCHCOCK PROBLEM can be written as an instance of the MINIMUM COST FLOW PROBLEM on a bipartite graph with infinite capacities. It is less obvious that any instance of the M INIMUM COST FLOW PROBLEM can be transformed to an equivalent (but larger) instance of the H ITCHCOCK PROBLEM: Lemma 9.3. (Orden [1956], Wagner [1959]) An instance of the MINIMUM COST FLOW PROBLEM with n vertices and m edges can be transformed to an equivalent instance of the HITCHCOCK PROBLEM with n C m vertices and 2m edges.

b( x ) = 4

b (e 1 ) = 5

e1

b (e 2 ) = 4 e2

b( y ) = − 1

e3

b( z ) = − 3

b (e 3 ) = 7

0 c(e1 ) 0 c(e 2 ) c(e 3 )

u (e 1 ) = 5, u (e 2 ) = 4, u (e 3 ) = 7

0

b (x) = − 1

b ( y) = − 5

b ( z ) = − 10

u ≡∞

Fig. 9.1.

Proof: Let .G; u; b; c/ be an instance of the MINIMUM COST FLOW PROBLEM. We define an equivalent instance .G 0 ; A0 ; B 0 ; b 0 ; c 0 / of the HITCHCOCK PROBLEM as follows: Let A0 WD E.G/, B 0 WD V .G/ and G 0 WD .A0 [ B 0 ; E1 [ E2 /, where E1 WD f..x; y/; x/ W .x; y/ 2 E.G/g and E2 WD f..x; y/; y/ W .x; y/ 2 E.G/g. Let c 0 ..e; x// WD 0 for .e; x/ 2 E1 and c 0 ..e; y// WD c.e/ for .e; y/ 2 E2 . Finally let b 0 .e/ WD u.e/ for e 2 E.G/ and X u.e/ for x 2 V .G/: b 0 .x/ WD b.x/ C e2ıG .x/

For an example, see Figure 9.1. We prove that both instances are equivalent. Let f be a b-flow in .G; u/. Define f 0 ..e; y// WD f .e/ and f 0 ..e; x// WD u.e/ f .e/ for e D .x; y/ 2 E.G/. Obviously f 0 is a b 0 -flow in G 0 with c 0 .f 0 / D c.f /. Conversely, if f 0 is a b 0 -flow in G 0 , then f ..x; y// WD f 0 ...x; y/; y// defines a b-flow in G with c.f / D c 0 .f 0 /. The above proof is due to Ford and Fulkerson [1962].

214

9 Minimum Cost Flows

9.2 An Optimality Criterion In this section we prove some simple results, in particular an optimality criterion, which will be the basis for the algorithms in the subsequent sections. We again use the concepts of residual graphs and augmenting paths. We extend the weights $

c to G by defining c. e / WD c.e/ for each edge e 2 E.G/. Our definition of a residual graph has the advantage that the weight of an edge in a residual graph Gf is independent of the flow f . Definition 9.4. Given a digraph G with capacities and a b-flow f , an f-augmenting cycle is a circuit in Gf . The following simple observation will prove useful: Proposition 9.5. Let G be a digraph with capacities u W E.G/ ! RC . Let f and $

f 0 be b-flows in .G; u/. Then g W E.G/ ! RC defined by g.e/ WD maxf0; f 0 .e/ $

f .e/g and g. e / WD maxf0; f .e/ f 0 .e/g for e 2 E.G/ is a circulation in G. Furthermore, g.e/ D 0 for all e … E.Gf / and c.g/ D c.f 0 / c.f /. $

Proof: At each vertex v 2 V .G/ we have X X X X g.e/ g.e/ D .f 0 .e/ f .e// .f 0 .e/ f .e// .v/ e2ı$

C e2ı$ .v/

G

G

.v/ e2ıG

C e2ıG .v/

D b.v/ b.v/ D 0; $

so g is a circulation in G. $

For e 2 E.G/ n E.Gf / we consider two cases: If e 2 E.G/ then f .e/ D u.e/ and thus f 0 .e/ f .e/, implying g.e/ D 0. If e D e0 for some e0 2 E.G/ then f .e0 / D 0 and thus g.e0 / D 0. The last statement is easily verified: X X X c.g/ D c.e/g.e/ D c.e/f 0 .e/ c.e/f .e/ D c.f 0 /c.f /: $

e2E. G /

e2E.G/

e2E.G/

Just as Eulerian graphs can be partitioned into circuits, circulations can be decomposed into flows on single circuits: Proposition 9.6. (Ford and Fulkerson [1962]) For any circulation f in a digraph G there is a family C of atP most jE.G/j circuits in G and positive numbers h.C / (C 2 C) such that f .e/ D C 2C; e2E.C / h.C / for all e 2 E.G/. Proof: This is a special case of Theorem 8.8.

9.2

An Optimality Criterion

215

Now we can prove an optimality criterion: Theorem 9.7. (Klein [1967]) Let .G; u; b; c/ be an instance of the MINIMUM COST FLOW PROBLEM. A b-flow f is of minimum cost if and only if there is no f -augmenting cycle with negative total weight. Proof: If there is an f -augmenting cycle C with weight < 0, we can augment f along C by some " > 0 and get a b-flow f 0 with cost decreased by ". So f is not a minimum cost flow. If f is not a minimum cost b-flow, there is another b-flow f 0 with smaller cost. Consider g as defined in Proposition 9.5. Then g is a circulation with c.g/ < 0. By Proposition 9.6, g can be decomposed into flows on single circuits. Since g.e/ D 0 for all e … E.Gf /, all these circuits are f -augmenting. At least one of them must have negative total weight, proving the theorem. This result goes back essentially to Tolsto˘ı [1930] and has been rediscovered several times in different forms. One equivalent formulation is the following: Corollary 9.8. (Ford and Fulkerson [1962]) Let .G; u; b; c/ be an instance of the MINIMUM COST FLOW PROBLEM. A b-flow f is of minimum cost if and only if there exists a feasible potential for .Gf ; c/. Proof: By Theorem 9.7 f is a minimum cost b-flow if and only if Gf contains no negative circuit. By Theorem 7.7 there is no negative circuit in .Gf ; c/ if and only if there exists a feasible potential. Feasible potentials can also be regarded as solutions of the linear programming dual of the MINIMUM COST FLOW PROBLEM. This is shown by the following different proof of the above optimality criterion: Second Proof of Corollary 9.8: We write the MINIMUM COST FLOW PROBLEM as a maximization problem and consider the LP X max c.e/xe e2E.G/

s.t.

X

xe

e2ı C .v/

and its dual min

X v2V .G/

s.t.

X

xe D b.v/

.v 2 V .G//

xe u.e/ xe 0

.e 2 E.G// .e 2 E.G//

(9.1)

e2ı .v/

b.v/yv C

X

u.e/´e

e2E.G/

yv yw C ´e c.e/ ´e 0

.e D .v; w/ 2 E.G// .e 2 E.G//

(9.2)

Let x be any b-flow, i.e. any feasible solution of (9.1). By Corollary 3.23 x is optimum if and only if there exists a feasible dual solution .y; ´/ of (9.2) such that x and .y; ´/ satisfy the complementary slackness conditions

216

9 Minimum Cost Flows

´e .u.e/xe / D 0 and xe .c.e/C´e Cyv yw / D 0 for all e D .v; w/ 2 E.G/: So x is optimum if and only if there exists a pair of vectors .y; ´/ with 0 D ´e c.e/ C yv yw

for e D .v; w/ 2 E.G/ with xe < u.e/

c.e/ C yv yw D ´e 0

for e D .v; w/ 2 E.G/ with xe > 0:

and

This is equivalent to the existence of a vector y such that c.e/ C yv yw 0 for all residual edges e D .v; w/ 2 E.Gx /, i.e. to the existence of a feasible potential y for .Gx ; c/.

9.3 Minimum Mean Cycle-Cancelling Algorithm Note that Klein’s Theorem 9.7 already suggests an algorithm: first find any b-flow (using a max-flow algorithm as described above), and then successively augment along negative weight augmenting cycles until no more exist. We must however be careful in choosing the cycle if we want to have polynomial running time (see Exercise 7). A good strategy is to choose an augmenting cycle with minimum mean weight each time:

MINIMUM MEAN CYCLE-CANCELLING ALGORITHM Input:

A digraph P G, capacities u W E.G/ ! RC , numbers b W V .G/ ! R with v2V .G/ b.v/ D 0, and weights c W E.G/ ! R.

Output:

A minimum cost b-flow f .

1

Find a b-flow f .

2

Find a circuit C in Gf whose mean weight is minimum. If C has nonnegative total weight (or Gf is acyclic) then stop.

3

Compute WD min uf .e/. Augment f along C by . e2E.C /

Go to . 2 As described in Section 9.1, 1 can be implemented with any algorithm for the MAXIMUM FLOW PROBLEM. 2 can be implemented with the algorithm presented in Section 7.3. We shall now prove that this algorithm terminates after a polynomial number of iterations. The proof will be similar to the one in Section 8.3. Let .f / denote the minimum mean weight of a circuit in Gf . Then Theorem 9.7 says that a b-flow f is optimum if and only if .f / 0. We first show that .f / is non-decreasing throughout the algorithm. Moreover, we can show that it is strictly increasing with every jE.G/j iterations. As usual we denote by n and m the number of vertices and edges of G, respectively. Lemma 9.9. Let f1 ; f2 ; : : : ; f t be a sequence of b-flows such that for i D 1; : : : ; t 1 we have .fi / < 0 and fi C1 results from fi by augmenting along Ci , where Ci is a circuit of minimum mean weight in Gfi . Then

9.3

Minimum Mean Cycle-Cancelling Algorithm

217

(a) .fk / .fkC1 / for all k. n (b) .fk / n2 .fl / for all k < l such that Ck [ Cl contains a pair of reverse edges. Proof: (a): Let fk ; fkC1 be two consecutive flows in this sequence. Consider the : Eulerian graph H resulting from .V .G/; E.Ck / [ E.CkC1 // by deleting pairs of reverse edges. (Edges appearing both in Ck and CkC1 are counted twice.) Every simple subgraph of H is a subgraph of Gfk , because each edge in E.GfkC1 / n E.Gfk / must be the reverse of an edge in E.Ck /. Since H is Eulerian, it can be decomposed into circuits, and each of these circuits has mean weight at least .fk /. So c.E.H // .fk /jE.H /j. Since the total weight of each pair of reverse edges is zero, c.E.H // D c.E.Ck // C c.E.CkC1 // D .fk /jE.Ck /j C .fkC1 /jE.CkC1 /j: Since jE.H /j jE.Ck /j C jE.CkC1 /j, we conclude .fk /.jE.Ck /j C jE.CkC1 /j/ .fk /jE.H /j c.E.H // D .fk /jE.Ck /j C .fkC1 /jE.CkC1 /j; implying .fkC1 / .fk /. (b): By (a) it is enough to prove the statement for those k; l such that for k < i < l, Ci [ Cl contains no pair of reverse edges. As in the proof of (a), consider the Eulerian graph H resulting from .V .G/, : E.Ck / [ E.Cl // by deleting pairs of reverse edges. Every simple subgraph of H is a subgraph of Gfk because any edge in E.Cl / n E.Gfk / must be the reverse of an edge in one of Ck ; CkC1 ; : : : ; Cl1 . But – due to the choice of k and l – only Ck among these contains the reverse of an edge of Cl . So as in (a) we have c.E.H // .fk /jE.H /j and c.E.H // D .fk /jE.Ck /j C .fl /jE.Cl /j: Since jE.H /j jE.Ck /j C

n2 n jE.Cl /j

(we deleted at least two edges) we get

n2 jE.Cl /j .fk /jE.H /j .fk / jE.Ck /j C n c.E.H // D .fk /jE.Ck /j C .fl /jE.Cl /j; implying .fk /

n n2

.fl /.

Corollary 9.10. During the execution of the MINIMUM MEAN CYCLE-CANCE1 LLING A LGORITHM , j.f /j decreases by at least a factor of 2 with every mn iterations.

218

9 Minimum Cost Flows

Proof: Let Ck ; CkC1 ; : : : ; CkCm be the augmenting cycles in consecutive iterations of the algorithm. Since each of these circuits contains one edge as a bottleneck edge (an edge removed afterwards from the residual graph), there must be two of these circuits, say Ci and Cj (k i < j k C m) whose union contains a pair of reverse edges. By Lemma 9.9 we then have .fk / .fi /

n n .fj / .fkCm /: n2 n2

So j.f /j decreases by at least a factor of n2 n with every m iterations. The n2 n corollary follows from this because of n < e 2 < 12 . This already proves that the algorithm runs in polynomial time provided that all edge costs are integral: j.f /j is at most jcmin j at the beginning, where cmin is the minimum cost of any edge, and decreases by at least a factor of 12 with every mn iterations. So after O.mn log.njcmin j// iterations, .f / is greater than n1 . If the edge costs are integral, this implies .f / 0 and the algorithm stops. So by Corollary 7.13, the running time is O m2 n2 log.njcmin j/ . Even better, we can also derive a strongly polynomial running time for the M INIMUM COST FLOW PROBLEM (first obtained by Tardos [1985]): Theorem 9.11. (Goldberg and Tarjan [1989]) The MINIMUM MEAN CYCLECANCELLING ALGORITHM runs in O m3 n2 log n time. Proof: We show that every mn.dlog ne C 1/ iterations at least one edge is fixed, i.e. the flow on this edge will not change anymore. Therefore there are at most O m2 n log n iterations. Using Theorem 9.2 for 1 and Corollary 7.13 for 2 then proves the theorem. Let f be the flow at some iteration, and let f 0 be the flow mn.dlog ne C 1/ iterations later. Define weights c 0 by c 0 .e/ WD c.e/ .f 0 / (e 2 E.Gf 0 /). Let be a feasible potential of .Gf 0 ; c 0 / (which exists by Theorem 7.7). We have 0 c0 .e/ D c .e/ .f 0 /, so c .e/ .f 0 /

for all e 2 E.Gf 0 /:

(9.3)

Now let C be the circuit of minimum mean weight in Gf that is chosen in the algorithm to augment f . Since by Corollary 9.10 .f / 2dlog neC1 .f 0 / 2n.f 0 / (see Figure 9.2), we have X X c .e/ D c.e/ D .f /jE.C /j 2n.f 0 /jE.C /j: e2E.C /

e2E.C /

So let e0 2 E.C / with c .e0 / 2n.f 0 /. By (9.3) we have e0 … E.Gf 0 /. Claim: For any b-flow f 00 with e0 2 E.Gf 00 / we have .f 00 / < .f 0 /.

9.4 µ( f )

Successive Shortest Path Algorithm

2n µ( f )

µ( f )

219

0

Fig. 9.2.

By Lemma 9.9(a) the claim implies that e0 will never be in the residual graph anymore, i.e. e0 and e0 are fixed mn.dlog ne C 1/ iterations after e0 is used in C . This completes the proof. To prove the claim, let f 00 be a b-flow with e0 2 E.Gf 00 /. We apply Proposition 9.5 to f 0 and f 00 and obtain a circulation g with g.e/ D 0 for all e … E.Gf 0 / and g.e0 / > 0 (because e0 2 E.Gf 00 / n E.Gf 0 /). By Proposition 9.6, g can be written as the sum of flows on f 0 -augmenting cycles. One of these circuits, say W , must contain e0 . By using c .e0 / D c .e0 / 2n.f 0 / and applying (9.3) to all e 2 E.W / n fe0 g we obtain a lower bound for the total weight of W : X c.E.W // D c .e/ 2n.f 0 / C .n 1/.f 0 / > n.f 0 /: e2E.W /

But the reverse of W is an f 00 -augmenting cycle (this can be seen by exchanging the roles of f 0 and f 00 ), and its total weight is less than n.f 0 /. This means that Gf 00 contains a circuit whose mean weight is less than .f 0 /, and so the claim is proved. The MINIMUM MEAN CYCLE-CANCELLING ALGORITHM was generalized in various ways by Karzanov and McCormick [1997].

9.4 Successive Shortest Path Algorithm The following theorem gives rise to another algorithm: Theorem 9.12. (Jewell [1958], Iri [1960], Busacker and Gowen [1961]) Let .G; u; b; c/ be an instance of the MINIMUM COST FLOW PROBLEM, and let f be a minimum cost b-flow. Let P be a shortest (with respect to c) s-t-path in Gf (for some s and t). Let f 0 be a flow obtained when augmenting f along P by at most the minimum residual capacity on P . Then f 0 is a minimum cost b 0 -flow (for some b 0 ). Proof: f 0 is a b 0 -flow for some b 0 . Suppose f 0 is not a minimum cost b 0 -flow. Then by Theorem 9.7 there is a circuit C in Gf 0 with negative total weight. Consider : the graph H resulting from .V .G/; E.C / [ E.P // by deleting pairs of reverse edges. (Again, edges appearing both in C and P are taken twice.) For any edge e 2 E.Gf 0 / n E.Gf /, the reverse of e must be in E.P /. Therefore every simple subgraph of H is a subgraph of Gf . As f is a minimum cost b-flow, no circuit in Gf , and hence in H , has negative total weight.

220

9 Minimum Cost Flows

We have c.E.H // D c.E.C // C c.E.P // < c.E.P //. Furthermore, H is the union of an s-t-path and some circuits. None of these circuits has negative weight. Therefore H , and thus Gf , contains an s-t-path of less weight than P , contradicting the choice of P . If the weights are conservative, we can start with f 0 as an optimum circulation (b-flow with b 0). Otherwise we can initially saturate all edges of negative cost, i.e., set f .e/ WD u.e/ for e 2 F WD fe 0 2 E.G/ W c.e 0 / < 0g and f .e/ WD 0 for e 2 E.G/ n F , and find a minimum cost b 0 -flow in .Gf ; uf /, where b 0 .v/ D b.v/ C exf .v/ for v 2 V .G/. For instances with infinite capacities more work is needed; see Exercise 5.

SUCCESSIVE SHORTEST PATH ALGORITHM Input:

A digraph P G, capacities u W E.G/ ! RC , numbers b W V .G/ ! R with v2V .G/ b.v/ D 0, and conservative weights c W E.G/ ! R.

Output:

A minimum cost b-flow f .

1

Set b 0 WD b and f .e/ WD 0 for all e 2 E.G/.

2

If b 0 D 0 then stop, else: Choose a vertex s with b 0 .s/ > 0. Choose a vertex t with b 0 .t/ < 0 such that t is reachable from s in Gf . If there is no such t then stop. (There exists no b-flow.) Find an s-t-path P in Gf of minimum weight. 0 0 Compute WD min min uf .e/; b .s/; b .t/ .

3 4

e2E.P /

Set b 0 .s/ WD b 0 .s/ and b 0 .t/ WD b 0 .t/ C . Augment f along P by . Go to . 2 If we allow arbitrary capacities, we have the same problems as with the FORDFULKERSON ALGORITHM (see Exercise 2 of Chapter 8; set all costs to zero). So henceforth we assume u and Pb to be integral. Then it is clear that the algorithm stops after at most B WD 12 v2V .G/ jb.v/j augmentations. By Theorem 9.12, the resulting flow is optimum if the initial zero flow is optimum. This is true if and only if c is conservative. We remark that if the algorithm decides that there is no b-flow, this decision is indeed correct. This is an easy observation, left as Exercise 13. Each augmentation requires a shortest path computation. Since negative weights occur, we have to use the MOORE-BELLMAN-FORD ALGORITHM whose running time is O.nm/ (Theorem 7.5), so the overall running time will be O.Bnm/. However, as in the proof of Theorem 7.8, it can be arranged that (except at the beginning) the shortest paths are computed in a graph with nonnegative weights:

9.4

Successive Shortest Path Algorithm

221

Theorem 9.13. (Tomizawa [1971], Edmonds and Karp [1972]) If u and b are integral, the SUCCESSIVE SHORTEST PATH ALGORITHM can Pbe implemented with a running time of O .nm C B.m C n log n//, where B D 12 v2V .G/ jb.v/j. Proof: We introduce a potential i W V .G/ ! R for each iteration i of the SUCCESSIVE SHORTEST PATH A LGORITHM . We start with any feasible potential 0 of .G; c/. By Corollary 7.7, this exists and can be computed in O.mn/ time. Now let fi 1 be the flow before iteration i . Then the shortest path computation in iteration i is done with the reduced costs ci 1 instead of c. Moreover, we extend Gfi 1 to Gf0 by adding edges .t; v/ of zero weight for all v 2 V .G/ (this is i 1 to ensure that all vertices are reachable from s). Let li .v/ denote the length of a shortest s-v-path in Gf0 with respect to the weights ci 1 . Then we set i .v/ WD i 1 i 1 .v/ C li .v/. We prove by induction on i that i is a feasible potential for .Gfi ; c/. This is clear for i D 0. For i > 0 and any edge e D .x; y/ 2 E.Gfi 1 / we have (by definition of li and the induction hypothesis) li .y/ li .x/ C ci 1 .e/ D li .x/ C c.e/ C i 1 .x/ i 1 .y/; so ci .e/ D c.e/Ci .x/i .y/ D c.e/Ci 1 .x/Cli .x/i 1 .y/li .y/ 0: For any edge e D .x; y/ 2 Pi (where Pi is the augmenting path in iteration i ) we have li .y/ D li .x/ C ci 1 .e/ D li .x/ C c.e/ C i 1 .x/ i 1 .y/; so ci .e/ D 0, and the reverse edge of e also has zero weight. Since each edge in E.Gfi / n E.Gfi 1 / is the reverse of an edge in Pi , ci is indeed a nonnegative weight function on E.Gfi /. We observe that in iteration i the shortest s-t-paths in Gfi 1 with respect to c are precisely the shortest s-t-paths in Gf0 with respect to ci 1 , because the added i 1 edges leaving t cannot occur and ci 1 .P / c.P / D i 1 .s/ i 1 .t/ for any s-t-path P . Hence we can use DIJKSTRA’S ALGORITHM – which runs in O .m C n log n/ time when implemented with a Fibonacci heap by Theorem 7.4 – for all shortest path computations except the initial one. Since we have at most B iterations, we obtain an overall running time of O .nm C B.m C n log n//. The running time of Theorem 9.13 is still exponential unless B is known to be small. If B D O.n/, this is the fastest algorithm known. For an application, see Section 11.1. In the rest of this section we show how to modify the algorithm in order to reduce the number of shortest path computations. We only consider the case when all capacities are infinite. By Lemma 9.3 each instance of the MINIMUM COST FLOW

222

9 Minimum Cost Flows

PROBLEM can be transformed to an equivalent instance with infinite capacities. The basic idea – due to Edmonds and Karp [1972] – is the following. In early iterations we consider only augmenting paths where – the amount of flow that can be pushed – is large. We start with D 2blog bmax c and reduce by a factor of two if no more augmentations by can be done. After blog bmax c C 1 iterations we have D 1 and stop (we again assume b to be integral). Such a scaling technique has proved useful for many algorithms (see also Exercise 14). A detailed description of the first scaling algorithm reads as follows:

CAPACITY SCALING ALGORITHM Input:

Output: 1 2

3 4 5

A digraph G with infinite P capacities u.e/ D 1 (e 2 E.G/), numbers b W V .G/ ! Z with v2V .G/ b.v/ D 0, and conservative weights c W E.G/ ! R. A minimum cost b-flow f .

Set b 0 WD b and f .e/ WD 0 for all e 2 E.G/. Set D 2blog bmax c , where bmax D maxfb.v/ W v 2 V .G/g. If b 0 D 0 then stop, else: Choose a vertex s with b 0 .s/ . Choose a vertex t with b 0 .t/ such that t is reachable from s in Gf . If there is no such s or t then go to . 5 Find an s-t-path P in Gf of minimum weight. Set b 0 .s/ WD b 0 .s/ and b 0 .t/ WD b 0 .t/ C . Augment f along P by . Go to . 2 If D 1 then stop. (There exists no b-flow.) Else set WD 2 and go to . 2

Theorem 9.14. (Edmonds and Karp [1972]) The CAPACITY SCALING ALGORITHM correctly solves the M INIMUM COST FLOW PROBLEM for integral b, infinite capacities and conservative weights. It can be implemented to run in O.n.m C n log n/ log.2 C bmax // time, where bmax D maxfb.v/ W v 2 V .G/g. Proof: As above, the correctness follows directly from Theorem 9.12. Note that at any time, the residual capacity of any edge is either infinite or an integral multiple of . To establish the running time, we call the period in which remains constant a phase. We prove that there are at most n augmentations within each phase. Let , f , and b 0 be the values at the beginning of some phase. Let S WD fv 2 V .G/ W b 0 .v/ g, S C WD fv 2 V .G/ W b 0 .v/ 2 g, T WD fv 2 V .G/ W b 0 .v/ g, and T C WD fv 2 V .G/ W b 0 .v/ 2 g. Let R be the set of vertices that are reachable from some element of S C in Gf . Note that S C R. We also have R \ T C D ;, because otherwise the previous phase would not have ended.

9.5

Orlin’s Algorithm

223

Let .si ; ti /, i D 1; : : : ; k, be the pairs .s; t/ in the considered phase; repetitions C are of course possible. As ıG .R/ D ;, we have jfi W si 2 R; ti … Rgj jfi W f si … R; ti 2 Rgj. Thus we can bound the number k of iterations in this phase by k jfi W si ; ti 2 Rgj C 2jfi W si … R; ti 2 Rgj C jfi W si ; ti … Rgj D jfi W ti 2 Rgj C jfi W si … Rgj jT \ Rj C jS n Rj n, where the second to last inequality holds because T C \ R D ; and S C n R D ;. This means that the total number of shortest path computations is O.n log.2 C bmax //. Combining this with the technique of Theorem 9.13 we obtain the O.mn C n log.2 C bmax /.m C n log n// bound. This was the first polynomial-time algorithm for the M INIMUM COST FLOW PROBLEM. By some further modifications we can even obtain a strongly polynomial running time. This is the subject of the next section.

9.5 Orlin’s Algorithm The CAPACITY SCALING ALGORITHM of the previous section can be improved further. A basic idea is that if an edge carries more than 2n units of flow at any stage of the CAPACITY SCALING ALGORITHM, it may be contracted. Namely, observe that such an edge will always keep a positive flow (and thus zero reduced cost with respect to any feasible potential in the residual graph): there are at most n more augmentations by , another n by 2 and so on; hence the total amount of flow moved in the rest of the algorithm is less than 2n . We shall describe ORLIN’S ALGORITHM without explicitly using contraction. This simplifies the description, especially from the point of view of implementing the algorithm. A set F keeps track of the edges (and their reverse edges) that can be contracted. .V .G/; F / will always arise from a forest by orienting each edge in both directions. A representative is chosen out of each connected component of .V .G/; F /. The algorithm maintains the property that the representative of a connected component is its only non-balanced vertex. This will lead to more augmentations in each phase, but still by less than 4n . For any vertex x, r.x/ denotes the representative of the connected component of .V .G/; F / containing x. G 0 denotes the subgraph of G containing the edges in F and all edges .x; y/ with r.x/ 6D r.y/. Edges outside G 0 will not be used anymore. ORLIN’S ALGORITHM does not require that b is integral. However, it can deal with uncapacitated problems only (but recall Lemma 9.3).

ORLIN’S ALGORITHM Input:

Output:

A digraph G with infinite P capacities u.e/ D 1 (e 2 E.G/), numbers b W V .G/ ! R with v2V .G/ b.v/ D 0, and conservative weights c W E.G/ ! R. A minimum cost b-flow f .

224

1

9 Minimum Cost Flows

Set b 0 WD b and f .e/ WD 0 for all e 2 E.G/. Set r.v/ WD v for all v 2 V .G/. Set F WD ; and G 0 WD G. Set D max jb 0 .v/j. v2V .G/

0

2

If b D 0 then stop.

3

. Choose a vertex s with b 0 .s/ > n1 n If there is no such s then go to . 4 Choose a vertex t with b 0 .t/ < n1 such that t is reachable from s in Gf . If there is no such t then stop. (There exists no b-flow.) Go to . 5

4

Choose a vertex t with b 0 .t/ < n1 n . If there is no such t then go to . 6 Choose a vertex s with b 0 .s/ > n1 such that t is reachable from s in Gf . If there is no such s then stop. (There exists no b-flow.) Find an s-t-path P in Gf0 of minimum weight. Set b 0 .s/ WD b 0 .s/ and b 0 .t/ WD b 0 .t/ C . Augment f along P by . Go to . 2 0 0 ; max / n F then set WD min jb .v/j , If f .e/ D 0 for all e 2 E.G 2 v2V .G/ else set WD 2 .

5

6

7

8

While there is an e D .x; y/ 2 E.G 0 / n F with f .e/ > 6n do: Set F WD F [ fe; e g. Let x 0 WD r.x/ and y 0 WD r.y/. Let Q be the x 0 -y 0 -path in F . If b 0 .x 0 / > 0 then augment f along Q by b 0 .x 0 /, else augment f along the reverse of Q by b 0 .x 0 /. 0 0 Set b .y / WD b 0 .y 0 / C b 0 .x 0 / and b 0 .x 0 / WD 0. For all e 0 D .v; w/ 2 E.G 0 / n F with fr.v/; r.w/g D fx 0 ; y 0 g do: Set E.G 0 / WD E.G 0 / n fe 0 g. Set r.´/ WD y 0 for all vertices ´ reachable from y 0 in F . Go to . 2

This algorithm is due to Orlin [1993]. See also (Plotkin and Tardos [1990]). We first prove its correctness. Let us call the time between two changes of a phase. We call a vertex v important if jb 0 .v/j > n1 . A phase ends when there is no n important vertex. Lemma 9.15. The number of augmentations in 5 during one phase is at most the number of important vertices at the beginning of this phase plus the number of augmentations in 7 at the beginning of this phase. l 0 m P jb .v/j n1 by Proof: Each augmentation in 5 decreases ˆ WD v2V .G/ n at least one, while an augmentation in 7 cannot increase ˆ by more than one.

9.5

Orlin’s Algorithm

225

Moreover, ˆ is the number of important vertices at the beginning of each phase. Lemma 9.16. ORLIN’S ALGORITHM solves the uncapacitated MINIMUM COST FLOW PROBLEM with conservative weights correctly. At any stage f is a minimumcost .b b 0 /-flow. Proof: We first prove that f is always a .b b 0 /-flow. In particular, we have to show that f is always nonnegative. To this end, we first observe that at any time the flow on each edge in E.G 0 / n F , and hence also the residual capacity of the reverse edge, is an integral multiple of . Moreover we claim that every edge e 2 F always has positive residual capacity. To see this, first observe that after e has become a member of F in the -phase there are at most n 1 augmentations in , 7 each by less than 2 . Moreover, any phase has at most 2n 1 augmentations by in 5 (cf. Lemma 9.15); hence the total amount of flow moved after e has become a member of F in the -phase is less than 2n in , 7 less than 2n in 5 during this phase, less than 2n 2 in 5 during the next phase, and so on, thus less than 6n overall. Hence we always have positive flow on every edge in F \ E.G/. Hence f is always nonnegative and thus it is always a .b b 0 /-flow. We now prove that f is always a minimum cost .b b 0 /-flow. This is true initially because c is conservative. While f is an optimum .b b 0 /-flow, each v-w-path in .V .G/; F / is a shortest v-w-path in Gf (a shorter path would result in a negative circuit in Gf ). Now the claim follows from Theorem 9.12: P in 5 and Q in 7 are shortest paths in Gf0 and .V .G/; F /, respectively, and hence in Gf (note that for any .v; w/ 2 E.Gf / n E.Gf0 / there is a v-w-path in .V .G/; F /). We finally show that if the algorithm stops in 3 or 4 with b 0 6D 0, then there is indeed no b-flow. Suppose the algorithm stops in , 3 implying that there is a vertex s with b 0 .s/ > n1 , but that no vertex t with b 0 .t/ < n1 is reachable from n s in Gf . ThenP let R be the set of vertices reachable from s in Gf . Since f is a .b b 0 /-flow, x2R .b.x/ b 0 .x// D 0. Therefore we have X X X b.x/ D b 0 .x/ D b 0 .s/ C b 0 .x/ > 0 x2R

x2R

x2Rnfsg

C but ıG .R/ D ;. This proves that no b-flow exists. An analogous proof applies in the case that the algorithm stops in . 4

We now analyse the running time. Lemma 9.17. (Plotkin and Tardos [1990]) If a vertex ´ is important at some stage of the algorithm, then the connected component of .V .G/; F / containing ´ increases during the next d2 log n C log me C 3 phases. Proof: Let jb 0 .´/j > n1 1 for a vertex ´ at the beginning of some phase of n the algorithm where D 1 . Let 0 be the -value in the preceding phase (and

226

9 Minimum Cost Flows

0 D 21 if there is none), and 2 the -value d2 log n C log me C 2 phases later. We have 12 0 1 4n2 m2 . Let b10 and f1 be the b 0 and f at the beginning of the 1 -phase, respectively, and let b20 and f2 be the b 0 and f at the end of the 2 -phase, respectively. Let Z be the connected component of .V .G/; F / containing ´ in the 1 -phase, and suppose that this remains unchanged for the d2 log n C log me C 3 phases considered. Note that 7 guarantees b 0 .v/ D 0 for all vertices v with r.v/ 6D v. Hence b 0 .v/ D 0 for all v 2 Z n f´g and X X X X b.x/ b10 .´/ D .b.x/ b10 .x// D f1 .e/ f1 .e/: (9.4) x2Z

x2Z

e2ı C .Z/

e2ı .Z/

The right-hand side is an integral multiple of 0 , and 1 n1 n1 1 1 1 < jb10 .´/j 0 < 0 1 : n n n n

(9.5)

ˇ ˇ ˇX ˇ 1 ˇ ˇ b.x/ˇ > 1 : (9.6) ˇ ˇ ˇ n x2Z P P P As in (9.4), we have e2ı C .Z/ f2 .e/ e2ı .Z/ f2 .e/ D x2Z b.x/b20 .´/. Using (9.6) and jb20 .´/j n1 2 we obtain n ˇ ˇ ˇX ˇ X 1 n1 ˇ ˇ 2 jf2 .e/j ˇ b.x/ˇ jb20 .´/j > 1 ˇ ˇ n n C x2Z e2ı .Z/[ı .Z/ 2 : > .4nm 1/2 > m 6n 2

Hence

Thus there exists at least one edge e with exactly one end in Z and f2 .e/ > 6n 22 . By 7 of the algorithm, this means that Z is increased at the beginning of the 22 phase. Theorem 9.18. (Orlin [1993]) ORLIN’S ALGORITHM solves the uncapacitated MINIMUM COST FLOW PROBLEM with conservative weights correctly in O.n log n.m C n log n// time. Proof: The correctness has been proved above (Lemma 9.16). In each phase, 7 takes O.m.i C 1// time, where i is the number of iterations in the while-loop. Note that the total number of iterations in this while-loop is at most n 1 as the number of connected components of .V .G/; F / decreases each time. By 6 and , 7 there can be at most dlog ne C 3 subsequent phases without an important vertex. Therefore, Lemma 9.17 implies that the total number of phases is O.n log m/. By Lemma 9.15, the total number of augmentations in 5 is at most n 1 plus the number of pairs .; ´/, where ´ is important at the beginning of the -phase. By

9.6

The Network Simplex Algorithm

227

Lemma 9.17, and since all vertices v with r.v/ 6D v have b 0 .v/ D 0 at any time, the number of these pairs is O.log m/ times the number of sets that are at some stage of the algorithm a connected component of .V .G/; F /. Since the family of these sets is laminar, there are at most 2n 1 such sets (Corollary 2.15), and thus O.n log m/ augmentations in 5 altogether. Using the technique of Theorem 9.13, we obtain an overall running time of O .mn log m C .n log m/.m C n log n//. We may assume m D O.n2 /, and thus log m D O.log n/, because among a set of uncapacitated parallel edges we need only a cheapest one. This is the best known running time for the uncapacitated M INIMUM COST FLOW PROBLEM. Theorem 9.19. (Orlin [1993]) The general MINIMUM COST FLOW PROBLEM can be solved in O .m log m.m C n log n// time, where n D jV .G/j and m D jE.G/j. Proof: We apply the construction given in Lemma 9.3. Thus we have to solve an uncapacitated MINIMUM COST FLOW PROBLEM on a bipartite graph H with : V .H / D A0 [ B 0 , where A0 D E.G/ and B 0 D V .G/. Since H is acyclic, an initial feasible potential can be computed in O.jE.H /j/ D O.m/ time. As shown above (Theorem 9.18), the overall running time is bounded by O.m log m/ shortest $

path computations in a subgraph of H with nonnegative weights. Before we call DIJKSTRA’S ALGORITHM we apply the following operation to each vertex a 2 A0 that is not an endpoint of the path we are looking for: add an edge .b; b 0 / for each pair of edges .b; a/; .a; b 0 / and set its weight to the sum of the weights of .b; a/ and .a; b 0 /; finally delete a. Clearly the resulting instance of the SHORTEST PATH PROBLEM is equivalent. Since each vertex in A0 has four incident $

edges in H , the resulting graph has O.m/ edges and at most n C 2 vertices. The preprocessing takes constant time per vertex, i.e. O.m/. The same holds for the final $

computation of the path in H and of the distance labels of the deleted vertices. We get an overall running time of O ..m log m/.m C n log n//. This is the fastest known strongly polynomial algorithm for the general M INICOST FLOW PROBLEM. An algorithm which achieves the same running time but works directly on capacitated instances has been described by Vygen [2002]. MUM

9.6 The Network Simplex Algorithm The MINIMUM COST FLOW PROBLEM is a special case of LINEAR PROGRAMMING. By applying the SIMPLEX A LGORITHM and exploiting the special structure we arrive at what is called the NETWORK SIMPLEX ALGORITHM. To make the connection clear, we first characterize the set of basic solutions (although we will not need this to prove correctness).

228

9 Minimum Cost Flows

Definition 9.20. Let .G; u; b; c/ be an instance of the MINIMUM COST FLOW PROBLEM. A b-flow f in .G; u/ is a spanning tree solution if .V .G/; fe 2 E.G/ W 0 < f .e/ < u.e/g/ contains no undirected circuit. Proposition 9.21. An instance of the MINIMUM COST FLOW PROBLEM either has an optimum solution which is a spanning tree solution or has no optimum solution at all. Proof: Given an optimum solution f and an undirected circuit C in .V .G/; fe 2 E.G/ W 0 < f .e/ < u.e/g/, we have two directed circuits C 0 and C 00 in Gf with the same underlying undirected graph as C . Let be the minimum residual capacity in E.C 0 / [ E.C 00 /. We can obtain two other feasible solutions f 0 and f 00 by augmenting f by along C 0 and C 00 , respectively. As 2c.f / D c.f 0 / C c.f 00 /, both f 0 and f 00 are also optimum solutions. At least one of them has fewer edges e with 0 < f .e/ < u.e/ than f , so after less than jE.G/j steps we arrive at an optimum spanning tree solution. Corollary 9.22. Let .G; u; b; c/ be an instance of the MINIMUM COST FLOW PROBLEM. Then the basic solutions of ( x 2 RE.G/ W 0 xe u.e/ .e 2 E.G//; X e2ı C .v/

xe

X

) xe D b.v/ .v 2 V .G//

e2ı .v/

are precisely the spanning tree solutions of .G; u; b; c/. Proof: Proposition 9.21 shows that each basic solution is a spanning tree solution. For a spanning tree solution f we consider the inequalities xe 0 for eP2 E.G/ withPf .e/ D 0, xe u.e/ for e 2 E.G/ with f .e/ D u.e/, and e2ı C .v/ xe e2ı .v/ xe D b.v/ for all v except one vertex of each connected component of .V .G/; fe 2 E.G/ W 0 < f .e/ < u.e/g/. These jE.G/j inequalities are all satisfied by f with equality, and the submatrix corresponding to these inequalities is nonsingular. Thus f is a basic solution. In a spanning tree solution there are three types of edges: those with zero flow, those with saturated capacity, and those whose flow is positive but less than the capacity. Assuming that G is connected, we can extend the last set of edges to a connected spanning subgraph without undirected circuits (i.e., an oriented spanning tree; hence the name “spanning tree solution”). Definition 9.23. Let .G; u; b; c/ be an instance of the MINIMUM COST FLOW PROBLEM where G is connected. A spanning tree structure is a quadruple : : .r; T; L; U / where r 2 V .G/, E.G/ D T [ L [ U , jT j D jV .G/j 1, and .V .G/; T / contains no undirected circuit. The b-flow associated with the spanning tree structure .r; T; L; U / is defined by

9.6

The Network Simplex Algorithm

229

f .e/ WD 0 for e 2 L, f .e/ WD u.e/ P for e 2 U , P P f .e/ WD v2Ce b.v/ C e2U \ı .Ce / u.e/ e2U \ı C .Ce / u.e/ for e 2 T , where for e D .v; w/ we denote by Ce the connected component of .V .G/; T n feg/ containing v. .r; T; L; U / is called feasible if 0 f .e/ u.e/ for all e 2 T . Call an edge .v; w/ in T downward if v belongs to the undirected r-w-path in T , otherwise upward. .r; T; L; U / is called strongly feasible if 0 < f .e/ u.e/ for each downward edge e 2 T and 0 f .e/ < u.e/ for each upward edge e 2 T . The unique function W V .G/ ! R with .r/ D 0 and c .e/ D 0 for all e 2 T is called the potential associated with the spanning tree structure .r; T; L; U /. b-flow f associated with a spanning tree structure satisfies P Evidently the P f .e/ C e2ı .v/ e2ı .v/ f .e/ D b.v/ for all v 2 V .G/ (though it is not always a feasible b-flow). Moreover we note: Proposition 9.24. Given an instance .G; u; b; c/ of the MINIMUM COST FLOW PROBLEM and a spanning tree structure .r; T; L; U /, the b-flow f and the potential associated with it can be computed in O.m/ and O.n/ time, respectively. Moreover, f is integral whenever b and u are integral, and is integral whenever c is integral. Proof: The potential associated with .r; T; L; U / can be computed simply by applying the GRAPH SCANNING ALGORITHM to the edges of T and their reverse edges. The b-flow associated with .r; T; L; U / can be computed in linear time by scanning the vertices in an order of nonincreasing distance from r. The integrality properties follow immediately from the definition. The NETWORK SIMPLEX ALGORITHM maintains a strongly feasible spanning tree structure and works towards optimality. Note that the optimality criterion in Corollary 9.8 immediately implies: Proposition 9.25. Let .r; T; L; U / be a feasible spanning tree structure and let be the potential associated with it. Suppose that c .e/ 0 for all e 2 L, and c .e/ 0 for all e 2 U . Then .r; T; L; U / is associated with an optimum b-flow.

$

Note that .v/ is the length of the r-v-path in G that contains only edges of T $

or their reverse edges. For an edge e D .v; w/ 2 E.G/ we define the fundamental circuit C of e to consist of e and the w-v-path that contains only edges of T and their reverse edges. The vertex of C that is closest to r in T is called its peak. Hence for e D .v; w/ … T , c .e/ D c.e/ C .v/ .w/ is the cost of sending one unit of flow along the fundamental circuit of e.

230

9 Minimum Cost Flows

There are several ways to obtain an initial feasible spanning tree structure. For example, one could compute any b-flow (by solving a MAXIMUM FLOW PROBLEM), apply the procedure in the proof of Proposition 9.21, choose r arbitrarily, and define T; L; U according to the flow (adding suitable edges to T if necessary). Alternatively, one could apply “phase one” of the SIMPLEX METHOD. However, this may not lead to a strongly feasible spanning tree structure. The simplest possibility is to introduce very expensive auxiliary edges with sufficient capacity between r and each other vertex: For each sink v 2 V .G/nfrg we introduce an edge .r; v/ with capacity b.v/, and for each other vertex v 2 V .G/ n frg we introduce an edge .v; r/ with capacity b.v/ C 1. The cost of each auxiliary edge should be high enough so that they never occur in an optimum solution, for example 1 C .jV .G/j 1/ maxe2E.G/ jc.e/j (Exercise 20). Then we can choose T as the set of all auxiliary edges, L as the set of all original edges, and U WD ; to obtain an initial strongly feasible spanning tree structure.

NETWORK SIMPLEX ALGORITHM Input: Output:

An instance .G; u; b; c/ of the MINIMUM COST FLOW PROBLEM and a strongly feasible spanning tree structure .r; T; L; U /. An optimum solution f .

1

Compute the b-flow f and the potential associated with .r; T; L; U /.

2

Let e 2 L with c .e/ < 0 or e 2 U with c .e/ > 0. If such an edge e does not exist then stop.

3

Let C be the fundamental circuit of e (if e 2 L) or of e (if e 2 U ). Let WD c .e/. Let ı WD mine0 2E.C / uf .e 0 /, and let e 0 be the last edge where the minimum is attained when traversing C in its orientation, starting at its peak. Let e0 2 E.G/ such that e 0 is e0 or e0 . Remove e from L or U . Set T WD .T [ feg/ n fe0 g. If e 0 D e0 then insert e0 into U else insert e0 into L. Augment f by ı along C . Let X be the connected component of .V .G/; T n feg/ containing r. If e 2 ı C .X / then set .v/ WD .v/ C for v 2 V .G/ n X . If e 2 ı .X / then set .v/ WD .v/ for v 2 V .G/ n X . Go to . 2

4

5

6

We remark that 6 could be replaced simply by going back to , 1 as f and computed in 6 are associated with the new spanning tree structure. Also note that e D e0 is possible; in this case X D V .G/, and T and do not change, but e moves from L to U or vice versa, and ı D u.e/.

9.7

Flows Over Time

231

Theorem 9.26. (Dantzig [1951], Cunningham [1976]) The NETWORK SIMPLEX ALGORITHM stops after finitely many iterations and returns an optimum solution. Proof: First observe that 6 maintains the property that f and are the b-flow and potential associated with .r; T; L; U /. Next we prove that the spanning tree structure is always strongly feasible. By the choice of ı we maintain the condition 0 f .e/ u.e/ for all e, and hence the spanning tree structure remains feasible. As the edges of the subpath of C from the head of e 0 to the peak did not attain the minimum in , 4 they will continue to have positive residual capacity after the augmentation. For the edges of the subpath of C from the peak to the tail of e 0 we have to make sure that their reverse edges have positive residual capacity after the augmentation. This is clear if ı > 0. Otherwise (if ı D 0), the fact that the spanning tree structure was strongly feasible before implies that neither e nor e can belong to this subpath (i.e. e D e0 or ı .X / \ E.C / \ fe; e g 6D ;), and that the reverse edges of the subpath of C from the peak to tail of e or e had positive residual capacity. By Proposition 9.25 the computed flow f is optimum when the algorithm terminates. We show that there are no two iterations with the same pair .f; /, and hence each spanning tree structure occurs at most once. In each iteration the cost of the flow is reduced by j jı. As 6D 0, we only need to consider iterations with ı D 0. Here the cost of the flow P remains constant. If e 6D e0 , then e 2 L \ ı .X / or e 2 U \ ı C .X /, and hence v2V .G/ .v/ strictly increases (by at least j j). Finally, if ı D 0 and e D e0 , then u.e/ D 0, X D V .G/, remains constant, and jfe 2 L W c .e/ < 0gj C jfe 2 U W c .e/ > 0gj strictly decreases. This shows that no two iterations feature the same spanning tree structure. Although the NETWORK SIMPLEX ALGORITHM is not a polynomial-time algorithm, it is quite efficient in practice. Orlin [1997] proposed a variant that runs in polynomial time. Polynomial-time dual network simplex algorithms were found by Orlin, Plotkin and Tardos [1993], and Armstrong and Jin [1997].

9.7 Flows Over Time We now consider flows over time (also sometimes called dynamic flows); i.e. the flow value on each edge may change over time, and flow entering an edge arrives at the endvertex after a specified delay: Definition 9.27. Let .G; u; s; t/ be a network with transit times l W E.G/ ! RC and a time horizon T 2 RC . Then an s-t-flow over time f consists of a Lebesguemeasurable function fe W Œ0; T ! RC for each e 2 E.G/ with fe ./ u.e/ for all 2 Œ0; T and e 2 E.G/ and

232

9 Minimum Cost Flows

exf .v; a/ WD

X Z e2ı .v/

X Z

maxf0;al.e/g

fe ./d

0

e2ı C .v/

a 0

fe ./d 0 (9.7)

for all v 2 V .G/ n fsg and a 2 Œ0; T . fe ./ is called the rate of flow entering e at time (and leaving this edge l.e/ time units later). (9.7) allows intermediate storage at vertices, like in s-t-preflows. It is natural to maximize the flow arriving at sink t:

MAXIMUM FLOW OVER TIME PROBLEM Instance: Task:

A network .G; u; s; t/. Transit times l W E.G/ ! RC and a time horizon T 2 RC . Find an s-t-flow over time f such that value .f / WD exf .t; T / is maximum.

Following Ford and Fulkerson [1958], we show that this problem can be reduced to the MINIMUM COST FLOW PROBLEM. Theorem 9.28. The MAXIMUM FLOW OVER TIME PROBLEM can be solved in the same time as the MINIMUM COST FLOW PROBLEM. Proof: Given an instance .G; u; s; t; l; T / as above, define a new edge e 0 D .t; s/ and G 0 WD G C e 0 . Set u.e 0 / WD u.E.G// C 1, c.e 0 / WD T and c.e/ WD l.e/ for e 2 E.G/. Consider the instance .G 0 ; u; 0; c/ of the MINIMUM COST FLOW PROBLEM. Let f 0 be an optimum solution, i.e. a minimum cost (with respect to c) circulation in .G 0 ; u/. By Proposition 9.6, f 0 can be decomposed into flows on 0 circuits, i.e. there P is a set C of circuits in G and positive numbers h W C ! RC such 0 that f .e/ D fh.C / W C 2 C; e 2 E.C /g. We have c.E.C // 0 for all C 2 C as f 0 is a minimum cost circulation. Let C 2 C with c.E.C // < 0. C must contain e 0 . For e D .v; w/ 2 E.C /nfe 0 g, let deC be the distance from s to v in .C; c/. Set o Xn fe ./ WD h.C / W C 2 C ; c.E.C // < 0; e 2 E.C /; deC deC c.E.C // for e 2 E.G/ and 2 Œ0; T . This defines an s-t-flow over time without intermediate storage (i.e. exf .v; a/ D 0 for all v 2 V .G/ n fs; tg and all a 2 Œ0; T ). Moreover,

value .f / D

X Z e2ı .t /

T l.e/ 0

fe ./d D

X

c.e/f 0 .e/:

e2E.G 0 /

We claim that f is optimum. To see this, let f be any s-t-flow over time, and set fe ./ WD 0 for e 2 E.G/ and … Œ0; T . Let .v/ WD T Cminf0; dist.G 0 0 ;c/ .t; v/g f for v 2 V .G/. As Gf0 0 contains no negative circuit (cf. Theorem 9.7), is a feasible potential in .Gf0 0 ; c/. We have

Exercises

value .f / D exf .t; T /

X

233

exf .v; .v//

v2V .G/

because of (9.7), .t/ D T , .s/ D 0 and 0 .v/ T for all v 2 V .G/. Hence ! Z .w/l.e/ Z .v/ X fe ./d fe ./d value .f / eD.v;w/2E.G/

X

0

0

..w/ l.e/ .v//u.e/

eD.v;w/2E.G/W.w/l.e/>.v/

X

D

..w/ l.e/ .v//f 0 .e/

eD.v;w/2E.G/

X

D

..w/ c.e/ .v//f 0 .e/

eD.v;w/2E.G 0 /

X

D

c.e/f 0 .e/

eD.v;w/2E.G 0 /

D value .f /:

Other flow over time problems are significantly more difficult. Hoppe and Tardos [2000] solved the so-called quickest transshipment problem (with several sources and sinks) with integral transit times using submodular function minimization (see Chapter 14). Finding minimum cost flows over time is NP-hard (Klinz and Woeginger [2004]). See Fleischer and Skutella [2007] for approximation algorithms and more information.

Exercises 1. Show that the M AXIMUM FLOW PROBLEM can be regarded as a special case of the MINIMUM COST FLOW PROBLEM. 2. Let G be a digraph with lower and upper capacities l; u W E.G/ ! RC , where l.e/ u.e/ for all e 2 E.G/, and let b1 ; b2 W V .G/ ! R with b1 .v/ b2 .v/ for all v 2 V .G/. Prove that there exists a flow f with l.e/ f .e/ u.e/ for all e 2 E.G/ and X X b1 .v/ f .e/ f .e/ b2 .v/ for all v 2 V .G/ e2ı .v/

e2ı C .v/

if and only if X e2ı C .X/

u.e/ max

8 <X :

v2X

b1 .v/;

X

v2V .G/nX

9 = b2 .v/

;

C

X e2ı .X/

l.e/

234

9 Minimum Cost Flows

for all X V .G/. Note: This generalizes Exercise 4 of Chapter 8 and Theorem 9.2. (Hoffman [1960]) 3. Prove the following theorem of Ore [1956]. Given a digraph G and nonnegative integers a.x/; b.x/ for each x 2 V .G/, then G has a spanning subgraph H with C jıH .x/j D a.x/ and jıH .x/j D b.x/ for all x 2 V .G/ if and only if X X a.x/ D b.x/ and x2V .G/

X x2X

a.x/

X

x2V .G/

C minfb.y/; jıG .X n fyg/ \ ıG .y/jg

for all X V .G/:

y2V .G/

(Ford and Fulkerson [1962]) 4. Let .G; u; c; b/ be an instance of the MINIMUM COST FLOW PROBLEM with c.e/ 0 for all e 2 E.G/. Let F be the set of edges e 2 E.G/ for which an optimum solution f with f .e/ > 0 exists. Prove that every circuit in .V .G/; F / consists only of edges e with c.e/ D 0. 5. Consider the MINIMUM COST FLOW PROBLEM where infinite capacities (u.e/ D 1 for some edges e) are allowed. (a) Show that an instance is unbounded if and only if it is feasible and there is a negative circuit all whose edges have infinite capacity. (b) Show how to decide in O.n3 C m/ time whether an instance is unbounded. (c) Show that for an instance that is not unbounded each infinite capacity can be equivalently replaced by a finite capacity. 6. Let .G; u; c; b/ be an instance of the MINIMUM COST FLOW PROBLEM. We call a function W V .G/ ! R an optimal potential if there exists a minimum cost b-flow f such that is a feasible potential with respect to .Gf ; c/. (a) Prove that a function W V .G/ ! R is an optimal potential if and only if for all X V .G/: X X b.X / C u.e/ u.e/: e2ı .X/Wc .e/ c.X / or assert that no such Y exists. Suppose this algorithm has a running time which is polynomial in size.c/. Prove that then there is an algorithm for finding a maximum weight set X 2 F for a given .E; F / 2 ‰ and c W E ! ZC , whose running time is polynomial in size.c/. (Grötschel and Lovász [1995]; see also Schulz, Weismantel and Ziegler [1995], and Schulz and Weismantel [2002]) Prove that ORLIN’S ALGORITHM always computes a spanning tree solution.

236

9 Minimum Cost Flows

16. Prove that in 7 of ORLIN’ S ALGORITHM one can replace the 6n-bound by 5n . 17. Consider the shortest path computations with nonnegative weights (using DIJKSTRA’S ALGORITHM) in the algorithms of Section 9.4 and 9.5. Show that even for graphs with parallel edges each of these computations can be performed in O.n2 / time, provided that we have the incidence list of G sorted by edge costs. Conclude that ORLIN’S ALGORITHM runs in O.mn2 log m/ time.

18. The PUSH-RELABEL ALGORITHM (Section 8.5) can be generalized to the M INIMUM COST FLOW PROBLEM . For an instance .G; u; b; c/ with integral costs c, we look for a b-flow f and a feasible potential in .Gf ; c/. We start by setting WD 0 and saturating all edges e with negative cost. Then we apply 3 of the PUSH-RELABEL ALGORITHM with the following modifications. An edge e is admissible if e 2 E.Gf / and c .e/ < 0. A vertex v is active if b.v/ C exf .v/ > 0. RELABEL.v/ consists of setting .v/ WD maxf.w/ c.e/ 1 W e D .v; w/ 2 E.Gf /g. In PUSH.e/ for e 2 ı C .v/ we set WD minfb.v/ C exf .v/; uf .e/g. (a) Prove that the number of RELABEL operations is O.n2 jcmax j/, where cmax D maxe2E.G/ c.e/. Hint: Some vertex w with b.w/ C exf .w/ < 0 must be reachable in Gf from any active vertex v. Note that b.w/ has never changed and recall the proofs of Lemmata 8.25 and 8.27. (b) Show that the overall running time is O.n2 mcmax /. (c) Prove that the algorithm computes an optimum solution. (d) Apply scaling to obtain an O.n2 m log cmax /-algorithm for the MINIMUM COST FLOW PROBLEM with integral costs c. (Goldberg and Tarjan [1990]) 19. Let .G; u; b; c/ be an instance of the MINIMUM COST FLOW PROBLEM, where u and b are integral. Prove the following statement using (a) the MINIMUM MEAN CYCLE-CANCELLING ALGORITHM or (b) the SUCCESSIVE SHORTEST PATH ALGORITHM, or (c) total unimodularity. If there exists a b-flow in .G; u/, then there exists a minimum cost b-flow which is integral. 20. Let .G; u; c; b/ be an instance of the MINIMUM COST FLOW PROBLEM. Let eN 2 E.G/ with c.e/ N > .jV .G/j 1/ maxe2E.G/nfeg N jc.e/j. Prove: If there exists a b-flow f in .G; u/ with f .e/ N D 0, then f .e/ N D 0 holds for every optimum solution f . 21. Given a network .G; u; s; t/ with integral transit times l W E.G/ ! ZC , a time horizon T 2 N, a value V 2 RC , and costs c W E.G/ ! RC . We look for an s-t-flow over time f with value .f / D V and minimum cost RT P e2E.G/ c.e/ 0 fe ./d . Show how to solve this in polynomial time if T is a constant. Hint: Consider a time-expanded network with a copy of G for each discrete time step.

References

237

References General Literature: Ahuja, R.K., Magnanti, T.L., and Orlin, J.B. [1993]: Network Flows. Prentice-Hall, Englewood Cliffs 1993 Cook, W.J., Cunningham, W.H., Pulleyblank, W.R., and Schrijver, A. [1998]: Combinatorial Optimization. Wiley, New York 1998, Chapter 4 Goldberg, A.V., Tardos, É., and Tarjan, R.E. [1990]: Network flow algorithms. In: Paths, Flows, and VLSI-Layout (B. Korte, L. Lovász, H.J. Prömel, A. Schrijver, eds.), Springer, Berlin 1990, pp. 101–164 Gondran, M., and Minoux, M. [1984]: Graphs and Algorithms. Wiley, Chichester 1984, Chapter 5 Jungnickel, D. [2007]: Graphs, Networks and Algorithms. Third Edition. Springer, Berlin 2007, Chapters 10 and 11 Lawler, E.L. [1976]: Combinatorial Optimization: Networks and Matroids. Holt, Rinehart and Winston, New York 1976, Chapter 4 Ruhe, G. [1991]: Algorithmic Aspects of Flows in Networks. Kluwer Academic Publishers, Dordrecht 1991 Skutella, M. [2009]: An introduction to network flows over time. In: Research Trends in Combinatorial Optimization (W.J. Cook, L. Lovász, J. Vygen, eds.), Springer, Berlin 2009, pp. 451–482

Cited References: Arkin, E.M., and Silverberg, E.B. [1987]: Scheduling jobs with fixed start and end times. Discrete Applied Mathematics 18 (1987), 1–8 Armstrong, R.D., and Jin, Z. [1997]: A new strongly polynomial dual network simplex algorithm. Mathematical Programming 78 (1997), 131–148 Busacker, R.G., and Gowen, P.J. [1961]: A procedure for determining a family of minimumcost network flow patterns. ORO Technical Paper 15, Operational Research Office, Johns Hopkins University, Baltimore 1961 Cunningham, W.H. [1976]: A network simplex method. Mathematical Programming 11 (1976), 105–116 Dantzig, G.B. [1951]: Application of the simplex method to a transportation problem. In: Activity Analysis and Production and Allocation (T.C. Koopmans, Ed.), Wiley, New York 1951, pp. 359–373 Edmonds, J., and Karp, R.M. [1972]: Theoretical improvements in algorithmic efficiency for network flow problems. Journal of the ACM 19 (1972), 248–264 Fleischer, L., and Skutella, M. [2007]: Quickest flows over time. SIAM Journal on Computing 36 (2007), 1600–1630 Ford, L.R., and Fulkerson, D.R. [1958]: Constructing maximal dynamic flows from static flows. Operations Research 6 (1958), 419–433 Ford, L.R., and Fulkerson, D.R. [1962]: Flows in Networks. Princeton University Press, Princeton 1962 Gale, D. [1957]: A theorem on flows in networks. Pacific Journal of Mathematics 7 (1957), 1073–1082 Goldberg, A.V., and Tarjan, R.E. [1989]: Finding minimum-cost circulations by cancelling negative cycles. Journal of the ACM 36 (1989), 873–886

238

9 Minimum Cost Flows

Goldberg, A.V., and Tarjan, R.E. [1990]: Finding minimum-cost circulations by successive approximation. Mathematics of Operations Research 15 (1990), 430–466 Grötschel, M., and Lovász, L. [1995]: Combinatorial optimization. In: Handbook of Combinatorics; Vol. 2 (R.L. Graham, M. Grötschel, L. Lovász, eds.), Elsevier, Amsterdam 1995 Hassin, R. [1983]: The minimum cost flow problem: a unifying approach to dual algorithms and a new tree-search algorithm. Mathematical Programming 25 (1983), 228–239 Hitchcock, F.L. [1941]: The distribution of a product from several sources to numerous localities. Journal of Mathematical Physics 20 (1941), 224–230 Hoffman, A.J. [1960]: Some recent applications of the theory of linear inequalities to extremal combinatorial analysis. In: Combinatorial Analysis (R.E. Bellman, M. Hall, eds.), AMS, Providence 1960, pp. 113–128 Hoppe, B., and Tardos, É. [2000]: The quickest transshipment problem. Mathematics of Operations Research 25 (2000), 36–62 Iri, M. [1960]: A new method for solving transportation-network problems. Journal of the Operations Research Society of Japan 3 (1960), 27–87 Jewell, W.S. [1958]: Optimal flow through networks. Interim Technical Report 8, MIT 1958 Karzanov, A.V., and McCormick, S.T. [1997]: Polynomial methods for separable convex optimization in unimodular linear spaces with applications. SIAM Journal on Computing 26 (1997), 1245–1275 Klein, M. [1967]: A primal method for minimum cost flows, with applications to the assignment and transportation problems. Management Science 14 (1967), 205–220 Klinz, B., and Woeginger, G.J. [2004]: Minimum cost dynamic flows: the series-parallel case. Networks 43 (2004), 153–162 Orden, A. [1956]: The transshipment problem. Management Science 2 (1956), 276–285 Ore, O. [1956]: Studies on directed graphs I. Annals of Mathematics 63 (1956), 383–406 Orlin, J.B. [1993]: A faster strongly polynomial minimum cost flow algorithm. Operations Research 41 (1993), 338–350 Orlin, J.B. [1997]: A polynomial time primal network simplex algorithm for minimum cost flows. Mathematical Programming 78 (1997), 109–129 Orlin, J.B., Plotkin, S.A., and Tardos, É. [1993]: Polynomial dual network simplex algorithms. Mathematical Programming 60 (1993), 255–276 Plotkin, S.A., and Tardos, É. [1990]: Improved dual network simplex. Proceedings of the 1st Annual ACM-SIAM Symposium on Discrete Algorithms (1990), 367–376 Schulz, A.S., Weismantel, R., and Ziegler, G.M. [1995]: 0/1-Integer Programming: optimization and augmentation are equivalent. In: Algorithms – ESA ’95; LNCS 979 (P. Spirakis, ed.), Springer, Berlin 1995, pp. 473–483 Schulz, A.S., and Weismantel, R. [2002]: The complexity of generic primal algorithms for solving general integer problems. Mathematics of Operations Research 27 (2002), 681–692 Tardos, É. [1985]: A strongly polynomial minimum cost circulation algorithm. Combinatorica 5 (1985), 247–255 Tolsto˘ı, A.N. [1930]: Metody nakhozhdeniya naimen’shego summovogo kilometrazha pri planirovanii perevozok v prostanstve. In: Planirovanie Perevozok, Sbornik pervy˘ı, Transpechat’ NKPS, Moskow 1930, pp. 23–55. (See A. Schrijver, On the history of the transportation and maximum flow problems, Mathematical Programming 91 (2002), 437–445) Tomizawa, N. [1971]: On some techniques useful for solution of transportation network problems. Networks 1 (1971), 173–194

References

239

Vygen, J. [2002]: On dual minimum cost flow algorithms. Mathematical Methods of Operations Research 56 (2002), 101–126 Wagner, H.M. [1959]: On a class of capacitated transportation problems. Management Science 5 (1959), 304–318

•

10 Maximum Matchings

Matching theory is one of the classical and most important topics in combinatorial theory and optimization. All the graphs in this chapter are undirected. Recall that a matching is a set of pairwise disjoint edges. Our main problem is:

CARDINALITY MATCHING PROBLEM Instance:

An undirected graph G.

Task:

Find a maximum cardinality matching in G.

Since the weighted version of this problem is significantly more difficult we postpone it to Chapter 11. But already the above cardinality version has applications: Suppose in the JOB ASSIGNMENT PROBLEM each job has the same processing time, say one hour, and we ask whether we can finish all the jobs within one hour. : In other words: given a bipartite graph G P with bipartition V .G/ D A [ B, we lookP for numbers x W E.G/ ! RC with e2ı.a/ x.e/ D 1 for each job a 2 A and e2ı.b/ x.e/ 1 for each employee b 2 B. We can write this as a linear inequality system x 0, M x 1l, M 0 x 1l, where the rows of M and M 0 are rows of the node-edge incidence matrix of G. These matrices are totally unimodular by Theorem 5.25. From Theorem 5.20 we conclude that if there is any solution x, then there is also an integral solution. Now observe that the integral solutions to the above linear inequality system are precisely the incidence vectors of the matchings in G covering A. Definition 10.1. Let G be a graph and M a matching in G. We say that a vertex v is covered by M if v 2 e for some e 2 M ; otherwise v is exposed (by M ). M is called a perfect matching if all vertices are covered by M . In Section 10.1 we consider matchings in bipartite graphs. Algorithmically this problem can be reduced to the M AXIMUM FLOW PROBLEM. The Max-Flow-MinCut Theorem as well as the concept of augmenting paths have nice interpretations in our context. Matching in general, non-bipartite graphs does not reduce directly to network flows. We introduce two necessary and sufficient conditions for a general graph to have a perfect matching in Sections 10.2 and 10.3. In Section 10.4 we consider factor-critical graphs which have a matching covering all vertices but v, for each v 2 V .G/. These play an important role in Edmonds’ algorithm for the CARDINALITY B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__10, c Springer-Verlag Berlin Heidelberg 2012

241

242

10 Maximum Matchings

MATCHING PROBLEM, described in Section 10.5, and its weighted version which we postpone to Sections 11.2 and 11.3.

10.1 Bipartite Matching Since the CARDINALITY MATCHING PROBLEM is easier if G is bipartite, we shall deal with this case first. In this section, a bipartite graph G is always assumed to : have the bipartition V .G/ D A [ B. Since we may assume that G is connected, we can regard this bipartition as unique (Exercise 25 of Chapter 2). For a graph G, let .G/ denote the maximum cardinality of a matching in G, while .G/ is the minimum cardinality of a vertex cover in G. Theorem 10.2. (König [1931]) If G is bipartite, then .G/ D .G/. :

Proof: Consider the graph G 0 D .V .G/ [ fs; tg; E.G/ [ ffs; ag W a 2 Ag [ ffb; tg W b 2 Bg/. Then .G/ is the maximum number of internally disjoint st-paths, while .G/ is the minimum number of vertices whose deletion makes t unreachable from s. The theorem now immediately follows from Menger’s Theorem 8.10. .G/ .G/ evidently holds for any graph (bipartite or not), but we do not have equality in general (as the triangle K3 shows). Several statements are equivalent to König’s Theorem. Hall’s Theorem is probably the best-known version. Theorem 10.3. (Hall [1935]) Let G be a bipartite graph with bipartition V .G/ D : A [ B. Then G has a matching covering A if and only if j.X /j jX j

for all X A:

(10.1)

Proof: The necessity of the condition is obvious. To prove the sufficiency, assume that G has no matching covering A, i.e. .G/ < jAj. By Theorem 10.2 this implies .G/ < jAj. Let A0 A; B 0 B such that A0 [ B 0 covers all the edges and jA0 [ B 0 j < jAj. Obviously .A n A0 / B 0 . Therefore j.A n A0 /j jB 0 j < jAj jA0 j D jA n A0 j, and the Hall condition (10.1) is violated. It is worthwhile to mention that it is not too difficult to prove Hall’s Theorem directly. The following proof is due to Halmos and Vaughan [1950]: Second Proof of Theorem 10.3: We show that any G satisfying the Hall condition (10.1) has a matching covering A. We use induction on jAj, the cases jAj D 0 and jAj D 1 being trivial. If jAj 2, we consider two cases: If j.X /j > jX j for every nonempty proper subset X of A, then we take any edge fa; bg (a 2 A, b 2 B), delete its two vertices and apply induction. The smaller graph satisfies the Hall condition because j.X /j jX j can have decreased by at most one for any X A n fag.

10.1

Bipartite Matching

243

Now assume that there is a nonempty proper subset X of A with j.X /j D jX j. By induction there is a matching covering X in GŒX [ .X /. We claim that we can extend this to a matching in G covering A. Again by the induction hypothesis, we have to show that GŒ.A n X / [ .B n .X // satisfies the Hall condition. To check this, observe that for any Y A n X we have (in the original graph G): j.Y / n .X /j D j.X [ Y /j j.X /j jX [ Y j jX j D jY j: A special case of Hall’s Theorem is the so-called “Marriage Theorem”: Theorem 10.4. (Frobenius [1917]) Let G be a bipartite graph with bipartition : V .G/ D A [ B. Then G has a perfect matching if and only if jAj D jBj and j.X /j jX j for all X A. The variety of applications of Hall’s Theorem is indicated by Exercises 4–7. The proof of König’s Theorem 10.2 shows how to solve the bipartite matching problem algorithmically: Theorem 10.5. The CARDINALITY MATCHING PROBLEM for bipartite graphs G can be solved in O.nm/ time, where n D jV .G/j and m D jE.G/j. :

Proof: Let G be a bipartite graph with bipartition V .G/ D A [ B. Add a vertex s and connect it to all vertices of A, and add another vertex t connected to all vertices of B. Orient the edges from s to A, from A to B, and from B to t. Let the capacities be 1 everywhere. Then a maximum integral s-t-flow corresponds to a maximum cardinality matching (and vice versa). So we apply the FORD-FULKERSON ALGORITHM and find a maximum s-tflow (and thus a maximum matching) after at most n augmentations. Since each augmentation takes O.m/ time, we are done. This result is essentially due to Kuhn [1955]. In fact, one can use the concept of shortest augmenting paths p again (cf. the EDMONDS-KARP ALGORITHM). In this way one obtains the O n.m C n/ -algorithm of Hopcroft and Karp [1973] and Karzanov [1973]. This algorithm will be discussed in Exercises 10 and 11. Slightimprovements of the HOPCROFT-KARP pALGORITHM yield running times q log.n2 =m/ mn of O n log (Alt et al. [1991]) and O m (Feder and Motwani n n log n [1995]). The latter bound is the best known for dense graphs. Let us reformulate the augmenting path concept in our context. Definition 10.6. Let G be a graph (bipartite or not), and let M be some matching in G. A path P is an M-alternating path if E.P / n M is a matching. An M alternating path is M-augmenting if it has positive length and its endpoints are exposed by M . One immediately checks that M -augmenting paths must have odd length.

244

10 Maximum Matchings

Theorem 10.7. (Petersen [1891], Berge [1957]) Let G be a graph (bipartite or not) with some matching M . Then M is maximum if and only if there is no M augmenting path. Proof: If there is an M -augmenting path P , the symmetric difference M 4E.P / is a matching and has greater cardinality than M , so M is not maximum. On the other hand, if there is a matching M 0 such that jM 0 j > jM j, the symmetric difference M 4M 0 is the vertex-disjoint union of alternating circuits and paths, where at least one path must be M -augmenting. This was already observed by Petersen and rediscovered by Berge; it is commonly known as Berge’s Theorem. In the bipartite case it of course also follows from Theorem 8.5.

10.2 The Tutte Matrix We now consider maximum matchings from an algebraic point of view. Let G be a simple undirected graph, and let G 0 be the directed graph resulting from G by arbitrarily orienting the edges. For any vector x D .xe /e2E.G/ of variables, we define the Tutte matrix x TG .x/ D .tvw /v;w2V .G/

by x tvw

8 ˆ <xfv;wg WD xfv;wg ˆ : 0

if .v; w/ 2 E.G 0 / if .w; v/ 2 E.G 0 / : otherwise

Such a matrix M , where M D M > , is called skew-symmetric. The matrix TG .x/, but not its rank, depends on the orientation G 0 of G. Note that det TG .x/ is a polynomial in the variables xe (e 2 E.G/). Theorem 10.8. (Tutte [1947]) G has a perfect matching if and only if det TG .x/ is not identically zero. Proof: Let V .G/ D fv1 ; : : : ; vn g, and let Sn be the set of all permutations on f1; : : : ; ng. By definition of the determinant, det TG .x/ D n

X 2Sn

sgn./

n Y i D1

tvxi ;v.i / :

o Q Let Sn0 WD 2 Sn W niD1 tvxi ;v.i / 6D 0 . Each permutation 2 Sn corresponds to a directed graph H WD .V .G/; f.vi ; v.i / / W i D 1; : : : ; ng/ where each C vertex x has jıH .x/j D jıH .x/j D 1. For permutations 2 Sn0 , H is a subgraph $

of G 0 .

10.2

The Tutte Matrix

245

If there exists a permutation 2 Sn0 such that H consists of even circuits only, then by taking every second edge of each circuit (and ignoring the orientations) we obtain a perfect matching in G. Otherwise, for each 2 Sn0 there is a permutation r./ 2 Sn0 such that Hr./ is obtained by reversing the first odd circuit in H , i.e. the odd circuit containing the vertex with minimum index. Of course r.r.// D . Observe that sgn./ D sgn.r.//, i.e. the two permutations have the same sign: if the first odd circuit consists of the vertices vi1 ; : : : ; vi2kC1 with .ij / D ij C1 (j D 1; : : : ; 2k) and .i2kC1 / D i1 , then we obtain r./ by 2k transpositions: for j D 1; : : : ; k exchange .i2j 1 / with Q Q .i2k / and then .i2j / with .i2kC1 /. Moreover, niD1 tvxi ;v.i / D niD1 tvxi ;vr./.i / . So the two corresponding terms in the sum n X Y det TG .x/ D sgn./ tvxi ;v.i / 2Sn0

i D1

cancel each other. Since this holds for all pairs ; r./ 2 Sn0 , we conclude that det TG .x/ is identically zero. So if G has no perfect matching, det TG .x/ is identically zero. On the other hand, if G has a perfect matching M , consider the permutation defined Q by .i / WD j and .j / WD i for all fvi ; vj g 2 M . The corresponding term niD1 tvxi ;v.i / D Q 2 cannot cancel out with any other term, so det TG .x/ is not identically e2M xe zero. Originally, Tutte used Theorem 10.8 to prove his main theorem on matchings, Theorem 10.13. Theorem 10.8 does not provide a good characterization of the property that a graph has a perfect matching. The problem is that the determinant is easy to compute if the entries are numbers (Theorem 4.10) but difficult to compute if the entries are variables. However, the theorem suggests a randomized algorithm for the CARDINALITY MATCHING PROBLEM: Corollary 10.9. (Lovász [1979]) Let x D .xe /e2E.G/ be a random vector where each coordinate is uniformly distributed in Œ0; 1. Then with probability 1 the rank of TG .x/ is exactly twice the size of a maximum matching. Proof: Suppose the rank of TG .x/ is k, say the first k rows are linearly indepenA B dent. We write TG .x/ D B > C , where A is a skew-symmetric .k k/-matrix and A B has rank k. Then there is a matrix D with D A B D B > C . We have AD > D .DA/> D B, and hence A has rank k. So the principal submatrix A of TG .x/ is nonsingular, and by Theorem 10.8 the subgraph induced by the corresponding vertices has a perfect matching. In particular, k is even and G has a matching of cardinality k2 . On the other hand, if G has a matching of cardinality k, the determinant of the principal submatrix T 0 whose rows and columns correspond to the 2k vertices covered by M is not identically zero by Theorem 10.8. The set of vectors x for

246

10 Maximum Matchings

which det T 0 .x/ D 0 must then have measure zero. So with probability one, the rank of TG .x/ is at least 2k. Of course it is not possible to choose random numbers from Œ0; 1 with a digital computer. However, it can be shown that it suffices to choose random integers from the finite set f1; 2; : : : ; N g. For sufficiently large N , the probability of error will become arbitrarily small (see Lovász [1979]). Lovász’ algorithm can be used to determine a maximum matching (not only its cardinality). See Rabin and Vazirani [1989], Mulmuley, Vazirani and Vazirani [1987], and Mucha and Sankowski [2004] for further randomized algorithms for finding a maximum matching in a graph. Moreover we note that Geelen [2000] has shown how to derandomize Lovász’ algorithm. Although its running time is worse than that of Edmonds’ matching algorithm (see Section 10.5), it is important for some generalizations of the CARDINALITY MATCHING PROBLEM (e.g., see Geelen and Iwata [2005]).

10.3 Tutte’s Theorem We now consider the CARDINALITY MATCHING PROBLEM in general graphs. A necessary condition for a graph to have a perfect matching is that every connected component is even (i.e. has an even number of vertices). This condition is not sufficient, as the graph K1;3 (Figure 10.1(a)) shows.

a

b

Fig. 10.1.

The reason that K1;3 has no perfect matching is that there is one vertex (the black one) whose deletion produces three odd connected components. The graph shown in Figure 10.1(b) is more complicated. Does this graph have a perfect matching? If we delete the three black vertices, we get five odd connected components (and one even connected component). If there were a perfect matching, at least one vertex of each odd connected component would have to be connected to one of the black vertices.

10.3

Tutte’s Theorem

247

This is impossible because the number of odd connected components exceeds the number of black vertices. More generally, for X V .G/ let qG .X / denote the number of odd connected components in G X . Then a graph for which qG .X / > jX j holds for some X V .G/ cannot have a perfect matching: otherwise there must be, for each odd connected component in G X , at least one matching edge connecting this connected component with X , which is impossible if there are more odd connected components than elements of X . Tutte’s Theorem says that the above necessary condition is also sufficient: Definition 10.10. A graph G satisfies the Tutte condition if qG .X / jX j for all X V .G/. A nonempty vertex set X V .G/ is a barrier if qG .X / D jX j. To prove the sufficiency of the Tutte condition we shall need an easy observation and an important definition: Proposition 10.11. For any graph G and any X V .G/ we have qG .X / jX j jV .G/j .mod 2/: Definition 10.12. A graph G is called factor-critical if G v has a perfect matching for each v 2 V .G/. A matching is called near-perfect if it covers all vertices but one. Now we can prove Tutte’s Theorem: Theorem 10.13. (Tutte [1947]) A graph G has a perfect matching if and only if it satisfies the Tutte condition: qG .X / jX j

for all X V .G/:

Proof: We have already seen the necessity of the Tutte condition. We now prove the sufficiency by induction on jV .G/j (the case jV .G/j 2 being trivial). Let G be a graph satisfying the Tutte condition. jV .G/j cannot be odd since otherwise the Tutte condition is violated because qG .;/ 1. So by Proposition 10.11, jX j qG .X / must be even for every X V .G/. Since jV .G/j is even and the Tutte condition holds, every singleton is a barrier. We choose a maximal barrier X . G X has jX j odd connected components. G X cannot have any even connected components because otherwise X [ fvg, where v is a vertex of some even connected component, is a barrier (G .X [ fvg/ has jX j C 1 odd connected components), contradicting the maximality of X . We now claim that each odd connected component of G X is factor-critical. To prove this, let C be some odd connected component of GX and v 2 V .C /. If C v has no perfect matching, by the induction hypothesis there is some Y V .C / n fvg

248

10 Maximum Matchings

such that qC v .Y / > jY j. By Proposition 10.11, qC v .Y / jY j must be even, so qC v .Y / jY j C 2: Since X; Y and fvg are pairwise disjoint, we have qG .X [ Y [ fvg/ D qG .X / 1 C qC .Y [ fvg/ D jX j 1 C qC v .Y / jX j 1 C jY j C 2 D jX [ Y [ fvgj: So X [ Y [ fvg is a barrier, contradicting the maximality of X . : We now consider the bipartite graph G 0 with bipartition V .G 0 / D X [ Z which arises when we delete edges with both ends in X and contract the odd connected components of G X to single vertices (forming the set Z). It remains to show that G 0 has a perfect matching. If not, then by Frobenius’ Theorem 10.4 there is some A Z such that jG 0 .A/j < jAj. This implies qG .G 0 .A// jAj > jG 0 .A/j, a contradiction. This proof is due to Anderson [1971]. The Tutte condition provides a good characterization of the perfect matching problem: either a graph has a perfect matching or it has a so-called Tutte set X proving that it has no perfect matching. An important consequence of Tutte’s Theorem is the so-called Berge-Tutte formula: Theorem 10.14. (Berge [1958]) 2.G/ C max .qG .X / jX j/ D jV .G/j: XV .G/

Proof: For any X V .G/, any matching must leave at least qG .X /jX j vertices uncovered. Therefore 2.G/ C qG .X / jX j jV .G/j. To prove the reverse inequality, let k WD

max .qG .X / jX j/:

XV .G/

We construct a new graph H by adding k new vertices to G, each of which is connected to all the old vertices. If we can prove that H has a perfect matching, then 2.G/ C k 2.H / k D jV .H /j k D jV .G/j; and the theorem is proved. Suppose H has no perfect matching, then by Tutte’s Theorem there is a set Y V .H / such that qH .Y / > jY j. By Proposition 10.11, k has the same parity as jV .G/j, implying that jV .H /j is even. Therefore Y 6D ; and thus qH .Y / > 1. But then Y contains all the new vertices, so

10.4

Ear-Decompositions of Factor-Critical Graphs

249

qG .Y \ V .G// D qH .Y / > jY j D jY \ V .G/j C k; contradicting the definition of k.

Let us close this section with a proposition for later use. Proposition 10.15. Let G be a graph and X V .G/ with jV .G/j 2.G/ D qG .X / jX j. Then any maximum matching of G contains a perfect matching in each even connected component of G X , a near-perfect matching in each odd connected component of G X , and matches all the vertices in X to vertices of distinct odd connected components of G X . Later we shall see (Theorem 10.32) that X can be chosen such that each odd connected component of G X is factor-critical.

10.4 Ear-Decompositions of Factor-Critical Graphs This section contains some results on factor-critical graphs which we shall need later. In Exercise 21 of Chapter 2 we have seen that the graphs having an eardecomposition are exactly the 2-edge-connected graphs. Here we are interested in odd ear-decompositions only. Definition 10.16. An ear-decomposition is called odd if every ear has odd length. Theorem 10.17. (Lovász [1972]) A graph is factor-critical if and only if it has an odd ear-decomposition. Furthermore, the initial vertex of the ear-decomposition can be chosen arbitrarily. Proof: Let G be a graph with a fixed odd ear-decomposition. We prove that G is factor-critical by induction on the number of ears. Let P be the last ear in the odd ear-decomposition, say P goes from x to y, and let G 0 be the graph before adding P . We have to show for any vertex v 2 V .G/ that G v contains a perfect matching. If v is not an inner vertex of P this is clear by induction (add every second edge of P to the perfect matching in G 0 v). If v is an inner vertex of P , then exactly one of PŒv;x and PŒv;y must be even, say PŒv;x . By induction there is a perfect matching in G 0 x. By adding every second edge of PŒy;v and of PŒv;x we obtain a perfect matching in G v. We now prove the reverse direction. Choose the initial vertex ´ of the eardecomposition arbitrarily, and let M be a near-perfect matching in G covering V .G/ n f´g. Suppose we already have an odd ear-decomposition of a subgraph G 0 of G such that ´ 2 V .G 0 / and M \E.G 0 / is a near-perfect matching in G 0 . If G D G 0 , we are done. If not, then – since G is connected – there must be an edge e D fx; yg 2 E.G/ n E.G 0 / with x 2 V .G 0 /. If y 2 V .G 0 /, e is the next ear. Otherwise let N be a near-perfect matching in G covering V .G/ n fyg. M 4N obviously contains the edges of a y-´-path P . Let w be the first vertex of P (when traversed from y)

250

10 Maximum Matchings

that belongs to V .G 0 /. The last edge of P 0 WD PŒy;w cannot belong to M (because no edge of M leaves V .G 0 /), and the first edge cannot belong to N . Since P 0 is M -N -alternating, jE.P 0 /j must be even, so together with e it forms the next ear. In fact, we have constructed a special type of odd ear-decomposition: Definition 10.18. Given a factor-critical graph G and a near-perfect matching M , an M-alternating ear-decomposition of G is an odd ear-decomposition such that each ear is an M -alternating path or a circuit C with jE.C / \ M j C 1 D jE.C / n M j. It is clear that the initial vertex of an M -alternating ear-decomposition must be the vertex exposed by M . The proof of Theorem 10.17 immediately yields: Corollary 10.19. For any factor-critical graph G and any near-perfect matching M in G there exists an M -alternating ear-decomposition. From now on, we shall only be interested in M -alternating ear-decompositions. An interesting way to store an M -alternating ear-decomposition efficiently is due to Lovász and Plummer [1986]: Definition 10.20. Let G be a factor-critical graph and M a near-perfect matching in G. Let r; P1 ; : : : ; Pk be an M -alternating ear-decomposition of G and ; ' W V .G/ ! V .G/ two functions. We say that and ' are associated with the eardecomposition r; P1 ; : : : ; Pk if .x/ D y if fx; yg 2 M , '.x/ D y if fx; yg 2 E.Pi / n M and x … frg [ V .P1 / [ [ V .Pi 1 /, .r/ D '.r/ D r. If M is fixed, we also say that ' is associated with r; P1 ; : : : ; Pk . If M is some fixed near-perfect matching and ; ' are associated with two M -alternating ear-decompositions, they are the same up to the order of the ears. Moreover, an explicit list of the ears can be obtained in linear time:

EAR-DECOMPOSITION ALGORITHM Input: Output: 1 2

A factor-critical graph G, functions ; ' associated with an M alternating ear-decomposition. An M -alternating ear-decomposition r; P1 ; : : : ; Pk .

Let initially be X WD frg, where r is the vertex with .r/ D r. Let k WD 0, and let the stack be empty. If X D V .G/ then go to . 5 If the stack is nonempty then let v 2 V .G/ n X be an endpoint of the topmost element of the stack, else choose v 2 V .G/ n X arbitrarily.

10.4

3

4

5

Ear-Decompositions of Factor-Critical Graphs

251

Set x WD v, y WD .v/ and P WD .fx; yg; ffx; ygg/. While '.'.x// D x do: Set P WD P C fx; '.x/g C f'.x/; .'.x//g and x WD .'.x//. While '.'.y// D y do: Set P WD P C fy; '.y/g C f'.y/; .'.y//g and y WD .'.y//. Set P WD P C fx; '.x/g C fy; '.y/g. P is the ear containing y as an inner vertex. Put P on top of the stack. While both endpoints of the topmost element P of the stack are in X do: Delete P from the stack, set k WD kC1, Pk WD P and X WD X [V .P /. Go to . 2 For all fy; ´g 2 E.G/ n .E.P1 / [ [ E.Pk // do: Set k WD k C 1 and Pk WD .fy; ´g; ffy; ´gg/.

Proposition 10.21. Let G be a factor-critical graph and ; ' functions associated with an M -alternating ear-decomposition. Then this ear-decomposition is unique up to the order of the ears. The EAR-DECOMPOSITION ALGORITHM correctly determines an explicit list of these ears; it runs in linear time. Proof: Let D be an M -alternating ear-decomposition associated with and '. The uniqueness of D as well as the correctness of the algorithm follows from the obvious fact that P as computed in 3 is indeed an ear of D. The running time of 1 – 4 is evidently O.jV .G/j/, while 5 takes O.jE.G/j/ time. The most important property of the functions associated with an alternating eardecomposition is the following: Lemma 10.22. Let G be a factor-critical graph and ; ' two functions associated with an M -alternating ear-decomposition. Let r be the vertex exposed by M . Then the maximal path given by an initial subsequence of x; .x/; '..x//; .'..x///; '..'..x////; : : : defines an M -alternating x-r-path of even length for all x 2 V .G/. Proof: Let x 2 V .G/ n frg, and let Pi be the first ear containing x. Clearly some initial subsequence of x; .x/; '..x//; .'..x///; '..'..x////; : : : must be a subpath Q of Pi from x to y, where y 2 frg [ V .P1 / [ [ V .Pi 1 /. Because we have an M -alternating ear-decomposition, the last edge of Q does not belong to M ; hence Q has even length. If y D r, we are done, otherwise we apply induction on i . The converse of Lemma 10.22 is not true: In the counterexample in Figure 10.2 (bold edges are matching edges, edges directed from u to v indicate '.u/ D v),

252

10 Maximum Matchings

Fig. 10.2.

and ' also define alternating paths to the vertex exposed by the matching. However, and ' are not associated with any alternating ear-decomposition. For the WEIGHTED MATCHING ALGORITHM (Section 11.3) we shall need a fast routine for updating an alternating ear-decomposition when the matching changes. Although the proof of Theorem 10.17 is algorithmic (provided that we can find a maximum matching in a graph), this is far too inefficient. We make use of the old ear-decomposition: Lemma 10.23. Given a factor-critical graph G, two near-perfect matchings M and M 0 , and functions ; ' associated with an M -alternating ear-decomposition. Then functions 0 ; ' 0 associated with an M 0 -alternating ear-decomposition can be found in O.jV .G/j/ time. Proof: Let v be the vertex exposed by M , and let v 0 be the vertex exposed by M 0 . Let P be the v 0 -v-path in M 4M 0, say P D x0 ; x1 ; : : : ; xk with x0 D v 0 and xk D v. An explicit list of the ears of the old ear-decomposition can be obtained from and ' by the EAR-DECOMPOSITION ALGORITHM in linear time (Proposition 10.21). Indeed, since we do not have to consider ears of length one, we can omit : 5 then the total number of edges considered is at most 32 .jV .G/j1/ (cf. Exercise 20). Suppose we have already constructed an M 0 -alternating ear-decomposition of a spanning subgraph of GŒX for some X V .G/ with v 0 2 X (initially X WD fv 0 g). Of course no M 0 -edge leaves X . Let p WD maxfi 2 f0; : : : ; kg W xi 2 X g (illustrated in Figure 10.3). At each stage we keep track of p and of the edge set ı.X / \ M . Their update when extending X is clearly possible in linear total time. Now we show how to extend the ear-decomposition. We shall add one or more ears in each step. The time needed for each step will be proportional to the total number of edges in new ears. Case 1: jı.X / \ M j 2. Let f 2 ı.X / \ M with xp … f . Evidently, f belongs to an M -M 0-alternating path which can be added as the next ear. The time needed to find this ear is proportional to its length. Case 2: jı.X / \ M j D 1. Then v … X , and e D fxp ; xpC1 g is the only edge in ı.X / \ M . Let R0 be the xpC1 -v-path determined by and ' (cf. Lemma 10.22). The first edge of R0 is e. Let q be the minimum index i 2 fp C 2; p C 4; : : : ; kg

10.4

Ear-Decompositions of Factor-Critical Graphs

253

xp + 1 xp

e

X M M

P

Fig. 10.3. 0 with xi 2 V .R0 / and V .RŒx / \ fxi C1 ; : : : ; xk g D ; (cf. Figure 10.4). Let pC1;x i

0 . So R has vertices xp , '.xp /, .'.xp //, '..'.xp ///, : : : ; xq , and R WD RŒx p ;xq can be traversed in time proportional to its length.

X x0 =

xq xp

xk =

xp + 1

Fig. 10.4.

Let S WD E.R/ n E.GŒX /, D WD .M 4M 0/ n .E.GŒX / [ E.PŒxq ;v //, and Z WD S 4D. S and D consist of M -alternating paths and circuits. Observe that every vertex outside X has degree 0 or 2 with respect to Z. Moreover, for every vertex outside X with two incident edges of Z, one of them belongs to M 0 . (Here the choice of q is essential.)

254

10 Maximum Matchings

Hence all connected components C of .V .G/; Z/ with E.C / \ ı.X / 6D ; can be added as next ears, and after these ears have been added, S n Z D S \ .M 4M 0 / is the vertex-disjoint union of paths each of which can then be added as an ear. Since e 2 D n S Z, we have Z \ ı.X / 6D ;, so at least one ear is added. It remains to show that the time needed for the above construction is proportional to the total number of edges in new ears. Obviously, it suffices to find S in O.jS j/ time. This is difficult because of the subpaths of R inside X . However, we do not really care what they look like. So we would like to shortcut these paths whenever possible. To achieve this, we modify the '-variables. Namely, in each application of Case 2, let RŒa;b be a maximal subpath of R inside X with a 6D b. Let y WD .b/; y is the predecessor of b on R. We set '.x/ WD y for all vertices x on RŒa;y where RŒx;y has odd length. It does not matter whether x and y are joined by an edge. See Figure 10.5 for an illustration.

y

X

R

xp

xp + 1

x0 =

Fig. 10.5.

The time required for updating the '-variables is proportional to the number of edges examined. Note that these changes of ' do not destroy the property of Lemma 10.22, and the '-variables are not used anymore except for finding M -alternating paths to v in Case 2. Now it is guaranteed that the time required for finding the subpaths of R inside X is proportional to the number of subpaths plus the number of edges examined for the first time inside X . Since the number of subpaths inside X is less than or equal to the number of new ears in this step, we obtain an overall linear running time.

10.5

Edmonds’ Matching Algorithm

255

Case 3: ı.X / \ M D ;. Then v 2 X . We consider the ears of the (old) M -alternating ear-decomposition in their order. Let R be the first ear with V .R/ n X 6D ;. Similar to Case 2, let S WD E.R/ n E.GŒX /, D WD .M 4M 0 / n E.GŒX /, and Z WD S 4D. Again, all connected components C of .V .G/; Z/ with E.C / \ ı.X / 6D ; can be added as next ears, and after these ears have been added, S n Z is the vertex-disjoint union of paths each of which can then be added as an ear. The total time needed for Case 3 is obviously linear.

10.5 Edmonds’ Matching Algorithm Recall Berge’s Theorem 10.7: A matching in a graph is maximum if and only if there is no augmenting path. Since this holds for non-bipartite graphs as well, our matching algorithm will again be based on augmenting paths. However, it is not at all clear how to find an augmenting path (or decide that there is none). In the bipartite case (Theorem 10.5) it was sufficient to mark the vertices that are reachable from an exposed vertex via an alternating edge progression. Since there were no odd circuits, vertices reachable by an alternating edge progression were also reachable by an alternating path. This is no longer the case when dealing with general graphs.

Fig. 10.6.

Consider the example in Figure 10.6 (the bold edges constitute a matching M ). When starting at v1 , we have an alternating edge progression v1 ; v2 ; v3 ; v4 ; v5 ; v6 , v7 ; v5 ; v4 ; v8 , but this is not a path. We have run through an odd circuit, namely v5 ; v6 ; v7 . Note that in our example there exists an augmenting path (v1 ; v2 ; v3 ; v7 , v6 ; v5 ; v4 ; v8 ) but it is not clear how to find it. The question arises what to do if we encounter an odd circuit. Surprisingly, it suffices to get rid of it by shrinking it to a single vertex. It turns out that the smaller graph has a perfect matching if and only if the original graph has one. This is the general idea of EDMONDS’ CARDINALITY MATCHING ALGORITHM. We formulate this idea in Lemma 10.25 after giving the following definition:

256

10 Maximum Matchings

Definition 10.24. Let G be a graph and M a matching in G. A blossom in G with respect to M is a factor-critical subgraph C of G with jM \ E.C /j D jV .C2/j1 . The vertex of C exposed by M \ E.C / is called the base of C . The blossom we have encountered in the above example (Figure 10.6) is induced by fv5 ; v6 ; v7 g. Note that this example contains other blossoms. Any single vertex is also a blossom in terms of our definition. Now we can formulate the Blossom Shrinking Lemma: Lemma 10.25. Let G be a graph, M a matching in G, and C a blossom in G (with respect to M ). Suppose there is an M -alternating v-r-path Q of even length from a vertex v exposed by M to the base r of C , where E.Q/ \ E.C / D ;. Let G 0 and M 0 result from G and M by shrinking V .C / to a single vertex. Then M is a maximum matching in G if and only if M 0 is a maximum matching in G 0 . Proof: Suppose that M is not a maximum matching in G. N WD M 4E.Q/ is a matching of the same cardinality, so it is not maximum either. By Berge’s Theorem 10.7 there then exists an N -augmenting path P in G. Note that N does not cover r. At least one of the endpoints of P , say x, does not belong to C . If P and C are disjoint, let y be the other endpoint of P . Otherwise let y be the first vertex on P – when traversed from x – belonging to C . Let P 0 result from PŒx;y when shrinking V .C / in G. The endpoints of P 0 are exposed by N 0 (the matching in G 0 corresponding to N ). Hence P 0 is an N 0 -augmenting path in G 0 . So N 0 is not a maximum matching in G 0 , and nor is M 0 (which has the same cardinality). To prove the converse, suppose that M 0 is not a maximum matching in G 0 . Let 0 N be a larger matching in G 0 . N 0 corresponds to a matching N0 in G which covers at most one vertex of C in G. Since C is factor-critical, N0 can be extended by k WD jV .C2/j1 edges to a matching N in G, where jN j D jN0 j C k D jN 0 j C k > jM 0 j C k D jM j; proving that M is not a maximum matching in G.

It is necessary to require that the base of the blossom is reachable from a vertex exposed by M by an M -alternating path of even length which is disjoint from the blossom. For example, the blossom induced by fv4 ; v6 ; v7 ; v2 ; v3 g in Figure 10.6 cannot be shrunk without destroying the only augmenting path. When looking for an augmenting path, we shall build up an alternating forest: Definition 10.26. Given a graph G and a matching M in G. An alternating forest with respect to M in G is a forest F in G with the following properties: (a) V .F / contains all the vertices exposed by M . Each connected component of F contains exactly one exposed vertex, its root.

10.5

Edmonds’ Matching Algorithm

257

Fig. 10.7.

(b) We call a vertex v 2 V .F / an outer (inner) vertex if it has even (odd) distance to the root of the connected component containing v. (In particular, the roots are outer vertices.) All inner vertices have degree 2 in F . (c) For any v 2 V .F /, the unique path from v to the root of the connected component containing v is M -alternating. Figure 10.7 shows an alternating forest. The bold edges belong to the matching. The black vertices are inner, the white vertices outer. Proposition 10.27. In any alternating forest the number of outer vertices that are not a root equals the number of inner vertices. Proof: Each outer vertex that is not a root has exactly one neighbour which is an inner vertex and whose distance to the root is smaller. This is obviously a bijection between the outer vertices that are not a root and the inner vertices. Informally, EDMONDS’ CARDINALITY MATCHING ALGORITHM works as follows. Given some matching M , we build up an M -alternating forest F . We start with the set S of exposed vertices and no edges. At any stage of the algorithm we consider a neighbour y of an outer vertex x. Let P .x/ denote the unique path in F from x to a root. There are three interesting cases, corresponding to three operations (“grow”, “augment”, and “shrink”): Case 1: y … V .F /. Then the forest will grow when we add fx; yg and the matching edge covering y.

258

10 Maximum Matchings

Case 2: y is an outer vertex in a different connected component of F . Then we augment M along P .x/ [ fx; yg [ P .y/. Case 3: y is an outer vertex in the same connected component of F (with root q). Let r be the first vertex of P .x/ (starting at x) also belonging to P .y/. (r can be one of x; y.) If r is not a root, it must have degree at least 3. So r is an outer vertex. Therefore C WD P .x/Œx;r [ fx; yg [ P .y/Œy;r is a blossom with at least three vertices. We shrink C . If none of the cases applies, all the neighbours of outer vertices are inner. We claim that M is maximum. Let X be the set of inner vertices, s WD jX j, and let t be the number of outer vertices. G X has t odd components (each outer vertex is isolated in G X ), so qG .X / jX j D t s. Hence by the trivial part of the Berge-Tutte formula, any matching must leave at least t s vertices uncovered. But on the other hand, the number of vertices exposed by M , i.e. the number of roots of F , is exactly t s by Proposition 10.27. Hence M is indeed maximum. Since this is not at all a trivial task, we shall spend some time on implementation details. The difficult question is how to perform the shrinking efficiently so that the original graph can be recovered afterwards. Of course, several shrinking operations may involve the same vertex. Our presentation is based on the one given by Lovász and Plummer [1986]. Rather than actually performing the shrinking operation, we allow our forest to contain blossoms. Definition 10.28. Given a graph G and a matching M in G. A subgraph F of G is a general blossom forest (with respect to M ) if there exists a partition V .F / D : : : V1 [ V2 [ [ Vk such that Fi WD F ŒVi is a maximal factor-critical subgraph of F with jM \ E.Fi /j D jVi2j1 (i D 1; : : : ; k) and after contracting each of V1 ; : : : ; Vk we obtain an alternating forest F 0 . Fi is called an outer blossom (inner blossom) if Vi is an outer (inner) vertex in F 0 . All the vertices of an outer (inner) blossom are called outer (inner). A general blossom forest where each inner blossom is a single vertex is a special blossom forest. Figure 10.8 shows a connected component of a special blossom forest with five nontrivial outer blossoms. This corresponds to one of the connected components of the alternating forest in Figure 10.7. The orientations of the edges will be explained later. All vertices of G not belonging to the special blossom forest are called out-of-forest. Note that the Blossom Shrinking Lemma 10.25 applies to outer blossoms only. However, in this section we shall deal only with special blossom forests. General blossom forests will appear only in the WEIGHTED MATCHING ALGORITHM in Chapter 11. To store a special blossom forest F , we introduce the following data structures. For each vertex x 2 V .G/ we have three variables .x/, '.x/, and .x/ with the following properties:

10.5

Edmonds’ Matching Algorithm

259

y

x

Fig. 10.8.

(

x y 8 ˆ x ˆ ˆ ˆ ˆ ˆ 1gI "2 WD min fslack.x; y/ W x outer; y out-of-forestg I 1 "3 WD min fslack.x; y/ W x; y outer, belonging to different blossomsg I 2 " WD minf"1 ; "2 ; "3 g: This " is the maximum number such that the dual change by " preserves dual feasibility. If " D 1, (11.2) is unbounded and so (11.1) is infeasible. In this case G has no perfect matching. Obviously, " can be computed in finite time. However, in order to obtain an O.n3 / overall running time we must be able to compute " in O.n/ time. This is easy as far as "1 is concerned, but requires additional data structures for "2 and "3 . For A 2 B let X A WD ´B : B2BWAB

We shall update these values whenever changing the dual solution; this can easily be done in linear time (using the tree-representation of B). Then ˚ "2 D min c.fx; yg/ fxg fyg W x outer; y out-of-forest ; ˚ 1 "3 D min c.fx; yg/ fxg fyg W x; y outer, fx; yg 6 B for B 2 B : 2 We introduce variables tvA and vA for each outer vertex v and each A 2 B, unless there is a B 2 B with A [ fvg B. vA is a vertex in A minimizing slack.v; vA /, and tvA WD slack.v; vA / C C A , where denotes the sum of the "-values in

11.3

Implementation of the Weighted Matching Algorithm

283

all dual changes. Observe that tvA does not change as long as v remains outer and A 2 B. Finally, we write t A WD minftvA W v … A; v outerg. We have n o "2 D min slack.v; vA / W v outer, A 2 B maximal out-of-forest n o D min t A A W A 2 B maximal out-of-forest ; and, similarly, "3 D

n o 1 min t A A W A 2 B maximal outer : 2

Although when computing "2 and "3 we are interested only in the values tvA for maximal out-of-forest and maximal outer blossoms of B, we update these variables also for inner blossoms and those that are not maximal, because they may become relevant later. Blossoms that are outer but not maximal will not become maximal outer before an augmentation takes place. After each augmentation, however, all these variables are recomputed. In the beginning, after each augmentation, and when a vertex v becomes outer which was not outer before, we have to compute vA and tvA , and possibly update t A , for all A 2 B (except those that are outer but not maximal). This can be done as follows:

UPDATE Input:

An outer vertex v.

Output:

Updated values of vA ; tvA and t A for all A 2 B and w for all out-offorest vertices w.

1

For each x 2 V .G/ do: Set vfxg WD x and tvfxg WD c.fv; xg/ fvg C .

2

For A 2 B with jAj > 1 (in an order of nondecreasing cardinality) do: 0 0 Set vA WD vA and tvA WD tvA A0 C A , where A0 is a maximal 0 proper subset of A in B for which tvA A0 is minimum.

3

For A 2 B with v … A, except those that are outer but not maximal, do: Set t A WD minft A ; tvA g.

Obviously this computation coincides with the above definition of vA and tvA . It is important that this procedure runs in linear time: Lemma 11.7. If B is laminar, the procedure UPDATE can be implemented with O.n/ time. Proof: By Proposition 2.15, a laminar family of subsets of V .G/ has cardinality at most 2jV .G/j D O.n/. If B is stored by its tree-representation, then a linear-time implementation is easy.

284

11 Weighted Matching

We can now go ahead with the formal description of the algorithm. Instead of identifying inner and outer vertices by the -, - and -values, we directly mark each vertex with its status (inner, outer or out-of-forest).

WEIGHTED MATCHING ALGORITHM Input:

A graph G, weights c W E.G/ ! R.

Output:

A minimum weight perfect matching in G, given by the edges fx; .x/g, or the answer that G has no perfect matching.

1

2 3

4

5

Set B WD ffvg W v 2 V .G/g and K WD 0. Set WD 0. Set ´fvg WD 12 minfc.e/ W e 2 ı.v/g and fvg WD ´fvg for all v 2 V .G/. Set kv WD 0, .v/ WD v, 0 .v/ WD v, and ' 0 .v/ WD v for all v 2 V .G/. Mark all vertices as outer. Set t A WD 1 for all A 2 B. For all outer vertices v do: UPDATE.v/. (“dual change”) Set "1 WD minf´A W A maximal inner element of B; jAj > 1g. Set "2 WD minft A A W A maximal out-of-forest element of Bg. Set "3 WD minf 21 .t A A / W A maximal outer element of Bg. Set " WD minf"1 ; "2 ; "3 g. If " D 1, then stop (G has no perfect matching). For each maximal outer element A of B do: Set ´A WD ´A C " and A0 WD A0 C " for all A0 2 B with A0 A. For each maximal inner element A of B do: Set ´A WD ´A " and A0 WD A0 " for all A0 2 B with A0 A. Set WD C ". If " D "1 then go to . 8 If " D "2 and txA A D slack.x; y/ D 0, x outer, y 2 A out-of-forest then go to . 5 If " D "3 and txA A D slack.x; y/ D 0, x; y outer, A maximal outer element of B, x … A, y 2 A then: Let P .x/ WD TREEPATH.x/ be given by .x D x0 ; x1 ; x2 ; : : : ; x2h /. Let P .y/ WD TREEPATH.y/ be given by .y D y0 ; y1 ; y2 ; : : : ; y2j /. If P .x/ and P .y/ are vertex-disjoint then go to , 6 else go to . 7 (“grow”) Set .ky .y// WD y and .y/ WD x. Mark all vertices v with kv .v/ D ky .y/ as inner. Mark all vertices v with .kv .v// D ky .y/ as outer. For each new outer vertex v do: UPDATE.v/. Go to . 3

11.3

6

7

8

Implementation of the Weighted Matching Algorithm

285

(“augment”) For i WD 0 to h 1 do: Set .x2i C1 / WD x2i C2 and .x2i C2 / WD x2i C1 . For i WD 0 to j 1 do: Set .y2i C1 / WD y2i C2 and .y2i C2 / WD y2i C1 . Set .x/ WD y and .y/ WD x. Mark all vertices v for which the endpoint of TREEPATH.v/ is either x2h or y2j as out-of-forest. Update all values ' i .v/ and i .v/ (using Lemma 10.23). If .v/ 6D v for all v then stop, else go to . 2 (“shrink”) Let r D x2h0 D y2j 0 be the first outer vertex of V .P .x// \ V .P .y// with kr .r/ D r. Let A WD fv 2 V .G/ W kv .v/ 2 V .P .x/Œx;r / [ V .P .y/Œy;r /g. Set K WD K C 1, B WD B [ fAg, ´A WD 0 and A WD 0. For all v 2 A do: Set kv WD kv C 1, b kv .v/ WD K, kv .v/ WD r, ' kv .v/ WD ' kv 1 .v/. For i WD 1 to h0 do: If kx2i 1 .x2i / 6D r then set ' kx2i .x2i / WD x2i 1 . If kx2i 1 1 .x2i 1 / 6D r then set ' kx2i 1 .x2i 1 / WD x2i . For i WD 1 to j 0 do: If ky2i 1 .y2i / 6D r then set ' ky2i .y2i / WD y2i 1 . If ky2i 1 1 .y2i 1 / 6D r then set ' ky2i 1 .y2i 1 / WD y2i . If kx 1 .x/ 6D r then set ' kx .x/ WD y. If ky 1 .y/ 6D r then set ' ky .y/ WD x. For each outer vertex v … A do: 0 0 Set tvA WD tvA A0 and vA WD vA , where A0 is a maximal proper 0 subset of A in B for which tvA A0 is minimum. A N Set t WD minftvA W v outer, there is no AN 2 B with A [ fvg Ag. Mark all v 2 A outer. For each new outer vertex v do: UPDATE.v/. Go to . 3 (“unpack”) Let A 2 B be a maximal inner blossom with ´A D 0 and jAj > 1. Set B WD B n fAg. Let y WD .kv .v// for some v 2 A. Let Q.y/ WD BLOSSOMPATH .y/ be given by .y D r0 ; r1 ; r2 ; : : : ; r2l1 ; r2l D ky .y//. Mark all v 2 A with kv 1 .v/ … V .Q.y// as out-of-forest. Mark all v 2 A with kv 1 .v/ D r2i 1 for some i as outer. For all v 2 A with kv 1 .v/ D r2i for some i (v remains inner) do: Set .kv .v// WD rj and .rj / WD rj 1 , where k 1 j WD minfj 0 2 f0; : : : ; 2lg W rj 0 .rj 0 / D kv 1 .v/g. For all v 2 A do: Set kv WD kv 1. For each new outer vertex v do: UPDATE.v/. Go to . 3

286

11 Weighted Matching

b

a r 10 r9

r8 r7

r6

r5 r3

r2

y = r0

r1

r4

Fig. 11.3.

Note that in contrast to our previous discussion, " D 0 is possible. The variables vA are not needed explicitly. The “unpack”-step 8 is illustrated in Figure 11.3, where a blossom with 19 vertices is unpacked. Two of the five sub-blossoms become out-of-forest, two become inner blossoms and one becomes an outer blossom. Before analysing the algorithm, let us demonstrate its major steps by an example. Consider the graph in Figure 11.4(a). Initially, the algorithm sets ´fag D ´fd g D ´fhg D 2, ´fbg D ´fcg D ´ff g D 4 and ´feg D ´fgg D6. In Figure 11.4(b) the slacks can be seen. So in the beginning the edges fa; d g; fa; hg; fb; cg; fb; f g; fc; f g are tight. Therefore we will have D 0 in the first iterations. We assume that the algorithm scans the vertices in alphabetical order. So the first steps are augment.a; d /;

a

b

8

a

augment.b; c/;

b

8

c

10

h

14 13

8

8

g

12

f

12

e

0

2 d

4 5

0

0

2

5

4

3 g

Fig. 11.4.

c

5

h

13

10

9

d

0 4

0

4

11

b

2

a 8

4

grow.f; b/:

f

2

e

11.3

a

Implementation of the Weighted Matching Algorithm

b

c

e

d c

b

b

g

f

h

a

d

287

e

a

g

f

h

Fig. 11.5.

a

b

b

0

2 a

c

4 0

0

3

b

0

d

c

d

h

2 3

0

0

g

3

2

1 0

0

f e

e

g

a

h

f

Fig. 11.6.

Figure 11.5(a) shows the current general blossom forest. The next steps are shrink.f; c/;

grow.h; a/;

resulting in the general blossom forest shown in Figure 11.5(b). Now all the tight edges are used up, so the dual variables have to change. In 3 we obtain " D "3 D 1, say A D fb; c; f g and dA D c. The new dual variables are ´fb;c;f g D 1, ´fag D 1, ´fd g D ´fhg D 3, ´fbg D ´fcg D ´ff g D 4, ´feg D ´fgg D 7. The current slacks are shown in Figure 11.6(a). The next step is augment.d; c/: The blossom fb; c; f g becomes out-of-forest (Figure 11.6(b)). Now again " D "3 D 0 in 3 as fe; f g is tight. The next steps are grow.e; f /;

grow.d; a/:

We arrive at Figure 11.7(a). No more edges incident to outer vertices are tight, and we get " D "1 D 1 in 3 and obtain the new dual solution ´fb;c;f g D 0, ´fag D 0, ´fd g D ´fhg D ´fbg D ´fcg D ´ff g D 4, ´feg D ´fgg D 8. The new slacks are shown in Figure 11.7(b). Since the dual variable for the inner blossom fB; C; F g becomes zero, we have to unpack.fb; c; f g/:

288

11 Weighted Matching

a

b

h

b

0

4 a

a 0

d

h

2

b

1

0

0

1

2

1 g

f

0

0

3

d

c

c

6

e

0

0 f

e

g

Fig. 11.7.

a

b

h

a

b

0

4 a d

0

0 c

0

2

d

h

2 0

0

1

g

0

2

1

b

0

0

e

f

f

e

c

7

g

Fig. 11.8.

The general blossom forest we get is shown in Figure 11.8(a). After another dual variable change with " D "3 D 12 we obtain ´fag D 0:5, ´fcg D ´ff g D 3:5, ´fbg D ´fd g D ´fhg D 4:5, ´feg D ´fgg D 8:5 (the slacks are shown in Figure 11.8(b)). The final steps are shrink.d; e/;

augment.g; h/;

11.3

Implementation of the Weighted Matching Algorithm

289

and the algorithm terminates. The final matching is M D ffe; f g; fb; cg; fa; d g, fg; hgg. We check that M has total weight 37, equal to the sum of the dual variables. Let us now check that the algorithm works correctly. Proposition 11.8. The following statements hold at any stage of the WEIGHTED MATCHING ALGORITHM: ˚ 1 kv (a) For each j ˚2 f1; : : : ; Kg let X.j / WD v 2 V .G/ W j 2 fb .v/; : : : ; b .v/g . Then B D X.j / W j D 1; : : : ; K [ ffvg W v 2 V .G/g is a laminar family. The sets Vr WD fv W kv .v/ D rg for r 2 V .G/ with kr .r/ D r are exactly the maximal elements of B. The vertices in each Vr are marked either all outer or all inner or all out-of-forest. Each .Vr ; ffv; ' kv .v/g W v 2 Vr n frgg [ ffv; .v/g W v 2 Vr n frgg/ is a blossom with base r. (b) The edges fx; .x/g form a matching M . M contains a near-perfect matching within each element of B. (c) For b D 1; : : : ; K the variables .v/ and ' i .v/, for those v and i with b i .v/ D b, are associated with an M -alternating ear-decomposition in GŒX.b/. (d) The edges fx; .x/g and fx; ' i .x/g for all x and i , and the edges f.x/, ..x//g for all bases x of maximal inner blossoms, are all tight. (e) The edges fx; .x/g, fx; ' kx .x/g for all inner or outer x, together with the edges f.x/; ..x//g for all bases x of maximal inner blossoms, form a general blossom forest F with respect to M . The vertex marks (inner, outer, out-offorest) are consistent with F . (f) Contracting the maximal sub-blossoms of any blossom in B 2 B with jBj > 1 results in a circuit. (g) For each outer vertex v, the procedure TREEPATH gives an M -alternating v-rpath, where r is the root of the tree in F containing v. Proof: The properties clearly hold at the beginning (after 2 is executed the first time). We show that they are maintained throughout the algorithm. This is easily seen for (a) by considering 7 and . 8 For (b), this follows from Proposition 11.6 and the assumption that (f) and (g) hold before augmenting. The proof that (c) continues to hold after shrinking is the same as in the nonweighted case (see Lemma 10.30 (c)). The '-values are recomputed after augmenting and not changed elsewhere. (d) is guaranteed by . 3 It is easy to see that (e) is maintained by : 5 The blossom containing y was outof-forest, and setting .y/ WD x and .v/ WD y for the base v of the blossom makes it inner. The blossom containing .ky .y// was also out-of-forest, and becomes outer. In , 6 two connected components of the general blossom forest become out-offorest, so (e) is maintained. In , 7 the vertices in the new blossom become outer because r was outer before. In , 8 for the vertices v 2 A with kv 1 .v/ … V .Q.y// we also have .kv .v// … V .Q.y//, so they become out-of-forest. For each other v 2 A we have kv 1 .v/ D rk for some k. Since fri ; ri C1 g 2 M iff i is even, v becomes outer iff k is odd.

290

11 Weighted Matching

(f) holds as any new blossom arises from an odd circuit in . 7 To see that (g) is maintained, it suffices to observe that .x/ and ..x// are set correctly for all bases x of maximal inner blossoms. This is easily checked for both 5 and . 8 Proposition 11.8(a) justifies calling the maximal elements of B inner, outer or out-of-forest in 3 and 8 of the algorithm. Next we show that the algorithm maintains a feasible dual solution. Lemma 11.9. At any stage of the algorithm, ´ is a feasible dual solution. If " D 1 then G has no perfect matching. Proof: We always have ´A D 0 for all A 2 A n B. ´A is decreased only for those A 2 B that are maximal in B and inner. So the choice of "1 guarantees that ´A continues to be nonnegativeP for all A with jAj > 1. P How can the constraints A2AWe2ı.A/ ´A c.e/ be violated? If A2AWe2ı.A/ ´A increases in , 3 e must either connect an outer and an out-of-forest vertex or two different outer blossoms. So the maximal " such that the new ´ still satisfies P 1 A2AWe2ı.A/ ´A c.e/ is slack.e/ in the first case and 2 slack.e/ in the second case. We thus have to prove that "2 and "3 are computed correctly: "2 D minfslack.v; w/ W v outer; w out-of-forestg and

n o 1 min slack.v; w/ W v; w outer; kv .v/ 6D kw .w/ : 2 We claim that at any stage of the algorithm the following holds for any outer N vertex v and any A 2 B such that there is no AN 2 B with A [ fvg A: "3 D

(a) (b) (c) (d) (e)

vA 2 A. A slack.v; P v / D minfslack.v; u/ W u 2 Ag. A D B2BWAB ´B . is the sum of the "-values in all dual changes so far. slack.v; vA / D tvA A . N t A D minftvA W v outer and there is no AN 2 B with A [ fvg Ag.

(a), (c), and (e) are easily seen to be true. (b) and (d) hold when vA is defined (in 7 or in UPDATE .v/), and afterwards slack.v; u/ decreases exactly by the amount that CA increases (due to (c)). Now (a), (b), (d), and (e) imply that "3 is computed correctly. Now suppose " D 1, i.e. " can be chosen arbitrarily large without destroying dual feasibility. Since the dual objective 1l´ increases by at least " in , 3 we conclude that the dual LP (11.2) is unbounded. Hence by Theorem 3.27 the primal LP (11.1) is infeasible. Now the correctness of the algorithm follows: Theorem 11.10. If the algorithm terminates in , 6 the edges fx; .x/g form a minimum weight perfect matching in G.

11.3

Implementation of the Weighted Matching Algorithm

291

Proof: Let x be the incidence vector of M (the matching consisting of the edges fx; .x/g). The complementary slackness conditions X xe > 0 ) ´A D c.e/ A2AWe2ı.A/

´A > 0 )

X

xe D 1

e2ı.A/

are satisfied: the first one holds since all the matching edges are tight (Proposition 11.8(d)), and the second one follows from Proposition 11.8(b). Since we have feasible primal and dual solutions (Lemma 11.9), both must be optimal (Corollary 3.23). So x is optimal for the LP (11.1) and integral, proving that M is a minimum weight perfect matching. Until now we have not proved that the algorithm terminates. Theorem 11.11. The running time of the WEIGHTED MATCHING ALGORITHM between two augmentations is O.n2 /. The overall running time is O.n3 /. Proof: By Lemma 11.7 and Proposition 11.8(a), the UPDATE procedure runs in linear time. Both 2 and 6 take O.n2 / time, once per augmentation. 3 and 4 take O.n/ time. Moreover, each of , 5 , 7 and 8 can be done in O.nk/ time, where k is the number of new outer vertices. (In , 7 the number of maximal proper subsets A0 of A to be considered is at most 2k C 1: every second sub-blossom of a new blossom must have been inner.) Since an outer vertex continues to be outer until the next augmentation, the total time spent by , 5 , 7 and 8 between two augmentations is O.n2 /. Moreover, each call of , 5 , 7 and 8 creates at least one new outer vertex. Since at least one of , 5 , 6 , 7 8 is called in each iteration, the number of iterations between two augmentations is O.n/. This proves the O.n2 / running time between two augmentations. Since there are only n2 augmentations, the total running time is O.n3 /. Corollary 11.12. The MINIMUM WEIGHT PERFECT MATCHING PROBLEM can be solved in O.n3 / time. Proof: This follows from Theorems 11.10 and 11.11.

The first O.n3 /-implementation of Edmonds’ algorithm for the MINIMUM WEIGHT PERFECT MATCHING PROBLEM was due to Gabow [1973] (see also Gabow [1976] and Lawler [1976]). The theoretically best running time, namely O.mn C n2 log n/, has also been obtained by Gabow [1990]. 3 For planar graphs a minimum weight perfect matching can be found in O n 2 log n time, as Lipton and Tarjan [1979,1980] showed by a divide and conquer approach, using the

292

11 Weighted Matching

fact that planar graphs have small “separators”. For Euclidean instances (a set of points in the plane defining a complete graph whose edge weights are given by the 3 5 Euclidean distances) Varadarajan [1998] found an O n 2 log n algorithm. Efficient implementations are described by Mehlhorn and Schäfer [2000], Cook and Rohe [1999], and Kolmogorov [2009]. They solve matching problems with millions of vertices optimally. A “primal” weighted matching algorithm – always maintaining a perfect matching and obtaining a feasible dual solution only at termination – was described by Cunningham and Marsh [1978].

11.4 Postoptimality In this section we prove a postoptimality result which we shall need in Section 12.2. We add two vertices to an instance that has already been solved: Lemma 11.13. Let .G; c/ be an instance of the MINIMUM WEIGHT PERFECT MATCHING PROBLEM, and let s; t 2 V .G/ be two vertices. Suppose we have run the WEIGHTED MATCHING ALGORITHM for the instance .G fs; tg; c/. Then a minimum weight perfect matching with respect to .G; c/ can be determined in O.n2 / time. Proof: The addition of two vertices requires the initialization of the data structures. In particular, for each v 2 fs; tg we mark v as outer, set .v/ WD v, add ˚fvg to B, set k˚v WD 0, 0 .v/ WD v, ' 0 .v/ WD v, and fvg WD ´v WD min 12 c.fs; tg/; min fc.fv; wg/ fwg W w 2 V .G/ n fs; tg , where we used the notation c.e/ WD 1 for e … E.G/. Then we start the WEIGHTED MATCHING A LGORITHM with . 2 By Theorem 11.11 the algorithm terminates after O.n2 / steps with an augmentation, yielding a minimum weight perfect matching in .G; c/. We also get a second postoptimality result: Lemma 11.14. (Weber [1981], Ball and Derigs [1983]) Suppose we have run the WEIGHTED MATCHING ALGORITHM for an instance .G; c/. Let s 2 V .G/, and let c 0 W E.G/ ! R with c 0 .e/ D c.e/ for all e 62 ı.s/. Then a minimum weight perfect matching with respect to .G; c 0 / can be determined in O.n2 / time. Proof: Let G 0 result from G by adding two vertices x; y, an edge fs; xg, and an edge fv; yg for each edge fv; sg 2 E.G/. We set c.fv; yg/ WD c 0 .fv; sg/ for these new edges. The weight of fs; xg can be chosen arbitrarily. We then find a minimum weight perfect matching in .G 0 ; c/, using Lemma 11.13. Removing the edge fs; xg and replacing the matching edge fv; yg by fv; sg yields a minimum weight perfect matching with respect to .G; c 0 /. The same result for a “primal” weighted matching algorithm was found by Cunningham and Marsh [1978].

11.5

The Matching Polytope

293

11.5 The Matching Polytope The correctness of the WEIGHTED MATCHING ALGORITHM also yields Edmonds’ characterization of the perfect matching polytope as a by-product. We again use the notation A WD fA V .G/ W jAj oddg. Theorem 11.15. (Edmonds [1965]) Let G be an undirected graph. The perfect matching polytope of G, i.e. the convex hull of the incidence vectors of all perfect matchings in G, is the set of vectors x satisfying X

xe 0

.e 2 E.G//

xe D 1

.v 2 V .G//

xe 1

.A 2 A/

e2ı.v/

X

e2ı.A/

Proof: By Corollary 3.32 it suffices to show that all vertices of the polytope described above are integral. By Theorem 5.13 this is true if the minimization problem has an integral optimum solution for any weight function. But our WEIGHTED MATCHING ALGORITHM finds such a solution for any weight function (cf. the proof of Theorem 11.10). An alternative proof will be given in Section 12.3 (see the remark after Theorem 12.18). We can also describe the matching polytope, i.e. the convex hull of the incidence vectors of all matchings in an undirected graph G: Theorem 11.16. (Edmonds [1965]) Let G be a graph. The matching polytope of G is the set of vectors x 2 RE.G/ satisfying C X e2ı.v/

xe 1 for all v 2 V .G/

and

X e2E.GŒA/

xe

jAj 1 for all A 2 A: 2

Proof: Since the incidence vector of any matching obviously satisfies these E.G/ inequalities, we only have to prove one direction. Let x 2 RC be a vector P P with e2ı.v/ xe 1 for v 2 V .G/ and e2E.GŒA/ xe jAj1 for A 2 A. We 2 prove that x is a convex combination of incidence vectors of matchings. We use the same construction as in the proof of Proposition 11.1: let H be the graph with V .H / WD f.v; i / W v 2 V .G/; i 2 f1; 2gg, and E.H / WD ff.v; i /; .w; i /g W fv; wg 2 E.G/; i 2 f1; 2gg [ ff.v; 1/; .v; 2/g W v 2 V .G/g. So H consists of two copies of G, and there is an edge joining the two copies of each vertex. Let yf.v;i /;.w;i /g WD P xe for each e D fv; wg 2 E.G/ and i 2 f1; 2g, and let yf.v;1/;.v;2/g WD 1 e2ıG .v/ xe for each v 2 V .G/. We claim that y belongs to the perfect matching polytope of H . Considering the subgraph induced by f.v; 1/ W v 2 V .G/g, which is isomorphic to G, we then get that x is a convex combination of incidence vectors of matchings in G.

294

11 Weighted Matching V (G)

∈ V (G)}

{( , 1) :

∈ V (G)}

{( , 2) :

A

A1

A2

B

B1

B2

C

:X

Fig. 11.9.

P / Obviously, y 2 RE.H and e2ıH .v/ ye D 1 for all v 2 V .H /. To show C that y belongs to the perfect matching polytope Pof H , we use Theorem 11.15. So let X V .H / with jX j odd. We prove that e2ıH .X/ ye 1. Let A WD fv 2 V .G/ W .v; 1/ 2 X; .v; 2/ … X g, B WD fv 2 V .G/ W .v; 1/ 2 X; .v; 2/ 2 X g and C WD fv 2 V .G/ W .v; 1/ … X; .v; 2/ 2 X g. Since jX j is odd, either A or C must have odd cardinality, w.l.o.g. jAj is odd. We write Ai WD f.a; i / W a 2 Ag and Bi WD f.b; i / W b 2 Bg for i D 1; 2 (see Figure 11.9). Then X X X X X X ye ye 2 ye ye C ye v2A1 e2ıH .v/

e2ıH .X/

D

X

X

e2E.H ŒA1 /

ye 2

v2A1 e2ıH .v/

X

e2EH .A1 ;B1 /

e2EH .B2 ;A2 /

xe

e2E.GŒA/

jA1 j .jAj 1/ D 1: Indeed, we can prove the following stronger result: Theorem 11.17. (Cunningham and Marsh [1978]) For any undirected graph G the linear inequality system X xe 0 xe 1 e2ı.v/ X eA

is TDI.

xe

jAj1 2

.e 2 E.G// .v 2 V .G// .A 2 A; jAj > 1/

11.5

The Matching Polytope

295

P Proof: For c W E.G/ ! Z we consider the LP max e2E.G/ c.e/xe subject to the above constraints. The dual LP is: X X jAj 1 ´A min yv C 2 v2V .G/ A2A; jAj>1 X X s.t. yv C ´A c.e/ .e 2 E.G// v2e

A2A; eA

yv 0 ´A 0

.v 2 V .G// .A 2 A; jAj > 1/

Let .G; c/ be the smallest counterexample, i.e. there is no integral optimum dual P solution and jV .G/j C jE.G/j C e2E.G/ jc.e/j is minimum. Then c.e/ 1 for all e (otherwise we can delete any edge of nonpositive weight), and G has no isolated vertices (otherwise we can delete them). Moreover, for any optimum solution y; ´ we claim that y D 0. To prove this, suppose Pyv > 0 for some v 2 V .G/. Then by complementary slackness (Corollary 3.23) e2ı.v/ xe D 1 for every primal optimum solution x. But then decreasing c.e/ by one for each e 2 ı.v/ yields a smaller instance .G; c 0 /, whose optimum LP value is one less (here we use primal integrality, i.e. Theorem 11.16). Since .G; c/ is the smallest counterexample, there exists an integral optimum dual solution y 0 ; ´0 for .G; c 0 /. Increasing yv0 by one yields an integral optimum dual solution for .G; c/, a contradiction. Now let y D 0 and ´ be an optimum dual solution for which X jAj2 ´A (11.4) A2A; jAj>1

is as large as possible. We claim that F WD fA W ´A > 0g is laminar. To see this, suppose there are sets X; Y 2 F with X n Y 6D ;, Y n X 6D ; and X \ Y 6D ;. Let WD minf´X ; ´Y g > 0. 0 If jX \ Y j is odd, then jX [ Y j is also odd. Set ´X WD ´X , ´0Y WD ´Y , 0 0 ´X\Y WD ´X\Y C (unless jX \ Y j D 1), ´X[Y WD ´X[Y C and ´A0 WD ´A for all other sets A. y; ´0 is also a feasible dual solution; moreover it is optimum as well. This is a contradiction since (11.4) is larger. 0 If jX \ Y j is even, then jX n Y j and jY n X j are odd. Set ´X WD ´X , 0 0 0 ´Y WD ´Y , ´XnY WD ´XnY C (unless jX n Y j D 1), ´Y nX WD ´Y nX C (unless jY n X j D 1) and ´A0 WD ´A for all other sets A. Set yv0 WD for v 2 X \ Y and yv0 WD 0 for v … X \ Y . Then .y 0 ; ´0 / is a feasible dual solution with X v2V .G/

yv0 C

X A2A; jAj>1

X jAj 1 0 jAj 1 ´A D jX \ Y j C ´A 2 2 A2A; jAj>1 C jXnY2 j1 C jY nXj1 jXj1 2 2 D

X

A2A; jAj>1

jAj 1 ´A ; 2

jY j1 2

296

11 Weighted Matching

hence it is also optimum. This contradicts the fact that any optimum dual solution .y 0 ; ´0 / must have y 0 D 0. Now let A 2 F with ´A … Z and A maximal. Set WD ´A b´A c > 0. Let A1 ; : : : ; Ak be the maximal proper subsets of A in F ; they must be pairwise disjoint because F is laminar. Setting ´A0 WD ´A and ´A0 i WD ´Ai C for i D 1; : : : ; k 0 WD ´D for all other D 2 A) yields another feasible dual solution y D 0; ´0 (and ´D (since c is integral). We have X B2A; jBj>1

jBj 1 0 ´B < 2

X B2A; jBj>1

jBj 1 ´B ; 2

contradicting the optimality of the original dual solution y D 0; ´.

This proof is due to Schrijver [1983a]. For different proofs, see Lovász [1979] and P Schrijver [1983b]. The P latter does not use Theorem 11.16. Moreover, replacing e2ı.v/ xe 1 by e2ı.v/ xe D 1 for v 2 V .G/ in Theorem 11.17 yields an alternative description of the perfect matching polytope, which is also TDI (by Theorem 5.18). Theorem 11.15 can easily be derived from this; however, the linear inequality system of Theorem 11.15 is not TDI in general (K4 is a counterexample). Theorem 11.17 also implies the Berge-Tutte formula (Theorem 10.14; see Exercise 15). Generalizations will be discussed in Section 12.1.

Exercises 1. Use Theorem 11.4 to prove a weighted version of König’s Theorem 10.2. (Egerváry [1931]) 2. Describe the convex hull of the incidence vectors of all (a) vertex covers, (b) stable sets, (c) edge covers, in a bipartite graph G. Show how Theorem 10.2 and the statement of Exercise 2(c) of Chapter 10 follow. Hint: Use Theorem 5.25 and Corollary 5.21. 3. Prove the Birkhoff-von-Neumann Theorem 11.5 directly. 4. Let G be a graph and P the fractional perfect matching polytope of G. Prove that the vertices of P are exactly the vectors x with 8 1 ˆ < 2 if e 2 E.C1 / [ [ E.Ck / xe D 1 if e 2 M ; ˆ : 0 otherwise where C1 ; : : : ; Ck are vertex-disjoint odd circuits and M is a perfect matching in G .V .C1 / [ [ V .Ck //. (Balinski [1972]; see Lovász [1979])

Exercises :

297

5. Let G be a bipartite graph with bipartition V D A [ B and A D fa1 ; : : : ; ap g, B D fb1 ; : : : ; bq g. Let c W E.G/ ! R be weights on the edges. We look for the maximum weight order-preserving matching M , i.e. for any two edges fai ; bj g; fai 0 ; bj 0 g 2 M with i < i 0 we require j < j 0 . Solve this problem with an O.n3 /-algorithm. Hint: Use dynamic programming. 6. Prove that, at any stage of the WEIGHTED MATCHING ALGORITHM, jBj 32 n. 7. Let G be a graph with nonnegative weights c W E.G/ ! RC . Let M be the matching at any intermediate stage of the WEIGHTED MATCHING ALGORITHM. Let X be the set of vertices covered by M . Show that any matching covering X is at least as expensive as M . (Ball and Derigs [1983]) 8. A graph with integral weights on the edges is said to have the even circuit property if the total weight of every circuit is even. Show that the WEIGHTED MATCHING ALGORITHM applied to a graph with the even circuit property maintains this property (with respect to the slacks) and also maintains a dual solution that is integral. Conclude that for any graph there exists an optimum dual solution ´ that is half-integral (i.e. 2´ is integral). 9. When the WEIGHTED MATCHING ALGORITHM is restricted to bipartite graphs, it becomes much simpler. Show which parts are necessary even in the bipartite case and which are not. Note: One arrives at what is called the Hungarian method for the ASSIGNMENT PROBLEM (Kuhn [1955]). This algorithm can also be regarded as an equivalent description of the procedure proposed in the proof of Theorem 11.2. 10. Suppose G is a complete graph and c W E.G/ ! RC satisfies the triangle inequality, i.e., c.fx; ´g/ c.fx; yg/ C c.fy; ´g/ for all x; y; ´ 2 V .G/. Show that then there exists an optimum solution ´ to (11.2) with ´ 0. 11. How can the bottleneck matching problem (find a perfect matching M such that maxfc.e/ W e 2 M g is minimum) be solved in O.n3 / time? 12. Show how to solve the MINIMUM WEIGHT EDGE COVER PROBLEM in polynomial time: given an undirected graph G and weights c W E.G/ ! R, find a minimum weight edge cover. 13. Given an undirected graph G with weights c W E.G/ ! RC and two vertices s and t, we look for a shortest s-t-path with an even (or with an odd) number of edges. Reduce this to a MINIMUM WEIGHT PERFECT MATCHING PROBLEM. Hint: Take two copies of G, connect each vertex with its copy by an edge of zero weight and delete s and t (or s and the copy of t). (Grötschel and Pulleyblank [1981]) 14. Let G be a k-regular and .k 1/-edge-connected graph with an even number of vertices, and let c W E.G/ ! RC . Prove that there exists a perfect matching M in G with c.M / k1 c.E.G//. Hint: Show that k1 1l is in the perfect matching polytope. (Naddef and Pulleyblank [1981]) 15. Show that Theorem 11.17 implies: (a) the Berge-Tutte formula (Theorem 10.14);

298

11 Weighted Matching

(b) Theorem 11.15; (c) the existence of an optimum half-integral dual solution to the dual LP (11.2) (cf. Exercise 8). Hint: Use Theorem 5.18. 16. The fractional perfect matching polytope Q of G is identical to the perfect matching polytope if G is bipartite (Theorem 11.4). Consider the first GomoryChvátal-truncation Q0 of Q (Definition 5.29). Prove that Q0 is always identical to the perfect matching polytope.

References General Literature: Gerards, A.M.H. [1995]: Matching. In: Handbooks in Operations Research and Management Science; Volume 7: Network Models (M.O. Ball, T.L. Magnanti, C.L. Monma, G.L. Nemhauser, eds.), Elsevier, Amsterdam 1995, pp. 135–224 Lawler, E.L. [1976]: Combinatorial Optimization; Networks and Matroids. Holt, Rinehart and Winston, New York 1976, Chapters 5 and 6 Papadimitriou, C.H., and Steiglitz, K. [1982]: Combinatorial Optimization; Algorithms and Complexity. Prentice-Hall, Englewood Cliffs 1982, Chapter 11 Pulleyblank, W.R. [1995]: Matchings and extensions. In: Handbook of Combinatorics; Vol. 1 (R.L. Graham, M. Grötschel, L. Lovász, eds.), Elsevier, Amsterdam 1995

Cited References: Balinski, M.L. [1972]: Establishing the matching polytope. Journal of Combinatorial Theory 13 (1972), 1–13 Ball, M.O., and Derigs, U. [1983]: An analysis of alternative strategies for implementing matching algorithms. Networks 13 (1983), 517–549 Birkhoff, G. [1946]: Tres observaciones sobre el algebra lineal. Revista Universidad Nacional de Tucumán, Series A 5 (1946), 147–151 Burkard, R., Dell’Amico, M., and Martello, S. [2009]: Assignment Problems. SIAM, Philadelphia 2009 Cook, W., and Rohe, A. [1999]: Computing minimum-weight perfect matchings. INFORMS Journal of Computing 11 (1999), 138–148 Cunningham, W.H., and Marsh, A.B. [1978]: A primal algorithm for optimum matching. Mathematical Programming Study 8 (1978), 50–72 Edmonds, J. [1965]: Maximum matching and a polyhedron with (0,1) vertices. Journal of Research of the National Bureau of Standards B 69 (1965), 125–130 Egerváry, E. [1931]: Matrixok kombinatorikus tulajdonságairol. Matematikai és Fizikai Lapok 38 (1931), 16–28 [in Hungarian] Gabow, H.N. [1973]: Implementation of algorithms for maximum matching on non-bipartite graphs. Ph.D. Thesis, Stanford University, Dept. of Computer Science, 1973 Gabow, H.N. [1976]: An efficient implementation of Edmonds’ algorithm for maximum matching on graphs. Journal of the ACM 23 (1976), 221–234 Gabow, H.N. [1990]: Data structures for weighted matching and nearest common ancestors with linking. Proceedings of the 1st Annual ACM-SIAM Symposium on Discrete Algorithms (1990), 434–443

References

299

Grötschel, M., and Pulleyblank, W.R. [1981]: Weakly bipartite graphs and the max-cut problem. Operations Research Letters 1 (1981), 23–27 Kolmogorov, V. [2009]: Blossom V: a new implementation of a minimum cost perfect matching algorithm. Mathematical Programming Computation 1 (2009), 43–67 Kuhn, H.W. [1955]: The Hungarian method for the assignment problem. Naval Research Logistics Quarterly 2 (1955), 83–97 Lipton, R.J., and Tarjan, R.E. [1979]: A separator theorem for planar graphs. SIAM Journal on Applied Mathematics 36 (1979), 177–189 Lipton, R.J., and Tarjan, R.E. [1980]: Applications of a planar separator theorem. SIAM Journal on Computing 9 (1980), 615–627 Lovász, L. [1979]: Graph theory and integer programming. In: Discrete Optimization I; Annals of Discrete Mathematics 4 (P.L. Hammer, E.L. Johnson, B.H. Korte, eds.), NorthHolland, Amsterdam 1979, pp. 141–158 Mehlhorn, K., and Schäfer, G. [2000]: Implementation of O.nm log n/ weighted matchings in general graphs: the power of data structures. In: Algorithm Engineering; WAE-2000; LNCS 1982 (S. Näher, D. Wagner, eds.), pp. 23–38; also electronically in The ACM Journal of Experimental Algorithmics 7 (2002) Monge, G. [1784]: Mémoire sur la théorie des déblais et des remblais. Histoire de l’Académie Royale des Sciences 2 (1784), 666–704 Munkres, J. [1957]: Algorithms for the assignment and transportation problems. Journal of the Society for Industrial and Applied Mathematics 5 (1957), 32–38 Naddef, D., and Pulleyblank, W.R. [1981]: Matchings in regular graphs. Discrete Mathematics 34 (1981), 283–291 von Neumann, J. [1953]: A certain zero-sum two-person game equivalent to the optimal assignment problem. In: Contributions to the Theory of Games II; Ann. of Math. Stud. 28 (H.W. Kuhn, ed.), Princeton University Press, Princeton 1953, pp. 5–12 Schrijver, A. [1983a]: Short proofs on the matching polyhedron. Journal of Combinatorial Theory B 34 (1983), 104–108 Schrijver, A. [1983b]: Min-max results in combinatorial optimization. In: Mathematical Programming; The State of the Art – Bonn 1982 (A. Bachem, M. Grötschel, B. Korte, eds.), Springer, Berlin 1983, pp. 439–500 Varadarajan, K.R. [1998]: A divide-and-conquer algorithm for min-cost perfect matching in the plane. Proceedings of the 39th Annual IEEE Symposium on Foundations of Computer Science (1998), 320–329 Weber, G.M. [1981]: Sensitivity analysis of optimal matchings. Networks 11 (1981), 41–56

•

12 b-Matchings and T-Joins

In this chapter we introduce two more combinatorial optimization problems, the MAXIMUM WEIGHT b-MATCHING PROBLEM in Section 12.1 and the MINIMUM WEIGHT T -JOIN PROBLEM in Section 12.2. Both can be regarded as generalizations of the MINIMUM WEIGHT PERFECT MATCHING PROBLEM and also include other important problems. On the other hand, both problems can be reduced to the MINIMUM WEIGHT PERFECT MATCHING PROBLEM. They have combinatorial polynomial-time algorithms as well as polyhedral descriptions. Since in both cases the SEPARATION PROBLEM turns out to be solvable in polynomial time, we obtain another polynomial-time algorithm for these generalized matching problems (using the ELLIPSOID METHOD; see Section 4.6). In fact, the SEPARATION PROBLEM can be reduced to finding a minimum capacity T -cut in both cases; see Sections 12.3 and 12.4. This problem, finding a minimum capacity cut ı.X / such that jX \ T j is odd for a specified vertex set T , can be solved with network flow techniques.

12.1 b-Matchings Definition 12.1. Let G be an undirected graph with integral edge capacities u W E.G/ ! N [ f1g and numbers b W V .G/ ! N. Then a b-matching P in .G; u/ is a function f W E.G/ ! ZC with f .e/ u.e/ for all e 2 E.G/ and e2ı.v/ f .e/ b.v/ for all v 2 V .G/. In the caseP u 1 we speak of a simple b-matching in G. A b-matching f is called perfect if e2ı.v/ f .e/ D b.v/ for all v 2 V .G/. In the case b 1 the capacities are irrelevant, and we are back to ordinary matchings. A simple b-matching is sometimes also called a b-factor. It can be regarded as a subset of edges. In Chapter 21 we shall be interested in perfect simple 2-matchings, i.e. subsets of edges such that each vertex is incident to exactly two of them.

MAXIMUM WEIGHT b-MATCHING PROBLEM Instance: Task:

A graph G, capacities u W E.G/ ! N[f1g, weights c W E.G/ ! R, and numbers b W V .G/ ! N. P Find a b-matching f in .G; u/ whose weight e2E.G/ c.e/f .e/ is maximum.

B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__12, c Springer-Verlag Berlin Heidelberg 2012

301

302

12 b-Matchings and T -Joins

Edmonds’ WEIGHTED MATCHING ALGORITHM can be extended to solve this problem (Marsh [1979]). We shall not describe this algorithm here, but shall rather give a polyhedral description and show that the SEPARATION PROBLEM can be solved in polynomial time. This yields a polynomial-time algorithm via the E LLIPSOID M ETHOD (cf. Corollary 3.33). The b-matching polytope of .G; u/ is defined to be the convex hull of all bmatchings in .G; u/. We first consider the uncapacitated case (u 1): Theorem 12.2. (Edmonds [1965]) Let G be an undirected graph and b W V .G/ ! N. The b-matching polytope of .G; 1/ is the set of vectors x 2 RE.G/ satisfying C X xe b.v/ .v 2 V .G//I e2ı.v/

X

$ xe

e2E.GŒX/

1 2

X

% b.v/

.X V .G//:

v2X

Proof: Since any b-matching obviously satisfies these constraints, we only have P with e2ı.v/ xe b.v/ for all v 2 V .G/ to show one direction. So let x 2 RE.G/ C P ˘ P and e2E.GŒX/ xe 12 v2X b.v/ for all X V .G/. We show that x is a convex combination of b-matchings. We define a new graph H by splitting up each vertex v into b.v/Scopies: we define Xv WD f.v; i / W i 2 f1; : : : ; b.v/gg for v 2 V .G/, V .H / WD v2V .G/ Xv and E.H / WD ffv 0 ; w 0 g W fv; wg 2 E.G/; v 0 2 Xv ; w 0 2 Xw g. Let ye WD 1 0 0 0 0 b.v/b.w/ xfv;wg for each edge e D fv ; w g 2 E.H /, v 2 Xv ; w 2 Xw . We claim that y is a convex combination of incidence vectors of matchings in H . By contracting the sets Xv (v 2 V .G/) in H we then return to G and x, and conclude that x is a convex combination of b-matchings in G. P To prove that y is in the matching polytope of H we use Theorem 11.16. holds for each v 2 V .H /. Let C V .H / with jC j e2ı.v/ ye 1 obviously P odd. We show that e2E.H ŒC / ye 12 .jC j 1/. If Xv C or Xv \ C D ; for each v 2 V .G/, this follows directly from the inequalities assumed for x. Otherwise let a; b 2 Xv , a 2 C , b 62 C . Then X X X X 2 ye D ye C ye e2E.H ŒC /

c2C nfag e2E.fcg;C nfcg/

X

X

X

X

ye

c2C nfag e2ı.c/

D

X

X

X

ye C

c2C nfag e2ı.c/nffc;bgg

D

e2E.fag;C nfag/

ye

e2E.fag;C nfag/

X

e2E.fbg;C nfag/

ye C

X

ye

e2E.fag;C nfag/

ye

c2C nfag e2ı.c/

jC j 1:

12.1

b-Matchings

303

Note that this construction yields an algorithm which, however, P in general has an exponential running time. But we note that in the special case v2V .G/ b.v/ D O.n/ we can solve the uncapacitated MAXIMUM WEIGHT b-MATCHING PROBLEM in O.n3 / time (using the WEIGHTED M ATCHING A LGORITHM ; cf. Corollary 11.12). Pulleyblank [1973,1980] described the facets of this polytope and showed that the linear inequality system in Theorem 12.2 is TDI. The following generalization allows finite capacities: Theorem 12.3. (Edmonds and Johnson [1970]) Let G be an undirected graph, u W E.G/ ! N [ f1g and b W V .G/ ! N. The b-matching polytope of .G; u/ is the set of vectors x 2 RE.G/ satisfying C X xe u.e/ xe b.v/ e2ı.v/

X

xe C

e2E.GŒX/

X

$ xe

e2F

1 2

.e 2 E.G//I .v 2 V .G//I X

b.v/ C

v2X

X

!% .X V .G/, F ı.X //:

u.e/

e2F

Proof: First observe that every b-matching x satisfies the constraints. This is clear E.G/ except for the with xe u.e/ (e 2 P last one; but note that any vector x 2 RC E.G/) and e2ı.v/ xe b.v/ (v 2 V .G/) satisfies 1 0 X X X X 1 @X X xe C xe D xe C xe xe A 2 e2F v2X e2ı.v/ e2F e2E.GŒX/ e2ı.X/nF ! X 1 X b.v/ C u.e/ : 2 v2X

e2F

If x is integral, the left-hand side is an integer, so we may round down the right-hand side. P Now let x 2 RE.G/ be a vector with xe u.e/ for all e 2 E.G/, e2ı.v/ xe C b.v/ for all v 2 V .G/ and $ !% X X X 1 X xe C xe b.v/ C u.e/ 2 e2E.GŒX/

e2F

v2X

e2F

for all X V .G/ and F ı.X /. We show that x is a convex combination of b-matchings in .G; u/. Let H be the graph resulting from G by subdividing each edge e D fv; wg with u.e/ 6D 1 by means of two new vertices .e; v/; .e; w/. (Instead of e, H now contains the edges fv; .e; v/g, f.e; v/; .e; w/g and f.e; w/; wg.) Set b..e; v// WD b..e; w// WD u.e/ for the new vertices. For each subdivided edge e D fv; wg set yfv;.e;v/g WD yf.e;w/;wg WD xe and yf.e;v/;.e;w/g WD u.e/ xe . For each original edge e with u.e/ D 1 set ye WD xe . We claim that y is in the b-matching polytope P of .H; 1/.

304

12 b-Matchings and T -Joins

P / We use Theorem 12.2. Obviously y 2 RE.H and e2ı.v/ ye b.v/ for all C v 2 V .H /. Suppose there is a set A V .H / with $ % X 1X ye > b.a/ : (12.1) 2 a2A

e2E.H ŒA/

Let B WD A \ V .G/. For each e D fv; wg 2 E.GŒB/ we may assume .e; v/; .e; w/ 2 A, for otherwise the addition of .e; v/ and .e; w/ does not destroy (12.1). On the other hand, we may assume that .e; v/ 2 A implies v 2 A: If .e; v/; .e; w/ 2 A but v … A, we can delete .e; v/ and .e; w/ from A without destroying (12.1). If .e; v/ 2 A but v; .e; w/ … A, we can just delete .e; v/ from A. Figure 12.1 shows the remaining possible edge types. A

Fig. 12.1.

Let F WD fe D fv; wg 2 E.G/ W jA \ f.e; v/; .e; w/gj D 1g. We have X X X X xe C xe D ye u.e/ e2E.GŒB/

e2F

e2E.H ŒA/

$ >

%

e2E.GŒB/; u.e/ c.J 0 \ E.C // D c.E.C / n J /. This proposition can be regarded as a special case of Theorem 9.7. We now solve the MINIMUM WEIGHT T -JOIN PROBLEM with nonnegative weights by reducing it to the MINIMUM WEIGHT PERFECT MATCHING PROBLEM. The main idea is contained in the following lemma: Lemma 12.9. Let G be a graph, c W E.G/ ! RC , and T V .G/. Every optimum T -join in G is the disjoint union of the edge sets of jT2 j paths whose ends are distinct and in T , and possibly some zero-weight circuits. Proof: By induction on jT j. The case T D ; is trivial since the minimum weight of an ;-join is zero. Let J be any optimum T -join in G; w.l.o.g. J contains no zero-weight circuit. By Proposition 12.8 J contains no circuit of positive weight. As c is nonnegative, J thus forms a forest. Let x; y be two leaves of the same connected component of this forest, i.e. jJ \ ı.x/j D jJ \ ı.y/j D 1, and let P be the x-y-path with edges in J . We have x; y 2 T , and J n E.P / is a minimum cost .T n fx; yg/-join (a cheaper .T n fx; yg/-join J 0 would imply a T -join J 0 4E.P / that is cheaper than J ). The assertion now follows from the induction hypothesis. Theorem 12.10. (Edmonds and Johnson [1973]) In the case of nonnegative weights, the MINIMUM WEIGHT T -JOIN PROBLEM can be solved in O.n3 / time. Proof: Let .G; c; T / be an instance. We first solve an ALL PAIRS SHORTEST PATHS PROBLEM in .G; c/; more precisely: in the graph resulting by replacing each edge by a pair of oppositely directed edges with the same weight. By Theorem 7.8 N c/ this takes O.mn C n2 log n/ time. In particular, we obtain the metric closure .G; N of .G; c/ (cf. Corollary 7.10). N ; c/. Now we find a minimum weight perfect matching M in .GŒT N By Corollary 3 11.12, this takes O.n / time. By Lemma 12.9, c.M N / is at most the minimum weight of a T -join. We consider the shortest x-y-path in G for each fx; yg 2 M (which we have already computed). Let J be the symmetric difference of the edge sets of all these paths. Evidently, J is a T -join in G. Moreover, c.J / c.M N /, so J is optimum.

308

12 b-Matchings and T -Joins

This method no longer works if we allow negative weights, because we would introduce negative circuits. However, we can reduce the M INIMUM WEIGHT T -JOIN PROBLEM with arbitrary weights to that with nonnegative weights: Theorem 12.11. Let G be a graph with weights c W E.G/ ! R and T V .G/. Let E be the set of edges with negative weight, V the set of vertices that are incident with an odd number of negative edges, and d W E.G/ ! RC with d.e/ WD jc.e/j. Then J 4E is a minimum c-weight T -join if and only if J is a minimum d weight .T 4V /-join. Proof: As E is a V -join, Proposition 12.6 implies that J 4E is a T -join if and only if J is a .T 4V /-join. Moreover, for any subset J of E.G/ we have c.J 4E / D c.J n E / C c.E n J / D d.J n E / C c.E n J / C c.J \ E / C d.J \ E / D d.J / C c.E / : Since c.E / is constant, the theorem follows.

Corollary 12.12. The MINIMUM WEIGHT T -JOIN PROBLEM can be solved in O.n3 / time. Proof: This follows directly from Theorems 12.10 and 12.11.

We are finally able to solve the SHORTEST PATH PROBLEM in undirected graphs: Corollary 12.13. The problem of finding a shortest path between two specified vertices in an undirected graph with conservative weights can be solved in O.n3 / time. Proof: Let s and t be the two specified vertices. Set T WD fs; tg and apply Corollary 12.12. After deleting zero-weight circuits, the resulting T -join is the edge set of a shortest s-t-path. Of course this also implies an O.mn3 /-algorithm for finding a circuit of minimum total weight in an undirected graph with conservative weights (and in particular to compute the girth). If we are interested in the ALLPAIRS SHORTEST PATHS PROBLEM in undirected graphs, we do not have to do n2 independent weighted matching computations (which would give a running time of O.n5 /). Using the postoptimality results of Section 11.4 we can prove: Theorem 12.14. The problem of finding shortest paths for all pairs of vertices in an undirected graph G with conservative weights c W E.G/ ! R can be solved in O.n4 / time.

12.3

T -Joins and T -Cuts

309

Proof: By Theorem 12.11 and the proof of Corollary 12.13 we have to compute an optimum .fs; tg4V /-join with respect to the weights d.e/ WD jc.e/j for all s; t 2 V .G/, where V is the set of vertices incident to an odd number of negative edges. Let dN .fx; yg/ WD dist.G;d / .x; y/ for x; y 2 V .G/, and let HX be the complete graph on X 4V (X V .G/). By the proof of Theorem 12.10 it is sufficient to compute a minimum weight perfect matching in Hfs;t g ; dN for all s and t. Our O.n4 /-algorithm proceeds as follows. We first compute dN (cf. Corollary 7.10) and run the WEIGHTED MATCHING ALGORITHM for the instance H; ; dN . Up to now we have spent O.n3 / time. We show that we can now compute a minimum weight perfect matching of Hfs;t g ; dN in O.n2 / time, for any s and t. There are four cases: Case 1: s; t 62 V . Then we add these two vertices and reoptimize by Lemma 11.13. In O.n2 / time we obtain a minimum weight perfect matching in Hfs;t g; dN . Case 2: s; t 2 V . Then we construct H 0 by adding two auxiliary vertices s 0 ; t 0 and two edges fs; s 0 g; ft; t 0 g with arbitrary weight. We reoptimize by Lemma 11.13 and delete the two new edges from the resulting minimum weight perfect matching in H 0 . Case 3: s 2 V and t 62 V . Then we construct H 0 by adding t, an auxiliary vertex s 0 , and an edge fs; s 0 g (with arbitrary cost) in addition to the edges incident to t. We reoptimize by Lemma 11.13 and delete the edge fs; s 0 g from the resulting minimum weight perfect matching in H 0 . Case 4: s 62 V and t 2 V . Symmetric to Case 3. Gabow [1983] improved the running time to O.minfn3 ; nm log ng/.

12.3 T-Joins and T-Cuts In this section we shall derive a polyhedral description of the MINIMUM WEIGHT T -JOIN PROBLEM. In contrast to the description of the perfect matching polytope (Theorem 11.15), where we had a constraint for each cut ı.X / with jX j odd, we now need a constraint for each T -cut. A T-cut is a cut ı.X / with jX \ T j odd. The following simple observation is very useful: Proposition 12.15. Let G be an undirected graph and T V .G/ with jT j even. Then for any T -join J and any T -cut C we have J \ C 6D ;. Proof: Suppose C D ı.X /, then jX \ T j is odd. So the number of edges in J \ C must be odd, in particular nonzero. A stronger statement can be found in Exercise 12. Proposition 12.15 implies that the minimum cardinality of a T -join is not less than the maximum number of pairwise edge-disjoint T -cuts. In general, we do not have equality: consider G D K4 and T D V .G/. However, for bipartite graphs equality holds:

310

12 b-Matchings and T -Joins

Theorem 12.16. (Seymour [1981]) Let G be a bipartite graph and T V .G/ such that a T -join in G exists. Then the minimum cardinality of a T -join equals the maximum number of pairwise edge-disjoint T -cuts. Proof: (Seb˝o [1987]) We only have to prove “”. We use induction on jV .G/j. If T D ; (in particular if jV .G/j D 1), the statement is trivial. So we assume jV .G/j jT j 2. Denote by .G; T / the minimum cardinality of a T -join in G (and 1 if no T -join exists). We will use Proposition 12.8 (for unit weights) and Proposition 12.6 several times. We may assume that there exists a T -join in G because otherwise there is an empty T -cut that we can list an infinite number of times. Choose a; b 2 V .G/ such that .G; T 4fag4fbg/ is minimum. Let T 0 WD T 4fag4fbg. As one possible choice of a and b consists of the endpoints of an edge in a minimum T -join (note that T 6D ;), we have .G; T 0 / < .G; T / and hence a 6D b and T 0 D T 4fa; bg. Claim: For any minimum T -join J in G we have jJ \ ı.a/j D jJ \ ı.b/j D 1. To prove this claim, let J be a minimum T -join and J 0 a minimum T 0 -join. J 4J 0 is the edge-disjoint union of an a-b-path P and some circuits C1 ; : : : ; Ck . We have jE.Ci / \ J j D jE.Ci / \ J 0 j for each i , because both J and J 0 are minimum. So jJ 4E.P /j D jJ 0 j, and J 00 WD J 4E.P / is also a minimum T 0 -join. Now J 00 \ ı.a/ D J 00 \ ı.b/ D ;, because if, say, fb; b 0 g 2 J 00 , J 00 n ffb; b 0 gg is a .T 4fag4fb 0g/-join, and we have .G; T 4fag4fb 0g/ < jJ 00 j D jJ 0 j D .G; T 0 /, contradicting the choice of a and b. We conclude that jJ \ ı.a/j D jJ \ ı.b/j D 1, and the claim is proved. In particular, a; b 2 T . Now let J be a minimum T -join in G. Contract B WD fbg [ .b/ to a single vertex vB , and let the resulting graph be G . G is also bipartite. Let T WD T n B if jT \ Bj is even and T WD .T n B/ [ fvB g otherwise. The set J , resulting from J by the contraction of B, is obviously a T -join in G . Since .b/ is a stable set in G (as G is bipartite), the claim implies that jJ j D jJ j C 1. It suffices to prove that J is a minimum T -join in G , because then we have .G; T / D jJ j D jJ j C 1 D .G ; T / C 1, and the theorem follows by induction (observe that ı.b/ is a T -cut in G disjoint from E.G /). So suppose that J is not a minimum T -join in G . Then by Proposition 12.8 there is a circuit C in G with jJ \E.C /j > jE.C /nJ j. Since G is bipartite, jJ \ E.C /j jE.C / n J j C 2. E.C / corresponds to an edge set Q in G. Q cannot be a circuit, because jJ \ Qj > jQ n J j and J is a minimum T -join. Hence Q is an x-y-path in G for some x; y 2 .b/ with x 6D y. Let C be the circuit in G formed by Q together with fx; bg and fb; yg. Since J is a minimum T -join in G, jJ \ E.C /j jE.C / n J j jE.C / n J j C 2 jJ \ E.C /j jJ \ E.C /j: Thus we must have equality throughout, in particular fx; bg; fb; yg … J and jJ \ E.C /j D jE.C /nJ j. So JN WD J 4E.C / is also a minimum T -join and jJN \ı.b/j D 3. But this is impossible by the claim.

12.3

T -Joins and T -Cuts

311

Corollary 12.17. Let G be a graph, c W E.G/ ! ZC , and T V .G/ such that a T -join in G exists. Let k be the minimum cost of a T -join in G. Then there are T -cuts C1 ; : : : ; C2k such that each edge e 2 E.G/ is contained in at most 2c.e/ of them. Proof: Let E0 be the set of edges with weight zero. We construct a bipartite graph G 0 by contracting the connected components of .V .G/; E0 / and replacing each edge e by a path of length 2c.e/. Let T 0 be the set of vertices in G 0 corresponding to connected components X of .V .G/; E0 / with jX \ T j odd. Claim: The minimum cardinality of a T 0 -join in G 0 is 2k. To prove this, first note that it cannot be more than 2k as every T -join J in G corresponds to a T 0 -join in G 0 of cardinality at most 2c.J /. Conversely, let J 0 be a T 0 -join in G 0 . It corresponds to an edge set J in G. Let TN WD T 4fv 2 V .G/ W jı.v/\J j oddg. Then each connected component X of .V .G/; E0 / contains an even number of vertices of TN (as jı.X / \ J j jX \ T j .mod 2/). By Proposition 12.7 0 .V .G/; E0 / has a TN -join JN , and J [ JN is a T -join in G with weight c.J / D jJ2 j . The claim is proved. By Theorem 12.16, there are 2k pairwise edge-disjoint T 0 -cuts in G 0 . Back in G, this yields a list of 2k T -cuts in G such that every edge e is contained in at most 2c.e/ of these. Karzanov [1986] described an efficient algorithm for finding such a T -cut packing. T -cuts are also essential in the following description of the T -join polyhedron: Theorem 12.18. (Edmonds and Johnson [1973]) Let G be an undirected graph, c W E.G/ ! RC , and T V .G/ such that a T -join in G exists. Then the incidence vector of each minimum weight T -join is an optimum solution of the LP ( ) X min cx W x 0; xe 1 for all T -cuts C : e2C

(This polyhedron is called the T-join polyhedron of G.) Proof: By Proposition 12.15, the incidence vector of a T -join satisfies the constraints. Moreover, by Proposition 12.7, every 0-1-vector satisfying the constraints is the incidence vector of an edge set containing a T -join. Therefore, by (g) )(f) of Theorem 5.13, it suffices to show that the LP value is an integer for every integral c for which the minimum is finite, i.e., for every c W E.G/ ! ZC . So let c W E.G/ ! ZC , and let k be the minimum weight (with respect to c) of a T -join in G. By Corollary 12.17 there are T -cuts C1 ; : : : ; C2k in G such that every edge e is contained in at most 2c.e/ of these. So for any feasible solution x of the above LP we have 2cx

2k X X i D1 e2Ci

xe 2k;

312

12 b-Matchings and T -Joins

proving that the optimum value of the LP is k.

This implies Theorem 11.15: let G be a graph with a perfect matching and T WD V .G/. Then Theorem 12.18 implies that ( ) X min cx W x 0; xe 1 for all T -cuts C e2C

is an integer for each c 2 ZE.G/ for which the minimum is finite. By Theorem 5.13, the polyhedron is integral, and so is its face 9 8 = < X X W x 1 for all T -cuts C; x D 1 for all v 2 V .G/ : x 2 RE.G/ e e C ; : e2C

e2ı.v/

One can also derive a description of the convex hull of the incidence vectors of all T -joins (Exercise 16). Theorems 12.18 and 4.21 (along with Corollary 3.33) imply another polynomial-time algorithm for the M INIMUM WEIGHT T -JOIN PROBLEM if we can solve the SEPARATION PROBLEM for the above description. This is obviously equivalent to checking whether there exists a T -cut with capacity less than one (here x serves as capacity vector). So it suffices to solve the following problem:

MINIMUM CAPACITY T -CUT PROBLEM Instance: Task:

A graph G, capacities u W E.G/ ! RC , and a nonempty set T V .G/ of even cardinality. Find a minimum capacity T -cut in G.

Note that the MINIMUM CAPACITY T -CUT PROBLEM also solves the SEPARAPROBLEM for the perfect matching polytope (Theorem 11.15; T WD V .G/). The following theorem solves the MINIMUM CAPACITY T -CUT PROBLEM: it suffices to consider the fundamental cuts of a Gomory-Hu tree. Recall that we can find a Gomory-Hu tree for an undirected graph with capacities in O.n4 / time (Theorem 8.38). TION

Theorem 12.19. (Padberg and Rao [1982]) Let G be an undirected graph with capacities u W E.G/ ! RC . Let H be a Gomory-Hu tree for .G; u/. Let T V .G/ with jT j 2 even. Then there is a minimum capacity T -cut among the fundamental cuts of H . Hence a minimum capacity T -cut can be found in O.n4 / time. Proof: Let ıG .X / be a minimum capacity T -cut in .G; u/. Let J be the set of edges e of H for which P jCe \ T j is odd, where Ce is a connected component of H e. As jıJ .x/j e2ıH .x/ jCe \ T j jfxg \ T j .mod 2/ for all x 2 V .G/, J is a T -join in H . By Proposition 12.15, there exists an edge f 2 ıH .X / \ J . We have u.ıG .X // minfu.ıG .Y // W jY \ f j D 1g D u.ıG .Cf //; showing that ıG .Cf / is a minimum capacity T -cut.

12.4

The Padberg-Rao Theorem

313

12.4 The Padberg-Rao Theorem Theorem 12.19 was generalized by Letchford, Reinelt and Theis [2008]: Lemma 12.20. Let G be an undirected graph with at least one edge, T V .G/ with jT j even, and c; c 0 W E.G/ ! RC [ f1g. Then there is an O.n4 /-algorithm which finds sets X P V .G/ and F ı.X / such that jX \ T j C jF j is odd and P 0 e2ı.X/nF c.e/ C e2F c .e/ is minimum. Proof: Since adding edges e with c.e/ D 0 and c 0 .e/ D 1 does not change anything, we may assume that G is connected. Let d.e/ WD minfc.e/; c 0 .e/g (e 2 E.G/). Let E 0 WD fe 2 E.G/ W c 0 .e/ < c.e/g and V 0 WD fv 2 V .G/ W jıE 0 .v/j oddg. Let T 0 WD T 4V 0 . Note: for X V .G/ we have jX \ T j C jı.X / \ E 0 j jX \ T j C jX \ V 0 j jX \ T 0 j .mod 2/. The algorithm first computes a Gomory-Hu tree H for .G; d /. For each f 2 E.H /, let Xf be the vertex set of a connected component of H f . Let gf 2 ıG .Xf / with jc 0 .gf / c.gf /j minimum. Then let Ff WD ıG .Xf / \ E 0 if jXf \ T 0 j is odd andP Ff WD .ıG .Xf /\E 0 /4fg P f g otherwise. Finally, we choose an f 2 E.H / such that e2ıG .Xf /nFf c.e/C e2Ff c 0 .e/ is minimum, and output X WD Xf and F WD Ff . The total running time is clearly dominated by computing the Gomory-Hu tree. Let ı.X / be optimum sets, i.e. jX \ T j C jF j is odd P X V .G/ and F P and e2ıG .X /nF c.e/ C e2F c 0 .e/ is minimum. Case 1: jX \T 0 j is odd. Then the set of f 2 E.H / such that jXf \T 0 j is odd is a T 0 -join in H , and thus has nonempty intersection with the T 0 -cut ıH .X /. Let f 2 0 ıH .X / with jXP f \ T j odd. By definition P of the Gomory-Hu tree, d.ıG .Xf // d.ıG .X // and e2ıG .Xf /nFf c.e/ C e2Ff c 0 .e/ D d.ıG .Xf //. Case 2: jX \ T 0 j is even. Let g 2 ıG .X / with jc 0 .g / c.g /j min imum. The unique circuit P in H 0 C g contains an edge f 0 2 ıH .X /. Then P .e/ D d.ıG .X //P C jc .g / c.g /j e2ıG .X /nF c.e/ C e2F cP d.ıG .Xf // C jc 0 .g / c.g /j e2ıG .Xf /nFf c.e/ C e2Ff c 0 .e/. Here the first inequality follows from the definition of a Gomory-Hu tree (note that f 2 ıH .X /), and the second inequality follows from g 2 ıG .Xf /. With this we can solve the SEPARATION PROBLEM for the b-matching polytope (Theorem 12.3) in polynomial time. This result is known as Padberg-Rao Theorem. Letchford, Reinelt and Theis [2008] simplified the proof and improved the running time: Theorem 12.21. (Padberg and Rao [1982], Letchford, Reinelt and Theis [2008]) For undirected graphs G, u W E.G/ ! N [ f1g and b W V .G/ ! N, the SEPARATION PROBLEM for the b-matching polytope of .G; u/ can be solved in O.n4 / time. E.G/

Proof: Given a vector x 2 RC with xe u.e/ for all e 2 E.G/ and P e2ıG .v/ xe b.v/ for all v 2 V .G/ (these trivial inequalities can be checked

314

12 b-Matchings and T -Joins

in linear time), we have to check the last set of inequalities in Theorem 12.3. In the proof of Theorem 12.3 we saw that these inequalities are automatically satisfied whenever b.X / C u.F / is even. They are violated iff X X b.X / 2 xe C .u.e/ 2xe / < 1 e2F

e2E.GŒX/

for some X V .G/ and F ı.X / with b.X / C u.F / odd. We extend G to a graph GN by adding a new vertex ´ and Pedges f´; vg for all N W b.v/ oddg, where b.´/ WD v 2 V .G/. Let T WD fv 2 V .G/ v2V .G/ b.v/. Let E 0 WD fe 2 E.G/ W u.e/ finite and oddg. We define c.e/ WD xe and c 0 .e/ WD u.e/xe for e 2 E 0 , c.e/P WD minfxe ; u.e/xe g and c 0 .e/ WD 1 for e 2 E.G/nE 0 , and c.f´; vg/ WD b.v/ e2ıG .v/ xe and c 0 .f´; vg/ WD 1 for v 2 V .G/. For X V .G/ we write DX WD fe 2 ıG .X / n E 0 W u.e/ < 2xe g. For each X V .G/ and F ıG .X / \ E 0 we have: jX \ T j C jF j b.X / C u.F [ DX / .mod 2/ and c.ıGN .X / n F / C c 0 .F / D

X v2X

C

0 @b.v/

X

1

e2ıG .v/

X

X

e2E.GŒX/

xe C

xe

e2.ıG .X/\E 0 /nF

minfxe ; u.e/ xe g C

e2ıG .X/nE 0

D b.X / 2

X

xe A C

X

X

.u.e/ xe /

e2F

.u.e/ 2xe /:

e2F [DX

N and F ı N .X / with c.ı N .X / n We conclude: if there are sets X V .G/ G G 0 0 F / C c .F / < 1, then we have FP E and w.l.o.g. ´ … X (otherwise take the P complement), and hence b.X / 2 e2E.GŒX/ xe C e2F [DX .u.e/ 2xe / < 1. P P Conversely, if b.X / 2 e2E.GŒX/ xe C e2F .u.e/ 2xe / < 1 for some X V .G/ and F ıG .X /, then w.l.o.g. DX F DX [ E 0 , and hence c.ıGN .X / n .F n DX // C c 0 .F n DX / < 1. N and F Hence the separation problem reduces to finding sets X V .G/ 0 ıGN .X / with jX \ T j C jF j odd and c.ıGN .X / n F / C c .F / minimum. This can be done with Lemma 12.20. A generalization of this result has been found by Caprara and Fischetti [1996]. The Padberg-Rao Theorem implies: Corollary 12.22. The MAXIMUM WEIGHT b-MATCHING PROBLEM can be solved in polynomial time. Proof: By Corollary 3.33 we have to solve the LP given in Theorem 12.3. By Theorem 4.21 it suffices to have a polynomial-time algorithm for the SEPARATION PROBLEM. Such an algorithm is provided by Theorem 12.21.

Exercises

315

Marsh [1979] extended Edmonds’ WEIGHTED MATCHING ALGORITHM to the MAXIMUM WEIGHT b-MATCHING PROBLEM. This combinatorial algorithm is of course more practical than using the ELLIPSOID METHOD. But Theorem 12.21 is also interesting for other purposes (see e.g. Section 21.4). See also Gerards [1995]. Combinatorial algorithms with strongly polynomial running time were described by Anstee [1987], and for the unweighted case by Goldberg and Karzanov [2004].

Exercises

1. Show that a minimum weight perfect simple 2-matching in an undirected graph G can be found in O.n6 / time. 2. Let G be an undirected graph and b1 ; b2 W V .G/ P ! N. Describe the convex hull of functions f W E.G/ ! ZC with b1 .v/ e2ı.v/ f .e/ b2 .v/. Hint: For X; Y V .G/ with X \ Y D ; consider the constraint 6 0 17 6 7 X X X 61 X 7 f .e/ f .e/ 4 @ b2 .x/ b1 .y/A5 ; 2 e2E.GŒX/

3.

4.

5.

6.

7.

e2E.GŒY /[E.Y;Z/

x2X

y2Y

where Z WD V .G/ n .X [ Y /. Use Theorem 12.3. (Schrijver [1983]) Can one generalize the result of Exercise 2 further by introducing lower and upper capacities on the edges? Note: This can be regarded as an undirected version of the problem in Exercise 2 of Chapter 9. For a common generalization of both problems and also the MINIMUM WEIGHT T -JOIN PROBLEM see the papers of Edmonds and Johnson [1973], and Schrijver [1983]. Even here a description of the polytope that is TDI is known. Prove Theorem 12.4. Hint: For the sufficiency, use Tutte’s Theorem 10.13 and the constructions in the proofs of Theorems 12.2 and 12.3. The subgraph degree polytope of a graph G is defined to be the convex hull of V .G/ all vectors b 2 ZC such that G has a perfect simple b-matching. Prove that its dimension is jV .G/j k, where k is the number of connected components of G that are bipartite. Given an undirected graph, an odd cycle cover is defined to be a subset of edges containing at least one edge of each odd circuit. Show how to find in polynomial time a minimum weight odd cycle cover in a planar graph with nonnegative weights on the edges. Can you also solve the problem for general weights? Hint: Consider the UNDIRECTED CHINESE POSTMAN PROBLEM in the planar dual graph and use Theorem 2.26 and Corollary 2.45. Consider the MAXIMUM WEIGHT CUT PROBLEM in planar graphs: Given an undirected planar graph G with weights c W E.G/ ! RC , we look for a

316

12 b-Matchings and T -Joins

maximum weight cut. Can one solve this problem in polynomial time? Hint: Use Exercise 6. Note: For general graphs this problem is NP-hard; see Theorem 16.6. (Hadlock [1975]) 8. Given a graph G with weights c W E.G/ ! RC and a set T V .G/ with jT j even. We construct a new graph G 0 by setting V .G 0 / WD f.v; e/ W v 2 e 2 E.G/g [ fvN W v 2 V .G/; jıG .v/j C jfvg \ T j oddg; E.G 0 / WD ff.v; e/; .w; e/g W e D fv; wg 2 E.G/g [ ff.v; e/; .v; f /g W v 2 V .G/; e; f 2 ıG .v/; e 6D f g [ ffv; N .v; e/g W v 2 e 2 E.G/; vN 2 V .G 0 /g; and define c 0 .f.v; e/; .w; e/g/ WD c.e/ for e D fv; wg 2 E.G/ and c 0 .e 0 / D 0 for all other edges e 0 of G 0 . Show that a minimum weight perfect matching in G 0 corresponds to a minimum weight T -join in G. Is this reduction preferable to the one used in the proof of Theorem 12.10?

9. The following problem combines simple perfect b-matchings and T -joins. We are given an undirected graph G with weights c W E.G/ ! R, a partition of the : : vertex set V .G/ D R [ S [ T , and a function b W R ! ZC . We ask for a minimum weight subset of edges J E.G/ such that jJ \ ı.v/j D b.v/ for v 2 R, jJ \ı.v/j is even for v 2 S , and jJ \ı.v/j is odd for v 2 T . Show how to reduce this problem to a MINIMUM WEIGHT PERFECT MATCHING PROBLEM. Hint: Consider the constructions in Section 12.1 and Exercise 8. 10. We consider the UNDIRECTED MINIMUM MEAN CYCLE PROBLEM: Given an undirected graph G and weights c W E.G/ ! R, find a circuit C in G // whose mean weight c.E.C is minimum. Let .G; c/ be an instance. Let D be jE.C /j the set of ;-joins in G. For a 2 R and X 2 D let c a .X / WD c.X / ajX j and a. Prove: cNa .X / WD c.X/ jXj (a) For any a 2 R, we can find an element X 2 D with c a .X / minimum in O.n3 / time. (b) Let a 2 R such that c a .Y / 0 for all Y 2 D, and let X 2 D with c a .X / minimum. Then there exists a Y 2 D with c aCb .Y / 0, where b D cNa .X /. (c) Consider the following procedure. Start with a D maxfc.e/ W e 2 E.G/g. Compute an element X 2 D with c a .X / minimum. Stop if c a .X / D 0. Otherwise replace a by a C cNa .X / and iterate. Show that jX j is getting smaller in each iteration. (d) Show that the algorithm in (c) computes an optimum solution in O.n5 / time. Note: The running time can be improved to O.n2 m C n3 log n/. Essentially the same algorithm works also for other minimum ratio problems. (Karzanov [1985], Barahona [1993], Babenko and Karzanov [2009])

Exercises

317

11. Given a graph G and a set T V .G/, describe a linear-time algorithm to find a T -join in G or decide that none exists. Hint: Consider a maximal forest in G. 12. Let G be an undirected graph, T V .G/ with jT j even, and F E.G/. Prove: F has nonempty intersection with every T -join if and only if F contains a T -cut. F has nonempty intersection with every T -cut if and only if F contains a T -join. 13. Let G be a graph and F E.G/. Prove that there exists a set A with F A E.G/ such that .V .G/; A/ is Eulerian if and only if G contains no cut B with B F and jBj odd.

14. Let G be a planar 2-connected graph with a fixed embedding, let C be the circuit bounding the outer face, and let T be an even cardinality subset of V .C /. Prove that the minimum cardinality of a T -join equals the maximum number of pairwise edge-disjoint T -cuts. Hint: Colour the edges of C red and blue such that, when traversing C , colours change precisely at the vertices in T . Consider the planar dual graph, split the vertex representing the outer face into a red and a blue vertex, and apply Menger’s Theorem 8.9. 15. Prove Theorem 12.18 using Theorem 11.15 and the construction of Exercise 8. (Edmonds and Johnson [1973]) 16. Let G be an undirected graph and T V .G/ with jT j even. Prove that the convex hull of the incidence vectors of all T -joins in G is the set of all vectors x 2 Œ0; 1E.G/ satisfying X X xe C .1 xe / 1 e2ıG .X/nF

e2F

for all X V .G/ and F ıG .X / with jX \ T j C jF j odd. Hint: Use Theorems 12.18 and 12.11. 17. Let G be an undirected graph. Show that the cone generated by the incidence vectors of all circuits in G is 8 9 < = X x 2 RE.G/ W x 0; x.e 0 / x.e/ for all cuts C in G and e 2 C : : ; 0 e 2C nfeg

Hint: Use Exercise 16. 18. Describe the UNDIRECTED MINIMUM MEAN CYCLE PROBLEM as a linear program with polynomially many variables and constraints. Hint: Use Exercise 17, add the constraint x.E.G// D 1, and use the Max-FlowMin-Cut Theorem. (Barahona [1993]) Note: Since we need extra variables, this is called an extended formulation. Barahona [1993] also showed how to solve the MINIMUM WEIGHT T -JOIN PROBLEM by starting with any T -join and successively applying Proposition

318

12 b-Matchings and T -Joins

12.8, looking for a minimum mean weight circuit, where weights of the current T -join are multiplied by 1. The number of iterations can be bounded by O.m2 log n/. Hence one can solve the MINIMUM WEIGHT T -JOIN PROBLEM (and hence the MINIMUM WEIGHT PERFECT MATCHING PROBLEM) by solving a polynomial number of polynomial-size LPs. Nevertheless, no polynomialsize LP description for weighted matching is known (cf. Yannakakis [1991]). 19. Let G be an undirected graph and T V .G/ with jT j D 2k even. Prove that the minimum cardinality of a T -cut in G equals the maximum of minkiD1 si ;ti over all pairings T D fs1 ; t1 ; s2 ; t2 ; : : : ; sk ; tk g. (s;t denotes the maximum number of pairwise edge-disjoint s-t-paths.) Can you think of a weighted version of this min-max formula? Hint: Use Theorem 12.19. (Rizzi [2002]) 20. This exercise gives an algorithm for the MINIMUM CAPACITY T -CUT PROBLEM without using Gomory-Hu trees. The algorithm is recursive and – given G, u and T – proceeds as follows: 1. First wePfind a set X V .G/ with T \ X 6D ; and T n X 6D ;, such that u.X / WD e2ıG .X/ u.e/ is minimum (cf. Exercise 30 of Chapter 8). If jT \ X j happens to be odd, we are done (return X ). 2. Otherwise we apply the algorithm recursively first to G, u and T \ X , and then to G, u and T n X . We obtain a set Y V .G/ with j.T \ X / \ Y j odd and u.Y / minimum and a set Z V .G/ with j.T n X / \ Zj odd and u.Z/ minimum. W.l.o.g. T n X 6 Y and X \ T 6 Z (otherwise replace Y by V .G/ n Y and/or Z by V .G/ n Z). 3. If u.X \ Y / < u.Z n X / then return X \ Y else return Z n X . Show that this algorithm works correctly and that its running time is O.n5 /, where n D jV .G/j. 21. Show how to solve the MAXIMUM WEIGHT b-MATCHING PROBLEM for the special case when b.v/ is even for all v 2 V .G/ in strongly polynomial time. Hint: Reduction to a MINIMUM COST FLOW PROBLEM as in Exercise 10 of Chapter 9.

References General Literature: Cook, W.J., Cunningham, W.H., Pulleyblank, W.R., and Schrijver, A. [1998]: Combinatorial Optimization. Wiley, New York 1998, Sections 5.4 and 5.5 Frank, A. [1996]: A survey on T -joins, T -cuts, and conservative weightings. In: Combinatorics, Paul Erd˝os is Eighty; Volume 2 (D. Miklós, V.T. Sós, T. Sz˝onyi, eds.), Bolyai Society, Budapest 1996, pp. 213–252 Gerards, A.M.H. [1995]: Matching. In: Handbooks in Operations Research and Management Science; Volume 7: Network Models (M.O. Ball, T.L. Magnanti, C.L. Monma, G.L. Nemhauser, eds.), Elsevier, Amsterdam 1995, pp. 135–224

References

319

Lovász, L., and Plummer, M.D. [1986]: Matching Theory. Akadémiai Kiadó, Budapest 1986, and North-Holland, Amsterdam 1986 Schrijver, A. [1983]: Min-max results in combinatorial optimization; Section 6. In: Mathematical Programming; The State of the Art – Bonn 1982 (A. Bachem, M. Grötschel, B. Korte, eds.), Springer, Berlin 1983, pp. 439–500 Schrijver, A. [2003]: Combinatorial Optimization: Polyhedra and Efficiency. Springer, Berlin 2003, Chapters 29–33

Cited References: Anstee, R.P. [1987]: A polynomial algorithm for b-matchings: an alternative approach. Information Processing Letters 24 (1987), 153–157 Babenko, M.A. and Karzanov, A.V. [2009]: Minimum mean cycle problem in bidirected and skew-symmetric graphs. Discrete Optimization 6 (2009), 92–97 Barahona, F. [1993]: Reducing matching to polynomial size linear programming. SIAM Journal on Optimization 3 (1993), 688–695 Caprara, A., and Fischetti, M. [1996]: f0; 12 g-Chvátal-Gomory cuts. Mathematical Programming 74 (1996), 221–235 Edmonds, J. [1965]: Maximum matching and a polyhedron with (0,1) vertices. Journal of Research of the National Bureau of Standards B 69 (1965), 125–130 Edmonds, J., and Johnson, E.L. [1970]: Matching: A well-solved class of integer linear programs. In: Combinatorial Structures and Their Applications; Proceedings of the Calgary International Conference on Combinatorial Structures and Their Applications 1969 (R. Guy, H. Hanani, N. Sauer, J. Schönheim, eds.), Gordon and Breach, New York 1970, pp. 69–87 Edmonds, J., and Johnson, E.L. [1973]: Matching, Euler tours and the Chinese postman problem. Mathematical Programming 5 (1973), 88–124 Gabow, H.N. [1983]: An efficient reduction technique for degree-constrained subgraph and bidirected network flow problems. Proceedings of the 15th Annual ACM Symposium on Theory of Computing (1983), 448–456 Goldberg, A.V., and Karzanov, A.V. [2004]: Maximum skew-symmetric flows and matchings. Mathematical Programming A 100 (2004), 537–568 Guan, M. [1962]: Graphic programming using odd and even points. Chinese Mathematics 1 (1962), 273–277 Hadlock, F. [1975]: Finding a maximum cut of a planar graph in polynomial time. SIAM Journal on Computing 4 (1975), 221–225 Karzanov, A.V. [1985]: Minimum mean weight cuts and cycles in directed graphs. In: Kachestvennye i Priblizhennye Metody Issledovaniya Operatornykh Uravneni˘ı (V.S. Klimov, ed.), Yaroslavl State University Press, Yaroslavl 1985, pp. 72–83 [in Russian]. English translation: American Mathematical Society Translations Ser. 2, Vol. 158 (1994), 47–55 Karzanov, A.V. [1986]: An algorithm for determining a maximum packing of odd-terminus cuts and its applications. In: Isslidovaniya po Prikladno˘ı Teorii Grafov (A.S. Alekseev, ed.), Nauka Siberian Dept., Novosibirsk, 1986, pp. 126–140 [in Russian]. English translation: American Mathematical Society Translations Ser. 2, Vol. 158 (1994), 57–70 Letchford, A.N., Reinelt, G., and Theis, D.O. [2008]: Odd minimum cut sets and b-matchings revisited. SIAM Journal on Discrete Mathematics 22 (2008), 1480–1487 Marsh, A.B. [1979]: Matching algorithms. Ph.D. thesis, Johns Hopkins University, Baltimore 1979

320

12 b-Matchings and T -Joins

Padberg, M.W., and Rao, M.R. [1982]: Odd minimum cut-sets and b-matchings. Mathematics of Operations Research 7 (1982), 67–80 Pulleyblank, W.R. [1973]: Faces of matching polyhedra. Ph.D. thesis, University of Waterloo, 1973 Pulleyblank, W.R. [1980]: Dual integrality in b-matching problems. Mathematical Programming Study 12 (1980), 176–196 Rizzi, R. [2002]: Minimum T -cuts and optimal T -pairings. Discrete Mathematics 257 (2002), 177–181 Seb˝o, A. [1987]: A quick proof of Seymour’s theorem on T -joins. Discrete Mathematics 64 (1987), 101–103 Seymour, P.D. [1981]: On odd cuts and multicommodity flows. Proceedings of the London Mathematical Society (3) 42 (1981), 178–192 Tutte, W.T. [1952]: The factors of graphs. Canadian Journal of Mathematics 4 (1952), 314–328 Tutte, W.T. [1954]: A short proof of the factor theorem for finite graphs. Canadian Journal of Mathematics 6 (1954), 347–352 Yannakakis, M. [1991]: Expressing combinatorial optimization problems by linear programs. Journal of Computer and System Sciences 43 (1991), 441–466

13 Matroids

Many combinatorial optimization problems can be formulated as follows. Given a set system .E; F /, i.e. a finite set E and some F 2E , and a cost function c W F ! R, find an element of F whose cost is minimum or maximum. PIn the following we consider modular functions c, i.e. assume that c.X / D c.;/C x2X .c.fxg/c.;// for all X E; equivalently we are given a function c W E ! R and write c.X / D P e2X c.e/. In this chapter we restrict ourselves to those combinatorial optimization problems where F describes an independence system (i.e. is closed under subsets) or even a matroid. The results of this chapter generalize several results obtained in previous chapters. In Section 13.1 we introduce independence systems and matroids and show that many combinatorial optimization problems can be described in this context. There are several equivalent axiom systems for matroids (Section 13.2) and an interesting duality relation discussed in Section 13.3. The main reason why matroids are important is that a simple greedy algorithm can be used for optimization over matroids. We analyze greedy algorithms in Section 13.4 before turning to the problem of optimizing over the intersection of two matroids. As shown in Sections 13.5 and 13.7 this problem can be solved in polynomial time. This also solves the problem of covering a matroid by independent sets as discussed in Section 13.6.

13.1 Independence Systems and Matroids Definition 13.1. A set system .E; F / is an independence system if (M1) ; 2 F ; (M2) If X Y 2 F then X 2 F . The elements of F are called independent, the elements of 2E n F dependent. Minimal dependent sets are called circuits, maximal independent sets are called bases. For X E, the maximal independent subsets of X are called bases of X . Definition 13.2. Let .E; F / be an independence system. For X E we define the rank of X by r.X / WD maxfjY j W Y X; Y 2 F g. Moreover, we define the closure of X by .X / WD fy 2 E W r.X [ fyg/ D r.X /g.

B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__13, c Springer-Verlag Berlin Heidelberg 2012

321

322

13 Matroids

Throughout this chapter, .E; F / will be an independence system, and c W E ! R will be a cost function. We shall concentrate on the following two problems:

MAXIMIZATION PROBLEM FOR INDEPENDENCE SYSTEMS Instance: Task:

An independence system .E; F/ and c W E ! R. P Find an X 2 F such that c.X / WD e2X c.e/ is maximum.

MINIMIZATION PROBLEM FOR INDEPENDENCE SYSTEMS Instance:

An independence system .E; F/ and c W E ! R.

Task:

Find a basis B such that c.B/ is minimum.

The instance specification is somewhat vague. The set E and the cost function c are given explicitly as usual. However, the set F is usually not given by an explicit list of its elements. Rather one assumes an oracle which – given a subset F E – decides whether F 2 F . We shall return to this question in Section 13.4. The following list shows that many combinatorial optimization problems actually have one of the above two forms: (1) MAXIMUM WEIGHT STABLE SET PROBLEM Given a graph G and weights c W V .G/ ! R, find a stable set X in G of maximum weight. Here E D V .G/ and F D fF E W F is stable in Gg. (2) TSP Given a complete undirected graph G and weights c W E.G/ ! RC , find a minimum weight Hamiltonian circuit in G. Here E D E.G/ and F D fF E W F is a subset of edges of a Hamiltonian circuit in Gg. (3) SHORTEST PATH PROBLEM Given a graph G (directed or undirected), c W E.G/ ! R and s; t 2 V .G/ such that t is reachable from s, find a shortest s-t-path in G with respect to c. Here E D E.G/ and F D fF E W F is a subset of edges of an s-t-pathg. (4) KNAPSACK PROBLEM Given n 2 N and nonnegative .1 i n/ and W , find a subset P numbers ci ; wi P S f1; : : : ; ng such that j 2S wj W and j 2S cj is maximum. n o P Here E D f1; : : : ; ng and F D F E W j 2F wj W . (5) MINIMUM SPANNING TREE PROBLEM Given a connected undirected graph G and weights c W E.G/ ! R, find a minimum weight spanning tree in G. Here E D E.G/ and the elements of F are the edge sets of the forests in G. (6) MAXIMUM WEIGHT FOREST PROBLEM Given an undirected graph G and weights c W E.G/ ! R, find a maximum weight forest in G. Here .E; F / is as in (5).

13.1

Independence Systems and Matroids

323

(7) STEINER TREE PROBLEM Given a connected undirected graph G, weights c W E.G/ ! RC , and a set T V .G/ of terminals, find a Steiner tree for T , i.e. a tree S with T V .S / and E.S / E.G/, such that c.E.S // is minimum. Here E D E.G/ and F contains all subsets of edges of Steiner trees for T . (8) MAXIMUM WEIGHT BRANCHING PROBLEM Given a digraph G and weights c W E.G/ ! R, find a maximum weight branching in G. Here E D E.G/ and F contains the edge sets of the branchings in G. (9) MAXIMUM WEIGHT MATCHING PROBLEM Given an undirected graph G and weights c W E.G/ ! R, find a maximum weight matching in G. Here E D E.G/ and F is the set of matchings in G. This list contains NP-hard problems ((1),(2),(4),(7)) as well as polynomially solvable problems ((5),(6),(8),(9)). Problem (3) is NP-hard in the above form but polynomially solvable for nonnegative weights. (NP-hardness is introduced in Chapter 15.) Definition 13.3. An independence system is a matroid if (M3) If X; Y 2 F and jX j > jY j, then there is an x 2 X n Y with Y [ fxg 2 F . The name matroid points out that the structure is a generalization of matrices. This will become clear by our first example: Proposition 13.4. The following independence systems .E; F / are matroids: (a) E F (b) E F (c) E (d) E (s (e) E F

is the set of columns of a matrix A over some field, and WD fF E W The columns in F are linearly independent over that fieldg. is the set of edges of some undirected graph G and WD fF E W .V .G/; F / is a forestg. is a finite set, k a nonnegative integer, and F WD fF E W jF j kg. is the set of edges of some undirected graph G, S a stable set in G, ks 2 ZC 2 S ), and F WD fF E W jıF .s/j ks for all s 2 S g. is the set of edges of some digraph G, S V .G/, ks 2 ZC (s 2 S ), and WD fF E W jıF .s/j ks for all s 2 S g.

Proof: In all cases it is obvious that .E; F / is indeed an independence system. So it remains to show that (M3) holds. For (a) this is well-known from linear algebra, for (c) it is trivial. To prove (M3) for (b), let X; Y 2 F and suppose Y [ fxg 62 F for all x 2 X n Y . We show that jX j jY j. For each edge x D fv; wg 2 X , v and w are in the same connected component of .V .G/; Y /. Hence each connected component Z V .G/ of .V .G/; X / is a subset of a connected component of .V .G/; Y /. So the number p of connected components of the forest .V .G/; X / is greater than or equal to the number q of connected components of the forest .V .G/; Y /. But then jV .G/j jX j D p q D jV .G/j jY j, implying jX j jY j.

324

13 Matroids

To verify (M3) for (d), let X; Y 2 F with jX j > jY j. Let S 0 WD fs 2 S W jıY .s/j D ks g. As jX j > jY j and jıX .s/j ks for all s 2 S 0 , there exists an e 2 X n Y with e … ı.s/ for s 2 S 0 . Then Y [ feg 2 F . For (e) the proof is identical except for replacing ı by ı . Some of these matroids have special names: The matroid in (a) is called the vector matroid of A. Let M be a matroid. If there is a matrix A over the field F such that M is the vector matroid of A, then M is called representable over F . There are matroids that are not representable over any field. The matroid in (b) is called the cycle matroid of G and will sometimes be denoted by M.G/. A matroid that is the cycle matroid of some graph, which may contain loops, is called a graphic matroid. The matroids in (c) are called uniform matroids. In our list of independence systems at the beginning of this section, the only matroids are the graphic matroids in (5) and (6). To check that all the other independence systems in the above list are not matroids in general is easily proved with the help of the following theorem (Exercise 1): Theorem 13.5. Let .E; F / be an independence system. Then the following statements are equivalent: (M3) If X; Y 2 F and jX j > jY j, then there is an x 2 X n Y with Y [ fxg 2 F . (M30 ) If X; Y 2 F and jX j D jY jC1, then there is an x 2 X nY with Y [fxg 2 F. (M300 ) For each X E, all bases of X have the same cardinality. Proof: Trivially, (M3),(M30) and (M3))(M300). To prove (M300 ))(M3), let X; Y 2 F and jX j > jY j. By (M300 ), Y cannot be a basis of X [ Y . So there must be an x 2 .X [ Y / n Y D X n Y such that Y [ fxg 2 F . Sometimes it is useful to have a second rank function: Definition 13.6. Let .E; F / be an independence system. For X E we define the lower rank by .X / WD minfjY j W Y X; Y 2 F and Y [ fxg … F for all x 2 X n Y g: The rank quotient of .E; F / is defined by q.E; F / WD min

F E

.F / : r.F /

Proposition 13.7. Let .E; F / be an independence system. Then q.E; F / 1. Furthermore, .E; F / is a matroid if and only if q.E; F/ D 1. Proof: q.E; F / 1 follows from the definition. q.E; F / D 1 is obviously equivalent to (M300 ). To estimate the rank quotient, the following statement can be used:

13.2

Other Matroid Axioms

325

Theorem 13.8. (Hausmann, Jenkyns and Korte [1980]) Let .E; F / be an independence system. If, for any A 2 F and e 2 E, A [ feg contains at most p circuits, then q.E; F / p1 . jJ j Proof: Let F E and J; K two bases of F . We show jKj p1 . Let J n K D fe1 ; : : : ; e t g. We construct a sequence K D K0 ; K1 ; : : : ; K t of independent subsets of J [ K such that J \ K Ki , Ki \ fe1 ; : : : ; e t g D fe1 ; : : : ; ei g and jKi 1 n Ki j p for i D 1; : : : ; t. Since Ki [ fei C1 g contains at most p circuits and each such circuit must meet Ki n J (because J is independent), there is an X Ki n J such that jX j p and .Ki n X / [ fei C1g 2 F . We set Ki C1 WD .Ki n X / [ fei C1 g. Now J K t 2 F . Since J is a basis of F , J D K t . We conclude that

jK n J j D

t X

jKi 1 n Ki j pt D p jJ n Kj;

i D1

proving jKj p jJ j.

This shows that in example (9) we have q.E; F / 12 (see also Exercise 1 of Chapter 10). In fact q.E; F / D 12 iff G contains a path of length 3 as a subgraph (otherwise q.E; F / D 1). For the independence system in example (1) of our list, the rank quotient can become arbitrarily small (choose G to be a star). In Exercise 6, the rank quotients for other independence systems will be discussed.

13.2 Other Matroid Axioms In this section we consider other axiom systems defining matroids. They characterize fundamental properties of the family of bases, the rank function, the closure operator and the family of circuits of a matroid. Theorem 13.9. Let E be a finite set and B 2E . B is the set of bases of some matroid .E; F / if and only if the following holds: (B1) B 6D ;; (B2) For any B1 ; B2 2 B and x 2 B1 n B2 there exists a y 2 B2 n B1 with .B1 n fxg/ [ fyg 2 B. Proof: The set of bases of a matroid satisfies (B1) (by (M1)) and (B2): For bases B1 ; B2 and x 2 B1 n B2 we have that B1 n fxg is independent. By (M3) there is some y 2 B2 n B1 such that .B1 n fxg/ [ fyg is independent. Indeed, it must be a basis, because all bases of a matroid have the same cardinality. On the other hand, let B satisfy (B1) and (B2). We first show that all elements of B have the same cardinality: Otherwise let B1 ; B2 2 B with jB1 j > jB2 j such that jB1 \ B2 j is maximum. Let x 2 B1 n B2 . By (B2) there is a y 2 B2 n B1 with .B1 n fxg/ [ fyg 2 B, contradicting the maximality of jB1 \ B2 j.

326

13 Matroids

Now let F WD fF E W there exists a B 2 B with F Bg: .E; F / is an independence system, and B is the family of its bases. To show that .E; F / satisfies (M3), let X; Y 2 F with jX j > jY j. Let X B1 2 B and Y B2 2 B, where B1 and B2 are chosen such that jB1 \ B2 j is maximum. If B2 \ .X n Y / 6D ;, we are done because we can augment Y . We claim that the other case, B2 \ .X n Y / D ;, is impossible. Namely, with this assumption we get jB1 \ B2 j C jY n B1 j C j.B2 n B1 / n Y j D jB2 j D jB1 j jB1 \ B2 j C jX n Y j: Since jX n Y j > jY n X j jY n B1 j, this implies .B2 n B1 / n Y 6D ;. So let y 2 .B2 n B1 / n Y . By (B2) there exists an x 2 B1 n B2 with .B2 n fyg/ [ fxg 2 B, contradicting the maximality of jB1 \ B2 j. See Exercise 8 for a similar statement. A very important property of matroids is that the rank function is submodular: Theorem 13.10. Let E be a finite set and r W 2E ! ZC . Then the following statements are equivalent: (a) r is the rank function of a matroid .E; F / (and F D fF E W r.F / D jF jg). (b) For all X; Y E: (R1) r.X / jX j; (R2) If X Y then r.X / r.Y /; (R3) r.X [ Y / C r.X \ Y / r.X / C r.Y /. (c) For all X E and x; y 2 E: (R10 ) r.;/ D 0; (R20 ) r.X / r.X [ fyg/ r.X / C 1; (R30 ) If r.X [ fxg/ D r.X [ fyg/ D r.X / then r.X [ fx; yg/ D r.X /. Proof: (a))(b): If r is a rank function of an independence system .E; F /, (R1) and (R2) evidently hold. If .E; F / is a matroid, we can also show (R3): Let X; Y E, and let A be a basis of X \ Y . By (M3), A can be extended to : : a basis A [ B of X and to a basis .A [ B/ [ C of X [ Y . Then A [ C is an independent subset of Y , so r.X / C r.Y / jA [ Bj C jA [ C j D 2jAj C jBj C jC j D jA [ B [ C j C jAj D r.X [ Y / C r.X \ Y /: (b))(c): (R10 ) is implied by (R1). r.X / r.X [ fyg/ follows from (R2). By (R3) and (R1),

13.2

Other Matroid Axioms

327

r.X [ fyg/ r.X / C r.fyg/ r.X \ fyg/ r.X / C r.fyg/ r.X / C 1; proving (R20 ). (R30 ) is trivial for x D y. For x 6D y we have, by (R2) and (R3), 2r.X / r.X / C r.X [ fx; yg/ r.X [ fxg/ C r.X [ fyg/; implying (R30 ). (c))(a): Let r W 2E ! ZC be a function satisfying (R10 )–(R30 ). Let F WD fF E W r.F / D jF jg: We claim that .E; F / is a matroid. (M1) follows from (R10 ). (R20 ) implies r.X / jX j for all X E. If Y 2 F , y 2 Y and X WD Y n fyg, we have jX j C 1 D jY j D r.Y / D r.X [ fyg/ r.X / C 1 jX j C 1; so X 2 F. This implies (M2). Now let X; Y 2 F and jX j D jY j C 1. Let X n Y D fx1 ; : : : ; xk g. Suppose that (M30 ) is violated, i.e. r.Y [ fxi g/ D jY j for i D 1; : : : ; k. Then by (R30 ) r.Y [ fx1 ; xi g/ D r.Y / for i D 2; : : : ; k. Repeated application of this argument yields r.Y / D r.Y [ fx1 ; : : : ; xk g/ D r.X [ Y / r.X /, a contradiction. So .E; F / is indeed a matroid. To show that r is the rank function of this matroid, we have to prove that r.X / D maxfjY j W Y X; r.Y / D jY jg for all X E. So let X E, and let Y a maximum subset of X with r.Y / D jY j. For all x 2 X n Y we have r.Y [ fxg/ < jY j C 1, so by (R20 ) r.Y [ fxg/ D jY j. Repeated application of (R30 ) implies r.X / D jY j. Theorem 13.11. Let E be a finite set and W 2E ! 2E a function. is the closure operator of a matroid .E; F / if and only if the following conditions hold for all X; Y E and x; y 2 E: (S1) (S2) (S3) (S4)

X .X /; X Y E implies .X / .Y /; .X / D ..X //; If y … .X / and y 2 .X [ fxg/ then x 2 .X [ fyg/.

Proof: If is the closure operator of a matroid, then (S1) holds trivially. For X Y and ´ 2 .X / we have by (R3) and (R2) r.X / C r.Y / D r.X [ f´g/ C r.Y / r..X [ f´g/ \ Y / C r.X [ f´g [ Y / r.X / C r.Y [ f´g/; implying ´ 2 .Y / and thus proving (S2). By repeated application of (R30 ) we have r..X // D r.X / for all X , which implies (S3).

328

13 Matroids

To prove (S4), suppose that there are X; x; y with y … .X /, y 2 .X [ fxg/ and x … .X [fyg/. Then r.X [fyg/ D r.X /C1, r.X [fx; yg/ D r.X [fxg/ and r.X [fx; yg/ D r.X [fyg/C1. Thus r.X [fxg/ D r.X /C2, contradicting (R20 ). To show the converse, let W 2E ! 2E be a function satisfying (S1)–(S4). Let F WD fX E W x … .X n fxg/ for all x 2 X g: We claim that .E; F / is a matroid. (M1) is trivial. For X Y 2 F and x 2 X we have x … .Y n fxg/ .X n fxg/, so X 2 F and (M2) holds. To prove (M3) we need the following statement: Claim: For X 2 F and Y E with jX j > jY j we have X 6 .Y /. We prove the claim by induction on jY n X j. If Y X , then let x 2 X n Y . Since X 2 F we have x … .X n fxg/ .Y / by (S2). Hence x 2 X n .Y / as required. If jY n X j > 0, then let y 2 Y n X . By the induction hypothesis there exists an x 2 X n .Y n fyg/. If x 62 .Y /, then we are done. Otherwise x … .Y n fyg/ but x 2 .Y / D ..Y n fyg/ [ fyg/, so by (S4) y 2 ..Y n fyg/ [ fxg/. By (S1) we get Y ..Y n fyg/ [ fxg/ and thus .Y / ..Y n fyg/ [ fxg/ by (S2) and (S3). Applying the induction hypothesis to X and .Y n fyg/ [ fxg (note that x 6D y) yields X 6 ..Y n fyg/ [ fxg/, so X 6 .Y / as required. Having proved the claim we can easily verify (M3). Let X; Y 2 F with jX j>jY j. By the claim there exists an x 2 X n .Y /. Now for each ´ 2 Y [ fxg we have ´ … .Y n f´g/, because Y 2 F and x … .Y / D .Y n fxg/. By (S4) ´ … .Y n f´g/ and x … .Y / imply ´ … ..Y n f´g/ [ fxg/ ..Y [ fxg/ n f´g/. Hence Y [ fxg 2 F . So (M3) indeed holds and .E; F/ is a matroid, say with rank function r and closure operator 0 . It remains to prove that D 0 . By definition, 0 .X / D fy 2 E W r.X [ fyg/ D r.X /g and r.X / D maxfjY j W Y X; y … .Y n fyg/ for all y 2 Y g for all X E. Let X E. To show 0 .X / .X /, let ´ 2 0 .X / n X . Let Y be a basis of X . Since r.Y [ f´g/ r.X [ f´g/ D r.X / D jY j < jY [ f´gj we have y 2 ..Y [ f´g/ n fyg/ for some y 2 Y [ f´g. If y D ´, then we have ´ 2 .Y /. Otherwise (S4) and y … .Y n fyg/ also yield ´ 2 .Y /. Hence by (S2) ´ 2 .X /. Together with (S1) this implies 0 .X / .X /. Now let ´ … 0 .X /, i.e. r.X [ f´g/ > r.X /. Let now Y be a basis of X [ f´g. Then ´ 2 Y and jY n f´gj D jY j 1 D r.X [ f´g/ 1 D r.X /. Therefore Y n f´g is a basis of X , implying X 0 .Y nf´g/ .Y nf´g/, and thus .X / .Y nf´g/. As ´ … .Y n f´g/, we conclude that ´ 62 .X /. Theorem 13.12. Let E be a finite set and C 2E . C is the set of circuits of an independence system .E; F /, where F D fF E W there exists no C 2 C with C F g, if and only if the following conditions hold: (C1) ; … C;

13.3

Duality

329

(C2) For any C1 ; C2 2 C, C1 C2 implies C1 D C2 . Moreover, if C is the set of circuits of an independence system .E; F /, then the following statements are equivalent: (a) .E; F / is a matroid. (b) For any X 2 F and e 2 E, X [ feg contains at most one circuit. (C3) For any C1 ; C2 2 C with C1 6D C2 and e 2 C1 \ C2 there exists a C3 2 C with C3 .C1 [ C2 / n feg. (C30 ) For any C1 ; C2 2 C, e 2 C1 \ C2 and f 2 C1 n C2 there exists a C3 2 C with f 2 C3 .C1 [ C2 / n feg. Proof: By definition, the family of circuits of any independence system satisfies (C1) and (C2). If C satisfies (C1), then .E; F / is an independence system. If C also satisfies (C2), it is the set of circuits of this independence system. (a))(C30 ): Let C be the family of circuits of a matroid, and let C1 ; C2 2 C, e 2 C1 \ C2 and f 2 C1 n C2 . By applying (R3) twice we have jC1 j 1 C r..C1 [ C2 / n fe; f g/ C jC2 j 1 D r.C1 / C r..C1 [ C2 / n fe; f g/ C r.C2 / r.C1 / C r..C1 [ C2 / n ff g/ C r.C2 n feg/ r.C1 n ff g/ C r.C1 [ C2 / C r.C2 n feg/ D jC1 j 1 C r.C1 [ C2 / C jC2 j 1: So r..C1 [ C2 / n fe; f g/ D r.C1 [ C2 /. Let B be a basis of .C1 [ C2 / n fe; f g. Then B [ ff g contains a circuit C3 , with f 2 C3 .C1 [ C2 / n feg as required. (C30 ))(C3): trivial. (C3))(b): If X 2 F and X [ feg contains two circuits C1 ; C2 , (C3) implies .C1 [ C2 / n feg … F . However, .C1 [ C2 / n feg is a subset of X . (b))(a): Follows from Theorem 13.8 and Proposition 13.7. Especially property (b) will be used often. For X 2 F and e 2 E such that X [ feg 62 F we write C.X; e/ for the unique circuit in X [ feg. If X [ feg 2 F we write C.X; e/ WD ;.

13.3 Duality Another basic concept in matroid theory is duality. Definition 13.13. Let .E; F / be an independence system. We define the dual of .E; F / by .E; F /, where F D fF E W there is a basis B of .E; F / such that F \ B D ;g: It is obvious that the dual of an independence system is again an independence system.

330

13 Matroids

Proposition 13.14. .E; F / D .E; F /. Proof: F 2 F , there is a basis B of .E; F / such that F \ B D ; , there is a basis B of .E; F/ such that F \ .E n B/ D ; , F 2 F . Theorem 13.15. Let .E; F / be an independence system, .E; F / its dual, and let r and r be the corresponding rank functions. (a) .E; F / is a matroid if and only if .E; F / is a matroid. (Whitney [1935]) (b) If .E; F / is a matroid, then r .F / D jF j C r.E n F / r.E/ for F E. Proof: Due to Proposition 13.14 we have to show only one direction of (a). So let .E; F / be a matroid. We define q W 2E ! ZC by q.F / WD jF j C r.E n F / r.E/. We claim that q satisfies (R1), (R2) and (R3). By this claim and Theorem 13.10, q is the rank function of a matroid. Since obviously q.F / D jF j if and only if F 2 F , we conclude that q D r , and (a) and (b) are proved. Now we prove the above claim: q satisfies (R1) because r satisfies (R2). To check that q satisfies (R2), let X Y E. Since .E; F / is a matroid, (R3) holds for r, so r.E n X / C 0 D r..E n Y / [ .Y n X // C r.;/ r.E n Y / C r.Y n X /: We conclude that r.E n X / r.E n Y / r.Y n X / jY n X j D jY j jX j (note that r satisfies (R1)), so q.X / q.Y /. It remains to show that q satisfies (R3). Let X; Y E. Using the fact that r satisfies (R3) we have q.X [ Y / C q.X \ Y / D jX [ Y j C jX \ Y j C r.E n .X [ Y // C r.E n .X \ Y // 2r.E/ D jX j C jY j C r..E n X / \ .E n Y // C r..E n X / [ .E n Y // 2r.E/ jX j C jY j C r.E n X / C r.E n Y / 2r.E/ D q.X / C q.Y /: For any graph G we have introduced the cycle matroid M.G/ which of course has a dual. For an embedded planar graph G there is also a planar dual G (which in general depends on the embedding of G/. It is interesting that the two concepts of duality coincide: Theorem 13.16. Let G be a connected planar graph with an arbitrary planar embedding, and G the planar dual. Then M.G / D .M.G// :

13.3

Duality

331

(Formally, the two matroids are isomorphic: they are identical up to renaming the elements of the ground set.) Proof: For T E.G/ we write T WD fe W e 2 E.G/ n T g, where e is the dual of edge e. We have to prove the following: Claim: T is the edge set of a spanning tree in G iff T is the edge set of a spanning tree in G .

Since .G / D G (by Proposition 2.42) and .T / D T it suffices to prove one direction of the claim. So let T E.G/, where T is the edge set of a spanning tree in G . .V .G/; T / must be connected, for otherwise a connected component would define a cut, the dual of which contains a circuit in T (Theorem 2.43). On the other hand, if .V .G/; T / contains a circuit, then the dual edge set is a cut and .V .G /; T / is disconnected. Hence .V .G/; T / is indeed a spanning tree in G. This implies that if G is planar then .M.G// is a graphic matroid. If, for any graph G, .M.G// is a graphic matroid, say .M.G// D M.G 0 /, then G 0 is evidently an abstract dual of G. By Exercise 39 of Chapter 2, the converse is also true: G is planar if and only if G has an abstract dual (Whitney [1933]). This implies that .M.G// is graphic if and only if G is planar. Note that Theorem 13.16 quite directly implies Euler’s formula (Theorem 2.32): Let G be a connected planar graph with a planar embedding, and let M.G/ be the cycle matroid of G. By Theorem 13.15 (b), r.E.G// C r .E.G// D jE.G/j. Since r.E.G// D jV .G/j 1 (the number of edges in a spanning tree) and r .E.G// D jV .G /j1 (by Theorem 13.16), we obtain that the number of faces of G is jV .G /j D jE.G/j jV .G/j C 2, Euler’s formula. (However, we used Euler’s formula in the proof of Proposition 2.42, which was used in our proof of Theorem 13.16.) Duality of independence systems has also some nice applications in polyhedral combinatorics. A set system .E; F / is called a clutter if X 6 Y for all X; Y 2 F . If .E; F / is a clutter, then we define its blocking clutter by BL.E; F / WD .E; fX E W X \ Y 6D ; for all Y 2 F ; X minimal with this propertyg/: For an independence system .E; F / and its dual .E; F / let B and B be the family of bases, and C and C the family of circuits, respectively. (Every clutter arises in both of these ways except for F D ; or F D f;g.) It follows immediately from the definitions that .E; B / D BL.E; C/ and .E; C / D BL.E; B/. Together with Proposition 13.14 this implies BL.BL.E; F// D .E; F / for every clutter .E; F /. We give some examples for clutters .E; F / and their blocking clutters .E; F 0 /. In each case E D E.G/ for some graph G: (1) F is the set of spanning trees, F 0 is the set of minimal cuts; (2) F is the set of arborescences rooted at r, F 0 is the set of minimal r-cuts; (3) F is the set of s-t-paths, F 0 is the set of minimal cuts separating s and t (this example works in undirected graphs and in digraphs);

332

13 Matroids

(4) F is the set of circuits in an undirected graph, F 0 is the set of complements of maximal forests; (5) F is the set of circuits in a digraph, F 0 is the set of minimal feedback edge sets (a feedback edge set is a set of edges whose removal makes the digraph acyclic); (6) F is the set of minimal edge sets whose contraction makes the digraph strongly connected, F 0 is the set of minimal directed cuts; (7) F is the set of minimal T -joins, F 0 is the set of minimal T -cuts. All these blocking relations can be verified easily: (1) and (2) follow directly from Theorems 2.4 and 2.5, (3), (4) and (5) are trivial, (6) follows from Corollary 2.7, and (7) from Proposition 12.7. In some cases, the blocking clutter gives a polyhedral characterization of the MINIMIZATION PROBLEM FOR INDEPENDENCE SYSTEMS for nonnegative cost functions: Definition 13.17. Let .E; F / be a clutter, .E; F 0 / its blocking clutter and P the convex hull of the incidence vectors of the elements of F . We say that .E; F / has the Max-Flow-Min-Cut property if ) ( n o X E E 0 x C y W x 2 P; y 2 RC D x 2 RC W xe 1 for all B 2 F : e2B

Examples are (2) and (7) of our list above (by Theorems 6.15 and 12.18), but also (3) and (6) (see Exercise 11). The following theorem relates the above coveringtype formulation to a packing formulation of the dual problem and allows to derive certain min-max theorems from others: Theorem 13.18. (Fulkerson [1971], Lehman [1979]) Let .E; F / be a clutter and .E; F 0 / its blocking clutter. Then the following statements are equivalent: (a) .E; F / has the Max-Flow-Min-Cut property; (b) .E; F 0 / has the Max-Flow-Min-Cut property;P ˚ 0 (c) minfc.A/ W A 2 F g D max 1ly W y 2 RF B2F 0 We2B yB c.e/ C ; for all e 2 E for every c W E ! RC . Proof: Since BL.E; F 0 / D BL.BL.E; F // D .E; F / it suffices to prove (a))(c))(b). The other implication (b))(a) then follows by exchanging the roles of F and F 0 . (a))(c): By Corollary 3.33 we have for every c W E ! RC o n minfc.A/ W A 2 F g D minfcx W x 2 P g D min c.x C y/ W x 2 P; y 2 RE C ; where P is the convex hull of the incidence vectors of elements of F . From this, the Max-Flow-Min-Cut property and the LP Duality Theorem 3.20 we get (c). (c))(b): Let P 0 denote the convex hull of the incidence vectors of the elements of F 0 . We have to show that

13.4

n

x C y W x 2 P 0 ; y 2 RE C

(

o D

x 2 RE C W

X

The Greedy Algorithm

333

) xe 1 for all A 2 F :

e2A

Since “” is trivial from the definition of blocking clutters we only show the other P inclusion. So let c 2 RE be a vector with c 1 for all A 2 F . By (c) we e C e2A have 1 minfc.A/ W A 2 F g ( D max 1ly W y 2

0 RF C ;

X

) yB c.e/ for all e 2 E ;

B2F 0 We2B

P 0 so let y 2 RF C P be a vector with 1ly D 1 and B2F 0 We2B yB 0 c.e/ for all e 2 E. Then xe ˚WD B2F 0 We2B yB (e 2 E) defines a vector x 2 P with x c, proving that c 2 x C y W x 2 P 0 ; y 2 RE C . For example, this theorem implies the Max-Flow-Min-Cut Theorem 8.6 quite directly: Let .G; u; s; t/ be a network. By Exercise 1 of Chapter 7 the minimum length of an s-t-path in .G; u/ equals the maximum number of s-t-cuts such that each edge e is contained in at most u.e/ of them. Hence the clutter of s-t-paths (example (3) in the above list) has the Max-Flow-Min-Cut Property, and so has its blocking clutter. Now (c) applied to the clutter of minimal s-t-cuts implies the MaxFlow-Min-Cut Theorem. Note however that Theorem 13.18 does not guarantee an integral vector attaining the maximum in (c), even if c is integral. The clutter of T -joins for G D K4 and T D V .G/ shows that this does not exist in general.

13.4 The Greedy Algorithm Again, let .E; F / be an independence system and c W E ! RC . We consider the MAXIMIZATION PROBLEM for .E; F ; c/ and formulate two “greedy algorithms”. We do not have to consider negative weights since elements with negative weight never appear in an optimum solution. We assume that .E; F / is given by an oracle. For the first algorithm we simply assume an independence oracle, i.e. an oracle which, given a set F E, decides whether F 2 F or not.

BEST-IN-GREEDY ALGORITHM Input: Output:

An independence system .E; F /, given by an independence oracle. Weights c W E ! RC . A set F 2 F .

1

Sort E D fe1 ; e2 ; : : : ; en g such that c.e1 / c.e2 / c.en /.

2

Set F WD ;.

3

For i WD 1 to n do: If F [ fei g 2 F then set F WD F [ fei g.

334

13 Matroids

The second algorithm requires a more complicated oracle. Given a set F E, this oracle decides whether F contains a basis. Let us call such an oracle a basissuperset oracle.

WORST-OUT-GREEDY ALGORITHM Input: Output:

An independence system .E; F /, given by a basis-superset oracle. Weights c W E ! RC . A basis F of .E; F /.

1

Sort E D fe1 ; e2 ; : : : ; en g such that c.e1 / c.e2 / c.en /.

2

Set F WD E.

3

For i WD 1 to n do: If F n fei g contains a basis then set F WD F n fei g.

Before we analyse these algorithms, let us take a closer look at the oracles required. It is an interesting question whether such oracles are polynomially equivalent, i.e. whether one can be simulated by a polynomial-time oracle algorithm using the other. The independence oracle and the basis-superset oracle do not seem to be polynomially equivalent: If we consider the independence system for the TSP (example (2) of the list in Section 13.1), it is easy (and the subject of Exercise 14) to decide whether a set of edges is independent, i.e. the subset of a Hamiltonian circuit (recall that we are working with a complete graph). On the other hand, it is a difficult problem to decide whether a set of edges contains a Hamiltonian circuit (this is NP-complete; cf. Theorem 15.25). Conversely, in the independence system for the SHORTEST PATH PROBLEM (example (3)), it is easy to decide whether a set of edges contains an s-t-path. Here it is not known how to decide whether a given set is independent (i.e. subset of an s-t-path) in polynomial time (Korte and Monma [1979] proved NP-completeness). For matroids, both oracles are polynomially equivalent. Other equivalent oracles are the rank oracle and closure oracle, which return the rank and the closure of a given subset of E, respectively (Exercise 17). However, even for matroids there are other natural oracles that are not polynomially equivalent. For example, the oracle deciding whether a given set is a basis is weaker than the independence oracle. The oracle which for a given F E returns the minimum cardinality of a dependent subset of F is stronger than the independence oracle (Hausmann and Korte [1981]). One can analogously formulate both greedy algorithms for the M INIMIZATION PROBLEM. It is easy to see that the BEST-IN-GREEDY for the MAXIMIZATION PROBLEM for .E; F ; c/ corresponds to the WORST-OUT-GREEDY for the MINIMIZATION PROBLEM for .E; F ; c/: adding an element to F in the BEST-I N GREEDY corresponds to removing an element from F in the WORST-OUT-GREEDY. Observe that KRUSKAL’S ALGORITHM (see Section 6.1) is a BEST-IN-GREEDY algorithm for the M INIMIZATION PROBLEM in a cycle matroid.

13.4

The Greedy Algorithm

335

The rest of this section contains some results concerning the quality of a solution found by the greedy algorithms. Theorem 13.19. (Jenkyns [1976], Korte and Hausmann [1978]) Let .E; F / be an independence system. For c W E ! RC we denote by G.E; F ; c/ the cost of some solution found by the BEST-IN-GREEDY for the MAXIMIZATION PROBLEM, and by OPT.E; F ; c/ the cost of an optimum solution. Then q.E; F/

G.E; F ; c/ 1 OPT.E; F ; c/

for all c W E ! RC . There is a cost function where the lower bound is attained. Proof: Let E D fe1 ; e2 ; : : : ; en g, c W E ! RC , and c.e1 / c.e2 / : : : c.en /. Let Gn be the solution found by the BEST-IN-GREEDY (when sorting E like this), while On is an optimum solution. We define Ej WD fe1 ; : : : ; ej g, Gj WD Gn \ Ej and Oj WD On \ Ej (j D 0; : : : ; n). Set dn WD c.en / and dj WD c.ej / c.ej C1 / for j D 1; : : : ; n 1. Since Oj 2 F, we have jOj j r.Ej /. Since Gj is a basis of Ej , we have jGj j .Ej /. With these two inequalities we conclude that c.Gn / D

n X .jGj j jGj 1 j/ c.ej / j D1

D

n X

jGj j dj

j D1

n X

.Ej / dj

j D1

q.E; F /

n X

r.Ej / dj

(13.1)

j D1

q.E; F/

n X

jOj j dj

j D1

D q.E; F /

n X

.jOj j jOj 1 j/ c.ej /

j D1

D q.E; F / c.On /: Finally we show that the lower bound is tight. Choose F E and bases B1 ; B2 of F such that jB1 j D q.E; F /: jB2 j

336

13 Matroids

(

Define c.e/ WD

1 0

for e 2 F for e 2 E n F

and sort e1 ; : : : ; en such that c.e1 / c.e2 / : : : c.en / and B1 Dfe1 ; : : : ; ejB1 j g. Then G.E; F ; c/ D jB1 j and OPT.E; F ; c/ D jB2 j, and the lower bound is attained. In particular we have the so-called Edmonds-Rado Theorem: Theorem 13.20. (Rado [1957], Edmonds [1971]) An independence system .E; F/ is a matroid if and only if the BEST-IN-GREEDY finds an optimum solution for the MAXIMIZATION PROBLEM for .E; F ; c/ for all cost functions c W E ! RC . Proof: By Theorem 13.19 we have q.E; F / < 1 if and only if there exists a cost function c W E ! RC for which the BEST-IN-GREEDY does not find an optimum solution. By Proposition 13.7 we have q.E; F / < 1 if and only if .E; F / is not a matroid. This is one of the rare cases where we can define a structure by its algorithmic behaviour. We also obtain a polyhedral description: Theorem 13.21. (Edmonds [1970]) Let .E; F / be a matroid and r W 2E ! ZC its rank function. Then the matroid polytope of .E; F /, i.e. the convex hull of the incidence vectors of all elements of F , is equal to ( ) X E x 2 R W x 0; xe r.A/ for all A E : e2A

Proof: Obviously, this polytope contains all incidence vectors of independent sets. By Corollary 3.32 it remains to show that all vertices of this polytope are integral. By Theorem 5.13 this is equivalent to showing that ( ) X max cx W x 0; xe r.A/ for all A E (13.2) e2A

has an integral optimum solution for any c W E ! R. W.l.o.g. c.e/ 0 for all e, since for e 2 E with c.e/ < 0 any optimum solution x of (13.2) has xe DP0. Let x be an optimum solution of (13.2). In (13.1) we replace jOj j by e2Ej xe P (j D 0; : : : ; n). We obtain c.Gn / e2E c.e/xe . So the BEST-IN-GREEDY produces a solution whose incidence vector is another optimum solution of (13.2). When applied to graphic matroids, this also yields Theorem 6.13. As in this special case, we also have total dual integrality in general. A generalization of this result will be proved in Section 14.2.

13.4

The Greedy Algorithm

337

The above observation that the BEST-IN-GREEDY for the MAXIMIZATION PROBLEM for .E; F ; c/ corresponds to the WORST-OUT-GREEDY for the MINIMIZATION PROBLEM for .E; F ; c/ suggests the following dual counterpart of Theorem 13.19: Theorem 13.22. (Korte and Monma [1979]) Let .E; F / be an independence system. For c W E ! RC let G.E; F ; c/ denote a solution found by the WORST-OUTGREEDY for the MINIMIZATION PROBLEM. Then 1

G.E; F ; c/ jF j .F / max F E jF j r .F / OPT.E; F ; c/

(13.3)

for all c W E ! RC , where and r are the rank functions of the dual independence system .E; F /. There is a cost function where the upper bound is attained. Proof: We use the same notation as in the proof of Theorem 13.19. By construction, Gj [ .E n Ej / contains a basis of E, but .Gj [ .E n Ej // n feg does not contain a basis of E for any e 2 Gj (j D 1; : : : ; n). In other words, Ej n Gj is a basis of Ej with respect to .E; F /, so jEj j jGj j .Ej /. Since On E n .Ej n Oj / and On is a basis, Ej n Oj is independent in .E; F /, so jEj j jOj j r .Ej /. We conclude that jGj j jEj j .Ej / jOj j jEj j r .Ej /:

and

Now the same calculation as (13.1) provides the upper bound. To see that this bound is tight, consider ( 1 for e 2 F ; c.e/ WD 0 for e 2 E n F where F E is a set where the maximum in (13.3) is attained. Let B1 be a basis of F with respect to .E; F /, with jB1 j D .F /. If we sort e1 ; : : : ; en such that c.e1 / c.e2 / : : : c.en / and B1 D fe1 ; : : : ; ejB1 j g, we have G.E; F ; c/ D jF j jB1 j and OPT.E; F ; c/ D jF j r .F /.

1

2

M >> 2

Fig. 13.1.

If we apply the WORST-OUT-GREEDY to the MAXIMIZATION PROBLEM or the BEST-IN-GREEDY to the MINIMIZATION PROBLEM, there is no positive G.E;F ;c/ . To see this, consider the problem of finding lower/finite upper bound for OPT.E;F ;c/

338

13 Matroids

a minimal vertex cover of maximum weight or a maximal stable set of minimum weight in the simple graph shown in Figure 13.1. However in the case of matroids, it does not matter whether we use the BESTIN-GREEDY or the WORST-OUT-GREEDY: since all bases have the same cardinality, the MINIMIZATION PROBLEM for .E; F ; c/ is equivalent to the M AXIMIZATION PROBLEM for .E; F ; c 0 /, where c 0 .e/ WD M c.e/ for all e 2 E and M WD 1 C maxfc.e/ W e 2 Eg. Therefore KRUSKAL’S ALGORITHM (Section 6.1) solves the MINIMUM SPANNING TREE PROBLEM optimally. The Edmonds-Rado Theorem 13.20 also yields the following characterization of optimum k-element solutions of the MAXIMIZATION PROBLEM. Theorem 13.23. Let .E; F / be a matroid, c W E ! R, k 2 N and X 2 F with jX j D k. Then c.X / D maxfc.Y / W Y 2 F ; jY j D kg if and only if the following two conditions hold: (a) For all y 2 E nX with X [fyg … F and all x 2 C.X; y/ we have c.x/ c.y/; (b) For all y 2 E n X with X [ fyg 2 F and all x 2 X we have c.x/ c.y/. Proof: The necessity is trivial: if one of the conditions is violated for some y and x, the k-element set X 0 WD .X [ fyg/ n fxg 2 F has greater weight than X . To see the sufficiency, let F 0 WD fF 2 F W jF j kg and c 0 .e/ WD c.e/ C M for all e 2 E, where M D maxfjc.e/j W e 2 Eg. Sort E D fe1 ; : : : ; en g such that c 0 .e1 / c 0 .en / and, for any i , c 0 .ei / D c 0 .ei C1 / and ei C1 2 X imply ei 2 X (i.e. elements of X come first among those of equal weight). Let X 0 be the solution found by the BEST-IN-GREEDY for the instance .E; F 0 ; c 0 / where 1 sorts the elements as above. Since .E; F 0 / is a matroid, the Edmonds-Rado Theorem 13.20 implies: c.X 0 / C kM D c 0 .X 0 / D maxfc 0 .Y / W Y 2 F 0 g D maxfc.Y / W Y 2 F ; jY j D kg C kM: We conclude the proof by showing that X D X 0 . We know that jX j D k D jX 0 j. So suppose X 6D X 0 , and let ei 2 X 0 n X with i minimum. Then X \ fe1 ; : : : ; ei 1 g D X 0 \ fe1 ; : : : ; ei 1 g. Now if X [ fei g … F, then (a) implies C.X; ei / X 0 , a contradiction. If X [ fei g 2 F , then (b) implies X X 0 which is also impossible. We shall need this theorem in Section 13.7. The special case that .E; F / is a graphic matroid and k D r.E/ is part of Theorem 6.3.

13.5 Matroid Intersection Definition 13.24. Given two independence systems .E; F1 / and .E; F2 /, we define their intersection by .E; F1 \ F2 /.

13.5

Matroid Intersection

339

The intersection of a finite number of independence systems is defined analogously. It is clear that the result is again an independence system. Proposition 13.25. Any independence system .E; F/ is the intersection of a finite number of matroids. Proof: Each circuit C of .E; F / defines a matroid .E; fF E W C n F ¤ ;g/ by Theorem 13.12 (this also follows easily from the definition). The intersection of all these matroids is of course .E; F /. Since the intersection of matroids is not a matroid in general, we cannot hope to get an optimum common independent set by a greedy algorithm. However, the following result, together with Theorem 13.19, implies a bound for the solution found by the BEST-IN-GREEDY: Proposition 13.26. If .E; F / is the intersection of p matroids, then q.E; F /

1 . p

Proof: By Theorem 13.12(b), X [ feg contains at most p circuits for any X 2 F and e 2 E. The statement now follows from Theorem 13.8. Of particular interest are independence systems that are the intersection of two matroids. The prime example here is the matching problem in a bipartite graph : G D .A [ B; E/. If F WD fF E W F is a matching in Gg, then .E; F/ is the intersection of two matroids. Namely, let F1 WD fF E W jıF .x/j 1 for all x 2 Ag and F2 WD fF E W jıF .x/j 1 for all x 2 Bg: .E; F1 /; .E; F2 / are matroids by Proposition 13.4(d). Clearly, F D F1 \ F2 . A second example is the independence system consisting of all branchings in a digraph G (Example 8 of the list at the beginning of Section 13.1). Here one matroid contains all sets of edges such that each vertex has at most one entering edge (see Proposition 13.4(e)), while the second matroid is the cycle matroid M.G/ of the underlying undirected graph. We shall now describe Edmonds’ algorithm for the following problem:

MATROID INTERSECTION PROBLEM Instance:

Two matroids .E; F1 /; .E; F2 /, given by independence oracles.

Task:

Find a set F 2 F1 \ F2 such that jF j is maximum.

We start with the following lemma. Recall that, for X 2 F and e 2 E, C.X; e/ denotes the unique circuit in X [ feg if X [ feg … F , and C.X; e/ D ; otherwise. Lemma 13.27. (Frank [1981]) Let .E; F / be a matroid and X 2 F . Let x1 ; : : : ; xs 2 X and y1 ; : : : ; ys … X with (a) xk 2 C.X; yk / for k D 1; : : : ; s and

340

13 Matroids

(b) xj … C.X; yk / for 1 j < k s. Then .X n fx1 ; : : : ; xs g/ [ fy1 ; : : : ; ys g 2 F . Proof: Let Xr WD .X n fx1 ; : : : ; xr g/ [ fy1 ; : : : ; yr g. We show that Xr 2 F for all r by induction. For r D 0 this is trivial. Let us assume that Xr1 2 F for some r 2 f1; : : : ; sg. If Xr1 [ fyr g 2 F then we immediately have Xr 2 F . Otherwise Xr1 [ fyr g contains a unique circuit C (by Theorem 13.12(b)). Since C.X; yr / Xr1 [ fyr g (by (b)), we must have C D C.X; yr /. But then by (a) xr 2 C.X; yr / D C , so Xr D .Xr1 [ fyr g/ n fxr g 2 F . The idea behind E DMONDS’ MATROID INTERSECTION ALGORITHM is the following. Starting with X D ;, we augment X by one element in each iteration. Since in general we cannot hope for an element e such that X [ feg 2 F1 \ F2 , we shall look for “alternating paths”. To make this convenient, we define an auxiliary graph. We apply the notion C.X; e/ to .E; Fi / and write Ci .X; e/ (i D 1; 2). E\ X

X

SX (2)

AX

(1)

AX

TX

Fig. 13.2.

Given a set X 2 F1 \ F2 , we define a directed auxiliary graph GX by .1/

AX WD f .x; y/ W y 2 E n X; x 2 C1 .X; y/ n fyg g; .2/

AX WD f .y; x/ W y 2 E n X; x 2 C2 .X; y/ n fyg g; .1/

.2/

GX WD .E; AX [ AX /: We set SX WD fy 2 E n X W X [ fyg 2 F1 g; TX WD fy 2 E n X W X [ fyg 2 F2 g

13.5

Matroid Intersection

341

(see Figure 13.2) and look for a shortest path from SX to TX . Such a path will enable us to augment the set X . (If SX \ TX 6D ;, we have a path of length zero and we can augment X by any element in SX \ TX .) Lemma 13.28. Let X 2 F1 \ F2 . Let y0 ; x1 ; y1 ; : : : ; xs ; ys be the vertices of a shortest y0 -ys -path in GX (in this order), with y0 2 SX and ys 2 TX . Then X 0 WD .X [ fy0 ; : : : ; ys g/ n fx1 ; : : : ; xs g 2 F1 \ F2 : Proof: First we show that X [ fy0 g, x1 ; : : : ; xs and y1 ; : : : ; ys satisfy the requirements of Lemma 13.27 with respect to F1 . Observe that X [ fy0 g 2 F1 because .1/ y0 2 SX . (a) is satisfied because .xj ; yj / 2 AX for all j , and (b) is satisfied because otherwise the path could be shortcut. We conclude that X 0 2 F1 . Secondly, we show that X [ fys g, xs ; xs1 ; : : : ; x1 and ys1 ; : : : ; y1 ; y0 satisfy the requirements of Lemma 13.27 with respect to F2 . Observe that X [ fys g 2 F2 .2/ because ys 2 TX . (a) is satisfied because .yj 1 ; xj / 2 AX for all j , and (b) is satisfied because otherwise the path could be shortcut. We conclude that X 0 2 F2 . We shall now prove that if there exists no SX -TX -path in GX , then X is already maximum. We need the following simple fact: Proposition 13.29. Let .E; F1 / and .E; F2 / be two matroids with rank functions r1 and r2 . Then for any F 2 F1 \ F2 and any Q E we have jF j r1 .Q/ C r2 .E n Q/: Proof: F \ Q 2 F1 implies jF \ Qj r1 .Q/. Similarly F n Q 2 F2 implies jF n Qj r2 .E n Q/. Adding the two inequalities completes the proof. Lemma 13.30. X 2 F1 \ F2 is maximum if and only if there is no SX -TX -path in GX . Proof: If there is an SX -TX -path, there is also a shortest one. We apply Lemma 13.28 and obtain a set X 0 2 F1 \ F2 of greater cardinality. Otherwise let R be the set of vertices reachable from SX in GX (see Figure 13.3). We have R \ TX D ;. Let r1 and r2 be the rank function of F1 and F2 , respectively. We claim that r2 .R/ D jX \ Rj. If not, there would be a y 2 R n X with .X \ R/ [ fyg 2 F2 . Since X [ fyg … F2 (because y … TX ), the circuit C2 .X; y/ .2/ must contain an element x 2 X n R. But then .y; x/ 2 AX means that there is an edge leaving R. This contradicts the definition of R. Next we prove that r1 .E nR/ D jX nRj. If not, there would be a y 2 .E nR/nX with .X nR/[fyg 2 F1 . Since X [fyg … F1 (because y … SX ), the circuit C1 .X; y/ .1/ must contain an element x 2 X \ R. But then .x; y/ 2 AX means that there is an edge leaving R. This contradicts the definition of R. Altogether we have jX j D r2 .R/Cr1 .E nR/. By Proposition 13.29, this implies optimality.

342

13 Matroids E \ X

X

SX (2)

AX

R E \ R (1)

AX

TX

Fig. 13.3.

The last paragraph of this proof yields the following min-max-equality: Theorem 13.31. (Edmonds [1970]) Let .E; F1 / and .E; F2 / be two matroids with rank functions r1 and r2 . Then max fjX j W X 2 F1 \ F2 g D min fr1 .Q/ C r2 .E n Q/ W Q Eg :

We are now ready for a detailed description of the algorithm.

EDMONDS’ MATROID INTERSECTION ALGORITHM Input:

Two matroids .E; F1 / and .E; F2 /, given by independence oracles.

Output:

A set X 2 F1 \ F2 of maximum cardinality.

1

Set X WD ;.

2

For each y 2 E n X and i 2 f1; 2g do: Compute Ci .X; y/ WD fx 2 X [ fyg W X [ fyg … Fi ; .X [ fyg/ n fxg 2 Fi g. Compute SX , TX , and GX as defined above.

3 4 5

Apply BFS to find a shortest SX -TX -path P in GX . If none exists then stop. Set X WD X 4V .P / and go to . 2

Theorem 13.32. EDMONDS’ MATROID INTERSECTION ALGORITHM correctly solves the MATROID INTERSECTION PROBLEM in O.jEj3 / time, where is the maximum complexity of the two independence oracles.

13.6

Matroid Partitioning

343

Proof: The correctness follows from Lemmata 13.28 and 13.30. 2 and 3 can be done in O.jEj2 /, 4 in O.jEj2 / time. Since there are at most jEj augmentations, the overall complexity is O.jEj3 /. Faster matroid intersection algorithms are discussed by Cunningham [1986] and Gabow and Xu [1996]. We remark that the problem of finding a maximum cardinality set in the intersection of three matroids is an NP-hard problem; see Exercise 17(c) of Chapter 15.

13.6 Matroid Partitioning Instead of the intersection of matroids we now consider their union which is defined as follows: Definition 13.33. Let .E; F1 /; : : : ; .E; Fk / be k matroids. A set X E is called : : partitionable if there exists a partition X D X1 [ [ Xk with Xi 2 Fi for i D 1; : : : ; k. Let F be the family of partitionable subsets of E. Then .E; F / is called the union or sum of .E; F1 /; : : : ; .E; Fk /. We shall prove that the union of matroids is a matroid again. Moreover, we solve the following problem via matroid intersection:

MATROID PARTITIONING PROBLEM Instance: Task:

A number k 2 N, k matroids .E; F1 /; : : : ; .E; Fk /, given by independence oracles. Find a partitionable set X E of maximum cardinality.

The main theorem with respect to matroid partitioning is: Theorem 13.34. (Nash-Williams [1967]) Let .E; F1 /; : : : ; .E; Fk / be matroids with rank functions r1 ; : : : ; rk , and let .E; F / be their union. F / is a mat Then .E; Pk roid, and its rank function r is given by r.X / D minAX jX n Aj C i D1 ri .A/ . Proof: .E; F / is obviously an independence system. Let X E. We first prove Pk r.X / D minAX jX n Aj C i D1 ri .A/ . :

:

For any Y X such that Y is partitionable, i.e. Y D Y1 [ [ Yk with Yi 2 Fi (i D 1; : : : ; k), and any A X we have jY j D jY n Aj C jY \ Aj jX n Aj C

k X i D1

jYi \ Aj jX n Aj C

k X

ri .A/;

i D1

P so r.X / minAX jX n Aj C kiD1 ri .A/ . On the other hand, let X 0 WD X f1; : : : ; kg. We define two matroids on X 0 . For Q X 0 and i 2 f1; : : : ; kg we write Qi WD fe 2 X W .e; i / 2 Qg. Let

344

13 Matroids

I1 WD fQ X 0 W Qi 2 Fi for all i D 1; : : : ; kg and

I2 WD fQ X 0 W Qi \ Qj D ; for all i 6D j g:

Evidently, both .X 0 ; I1 / and .X 0 ; I2 / are matroids, ˇS and ˇtheir rank functions are Pk ˇ ˇ given by s1 .Q/ WD i D1 ri .Qi / and s2 .Q/ WD ˇ kiD1 Qi ˇ for Q X 0 . Now the family of partitionable subsets of X can be written as fA X W there is a function f W A ! f1; : : : ; kg with f.e; f .e// W e 2 Ag 2 I1 \ I2 g: So the maximum cardinality of a partitionable set is the maximum cardinality of a common independent set in I1 and I2 . By Theorem 13.31 this maximum cardinality equals min fs1 .Q/ C s2 .X 0 n Q/ W Q X 0 g. If Q X 0 attains this minimum, then for A WD Q1 \ \ Qk we have ˇ ˇ k k k ˇ ˇ X \ X ˇ ˇ 0 r.X / D s1 .Q/Cs2 .X nQ/ D ri .Qi /C ˇX n Qi ˇ ri .A/CjX nAj: ˇ ˇ i D1

i D1

i D1

P So we have found a set A X with kiD1 ri .A/ C jX n Aj r.X /. Having proved the formula for the rank function r, we finally show that r is submodular. By Theorem 13.10, this implies that .E; F / is a matroid. To show the submodularity, let X; Y E, and let A X , B Y with r.X / D jX n Aj C Pk Pk i D1 ri .A/ and r.Y / D jY n Bj C i D1 ri .B/. Then r.X / C r.Y / D jX n Aj C jY n Bj C

k X

.ri .A/ C ri .B//

i D1

j.X [ Y / n .A [ B/j C j.X \ Y / n .A \ B/j C

k X

.ri .A [ B/ C ri .A \ B//

i D1

r.X [ Y / C r.X \ Y /: The construction in the above proof (Edmonds [1970]) reduces the MATROID PARTITIONING PROBLEM to the MATROID INTERSECTION PROBLEM. A reduction in the other direction is also possible (Exercise 21), so both problems can be regarded as equivalent. Note that we can find a maximum independent set in the union of an arbitrary number of matroids efficiently, while the intersection of more than two matroids is intractable.

13.7

Weighted Matroid Intersection

345

13.7 Weighted Matroid Intersection Now we consider the more general weighted version of matroid intersection.

WEIGHTED MATROID INTERSECTION PROBLEM Instance: Task:

Two matroids .E; F1 / and .E; F2 /, given by independence oracles. Weights c W E ! R. Find a set X 2 F1 \ F2 whose weight c.X / is maximum.

We shall describe a primal-dual algorithm due to Frank [1981] for this problem. It generalizes EDMONDS’ MATROID INTERSECTION ALGORITHM. Again we start with X WD X0 D ; and increase the cardinality in each iteration by one. We obtain sets X0 ; : : : ; Xm 2 F1 \ F2 with jXk j D k (k D 0; : : : ; m) and m D maxfjX j W X 2 F1 \ F2 g. Each Xk will be optimum, i.e. c.Xk / D maxfc.X / W X 2 F1 \ F2 ; jX j D kg:

(13.4)

Hence at the end we just choose an optimum set among X0 ; : : : ; Xm . The main idea is to split up the weight function. At any stage we have two functions c1 ; c2 W E ! R with c1 .e/ C c2 .e/ D c.e/ for all e 2 E. For each k we shall guarantee ci .Xk / D maxfci .X / W X 2 Fi ; jX j D kg

.i D 1; 2/:

(13.5)

This condition obviously implies (13.4). To obtain (13.5) we use the optimality criterion of Theorem 13.23. Instead of GX , SX and TX only a subgraph GN and subsets SN , TN are considered.

WEIGHTED MATROID INTERSECTION ALGORITHM Input: Output:

Two matroids .E; F1 / and .E; F2 /, given by independence oracles. Weights c W E ! R. A set X 2 F1 \ F2 of maximum weight.

1

Set k WD 0 and X0 WD ;. Set c1 .e/ WD c.e/ and c2 .e/ WD 0 for all e 2 E.

2

For each y 2 E n Xk and i 2 f1; 2g do: Compute Ci .Xk ; y/ WD fx 2 Xk [ fyg W Xk [ fyg … Fi ; .Xk [ fyg/ n fxg 2 Fi g: Compute

3

A.1/ WD f .x; y/ W y 2 E n Xk ; x 2 C1 .Xk ; y/ n fyg g; A.2/ WD f .y; x/ W y 2 E n Xk ; x 2 C2 .Xk ; y/ n fyg g; S WD f y 2 E n Xk W Xk [ fyg 2 F1 g; T WD f y 2 E n Xk W Xk [ fyg 2 F2 g:

346

4

13 Matroids

Compute m1 WD maxfc1 .y/ W y 2 S g; m2 WD maxfc2 .y/ W y 2 T g; SN WD f y 2 S W c1 .y/ D m1 g; TN WD f y 2 T W c2 .y/ D m2 g; .1/ N A WD f .x; y/ 2 A.1/ W c1 .x/ D c1 .y/ g; AN.2/ WD f .y; x/ 2 A.2/ W c2 .x/ D c2 .y/ g; GN WD .E; AN.1/ [ AN.2/ /:

5 6 7

N Apply BFS to compute the set R of vertices reachable from SN in G. If R \ TN 6D ; then: Find an SN -TN -path P in GN with a minimum number of edges, set XkC1 WD Xk 4V .P / and k WD k C 1 and go to . 2 Compute "1 WD minfc1 .x/ c1 .y/ W .x; y/ 2 ıAC.1/ .R/g;

"2 WD minfc2 .x/ c2 .y/ W .y; x/ 2 ıAC.2/ .R/g; "3 WD minfm1 c1 .y/ W y 2 S n Rg; "4 WD minfm2 c2 .y/ W y 2 T \ Rg; " WD minf"1 ; "2 ; "3 ; "4 g

8

(where min ; WD 1). If " < 1 then: Set c1 .x/ WD c1 .x/ " and c2 .x/ WD c2 .x/ C " for all x 2 R. Go to . 4 If " D 1 then: Among X0 ; X1 ; : : : ; Xk , let X be the one with maximum weight. Stop.

See Edmonds [1979] and Lawler [1976] for earlier versions of this algorithm. To prove correctness, we need the following generalization of Lemma 13.27: Lemma 13.35. (Frank [1981]) Let .E; F / be a matroid, c W E ! R, and X 2 F. Let x1 ; : : : ; xl 2 X and y1 ; : : : ; yl … X with (a) xj 2 C.X; yj / and c.xj / D c.yj / for j D 1; : : : ; l, and (b) xi … C.X; yj / or c.xi / > c.yj / for 1 i; j l with i 6D j . Then .X n fx1 ; : : : ; xl g/ [ fy1 ; : : : ; yl g 2 F . Proof: We again use induction on l. The case l D 1 is trivial by (a). Let D minli D1 c.xi /, and let h be an index for which the minimum is attained. Let X 0 WD .X n fxh g/ [ fyh g. By (a), X 0 2 F. We show C.X 0 ; yj / D C.X; yj / for all j 6D h; then (a) and (b) hold also for X 0 and the remaining indices f1; : : : ; lg n fhg, and we are done by induction.

13.7

Weighted Matroid Intersection

347

Let j 6D h, and suppose that C.X 0 ; yj / 6D C.X; yj /. Then xh 2 C.X; yj /. But then (a) and (b) imply D c.xh / > c.yj / D c.xj / , a contradiction. Theorem 13.36. (Frank [1981]) The WEIGHTED MATROID INTERSECTION ALGORITHM correctly solves the WEIGHTED MATROID INTERSECTION PROBLEM in O.jEj4 C jEj3 / time, where is the maximum complexity of the two independence oracles. Proof: Let m be the final value of k (we will show later that the algorithm terminates). The algorithm computes sets X0 ; X1 ; : : : ; Xm . When the algorithm stops, we have "1 D "2 D "3 D "4 D 1, so T is not reachable from S in .E; A.1/ [ A.2/ /. Then Lemma 13.30 implies m D jXm j D maxfjX j W X 2 F1 \ F2 g. To prove correctness, we show that we have at any stage Xk 2 F1 \ F2 and (13.5). Since c D c1 C c2 always holds, this implies c.Xk / D maxfc.X / W X 2 F1 \ F2 ; jX j D kg for all k D 0; : : : ; m, and hence the correctness. Initially, k D 0, Xk D ; 2 F1 \ F2 , and (13.5) is trivial. We now show that each iteration of the algorithm preserves the properties. We first note that (13.5) and Theorem 13.23(a) imply (i) c1 .x/ > c1 .y/ for all .x; y/ 2 A.1/ n AN.1/ , and (ii) c2 .x/ > c2 .y/ for all .y; x/ 2 A.2/ n AN.2/ . We first consider an iteration in which R \ TN 6D ;. Then we find a path P in , 5 say with vertices y0 ; x1 ; y1 ; : : : ; xl ; yl in this order. Similarly as in Lemma 13.28, we show that .E; F1 /, X [ fy0 g, x1 ; : : : ; xl , and y1 ; : : : ; yl satisfy the requirements of Lemma 13.35: X [ fy0 g 2 F1 follows from y0 2 S . Condition (a) of Lemma 13.35 follows from .xj ; yj / 2 AN.1/ for j D N Hence 1; : : : ; l, and (b) follows from (i) and the fact that P is a shortest path in G. XkC1 2 F1 . Analogously, .E; F2 /, Xk [ fyl g, x1 ; : : : ; xl , and y0 ; : : : ; yl1 satisfy the requirements of Lemma 13.35. Here Xk [ fyl g 2 F2 follows from yl 2 T . Condition (a) of Lemma 13.35 follows from .yj 1 ; xj / 2 AN.2/ for j D 1; : : : ; l, and (b) N Hence XkC1 2 F2 . again follows from (ii) and the fact that P is a shortest path in G. So we have shown XkC1 2 F1 \ F2 . To show that XkC1 satisfies (13.5) we use Theorem 13.23. By definition of GN we have c1 .XkC1 / D c1 .Xk / C c1 .y0 / and c2 .XkC1 / D c2 .Xk / C c2 .ys /. Since Xk satisfies (13.5), conditions (a) and (b) of Theorem 13.23 must hold with respect to Xk and each of F1 and F2 . N both conditions continue to hold for Xk [ fy0 g By definition of SN and y0 2 S, and F1 . Therefore c1 .XkC1 / D c1 .Xk [ fy0 g/ D maxfc1 .Y / W Y 2 F1 ; jY j D k C 1g. Moreover, by definition of TN and yl 2 TN , (a) and (b) of Theorem 13.23 continue to hold for Xk [ fyl g and F2 , implying c2 .XkC1 / D c2 .Xk [ fyl g/ D maxfc2 .Y / W Y 2 F2 ; jY j D k C 1g. In other words, (13.5) indeed holds for XkC1 . Now consider an iteration in which R \ TN D ;, so we change c1 and c2 in . 8 C We first show that " > 0. Since by the definition of R we have ıG N .R/ D ;, (i) and (ii) directly imply "1 > 0 and "2 > 0.

348

13 Matroids

m1 c1 .y/ holds for all y 2 S . If in addition y … R then y … SN , so m1 > c1 .y/. Therefore "3 > 0. Similarly, "4 > 0 (using TN \ R D ;). We conclude that " > 0. We can now prove that 8 preserves (13.5). Let c10 be the modified c1 , i.e. ( c1 .x/ " if x 2 R 0 : c1 .x/ WD c1 .x/ if x … R We prove that Xk and c10 satisfy the conditions of Theorem 13.23 with respect to F1 . To prove (a), let y 2 E n Xk and x 2 C1 .Xk ; y/ n fyg. Suppose c10 .x/ < 0 c1 .y/. Since c1 .x/ c1 .y/ and " > 0, we must have x 2 R and y … R. Since also .x; y/ 2 A.1/ , we have " "1 c1 .x/ c1 .y/ D .c10 .x/ C "/ c10 .y/, a contradiction. To prove (b), let x 2 Xk and y 2 E n Xk with Xk [ fyg 2 F1 . Now suppose c10 .y/ > c10 .x/. Since c1 .y/ m1 c1 .x/, we must have x 2 R and y … R. Since y 2 S we have " "3 m1 c1 .y/ c1 .x/ c1 .y/ D .c10 .x/ C "/ c10 .y/, a contradiction. Let c20 be the modified c2 , i.e. ( c2 .x/ C " if x 2 R : c20 .x/ WD c2 .x/ if x … R We show that Xk and c20 satisfy the conditions of Theorem 13.23 with respect to F2 . To prove (a), let y 2 E n Xk and x 2 C2 .Xk ; y/ n fyg. Suppose c20 .x/ < c20 .y/. Since c2 .x/ c2 .y/, we must have y 2 R and x … R. Since also .y; x/ 2 A.2/ , we have " "2 c2 .x/ c2 .y/ D c20 .x/ .c20 .y/ "/, a contradiction. To prove (b), let x 2 Xk and y 2 E n Xk with Xk [ fyg 2 F2 . Now suppose c20 .y/ > c20 .x/. Since c2 .y/ m2 c2 .x/, we must have y 2 R and x … R. Since y 2 T we have " "4 m2 c2 .y/ c2 .x/ c2 .y/ D c20 .x/ .c20 .y/ "/, a contradiction. So we have proved that (13.5) is not violated during , 8 and thus the algorithm works correctly. We now consider the running time. Observe that after an update of the weights in , 8 the new sets SN , TN , and R, as computed subsequently in 4 and , 5 are supersets of the old SN , TN , and R, respectively. If " D "4 < 1, an augmentation (increase of k) follows. Otherwise the cardinality of R increases immediately (in ) 5 by at least one. So 4 – 8 are repeated less than jEj times between two augmentations. Since the running time of 4 – 8 is O.jEj2 /, the total running time between 3 two augmentations is O.jEj / plus O.jEj2 / oracle calls (in ). 2 Since there are m jEj augmentations, the stated overall running time follows. The running time can easily be improved to O.jEj3 / (Exercise 23).

Exercises

349

Exercises 1. Prove that all the independence systems apart from (5) and (6) in the list at the beginning of Section 13.1 are – in general – not matroids. 2. Show that the uniform matroid with four elements and rank 2 is not a graphic matroid. 3. Prove that every graphic matroid is representable over every field. 4. Let G be an undirected graph, K 2 N, and let F contain those subsets of E.G/ that are the union of K forests. Prove that .E.G/; F / is a matroid. : 5. Let G be a bipartite graph with bipartition V .G/ D A [ B and .A; F/ a matroid. Prove that then .B; fY B W Y D ; or 9X 2 F W GŒX [ Y has a perfect matchingg/ is a matroid. 6. Compute tight lower bounds for the rank quotients of the independence systems listed at the beginning of Section 13.1. 7. Let S be a finite family of finite sets. A set T is a transversal of S if there is a bijection ˆ W T ! S with t 2 ˆ.t/ for all t 2 T . (For a necessary and sufficient condition for the existence of a transversal, see Exercise 6 of Chapter 10.) Assume that S has a transversal. Prove that the family of transversals of S is the family of bases of a matroid. 8. Let E be a finite set and B 2E . Show that B is the set of bases of some matroid .E; F / if and only if the following holds: (B1) B 6D ;; (B2) For any B1 ; B2 2 B and y 2 B2 n B1 there exists an x 2 B1 n B2 with .B1 n fxg/ [ fyg 2 B. 9. Let G be a graph. Let F be the family of sets X V .G/, for which a maximum matching exists that covers no vertex in X . Prove that .V .G/; F / is a matroid. What is the dual matroid? 10. Show that M.G / D .M.G// also holds for disconnected graphs G, extending Theorem 13.16. Hint: Use Exercise 36(a) of Chapter 2. 11. Show that the clutters in (3) and (6) in the list of Section 13.3 have the MaxFlow-Min-Cut property. (Use Theorem 19.17.) Show that the clutters in (1), (4) and (5) do not have the Max-Flow-Min-Cut property in general. 12. A clutter .E; F / is called binary if for all X1 ; : : : ; Xk 2 F with k odd there exists a Y 2 F with Y X1 4 4Xk . Prove that the clutter of minimal T -joins and the clutter of minimal T -cuts (example (7) of the list in Section 13.3) are binary. Prove that a clutter is binary if and only if jA \ Bj is odd for all A 2 F and all B 2 F 0 , where .E; F 0 / is the blocking clutter. Conclude that a clutter is binary if and only if its blocking clutter is binary. Note: Seymour [1977] classified the binary clutters with the Max-Flow-MinCut property. 13. Let P be a polyhedron of blocking type, i.e. we have x C y 2 P for all x 2 P and y 0. The blocking polyhedron of P is defined to be B.P / WD f´ W ´> x 1 for all x 2 P g. Prove that B.P / is again a polyhedron of blocking type and

350

14. 15. 16.

17.

18.

19.

20.

21.

22.

23. 24.

13 Matroids

that B.B.P // D P . Note: Compare this with Theorem 4.22. How can one check (in polynomial time) whether a given set of edges of a complete graph G is a subset of some Hamiltonian circuit in G? Prove that if .E; F / is a matroid, then the BEST-IN-GREEDY maximizes any bottleneck function c.F / D minfce W e 2 F g over the bases. Let .E; F / be a matroid and c W E ! R such that c.e/ 6D c.e 0 / for all e 6D e 0 and c.e/ 6D 0 for all e. Prove that both the MAXIMIZATION and the MINIMIZATION PROBLEM for .E; F ; c/ have a unique optimum solution. Prove that for matroids the independence, basis-superset, closure and rank oracles are polynomially equivalent. Hint: To show that the rank oracle reduces to the independence oracle, use the BEST-IN-GREEDY. To show that the independence oracle reduces to the basissuperset oracle, use the WORST-OUT-GREEDY. (Hausmann and Korte [1981]) Given an undirected graph G, we wish to colour the edges with a minimum number of colours such that for any circuit C of G, the edges of C do not all have the same colour. Show that there is a polynomial-time algorithm for this problem. Let .E; F1 /; : : : ; .E; Fk / be matroids with rank functions r1 ; : : : ; rk . Prove that P a set X E is partitionable if and only if jAj kiD1 ri .A/ for all A X . Show that Theorem 6.20 is a special case. (Edmonds and Fulkerson [1965]) Let .E; F / be a matroid with rank function r. Prove (using Theorem 13.34): (a) .E; F / has k pairwise disjoint bases if and only if kr.A/CjE nAj kr.E/ for all A E. (b) .E; F / has k independent sets whose union is E if and only if kr.A/ jAj for all A E. Show that Theorem 6.20 and Theorem 6.17 are special cases. Let .E; F1 / and .E; F2 / be two matroids. Let X be a maximal partitionable : subset with respect to .E; F1 / and .E; F2 /: X D X1 [ X2 with X1 2 F1 and X2 2 F2 . Let B2 X2 be a basis of F2 . Prove that then X n B2 is a maximum-cardinality set in F1 \ F2 . (Edmonds [1970]) Let .E; S/ be a set system, and let .E; F / be a matroid with rank function r.S Show that S has a transversal that is independent in .E; F / if and only if r B2B B jBj for all B S. Hint: First describe the rank function of the matroid whose independent sets are all transversals (Exercise 7), using Theorem 13.34. Then apply Theorem 13.31. (Rado [1942]) Show that the running time of the WEIGHTED MATROID INTERSECTION ALGORITHM (cf. Theorem 13.36) can be improved to O.jEj3 /. Let .E; F1 / and .E; F2 / be two matroids, and c W E ! R. Let X0 ; : : : ; Xm 2 F1 \ F2 with jXk j D k and c.Xk / D maxfc.X / W X 2 F1 \ F2 ; jX j D kg for

References

351

all k. Prove that for k D 1; : : : ; m 2 c.XkC1 / c.Xk / c.Xk / c.Xk1 /: (Krogdahl [unpublished]) 25. Consider the following problem. Given a digraph G with edge weights, a vertex s 2 V .G/, and a number k, find a minimum weight subgraph H of G containing k edge-disjoint paths from s to each other vertex. Show that this reduces to the WEIGHTED MATROID INTERSECTION PROBLEM. Hint: See Exercise 26 of Chapter 6 and Exercise 4 of this chapter. (Edmonds [1970]; Frank and Tardos [1989]; Gabow [1995]) : 26. Let A and B be two finite sets of cardinality n 2 N, G D .A [ B; ffa; bg W a 2 A; b 2 Bg/ the complete bipartite graph, aN 2 A, and c W E.G/ ! R a cost function. Let T be the family of edge sets of all spanning trees T in G with jıT .a/j D 2 for all a 2 A n fag. N Show that a minimum cost element of T can be computed in O.n7 / time. How many edges will be incident to a? N

References General Literature: Bixby, R.E., and Cunningham, W.H. [1995]: Matroid optimization and algorithms. In: Handbook of Combinatorics; Vol. 1 (R.L. Graham, M. Grötschel, L. Lovász, eds.), Elsevier, Amsterdam, 1995 Cook, W.J., Cunningham, W.H., Pulleyblank, W.R., and Schrijver, A. [1998]: Combinatorial Optimization. Wiley, New York 1998, Chapter 8 Faigle, U. [1987]: Matroids in combinatorial optimization. In: Combinatorial Geometries (N. White, ed.), Cambridge University Press, 1987 Frank, A. [2011]: Connections in Combinatorial Optimization. Oxford University Press, Oxford 2011 Gondran, M., and Minoux, M. [1984]: Graphs and Algorithms. Wiley, Chichester 1984, Chapter 9 Lawler, E.L. [1976]: Combinatorial Optimization; Networks and Matroids. Holt, Rinehart and Winston, New York 1976, Chapters 7 and 8 Oxley, J.G. [1992]: Matroid Theory. Oxford University Press, Oxford 1992 von Randow, R. [1975]: Introduction to the Theory of Matroids. Springer, Berlin 1975 Recski, A. [1989]: Matroid Theory and its Applications. Springer, Berlin 1989 Schrijver, A. [2003]: Combinatorial Optimization: Polyhedra and Efficiency. Springer, Berlin 2003, Chapters 39–42 Welsh, D.J.A. [1976]: Matroid Theory. Academic Press, London 1976

Cited References: Cunningham, W.H. [1986] : Improved bounds for matroid partition and intersection algorithms. SIAM Journal on Computing 15 (1986), 948–957

352

13 Matroids

Edmonds, J. [1970]: Submodular functions, matroids and certain polyhedra. In: Combinatorial Structures and Their Applications; Proceedings of the Calgary International Conference on Combinatorial Structures and Their Applications 1969 (R. Guy, H. Hanani, N. Sauer, J. Schönheim, eds.), Gordon and Breach, New York 1970, pp. 69–87 Edmonds, J. [1971]: Matroids and the greedy algorithm. Mathematical Programming 1 (1971), 127–136 Edmonds, J. [1979]: Matroid intersection. In: Discrete Optimization I; Annals of Discrete Mathematics 4 (P.L. Hammer, E.L. Johnson, B.H. Korte, eds.), North-Holland, Amsterdam 1979, pp. 39–49 Edmonds, J., and Fulkerson, D.R. [1965]: Transversals and matroid partition. Journal of Research of the National Bureau of Standards B 69 (1965), 67–72 Frank, A. [1981]: A weighted matroid intersection algorithm. Journal of Algorithms 2 (1981), 328–336 Frank, A., and Tardos, É. [1989]: An application of submodular flows. Linear Algebra and Its Applications 114/115 (1989), 329–348 Fulkerson, D.R. [1971]: Blocking and anti-blocking pairs of polyhedra. Mathematical Programming 1 (1971), 168–194 Gabow, H.N. [1995]: A matroid approach to finding edge connectivity and packing arborescences. Journal of Computer and System Sciences 50 (1995), 259–273 Gabow, H.N., and Xu, Y. [1996]: Efficient theoretic and practical algorithms for linear matroid intersection problems. Journal of Computer and System Sciences 53 (1996), 129– 147 Hausmann, D., Jenkyns, T.A., and Korte, B. [1980]: Worst case analysis of greedy type algorithms for independence systems. Mathematical Programming Study 12 (1980), 120–131 Hausmann, D., and Korte, B. [1981]: Algorithmic versus axiomatic definitions of matroids. Mathematical Programming Study 14 (1981), 98–111 Jenkyns, T.A. [1976]: The efficiency of the greedy algorithm. Proceedings of the 7th S-E Conference on Combinatorics, Graph Theory, and Computing, Utilitas Mathematica, Winnipeg 1976, pp. 341–350 Korte, B., and Hausmann, D. [1978]: An analysis of the greedy algorithm for independence systems. In: Algorithmic Aspects of Combinatorics; Annals of Discrete Mathematics 2 (B. Alspach, P. Hell, D.J. Miller, eds.), North-Holland, Amsterdam 1978, pp. 65–74 Korte, B., and Monma, C.L. [1979]: Some remarks on a classification of oracle-type algorithms. In: Numerische Methoden bei graphentheoretischen und kombinatorischen Problemen; Band 2 (L. Collatz, G. Meinardus, W. Wetterling, eds.), Birkhäuser, Basel 1979, pp. 195–215 Lehman, A. [1979]: On the width-length inequality. Mathematical Programming 17 (1979), 403–417 Nash-Williams, C.S.J.A. [1967]: An application of matroids to graph theory. In: Theory of Graphs; Proceedings of an International Symposium in Rome 1966 (P. Rosenstiehl, ed.), Gordon and Breach, New York, 1967, pp. 263–265 Rado, R. [1942]: A theorem on independence relations. Quarterly Journal of Math. Oxford 13 (1942), 83–89 Rado, R. [1957]: Note on independence functions. Proceedings of the London Mathematical Society 7 (1957), 300–320

References

353

Seymour, P.D. [1977]: The matroids with the Max-Flow Min-Cut property. Journal of Combinatorial Theory B 23 (1977), 189–222 Whitney, H. [1933]: Planar graphs. Fundamenta Mathematicae 21 (1933), 73–84 Whitney, H. [1935]: On the abstract properties of linear dependence. American Journal of Mathematics 57 (1935), 509–533

•

14 Generalizations of Matroids

There are several interesting generalizations of matroids. We have already seen independence systems in Section 13.1, which arose from dropping the axiom (M3). In Section 14.1 we consider greedoids, arising by dropping (M2) instead. Moreover, certain polytopes related to matroids and to submodular functions, called polymatroids, lead to strong generalizations of important theorems; we shall discuss them in Section 14.2. In Sections 14.3 and 14.4 we consider two approaches to the problem of minimizing an arbitrary submodular function: one using the ELLIPSOID METHOD, and one with a combinatorial algorithm. For the important special case of symmetric submodular functions we mention a simpler algorithm in Section 14.5.

14.1 Greedoids By definition, set systems .E; F / are matroids if and only if they satisfy (M1) ; 2 F ; (M2) If X Y 2 F then X 2 F ; (M3) If X; Y 2 F and jX j > jY j, then there is an x 2 X n Y with Y [ fxg 2 F . If we drop (M3), we obtain independence systems, discussed in Sections 13.1 and 13.4. Now we drop (M2) instead: Definition 14.1. A greedoid is a set system .E; F/ satisfying (M1) and (M3). Instead of the subclusiveness (M2) we have accessibility: We call a set system .E; F/ accessible if ; 2 F and for any X 2 F n f;g there exists an x 2 X with X nfxg 2 F . Greedoids are accessible (accessibility follows directly from (M1) and (M3)). Though more general than matroids, they comprise a rich structure and, on the other hand, generalize many different, seemingly unrelated concepts. We start with the following result: Theorem 14.2. Let .E; F / be an accessible set system. The following statements are equivalent: (a) For any X Y E and ´ 2 E n Y with X [ f´g 2 F and Y 2 F we have Y [ f´g 2 F ; B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__14, c Springer-Verlag Berlin Heidelberg 2012

355

356

14 Generalizations of Matroids

(b) F is closed under union. Proof: (a) )(b): Let X; Y 2 F ; we show that X [ Y 2 F . Let Z be a maximal set with Z 2 F and X Z X [ Y . Suppose Y n Z 6D ;. By repeatedly applying accessibility to Y we get a set Y 0 2 F with Y 0 Z and an element y 2 Y n Z with Y 0 [ fyg 2 F . We apply (a) to Z, Y 0 and y and obtain Z [ fyg 2 F , contradicting the choice of Z. (b) )(a) is trivial. If the conditions in Theorem 14.2 hold, then .E; F / is called an antimatroid. Proposition 14.3. Every antimatroid is a greedoid. Proof: Let .E; F / be an antimatroid, i.e. accessible and closed under union. To prove (M3), let X; Y 2 F with jX j > jY j. Since .E; F / is accessible there is an order X D fx1 ; : : : ; xn g with fx1 ; : : : ; xi g 2 F for i D 0; : : : ; n. Let i 2 f1; : : : ; ng be the minimum index with xi … Y ; then Y [ fxi g D Y [ fx1 ; : : : ; xi g 2 F (since F is closed under union). Another equivalent definition of antimatroids is by a closure operator: Proposition 14.4. Let .E; F/ be a set system such that F is closed under union and ; 2 F. Define \ .A/ WD fX E W A X; E n X 2 F g Then is a closure operator, i.e. satisfies (S1)–(S3) of Theorem 13.11. Proof: Let X Y E. X .X/ .Y / is trivial. To prove (S3), assume that there exists a y 2 ..X// n .X/. Then y 2 Y for all Y E with .X/ Y and E n Y 2 F, but there exists a Z E n fyg with X Z and E n Z 2 F . This implies .X/ 6 Z, a contradiction. Theorem 14.5. Let .E; F/ be a set system such that F is closed under union and ; 2 F . Then .E; F / is accessible if and only if the closure operator of Proposition 14.4 satisfies the anti-exchange property: if X E, y; ´ 2 E n .X/, y 6D ´ and ´ 2 .X [ fyg/, then y … .X [ f´g/. Proof: If .E; F / is accessible, then (M3) holds by Proposition 14.3. To show the anti-exchange property, let X E, B WD E n .X/, and y; ´ 2 B with ´ … A WD E n .X [ fyg/. Observe that A 2 F , B 2 F and A B n fy; ´g. By applying (M3) to A and B we get an element b 2 B n A E n .X [ A/ with A [ fbg 2 F . A [ fbg cannot be a subset of E n .X [ fyg/ (otherwise .X [ fyg/ E n .A [ fbg/, contradicting .X [ fyg/ D E n A). Hence b D y. So we have A[fyg 2 F and thus .X [f´g/ E n.A[fyg/. We have proved y … .X [f´g/. To show the converse, let A 2 F n f;g and let X WD E n A. We have .X/ D X . Let a 2 A such that j.X [fag/j is minimum. We claim that .X [fag/ D X [fag, i.e. A n fag 2 F .

14.1

Greedoids

357

Suppose, on the contrary, that b 2 .X [ fag/ n .X [ fag/. By the anti-exchange property we have a … .X [ fbg/. Moreover, .X [ fbg/ ..X [ fag/ [ fbg/ D ..X [ fag// D .X [ fag/: Hence .X [ fbg/ is a proper subset of .X [ fag/, contradicting the choice of a. The anti-exchange property of Theorem 14.5 is different from (S4). While (S4) of Theorem 13.11 is a property of linear hulls in Rn , this is a property of convex hulls in Rn : if y 6D ´, ´ 62 conv.X / and ´ 2 conv.X [ fyg/, then clearly y … conv.X [f´g/. So for any finite set E Rn , .E; fX E W X \conv.E nX / D ;g/ is an antimatroid. Greedoids generalize matroids and antimatroids, but they also contain other interesting structures. One example is the blossom structure we used in EDMONDS’ CARDINALITY MATCHING ALGORITHM (Exercise 1). Another basic example is: Proposition 14.6. Let G be a graph (directed or undirected) and r 2 V .G/. Let F be the family of all edge sets of arborescences in G rooted at r, or trees in G containing r (not necessarily spanning). Then .E.G/; F / is a greedoid. Proof: (M1) is trivial. We prove (M3) for the directed case; the same argument applies to the undirected case. Let .X1 ; F1 / and .X2 ; F2 / be two arborescences in G rooted at r with jF1 j > jF2 j. Then jX1 j D jF1 j C 1 > jF2 j C 1 D jX2 j, so let x 2 X1 n X2 . The r-x-path in .X1 ; F1 / contains an edge .v; w/ with v 2 X2 and w … X2 . This edge can be added to .X2 ; F2 /, proving that F2 [ f.v; w/g 2 F . This greedoid is called the directed (undirected) branching greedoid of G. The problem of finding a maximum weight spanning tree in a connected graph G with nonnegative weights is the MAXIMIZATION PROBLEM for the cycle matroid M.G/. The BEST-IN-GREEDY ALGORITHM is in this case nothing but KRUSKAL’S ALGORITHM. Now we have a second formulation of the same problem: we are looking for a maximum weight set F with F 2 F , where .E.G/; F / is the undirected branching greedoid of G. We now formulate a general greedy algorithm for greedoids. In the special case of matroids, it is exactly the BEST-IN-GREEDY ALGORITHM discussed in Section 13.4. If we have an undirected branching greedoid with a modular cost function c, it is PRIM’S ALGORITHM:

GREEDY ALGORITHM FOR GREEDOIDS Input: Output:

A greedoid .E; F / and a function c W 2E ! R, given by an oracle which for any given X E says whether X 2 F and returns c.X /. A set F 2 F .

1

Set F WD ;.

2

Let e 2 E n F such that F [ feg 2 F and c.F [ feg/ is maximum; if no such e exists then stop. Set F WD F [ feg and go to . 2

3

358

14 Generalizations of Matroids

Even for modular cost functions c this algorithm does not always provide an optimal solution. At least we can characterize those greedoids where it works: Theorem 14.7. Let .E; F / be a greedoid. The GREEDY ALGORITHM FOR GREEDOIDS finds a set F 2 F of maximum weight for each modular weight function c W 2E ! RC if and only if .E; F / has the so-called strong exchange property: For all A 2 F , B maximal in F , A B and x 2 E n B with A [ fxg 2 F there exists a y 2 B n A such that A [ fyg 2 F and .B n fyg/ [ fxg 2 F . Proof: Suppose .E; F / is a greedoid with the strong exchange property. Let c W E ! RC , and let A D fa1 ; : : : ; al g be the solution found by the GREEDY ALGORITHM FOR GREEDOIDS, where the elements are chosen in the order a1 ; : : : ; al . : Let B D fa1 ; : : : ; ak g [ B 0 be an optimum solution such that k is maximum, and suppose that k < l. Then we apply the strong exchange property to fa1 ; : : : ; ak g, B and akC1 . We conclude that there exists a y 2 B 0 with fa1 ; : : : ; ak ; yg 2 F and .B n y/ [ fakC1 g 2 F . By the choice of akC1 in 2 of the GREEDY ALGORITHM FOR GREEDOIDS we have c.akC1 / c.y/ and thus c..B n y/ [ fakC1 g/ c.B/, contradicting the choice of B. Conversely, let .E; F / be a greedoid that does not have the strong exchange property. Let A 2 F , B maximal in F , A B and x 2 E n B with A [ fxg 2 F such that for all y 2 B n A with A [ fyg 2 F we have .B n y/ [ fxg … F. Let Y WD fy 2 B n A W A [ fyg 2 F g. We set c.e/ WD 2 for e 2 B n Y , and c.e/ WD 1 for e 2 Y [ fxg and c.e/ WD 0 for e 2 E n .B [ fxg/. Then the GREEDY ALGORITHM FOR GREEDOIDS might choose the elements of A first (they have weight 2) and then might choose x. It will eventually end up with a set F 2 F that cannot be optimal, since c.F / c.B [ fxg/ 2 < c.B [ fxg/ 1 D c.B/ and B 2 F . Indeed, optimizing modular functions over general greedoids is NP-hard. This follows from the following observation (together with Corollary 15.24): Proposition 14.8. The problem of deciding, given an undirected graph G and k 2 N, whether G has a vertex cover of cardinality k, linearly reduces to the following problem: Given a greedoid .E; F / (by a membership oracle) and a function c W E ! RC , find an F 2 F with c.F / maximum. :

Proof: Let G be any undirected graph and k 2 N. Let D WD V .G/ [ E.G/ and F WD fX D W for all e D fv; wg 2 E.G/ \ X we have v 2 X or w 2 X g: .D; F / is an antimatroid: it is accessible and closed under union. In particular, by Proposition 14.3, it is a greedoid. Now consider F 0 WD fX 2 F W jX j jE.G/j C kg. Since (M1) and (M3) are preserved, .D; F 0 / is also a greedoid. Set c.e/ WD 1 for e 2 E.G/ and c.v/ WD 0

14.2

Polymatroids

359

for v 2 V .G/. Then there exists a set F 2 F 0 with c.F / D jE.G/j if and only if G contains a vertex cover of size k. On the other hand, there are interesting functions that can be maximized over arbitrary greedoids, for example bottleneck functions c.F / WD minfc 0 .e/ W e 2 F g for some c 0 W E ! RC (Exercise 2). See the book by Korte, Lovász and Schrader [1991] for more results in this area.

14.2 Polymatroids From Theorem 13.10 we know the tight connection between matroids and submodular functions. Submodular functions define the following interesting class of polyhedra: Definition 14.9. A polymatroid is a polytope of type ( ) X P .f / WD x 2 RE W x 0; xe f .A/ for all A E e2A

where E is a finite set and f W 2E ! RC is a submodular function. It is not hard to see that for any polymatroid f can be chosen such that f .;/ D 0 and f is monotone (Exercise 6; a function f W 2E ! R is called monotone if f .X / f .Y / for X Y E). Edmonds’ original definition was different; see Exercise 7. Moreover, we mention that the term polymatroid is sometimes not used for the polytope but for the pair .E; f /. If f is the rank function of a matroid, P .f / is the convex hull of the incidence vectors of the independent sets of this matroid (Theorem 13.21). We know that the BEST-IN-GREEDY optimizes any linear function over a matroid polytope. A similar greedy algorithm also works for general polymatroids. We assume that f is monotone:

POLYMATROID GREEDY ALGORITHM Input: Output: 1 2

A finite set E and a submodular, monotone function f W 2E ! RC with f .;/ 0 (given by an oracle). A vector c 2 RE . A vector x 2 P .f / with cx maximum.

Sort E D fe1 ; : : : ; en g such that c.e1 / c.ek / > 0 c.ekC1 / c.en /. If k 1 then set x.e1 / WD f .fe1 g/. Set x.ei / WD f .fe1 ; : : : ; ei g/ f .fe1 ; : : : ; ei 1 g/ for i D 2; : : : ; k. Set x.ei / WD 0 for i D k C 1; : : : ; n.

360

14 Generalizations of Matroids

Proposition 14.10. Let E D fe1 ; : : : ; en g and f W 2E ! R be a submodular function with f .;/ 0. Let b W E ! R with b.e1 / Pf .fe1 g/ and b.ei / f .fe1 ; : : : ; ei g/ f .fe1 ; : : : ; ei 1 g/ for i D 2; : : : ; n. Then a2A b.a/ f .A/ for all A E. Proof: Induction on i D maxfj The assertion is trivial for A D ; P W ej 2 Ag. P and A D fe1 g. If i 2, then a2A b.a/ D a2Anfei g b.a/ C b.ei / f .A n fei g/ C b.ei / f .A n fei g/ C f .fe1 ; : : : ; ei g/ f .fe1 ; : : : ; ei 1 g/ f .A/, where the first inequality follows from the induction hypothesis and the third one from submodularity. Theorem 14.11. The POLYMATROID GREEDY ALGORITHM correctly finds an x 2 P .f / with cx maximum. If f is integral, then x is also integral. Proof: Let x 2 RE be the output of the POLYMATROID GREEDY ALGORITHM for E, f and c. By definition, if f is integral, then x is also integral. We have x 0 since f is monotone, and thus x 2 P .f / by Proposition 14.10. Now let y 2 RE C with cy > cx. Similarly as in the proof of Theorem 13.19 we set dj WD c.ej / c.ej C1 / (j D 1; : : : ; k 1) and dk WD c.ek /, and we have k X j D1

dj

j X

x.ei / D cx < cy

i D1

k X

c.ej /y.ej / D

j D1

k X j D1

dj

j X

y.ei /:

i D1

Pj Since dj 0 for all j there is an index j 2 f1; : : : ; kg with i D1 y.ei / > Pj Pj i D1 x.ei /; however, since i D1 x.ei / D f .fe1 ; : : : ; ej g/ this means that y … P .f /. As with matroids, we can also handle the intersection of two polymatroids. The following polymatroid intersection theorem has many implications: Theorem 14.12. (Edmonds [1970,1979]) Let E be a finite set, and let f; g W 2E ! RC be submodular functions. Then the system X x0 xe f .A/ e2A X xe g.A/

.A E/ .A E/

e2A

is TDI. Proof: Consider the primal-dual pair of LPs ) ( X X xe f .A/ and xe g.A/ for all A E max cx W x 0; e2A

e2A

14.2

and

8 <X .f .A/yA C g.A/´A / W y; ´ 0; min : AE

X

AE; e2A

Polymatroids

361

9 = .yA C ´A / ce for all e 2 E : ;

To show total dual integrality, we use Lemma 5.23. Let c W E.G/ ! Z, and let y; ´ be an optimum dual solution for which X .yA C ´A /jAjjE n Aj (14.1) AE

is as small as possible. We claim that F WD fA E W yA > 0g is a chain, i.e. for any A; B 2 F either A B or B A. To see this, suppose A; B 2 F with A \ B 6D A and A \ B 6D B. Let WD 0 0 minfyA ; yB g. Set yA0 WD yA , yB0 WD yB , yA\B WD yA\B C , yA[B WD 0 0 yA[B C , and y .S / WD y.S / for all other S E. Since y ; ´ is a feasible dual solution, it is also optimum (f is submodular) and contradicts the choice of y, because (14.1) is smaller for y 0 ; ´. By the same argument, F 0 WD fA E W ´A > 0g is a chain. Now let M and 0 M be the matrices whose columns are indexed with the elements of E and whose 0 rows are the incidence vectors the of elements of F and F , respectively. By Lemma M 5.23, it suffices to show that M 0 is totally unimodular. Here we use Ghouila-Houri’s Theorem 5.24. Let R be a set of rows, say R D fA1 ; : : : ; Ap ; B1 ; : : : ; Bq g with A1 Ap and B1 Bq . Let R1 WD fAi W i oddg [ fBi W i eveng and R2 WD R n R1 . Since for any e 2 E we have fR 2 R W e 2 Rg D fA1 ; : : : ; Ape g [ fB1 ; : : : ; Bqe g for some pe 2 f0; : : : ; pg and qe 2 f0; : : : ; qg, the sum of the rows in R1 minus the sum of the rows in R2 is a vector with entries 1; 0; 1 only. So the criterion of Theorem 5.24 is satisfied. One can optimize linear functions over the intersection of two polymatroids. However, this is not as easy as with a single polymatroid. But we can use the ELLIPSOID M ETHOD if we can solve the S EPARATION PROBLEM for each polymatroid. We return to this question in Section 14.3. Corollary 14.13. (Edmonds [1970]) Let .E; M1 / and .E; M2 / be two matroids with rank functions r1 and r2 . Then the convex hull of the incidence vectors of the elements of M1 \ M2 is the polytope ( ) X E x 2 RC W xe minfr1 .A/; r2 .A/g for all A E : e2A

Proof: As r1 and r2 are nonnegative and submodular (by Theorem 13.10), the above inequality system is TDI (by Theorem 14.12). Since r1 and r2 are integral, the polytope is integral (by Corollary 5.15). Since r1 .A/ jAj for all A E, the

362

14 Generalizations of Matroids

vertices (the convex hull of which the polytope is by Corollary 3.32) are 0-1-vectors, and thus incidence vectors of common independent sets (elements of M1 \ M2 ). On the other hand, each such incidence vector satisfies the inequalities (by definition of the rank function). Of course, the description of the matroid polytope (Theorem 13.21) follows from this by setting M1 D M2 . Theorem 14.12 has some further consequences: Corollary 14.14. (Edmonds [1970]) Let E be a finite set, and let f; g W 2E ! RC be submodular and monotone functions with f .;/ D g.;/ D 0. Then maxf1lx W x 2 P .f / \ P .g/g D min .f .A/ C g.E n A//: AE

Moreover, if f and g are integral, there exists an integral x attaining the maximum. Proof: By Theorem 14.12, the dual to maxf1lx W x 2 P .f / \ P .g/g; which is 8 <X min .f .A/yA Cg.A/´A / W y; ´ 0; : AE

X

9 = .yA C´A / 1 for all e 2 E

AE; e2A

;

;

S S has an integral optimum solution y; ´. Let B WD AWyA 1 A and C WD AW´A 1 A. We have B [ C D E. Since f and g are submodular and nonnegative, and f .;/ D g.;/ D 0, X .f .A/yA C g.A/´A / f .B/ C g.C /: AE

Since E n B C and g is monotone, this is at least f .B/ C g.E n B/, proving “”. The other inequality “” is trivial, because for any A E we obtain a feasible dual solution y; ´ by setting yA WD 1, ´E nA WD 1 and all other components to zero. The integrality follows directly from Theorem 14.12 and Corollary 5.15. Theorem 13.31 is a special case. Moreover we obtain: Corollary 14.15. (Frank [1982]) Let E be a finite set and f; g W 2E ! R such that f is supermodular, g is submodular and f g. Then there exists a modular function h W 2E ! R with f h g. If f and g are integral, h can be chosen integral. Proof: Let M WD 2 maxfjf .A/j C jg.A/j W A Eg. Let f 0 .A/ WD g.E/ f .E n A/ C M jAj and g 0 .A/ WD g.A/ f .;/ C M jAj for all A E. f 0 and g0 are nonnegative, submodular and monotone. An application of Corollary 14.14 yields

14.3

Minimizing Submodular Functions

363

maxf1lx W x 2 P .f 0 / \ P .g 0 /g D min .f 0 .A/ C g 0 .E n A// AE

D min .g.E/ f .E n A/ C M jAj C g.E n A/ f .;/ C M jE n Aj/ AE

g.E/ f .;/ C M jEj: .;/CM jEj. If f and g are integral, x So let x 2 P .f 0 /\P .g0 / with 1lx D g.E/f P can be chosen integral. Let h0 .A/ WD e2A xe and h.A/ WD h0 .A/ C f .;/ M jAj for all A E. The function h is modular. Moreover, for all A E we have h.A/ g 0 .A/Cf .;/M jAj D g.A/ and h.A/ D 1lxh0 .E nA/Cf .;/M jAj g.E/ C M jEj M jAj f 0 .E n A/ D f .A/. The analogy to convex and concave functions is obvious; see also Exercise 10.

14.3 Minimizing Submodular Functions The SEPARATION PPROBLEM for a polymatroid P .f / and a vector x asks for a set A with f .A/ < e2A x.e/. So this P problem reduces to finding a set A minimizing g.A/, where g.A/ WD f .A/ e2A x.e/. Note that if f is submodular, then g is also submodular. Therefore it is an interesting problem to minimize submodular functions. Another motivation might be that submodular functions can be regarded as the discrete analogue of convex functions (Corollary 14.15 and Exercise 10). We have already solved a special case in Section 8.7: finding the minimum cut in an undirected graph can be regarded as minimizing a certain symmetric submodular function f W 2U ! RC over 2U n f;; U g. Before returning to this special case we first show how to minimize general submodular functions. For simplicity we restrict ourselves to integer-valued submodular functions:

SUBMODULAR FUNCTION MINIMIZATION PROBLEM Instance: Task:

A finite set U . A submodular function f W 2U ! Z (given by an oracle). Find a subset X U with f .X / minimum.

Grötschel, Lovász and Schrijver [1981] showed how this problem can be solved with the help of the E LLIPSOID METHOD. The idea is to determine the minimum by binary search; this will reduce the problem to the SEPARATION PROBLEM for a polymatroid. Using the equivalence of separation and optimization (Section 4.6), it thus suffices to optimize linear functions over polymatroids. However, this can be done easily by the POLYMATROID GREEDY ALGORITHM. We first need an upper bound on jf .S /j for S U : Proposition 14.16. For any submodular function f W 2U ! Z and any S U we have

364

14 Generalizations of Matroids

f .U /

X

maxf0; f .fug/f .;/g f .S / f .;/C

u2U

X

maxf0; f .fug/f .;/g:

u2U

In particular, a number B with jf .S /j B for all S U can be computed in linear time, with jU j C 2 oracle calls to f . Proof: By repeated application of submodularity we get for ; 6D S U (let x 2 S ): X f .S / f .;/Cf .S nfxg/Cf .fxg/ jS jf .;/Cf .;/C f .fxg/; x2S

and for S U (let y 2 U n S ): f .S / f .fyg/ C f .S [ fyg/ C f .;/ X f .fyg/ C f .U / C jU n S jf .;/: y2U nS

Proposition 14.17. The following problem can be solved in polynomial time: Given a finite set U , a submodular and monotone function f W 2U ! ZC (by an oracle) with f .S / > 0 for S 6D ;, a number B 2 N with f .S / B for all S U , andPa vector x 2 ZU C , decide if x 2 P .f / and otherwise return a set S U with v2S x.v/ > f .S /. Proof: This is the SEPARATION PROBLEM for the polymatroid P .f /. We will use Theorem 4.23, because we have already solved the optimization problem for P .f /: the POLYMATROID GREEDY ALGORITHM maximizes any linear function over P .f / (Theorem 14.11). We have to check the prerequisites of Theorem 4.23. Since the zero vector and the unit vectors are all in P .f /, we can take x0 WD 1l as a point in the interior, 1 where D jU jC1 . We have size.x0 / D O.jU j log jU j/. Moreover, each vertex of P .f / is produced by the POLYMATROID GREEDY ALGORITHM (for some objective function; cf. Theorem 14.11) and thus has size O.jU j.2 C log B//. We conclude that the SEPARATION PROBLEM can be solved in polynomial time. By Theorem 4.23, we get a facet-defining inequality of P .f / violated by x if x … P .f /. This P corresponds to a set S U with v2S x.v/ > f .S /. If f is not monotone, we cannot apply this result directly. Instead we consider a different function: Proposition 14.18. Let f W 2U ! R be a submodular function and ˇ 2 R. Then g W 2U ! R, defined by X .f .U n feg/ f .U //; g.X / WD f .X / ˇ C e2X

is submodular and monotone.

14.4

Schrijver’s Algorithm

365

Proof: The submodularity of g follows directly from the submodularity of f . To show that g is monotone, let X U and e 2 U n X . We have g.X [ feg/ g.X / D f .X [ feg/ f .X / C f .U n feg/ f .U / 0 since f is submodular. Theorem 14.19. The SUBMODULAR FUNCTION MINIMIZATION PROBLEM can be solved in time polynomial in jU j C log maxfjf .S /j W S U g. Proof: Let U be a finite set; suppose we are given f by an oracle. First compute a number B 2 N with jf .S /j B for all S U (cf. Proposition 14.16). Since f is submodular, we have for each e 2 U and for each X U n feg: f .feg/ f .;/ f .X [ feg/ f .X / f .U / f .U n feg/:

(14.2)

If, for some e 2 U , f .feg/ f .;/ 0, then by (14.2) there is an optimum set S containing e. In this case we consider the instance .U 0 ; B; f 0 / defined by U 0 WD U n feg and f 0 .X / WD f .X [ feg/ for X U n feg, find a set S 0 U 0 with f 0 .S 0 / minimum and output S WD S 0 [ feg. Similarly, if f .U / f .U n feg/ 0, then by (14.2) there is an optimum set S not containing e. In this case we simply minimize f restricted to U n feg. In both cases we have reduced the size of the ground set. So we may assume that f .feg/ f .;/ > 0 and f .U n feg/ f .U / > 0 for all e 2 U . Let x.e/ WD f .U n feg/ f P .U /. For each integer ˇ with B ˇ f .;/ we define g.X / WD f .X / ˇ C e2X x.e/. By Proposition 14.18, g is submodular and monotone. Furthermore we have g.;/ D f .;/ ˇ 0 and g.feg/ D f .feg/ ˇ C x.e/ > 0 for all e 2 U , and thus g.X / > 0 for all ; 6D X U . Now we apply Proposition 14.17 and check if x 2 P .g/. If yes, we have f .X / ˇ for all X U and we are done. Otherwise we get a set S with f .S / < ˇ. Now we apply binary search: by choosing ˇ appropriately each time, we need O.log.2B// iterations to find the number ˇ 2 fB; B C 1; : : : ; f .;/g for which f .X / ˇ for all X U but f .S / < ˇ C 1 for some S U . This set S minimizes f . The first strongly polynomial-time algorithm has been designed by Grötschel, Lovász and Schrijver [1988], also based on the ellipsoid method. Combinatorial algorithms to solve the SUBMODULAR FUNCTION MINIMIZATION PROBLEM in strongly polynomial time have been found by Schrijver [2000] and independently by Iwata, Fleischer and Fujishige [2001]. In the next section we describe Schrijver’s algorithm.

14.4 Schrijver’s Algorithm For a finite set U and a submodular function f W 2U ! Z, assume w.l.o.g. that U D f1; : : : ; ng and f .;/ D 0. At each stage, Schrijver’s [2000] algorithm maintains a point x in the so-called base polyhedron of f , defined by

366

14 Generalizations of Matroids

( U

x2R W

X

x.u/ f .A/ for all A U;

u2A

X

) x.u/ D f .U / :

u2U

We mention that the set of vertices of this base polyhedron is precisely the set of vectors b for all total orders of U , where we define b .u/ WD f .fv 2 U W v ug/ f .fv 2 U W v ug/ (u 2 U ). This fact, which we will not need here, can be proved in a similar way as Theorem 14.11 (Exercise 14). The point x is always written as an explicit convex combination x D 1 b 1 C C k b k of these vertices. Initially, one can choose k D 1 and any total order. For a total order and s; u 2 U , we denote by s;u the total order that results from by moving u just before s. Moreover, let u denote the incidence vector of u (u 2 U ).

SCHRIJVER’S ALGORITHM Input: Output:

A finite set U D f1; : : : ; ng. A submodular function f W 2U ! Z with f .;/ D 0 (given by an oracle). A subset X U with f .X / minimum.

1

Set k WD 1, let 1 be any total order on U , and set x WD b 1 .

2

Set D WD .U; A/, where A D f.u; v/ W u i v for some i 2 f1; : : : ; kgg.

3

Let P WD fv 2 U W x.v/ > 0g and N WD fv 2 U W x.v/ < 0g, and let X be the set of vertices not reachable from P in the digraph D. If N X , then stop else let d.v/ denote the distance from P to v in D. Choose the vertex t 2 N reachable from P with .d.t/; t/ lexicographically maximum. Choose the maximal vertex s with .s; t/ 2 A and d.s/ D d.t/ 1. Let i 2 f1; : : : ; kg such that ˛ WD jfv W s i v i tgj is maximum (the number of indices attaining this maximum will be denoted by ˇ).

4

5

6

Compute a number with 0 x.t/ and write x 0 WD x C .t s / as an explicit convex combination of at most n vectors, chosen among s;u b 1 ; : : : ; b k and b i for all u 2 U with s i u i t, with the additional i property that b does not occur if x 0 .t/ < 0. Set x WD x 0 , rename the vectors in the convex combination of x as b 1 ; : : : ; b k0 , set k WD k 0 , and go to . 2

Theorem 14.20. (Schrijver [2000]) SCHRIJVER’S ALGORITHM works correctly. Proof: The algorithm terminates if D contains no path from P to N and outputs of vertices not reachable from P . Clearly N X U n P , so P the set X P u2X x.u/ u2W x.u/ for each W U . Moreover, no edge enters X , so either X D ; or for each j 2 f1; : : : ; kg there exists a v 2 X with X D fu 2 U W u j vg.

14.4

Schrijver’s Algorithm

367

P j Hence, by definition, P u2X b .u/ D f .X / for all j 2 f1; : : : ; kg. Moreover, by Proposition 14.10, u2W b j .u/ f .W / for all W U and j 2 f1; : : : ; kg. Therefore, for each W U , f .W /

k X j D1

X

X

j

b j .u/ D

k XX

j b j .u/ D

u2W j D1

u2W k XX

x.u/ D

x.u/

u2W

j b j .u/ D

u2X j D1

u2X

X

k X j D1

j

X

b j .u/ D f .X /;

u2X

proving that X is an optimum solution.

Lemma 14.21. (Schrijver [2000]) Each iteration can be performed in O.n3 C n2 / time, where is the time for an oracle call. Proof: It suffices to show that 5 can be done in O.n3 C n2 / time. Let x D 1 k 1 b C C k b and s i t. We first show: Claim: ı.t s /, for some ı 0, can be written as a convex combination of s;v the vectors b i b i for s i v i t in O. n2 / time. To prove this, we need some preliminaries. Let s i v i t. By definition, s;v b i .u/ D b i .u/ for u i s or u i v. As f is submodular, we have for s i u i v: s;v

b i .u/ D f .fw 2 U W w s;v ug/ f .fw 2 U W w s;v ug/ i i

f .fw 2 U W w i ug/ f .fw 2 U W w i ug/ D b i .u/:

Moreover, for u D v we have: s;v

b i .v/ D f .fw 2 U W w s;v vg/ f .fw 2 U W w s;v vg/ i i D f .fw 2 U W w i sg [ fvg/ f .fw 2 U W w i sg/ f .fw 2 U W w i vg/ f .fw 2 U W w i vg/ D b i .v/: P P s;v Finally, observe that u2U b i .u/ D f .U / D u2U b i .u/. s;v As the claim is trivial if b i D b i for some s i v i t, we may assume s;v b i .v/ > b i .v/ for all s i v i t. We recursively set v WD

tv

P

s;w

vi wi t

s;v

w .b i .v/ b i .v//

b i .v/ b i .v/

0

P s;v for s i v i t, and obtain si vi t v .b i b i / D t s , because P P s;v s;v i .u/ b i .u// D i .u/ b i .u// D t for u si vi t v .b ui vi t v .b all s i u i t, and the sum over all components is zero.

368

14 Generalizations of Matroids

By setting ı WD

P

1 si vi t

v

and multiplying each u by ı, we see that the claim

follows. Now consider WD minfi ı; x.t/g and x 0 WD x C .t s /. If D i ı P P s;v x.t/, then we have x 0 D jkD1 j b j Ci si vi t v .b i b i /, i.e. we have s;v

written x 0 as a convex combination of b j (j 2 f1; : : : ; kg n fi g) and b i (s i v i t). If D x.t/, we may additionally use b i in the convex combination. We finally reduce this convex combination to at most n vectors in O.n3 / time, as shown in Exercise 5 of Chapter 4. Lemma 14.22. (Vygen [2003]) O.n5 / iterations.

SCHRIJVER’S ALGORITHM terminates after s;v

Proof: If an edge .v; w/ is introduced after a new vector b i has been added in 5 of an iteration, then s i w i v i t in this iteration. Thus d.w/ d.s/ C 1 D d.t/ d.v/ C 1 in this iteration, and the introduction of the new edge cannot make the distance from P to any u 2 U smaller. As 5 makes sure that no element is ever added to P , the distance d.u/ never decreases for any u 2 U . Call a block a sequence of iterations where the pair .t; s/ remains constant. Note that each block has O.n2 / iterations, because .˛; ˇ/ decreases lexicographically in each iteration within each block. It remains to prove that there are O.n3 / blocks. A block can end only because of at least one of the following reasons (by the choice of t and s, since an iteration with t D t does not add any edge whose head is t , and since a vertex v can enter N only if v D s and hence d.v/ < d.t/): (a) the distance d.v/ increases for some v 2 U . (b) t is removed from N . (c) .s; t/ is removed from A. We now count the number of blocks of these three types. Clearly there are O.n2 / blocks of type (a). Now consider type (b). We claim that for each t 2 U there are O.n2 / iterations with t D t and x 0 .t/ D 0. This is easy to see: between every two such iterations, d.v/ must change for some v 2 U , and this can happen O.n2 / times as d -values can only increase. Thus there are O.n3 / blocks of type (b). We finally show that there are O.n3 / blocks of type (c). It suffices to show that d.t/ will change before the next such block with the pair .s; t/. For s; t 2 U , we say that s is t-boring if .s; t/ … A or d.t/ d.s/. Let s ; t 2 U , and consider the time period after a block with s D s and t D t ending because .s ; t / is removed from A, until the subsequent change of d.t /. We prove that each v 2 fs ; : : : ; ng is t -boring throughout this period. Applying this for v D s concludes the proof. At the beginning of the period, each v 2 fs C 1; : : : ; ng is t -boring due to the choice of s D s in the iteration immediately preceding the period. s is also t -boring as .s ; t / is removed from A. As d.t / remains constant within the considered time period and d.v/ never decreases for any v, we only have to check the introduction of new edges.

14.5

Symmetric Submodular Functions

369

Suppose that, for some v 2 fs ; : : : ; ng, the edge .v; t / is added to A after an iteration that chooses the pair .s; t/. Then, by the initial remarks of this proof, s i t i v i t in this iteration, and thus d.t / d.s/ C 1 D d.t/ d.v/ C 1. Now we distinguish two cases: If s > v, then we have d.t / d.s/: either because t D s, or as s was t -boring and .s; t / 2 A. If s < v, then we have d.t/ d.v/: either because t D v, or by the choice of s and since .v; t/ 2 A. In both cases we conclude that d.t / d.v/, and v remains t -boring. Theorem 14.20, Lemma 14.21 and Lemma 14.22 imply: Theorem 14.23. The SUBMODULAR FUNCTION MINIMIZATION PROBLEM can be solved in O.n8 C n7 / time, where is the time for an oracle call. Iwata [2002] described a fully combinatorial algorithm (using only additions, subtractions, comparisons and oracle calls, but no multiplication or division). He also improved the running time (Iwata [2003]). The currently fastest strongly polynomial-time algorithm was found by Orlin [2007]; it runs in O.n6 C n5 / time.

14.5 Symmetric Submodular Functions A submodular function f W 2U ! R is called symmetric if f .A/ D f .U n A/ for all A U . In this special case the SUBMODULAR FUNCTION MINIMIZATION PROBLEM is trivial, since 2f .;/ D f .;/Cf .U / f .A/Cf .U nA/ D 2f .A/ for all A U , implying that the empty set is optimal. Hence the problem is interesting only if this trivial case is excluded: one looks for a nonempty proper subset A of U such that f .A/ is minimum. Generalizing the algorithm of Section 8.7, Queyranne [1998] has found a relatively simple combinatorial algorithm for this problem using only O.n3 / oracle calls. The following lemma is a generalization of Lemma 8.41 (Exercise 16): Lemma 14.24. Given a symmetric submodular function f W 2U ! R with n WD jU j 2, we can find two elements x; y 2 U with x 6D y and f .fxg/ D minff .X / W x 2 X U n fygg in O.n2 / time, where is the time bound of the oracle for f . Proof: We construct an order U D fu1 ; : : : ; un g by doing the following for k D 1; : : : ; n 1. Suppose that u1 ; : : : ; uk1 are already constructed; let Uk1 WD fu1 ; : : : ; uk1 g. For C U we define 1 wk .C / WD f .C / .f .C n Uk1 / C f .C [ Uk1 / f .Uk1 //: 2 Note that wk is also symmetric. Let uk be an element of U n Uk1 that maximizes wk .fuk g/. Finally, let un be the only element in U n fu1 ; : : : ; un1 g. Obviously the construction of the order u1 ; : : : ; un can be done in O.n2 / time.

370

14 Generalizations of Matroids

Claim: For all k D 1; : : : ; n 1 and all x; y 2 U n Uk1 with x 6D y and wk .fxg/ wk .fyg/ we have wk .fxg/ D minfwk .C / W x 2 C U n fygg: We prove the claim by induction on k. For k D 1 the assertion is trivial since w1 .C / D 12 f .;/ for all C U . Let now k > 1 and x; y 2 U n Uk1 with x 6D y and wk .fxg/ wk .fyg/. Moreover, let Z U with uk1 … Z, and let ´ 2 Z n Uk1 . By the choice of uk1 we have wk1 .f´g/ wk1 .fuk1 g/; thus by the induction hypothesis we get wk1 .f´g/ wk1 .Z/. Furthermore, the submodularity of f implies .wk .Z/ wk1 .Z// .wk .f´g/ wk1 .f´g// 1 D .f .Z [ Uk2 / f .Z [ Uk1 / f .Uk2 / C f .Uk1 // 2 1 .f .f´g [ Uk2 / f .f´g [ Uk1 / f .Uk2 / C f .Uk1 // 2 1 D .f .Z [ Uk2 / C f .f´g [ Uk1 / f .Z [ Uk1 / f .f´g [ Uk2 // 2 0: Hence wk .Z/ wk .f´g/ wk1 .Z/ wk1 .f´g/ 0. To conclude the proof of the claim, let C U with x 2 C and y … C . There are two cases: Case 1: uk1 … C . Then the above result for Z D C and ´ D x yields wk .C / wk .fxg/ as required. Case 2: uk1 2 C . Then we apply the above to Z D U n C and ´ D y and get wk .C / D wk .U n C / wk .fyg/ wk .fxg/. This completes the proof of the claim. Applying it to k D n 1, x D un and y D un1 we get wn1 .fun g/ D minfwn1 .C / W un 2 C U n fun1 gg: Since wn1 .C / D f .C / 12 .f .fun g/ C f .U n fun1 g/ f .Un2 // for all C U with un 2 C and un1 … C , the lemma follows (set x WD un and y WD un1 ). The above proof is due to Fujishige [1998]. Now we can proceed analogously to the proof of Theorem 8.42: Theorem 14.25. (Queyranne [1998]) Given a symmetric submodular function f W 2U ! R, a nonempty proper subset A of U such that f .A/ is minimum can be found in O.n3 / time where is the time bound of the oracle for f . Proof: If jU j D 1, the problem is trivial. Otherwise we apply Lemma 14.24 and find two elements x; y 2 U with f .fxg/ D minff .X / W x 2 X U n fygg in O.n2 / time. Next we recursively find a nonempty proper subset of U n fxg minimizing the function f 0 W 2U nfxg ! R, defined by f 0 .X / WD f .X / if y … X

Exercises

371

and f 0 .X / WD f .X [ fxg/ if y 2 X . One readily observes that f 0 is symmetric and submodular. Let ; 6D Y U n fxg be a set minimizing f 0 ; w.l.o.g. y 2 Y (as f 0 is symmetric). We claim that either fxg or Y [ fxg minimizes f (over all nonempty proper subsets of U ). To see this, consider any C U with x 2 C . If y … C , then we have f .fxg/ f .C / by the choice of x and y. If y 2 C , then f .C / D f 0 .C n fxg/ f 0 .Y / D f .Y [ fxg/. Hence f .C / minff .fxg/; f .Y [ fxg/g for all nonempty proper subsets C of U . To achieve the asserted running time we of course cannot compute f 0 explicitly. Rather we store a partition of U , initially consisting of the singletons. At each step of the recursion we build the union of those two sets of the partition that contain x and y. In this way f 0 can be computed efficiently (using the oracle for f ). This result has been further generalized by Nagamochi and Ibaraki [1998] and by Rizzi [2000].

Exercises 1. Let G be an undirected graph and M a maximum matching in G. Let F be the family of those subsets X E.G/ for which there exists a special blossom forest F with respect to M with E.F / n M D X . Prove that .E.G/ n M; F / is a greedoid. Hint: Use Exercise 24 of Chapter 10. 2. Let .E; F / be a greedoid and c 0 W E ! RC . We consider the bottleneck function c.F / WD minfc 0 .e/ W e 2 F g for F E. Show that the GREEDY ALGORITHM FOR G REEDOIDS , when applied to .E; F / and c, finds an F 2 F with c.F / maximum. 3. This exercise shows that greedoids can also be defined as languages (cf. Definition 15.1). Let E be a finite set. A language L over the alphabet E is called a greedoid language if (a) L contains the empty string; (b) xi 6D xj for all .x1 ; : : : ; xn / 2 L and 1 i < j n; (c) .x1 ; : : : ; xn1 / 2 L for all .x1 ; : : : ; xn / 2 L; (d) If .x1 ; : : : ; xn /; .y1 ; : : : ; ym / 2 L with m < n, then there exists an i 2 f1; : : : ; ng such that .y1 ; : : : ; ym ; xi / 2 L. L is called an antimatroid language if it satisfies (a), (b), (c) and (d0 ) If .x1 ; : : : ; xn /; .y1 ; : : : ; ym / 2 L with fx1 ; : : : ; xn g 6 fy1 ; : : : ; ym g, then there exists an i 2 f1; : : : ; ng such that .y1 ; : : : ; ym ; xi / 2 L. Prove: A language L over the alphabet E is a greedoid language (an antimatroid language) if and only if the set system .E; F / is a greedoid (antimatroid), where F WD ffx1 ; : : : ; xn g W .x1 ; : : : ; xn / 2 Lg. 4. Let U be a finite set and f W 2U ! R. Prove that f is submodular if and only if f .X [ fy; ´g/ f .X [ fyg/ f .X [ f´g/ f .X / for all X U and y; ´ 2 U with y 6D ´.

372

14 Generalizations of Matroids

5. Let .G; u; s; t/ be a network and U WD ı C .s/. Let P WD fx 2 RU C W there is an s-t-flow f in .G; u/ with f .e/ D xe for all e 2 U g. Prove that P is a polymatroid. 6. Let P be a polymatroid. Show that then there is a submodular and monotone function f with f .;/ D 0 and P D P .f /. 7. Prove that a nonempty compact set P RnC is a polymatroid if and only if (a) For all 0 x y 2 P we have x 2 P . (b) For all x 2 RnC and all y; ´ x with y; ´ 2 P that are maximal with this property (i.e. y w x and w 2 P implies w D y, and ´ w x and w 2 P implies w D ´) we have 1ly D 1l´. Note: This is the original definition of Edmonds [1970]. 8. Prove that the P OLYMATROID GREEDY ALGORITHM, when applied to a vector E c 2 RE C and a submodular but not necessarily monotone function f W 2 ! R with f .;/ 0, solves ( ) X max cx W xe f .A/ for all A E : e2A

9. Prove Theorem 14.12 for the special case that f and g are rank functions of matroids by constructing an integral optimum dual solution from c1 and c2 as generated by the WEIGHTED MATROID INTERSECTION ALGORITHM. (Frank [1981])

10. Let S be a finite set and f W 2S ! R. Define f 0 W RSC ! R as follows. For any x 2 RSC there are unique k 2 ZC , 1 ; : : : ; k > 0 and ; T1 T2 P Tk S such that x D kiD1 i Ti , where Ti is the incidence vector of Ti . P Then f 0 .x/ WD kiD1 i f .Ti /. Prove that f is submodular if and only if f 0 is convex. (Lovász [1983]) 11. Let E be a finite set and f W 2E ! RC a submodular function with f .feg/ 2 for all e 2 E. (The pair .E; f / is sometimes called a 2-polymatroid.) The POLYMATROID MATCHING PROBLEM asks for a maximum cardinality set X E with f .X / D 2jX j. (f is of course given by an oracle.) Let E1 ; : : : ; Ek be pairwise disjoint unordered pairs and let .E; F / be a matroid (given by an independence oracle), where E D E1 [ [ Ek . The MATROID PARITY PROBLEM asks for a maximum cardinality set I f1; : : : ; kg with S i 2I Ei 2 F . (a) Show that the MATROID PARITY PROBLEM polynomially reduces to the POLYMATROID MATCHING PROBLEM.

(b) Show that the POLYMATROID MATCHING PROBLEM polynomially reduces to the MATROID PARITY PROBLEM. Hint: Use an algorithm for the SUBMODULAR FUNCTION MINIMIZATION PROBLEM.

(c) Show that there is no algorithm for the POLYMATROID MATCHING PROBLEM whose running time is polynomial in jEj. (Jensen and Korte [1982], Lovász [1981])

Exercises

373

(A problem polynomially reduces to another one if the former can be solved with a polynomial-time oracle algorithm using an oracle for the latter; see Chapter 15.) Note: A polynomial-time algorithm for an important special case was given by Lovász [1980,1981]. 12. A function f W 2S ! R[f1g is called crossing submodular if f .X /Cf .Y / f .X [Y /Cf .X \Y / for any two sets X; Y S with X \Y 6D ; and X [Y 6D S . The SUBMODULAR FLOW PROBLEM is as follows: Given a digraph G, functions l W E.G/ ! R [ f1g, u W E.G/ ! R [ f1g, c W E.G/ ! R, and a crossing submodular function b W 2V .G/ ! R [ f1g. Then a feasible submodular flow is a function f W E.G/ ! R with l.e/ f .e/ u.e/ for all e 2 E.G/ and X X f .e/ f .e/ b.X / e2ı .X/

e2ı C .X/

for all X V .G/. The taskPis to decide whether a feasible flow exists and, if yes, to find one whose cost e2E.G/ c.e/f .e/ is minimum possible. Show that this problem generalizes the MINIMUM COST FLOW PROBLEM and the problem of optimizing a linear function over the intersection of two polymatroids. Note: The SUBMODULAR FLOW PROBLEM, introduced by Edmonds and Giles [1977], can be solved in strongly polynomial time; see Fujishige, Röck and Zimmermann [1989]. See also Fleischer and Iwata [2000].

13. Show that the inequality system describing a feasible submodular flow (Exercise 12) is TDI. Show that this implies Theorems 14.12 and 19.17. (Edmonds and Giles [1977]) 14. Prove that the set of vertices of the base polyhedron of a submodular function f with f .;/ D 0 is precisely the set of vectors b for all total orders of U , where b .u/ WD f .fv 2 U W v ug/ f .fv 2 U W v ug/ (u 2 U ). Hint: See the proof of Theorem 14.11. 15. Let f W2U ! R be a submodular function with f .;/D0, and let˚P B.f / denote its base polyhedron. Prove that minff .X / W X U g D max u2U ´.u/ W ˚P ´.A/ minf0; f .A/g for all AU D max minf0; y.u/g W y 2 B.f / . u2U Hint: Use Corollary 14.14 or the correctness of SCHRIJVER’S ALGORITHM. 16. Show that Lemma 8.41 is a special case of Lemma 14.24. 17. Let f W 2U ! R be a submodular function. Let R be a random subset of U , where each element is chosen independently with probability 12 . Prove: (a) Exp.f .R// 12 .f .;/ C f .U //. (b) For each A U we have Exp.f .R// 14 .f .;/ C f .A/ C f .U n A/ C f .U //. Hint: Apply (a) twice. (c) If f is nonnegative, then Exp.f .R// 14 maxAU f .A/. Note: Part (c) implies a randomized 4-factor approximation algorithm for (nonnegative) submodular function maximization. This problem cannot be solved

374

14 Generalizations of Matroids

optimally with a polynomial number of oracle calls. (Feige, Mirrokni and Vondrák [2011]; they also prove stronger results.)

References General Literature: Bixby, R.E., and Cunningham, W.H. [1995]: Matroid optimization and algorithms. In: Handbook of Combinatorics; Vol. 1 (R.L. Graham, M. Grötschel, L. Lovász, eds.), Elsevier, Amsterdam, 1995 Björner, A., and Ziegler, G.M. [1992]: Introduction to greedoids. In: Matroid Applications (N. White, ed.), Cambridge University Press, Cambridge 1992 Frank, A. [2011]: Connections in Combinatorial Optimization. Oxford University Press, Oxford 2011 Fujishige, S. [2005]: Submodular Functions and Optimization. Second Edition. Elsevier, Amsterdam 2005 Iwata, S. [2008]: Submodular function minimization. Mathematical Programming B 112 (2008), 45–64 Korte, B., Lovász, L., and Schrader, R. [1991]: Greedoids. Springer, Berlin 1991 McCormick, S.T. [2004]: Submodular function minimization. In: Discrete Optimization (K. Aardal, G.L. Nemhauser, R. Weismantel, eds.), Elsevier, Amsterdam 2005 Schrijver, A. [2003]: Combinatorial Optimization: Polyhedra and Efficiency. Springer, Berlin 2003, Chapters 44–49

Cited References: Edmonds, J. [1970]: Submodular functions, matroids and certain polyhedra. In: Combinatorial Structures and Their Applications; Proceedings of the Calgary International Conference on Combinatorial Structures and Their Applications 1969 (R. Guy, H. Hanani, N. Sauer, J. Schönheim, eds.), Gordon and Breach, New York 1970, pp. 69–87 Edmonds, J. [1979]: Matroid intersection. In: Discrete Optimization I; Annals of Discrete Mathematics 4 (P.L. Hammer, E.L. Johnson, B.H. Korte, eds.), North-Holland, Amsterdam 1979, pp. 39–49 Edmonds, J., and Giles, R. [1977]: A min-max relation for submodular functions on graphs. In: Studies in Integer Programming; Annals of Discrete Mathematics 1 (P.L. Hammer, E.L. Johnson, B.H. Korte, G.L. Nemhauser, eds.), North-Holland, Amsterdam 1977, pp. 185–204 Feige, U., Mirrokni, V.S., and Vondrák, J. [2011]: Maximizing non-monotone submodular functions. SIAM Journal on Computing 40 (2011), 1133–1153 Fleischer, L., and Iwata, S. [2000]: Improved algorithms for submodular function minimization and submodular flow. Proceedings of the 32nd Annual ACM Symposium on Theory of Computing (2000), 107–116 Frank, A. [1981]: A weighted matroid intersection algorithm. Journal of Algorithms 2 (1981), 328–336 Frank, A. [1982]: An algorithm for submodular functions on graphs. In: Bonn Workshop on Combinatorial Optimization; Annals of Discrete Mathematics 16 (A. Bachem, M. Grötschel, B. Korte, eds.), North-Holland, Amsterdam 1982, pp. 97–120

References

375

Fujishige, S. [1998]: Another simple proof of the validity of Nagamochi and Ibaraki’s min-cut algorithm and Queyranne’s extension to symmetric submodular function minimization. Journal of the Operations Research Society of Japan 41 (1998), 626–628 Fujishige, S., Röck, H., and Zimmermann, U. [1989]: A strongly polynomial algorithm for minimum cost submodular flow problems. Mathematics of Operations Research 14 (1989), 60–69 Grötschel, M., Lovász, L., and Schrijver, A. [1981]: The ellipsoid method and its consequences in combinatorial optimization. Combinatorica 1 (1981), 169–197 Grötschel, M., Lovász, L., and Schrijver, A. [1988]: Geometric Algorithms and Combinatorial Optimization. Springer, Berlin 1988 Iwata, S. [2002]: A fully combinatorial algorithm for submodular function minimization. Journal of Combinatorial Theory B 84 (2002), 203–212 Iwata, S. [2003]: A faster scaling algorithm for minimizing submodular functions. SIAM Journal on Computing 32 (2003), 833–840 Iwata, S., Fleischer, L., and Fujishige, S. [2001]: A combinatorial, strongly polynomial-time algorithm for minimizing submodular functions. Journal of the ACM 48 (2001), 761–777 Jensen, P.M., and Korte, B. [1982]: Complexity of matroid property algorithms. SIAM Journal on Computing 11 (1982), 184–190 Lovász, L. [1980]: Matroid matching and some applications. Journal of Combinatorial Theory B 28 (1980), 208–236 Lovász, L. [1981]: The matroid matching problem. In: Algebraic Methods in Graph Theory; Vol. II (L. Lovász, V.T. Sós, eds.), North-Holland, Amsterdam 1981, 495–517 Lovász, L. [1983]: Submodular functions and convexity. In: Mathematical Programming: The State of the Art – Bonn 1982 (A. Bachem, M. Grötschel, B. Korte, eds.), Springer, Berlin 1983 Nagamochi, H., and Ibaraki, T. [1998]: A note on minimizing submodular functions. Information Processing Letters 67 (1998), 239–244 Orlin, J.B. [2007]: A faster strongly polynomial time algorithm for submodular function minimization. Mathematical Programming 118 (2009), 237–251 Queyranne, M. [1998]: Minimizing symmetric submodular functions. Mathematical Programming B 82 (1998), 3–12 Rizzi, R. [2000]: On minimizing symmetric set functions. Combinatorica 20 (2000), 445–450 Schrijver, A. [2000]: A combinatorial algorithm minimizing submodular functions in strongly polynomial time. Journal of Combinatorial Theory B 80 (2000), 346–355 Vygen, J. [2003]: A note on Schrijver’s submodular function minimization algorithm. Journal of Combinatorial Theory B 88 (2003), 399–402

•

15 NP-Completeness

For many combinatorial optimization problems a polynomial-time algorithm is known; the most important ones are presented in this book. However, there are also many important problems for which no polynomial-time algorithm is known. Although we cannot prove that none exists we can show that a polynomialtime algorithm for one “hard” (more precisely: NP-hard) problem would imply a polynomial-time algorithm for almost all problems discussed in this book (more precisely: all NP-easy problems). To formalize this concept and prove the above statement we need a machine model, i.e. a precise definition of a polynomial-time algorithm. Therefore we discuss Turing machines in Section 15.1. This theoretical model is not suitable to describe more complicated algorithms. However we shall argue that it is equivalent to our informal notion of algorithms: every algorithm in this book can, theoretically, be written as a Turing machine, with a loss in efficiency that is polynomially bounded. We indicate this in Section 15.2. In Section 15.3 we introduce decision problems, and in particular the classes P and NP. While NP contains most decision problems appearing in this book, P contains only those for which there are polynomial-time algorithms. It is an open question whether P D NP. Although we shall discuss many problems in NP for which no polynomial-time algorithm is known, nobody can (so far) prove that none exists. We specify what it means that one problem reduces to another, or that one problem is at least as hard as another one. In this notion, the hardest problems in NP are the NP-complete problems; they can be solved in polynomial time if and only if P D NP. In Section 15.4 we exhibit the first NP-complete problem, SATISFIABILITY. In Section 15.5 some more decision problems, more closely related to combinatorial optimization, are proved to be NP-complete. In Sections 15.6 and 15.7 we shall discuss related concepts, also extending to optimization problems.

15.1 Turing Machines In this section we present a very simple model for computation: the Turing machine. It can be regarded as a sequence of simple instructions working on a string. The input and the output will be a binary string: B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__15, c Springer-Verlag Berlin Heidelberg 2012

377

378

15 NP-Completeness

Definition 15.1. An alphabet is a finite set with at least two elements, not containing the special symbol t (which we shall use for blanks). For an alphabet A we denote by a string over A aS finite sequence of elements of A, by An the set of strings of length n, and by A WD n2ZC An the set of all strings over A. We use the convention that A0 contains exactly one element, the empty string. A language over A is a subset of A . The elements of a language are often called words. If x 2 An we write size.x/ WD n for the length of the string. We shall often work with the alphabet A D f0; 1g and the set f0; 1g of all 01-strings (or binary strings). The components of a 0-1-string are sometimes called its bits. So there is exactly one 0-1-string of zero length, the empty string. A Turing machine gets as input a string x 2 A for some fixed alphabet A. The input is completed by blank symbols (denoted by t) to a two-way infinite string s 2 .A [ ftg/Z . This string s can be regarded as a tape with a read-write head; only a single position can be read and modified at each step, and the read-write head can be moved by one position in each step. A Turing machine consists of a set of N C 1 instructions numbered 0; : : : ; N . In the beginning instruction 0 is executed and the current position of the string is position 1. Now each instruction is of the following type. Read the bit at the current position, and depending on its value do the following: overwrite the current bit by some element of A [ ftg, possibly move the current position by one to the left or to the right, and go to an instruction which will be executed next. There is a special instruction denoted by 1 which marks the end of the computation. The components of our infinite string s indexed by 1; 2; 3; : : : up to the first t then yield the output string. Formally we define a Turing machine as follows: Definition 15.2. (Turing [1936]) Let A be an alphabet and AN WD A [ ftg. A Turing machine (with alphabet A) is defined by a function ˆ W f0; : : : ; N g AN ! f1; : : : ; N g AN f1; 0; 1g for some N 2 ZC . The computation of ˆ on input x, where x 2 A , is the finite or infinite sequence of triples .n.i / ; s .i / ; .i / / with n.i / 2 f1; : : : ; N g, s .i / 2 ANZ and .i / 2 Z (i D 0; 1; 2; : : :) defined recursively as follows (n.i / denotes the current instruction, s .i / represents the string, and .i / is the current position): .0/ .0/ n.0/ WD 0. sj WD xj for 1 j size.x/, and sj WD t for all j 0 and j > size.x/. .0/ WD 1. If .n.i / ; s .i / ; .i / / is already defined, we distinguish two cases. If n.i / 6D 1, then let .m; ; ı/ WD ˆ n.i / ; s.i.i/ / and set n.i C1/ WD m, s.i.iC1/ WD , sj.i C1/ WD sj.i / / for j 2 Z n f .i / g, and .i C1/ WD .i / C ı. If n.i / D 1, then this is the end of the sequence. We then define time.´L; x/ WD i ˚ .i / and output.´L; x/ 2 Ak , where k WD min j 2 N W sj D t 1, by output.´L; x/j .i /

WD sj for j D 1; : : : ; k.

15.2

Church’s Thesis

379

If this sequence is infinite (i.e. n.i / 6D 1 for all i ), then we set time.ˆ; x/ WD 1. In this case output.´L; x/ is undefined. Of course we are interested mostly in Turing machines whose computation is finite or even polynomially bounded: Definition 15.3. Let A be an alphabet. A computational problem is a pair .X; R/, where X A is a language and R X A is a relation such that for every x 2 X there exists a y 2 A with .x; y/ 2 R. Let ˆ be a Turing machine with alphabet A such that time.´L; x/ < 1 and .x; output.´L; x// 2 R for each x 2 X . Then we say that ˆ computes .X; R/. If there exists a polynomial p such that for all x 2 X we have time.´L; x/ p.size.x//, then ˆ is a polynomial-time Turing machine. If jfy 2 A W .x; y/ 2 Rgj D 1 for all x 2 X , we can define f W X ! A by .x; f .x// 2 R and say that ˆ computes f . In the case X D A and f W X ! f0; 1g we say that ˆ decides the language L WD fx 2 X W f .x/ D 1g. If there exists some polynomial-time Turing machine computing a function f (or deciding a language L), then we say that f is computable in polynomial time (or L is decidable in polynomial time, respectively). To make these definitions clear we give an example. The following Turing machine ˆ W f0; : : : ; 3g f0; 1; tg ! f1; : : : ; 3g f0; 1; tg f1; 0; 1g computes the successor function n 7! n C 1 (n 2 N), where the numbers are coded by their usual binary representation. ˆ.0; 0/ D .0; 0; 1/ ˆ.0; 1/ D .0; 1; 1/ ˆ.0; t/ D .1; t; 1/ ˆ.1; 1/ D .1; 0; 1/ ˆ.1; 0/ D .1; 1; 0/ ˆ.1; t/ D .2; t; 1/ ˆ.2; 0/ D .3; 1; 1/ ˆ.3; 0/ D .3; 0; 1/ ˆ.3; t/ D .1; 0; 0/

0 While s 6D t do WD C 1. Set WD 1. 1 While s D 1 do s WD 0 and WD 1. If s D 0 then s WD 1 and stop. Set WD C 1. 2 Set s WD 1 and WD C 1. 3 While s D 0 do WD C 1. Set s WD 0 and stop.

Note that several values of ˆ are not specified as they are never used in any computation. The comments on the right-hand side illustrate the computation. Instructions 2 and 3 are used only if the input consists of 1’s only, i.e. n D 2k 1 for some k 2 N. We have time.´L; x/ 3size.x/ C 3 for all inputs x, so ˆ is a polynomial-time Turing machine. In the next section we shall show that the above definition is consistent with our informal definition of a polynomial-time algorithm in Section 1.2: each polynomialtime algorithm in this book can be simulated by a polynomial-time Turing machine.

380

15 NP-Completeness

15.2 Church’s Thesis The Turing machine is the most customary theoretical model for algorithms. Although it seems to be very restricted, it is as powerful as any other reasonable model: the set of computable functions, and also the set of functions computable in polynomial time, is always the same. This statement, known as Church’s thesis, is of course too imprecise to be proved. However, there are strong results supporting this claim. For example, each program in a common programming language like C can be modelled by a Turing machine. In particular, all algorithms in this book can be rewritten as Turing machines. This is usually very inconvenient (thus we shall never do it), but theoretically it is possible. Moreover, any function computable in polynomial time by a C program is also computable in polynomial time by a Turing machine (and vice versa). Since it is not a trivial task to implement more complicated programs on a Turing machine we consider as an intermediate step a Turing machine with two strings (tapes) and two independent read-write heads, one for each tape: Definition 15.4. Let A be an alphabet and AN WD A [ ftg. A two-tape Turing machine is defined by a function ˆ W f0; : : : ; N g AN2 ! f1; : : : ; N g AN2 f1; 0; 1g2 for some N 2 ZC . The computation of ˆ on input x, where x 2 A , is the finite or infinite sequence of 5-tuples .n.i / ; s .i / ; t .i / ; .i / ; .i / / with n.i / 2 f1; : : : ; N g, s .i / ; t .i / 2 ANZ and .i / ; .i / 2 Z (i D 0; 1; 2; : : :) defined recursively as follows: .0/ .0/ n.0/ WD 0. sj WD xj for 1 j size.x/, and sj WD t for all j 0 and .0/

j > size.x/. tj WD t for all j 2 Z. .0/ WD 1 and .0/ WD 1. If .n.i / ; s .i / ; t .i / ; .i / ; .i / / isalready defined, we distinguish two cases. If n.i / 6D 1, then let .m; ; ; ı; / WD ˆ n.i / ; s.i.i/ / ; t.i.i// and set n.i C1/ WD m, s.i.iC1/ WD , /

WD , tj.i C1/ WD tj.i / for j 2 Z n f.i /g, sj.i C1/ WD sj.i / for j 2 Z n f .i / g, t.i.iC1/ / .i C1/ WD .i / C ı, and .i C1/ WD .i / C . If n.i / D 1, then this is the end of the sequence. time .ˆ; x/ and output .ˆ; x/ are defined as with the one-tape Turing machine.

Turing machines with more than two tapes can be defined analogously, but we shall not need them. Before we show how to perform standard operations with a twotape Turing machine, let us note that a two-tape Turing machine can be simulated by an ordinary (one-tape) Turing machine. Theorem 15.5. Let A be an alphabet, and let ˆ W f0; : : : ; N g .A [ ftg/2 ! f1; : : : ; N g .A [ ftg/2 f1; 0; 1g2 be a two-tape Turing machine. Then there exists an alphabet B A and a (onetape) Turing machine

15.2

Church’s Thesis

381

ˆ0 W f0; : : : ; N 0 g .B [ ftg/ ! f1; : : : ; N 0 g .B [ ftg/ f1; 0; 1g such that output.´L0 ; x/ D output.´L; x/ and time.´L0 ; x/ D O.time.´L; x//2 for x 2 A . Proof: We use the letters s and t for the two strings of ˆ, and denote by and the positions of the read-write heads, as in Definition 15.4. The string of ˆ0 will be denoted by u and its read-write head position by . We have to encode both strings s; t and both read-write head positions ; in one string u. To make this possible each symbol uj of u is a 4-tuple .sj ; pj ; tj ; rj /, where sj and tj are the corresponding symbols of s and t, and pj ; rj 2 f0; 1g indicate whether the read-write heads of the first and second string currently scans position j ; i.e. we have pj D 1 iff D j , and rj D 1 iff D j . So we define BN WD .AN f0; 1g AN f0; 1g/; then we identify a 2 AN with .a; 0; t; 0/ to allow inputs from A . The first step of ˆ0 consists in initializing the marks p1 and r1 to 1: ˆ0 .0; .:; 0; :; 0// D .1; .:; 1; :; 1/; 0/

0 Set WD

and WD

.

Here a dot stands for an arbitrary value (which is not modified). Now we show how to implement a general instruction ˆ.m; ; / D .m0 ; 0 ; 0 , ı; /. We first have to find the positions and . It is convenient to assume that our single read-write head is already at the leftmost of the two positions and ; i.e. D minf; g. We have to find the other position by scanning the string u to the right, we have to check whether s D and t D and, if so, perform the operation required (write new symbols to s and t, move and , jump to the next instruction). The following block implements one instruction ˆ.m; ; / D .m0 ; 0 ; 0 ; ı; / N 2 such blocks, one for each choice of and . for m D 0; for each m we have jAj 13 the first block for m0 with , M where The second block for m D 0 starts with , 2 0 2 0 N N M WD 12jAj m C 1. All in all we get N D 12.N C 1/jAj . A dot again stands for an arbitrary value which is not modified. Similarly, and stand for an arbitrary element of AN n fg and AN n fg, respectively. We assume that 10 11 and 12 guarantee that this property also D minf; g initially; note that , holds at the end. ˆ0 .1; .; 1; :; :// ˆ0 .1; .:; :; ; 1// ˆ0 .1; .; 1; ; 1// ˆ0 .1; .; 1; :; 0// ˆ0 .1; .:; 0; ; 1// ˆ0 .2; .:; :; :; 0// ˆ0 .2; .:; :; ; 1//

D D D D D D D

13 .13; .; 1; :; :/; 0/ 1 If D and s 6D then go to . 13 .13; .:; :; ; 1/; 0/ If D and t 6D then go to . .2; .; 1; ; 1/; 0/ If D then go to . 2 .2; .; 1; :; 0/; 0/ .6; .:; 0; ; 1/; 0/ If D then go to . 6 .2; .:; :; :; 0/; 1/ While D 6 do WD C 1. 2 .12; .:; :; ; 1/; 1/ If t 6D then set WD 1 12 and go to . 0 0 0 ˆ .2; .:; :; ; 1// D .3; .:; :; ; 0/; / Set t WD and WD C .

382

15 NP-Completeness

ˆ0 .3; .:; :; :; 0// ˆ0 .4; .:; 0; :; :// ˆ0 .4; .; 1; :; :// ˆ0 .5; .:; 0; :; ://

D D D D

ˆ0 .6; .:; 0; :; :// D ˆ0 .6; .; 1; :; :// D ˆ0 .6; .; 1; :; :; // ˆ0 .7; .:; 0; :; :// ˆ0 .8; .:; :; :; 0// ˆ0 .8; .:; :; ; 1// ˆ0 .9; .:; :; :; 0// ˆ0 .10; .:; :; :; :// ˆ0 .11; .:; 0; :; 0// ˆ0 .11; .:; 1; :; :// ˆ0 .11; .:; 0; :; 1// ˆ0 .12; .:; 0; :; 0// ˆ0 .12; .:; 1; :; :// ˆ0 .12; .:; :; :; 1//

D D D D D D D D D D D D

.4; .:; :; :; 1/; 1/ .4; .:; 0; :; :/; 1/ .5; . 0 ; 0; :; :/; ı/ .10; .:; 1; :; :/; 1/

3 Set WD and WD C 1. 4 While 6D do WD 1. Set s WD 0 and WD C ı. 5 Set WD and WD 1. 10 Go to . .6; .:; 0; :; :/; 1/ 6 While 6D do WD C 1. .12; .; 1; :; :/; 1/ If s 6D then set WD 1 12 and go to . 0 0 .7; . ; 0; :; :/; ı/ Set s WD and WD C ı. .8; .:; 1; :; :/; 1/ Set WD and WD C 1. 7 .8; .:; :; :; 0/; 1/ 8 While 6D do WD 1. .9; .:; :; 0 ; 0/; / Set t WD 0 and WD C . .10; .:; :; :; 1/; 1/ 9 Set WD and WD 1. 10 Set .11; .:; :; :; :/; 1/ WD 1. 11 While .11; .:; 0; :; 0/; 1/ 62 f; g do WD C 1. M .M; .:; 1; :; :/; 0/ Go to . .M; .:; 0; :; 1/; 0/ 12 While .12; .:; 0; :; 0/; 1/ 62 f; g do WD 1. .13; .:; 1; :; :/; 0/ .13; .:; :; :; 1/; 0/ 2

N blocks like the above for Any computation of ˆ0 passes through at most jAj each computation step of ˆ. The number of computation steps within each block is N is a constant and j j is bounded by time.´L; x/ we at most 2j jC10. Since jAj conclude that the whole computation of ˆ is simulated by ˆ0 with O .time.´L; x//2 steps. Finally we have to clean up the output: replace each symbol .; :; :; :/ by .; 0; t; 0/. Obviously this at most doubles the total number of steps. With a two-tape Turing machine it is not too difficult to implement more complicated instructions, and thus arbitrary algorithms: We use the alphabet A D f0; 1; #g and model an arbitrary number of variables by the string x0 ##1#x1##10#x2 ##11#x3##100#x4##101#x5## : : :

(15.1)

which we store on the first tape. Each group (except the first one) contains a binary representation of the index i followed by the value of xi , which we assume to be a binary string. The first variable x0 and the second tape are used only as registers for intermediate results of computation steps. Random access to variables is not possible in constant time with a Turing machine, no matter how many tapes we have. If we simulate an arbitrary algorithm

15.2

Church’s Thesis

383

by a two-tape Turing machine, we will have to scan the first tape quite often. Moreover, if the length of the string in one variable changes, the substring to the right has to be shifted. Nevertheless each standard operation (i.e. each elementary step of an algorithm) can be simulated with O.l 2 / computation steps of a two-tape Turing machine, where l is the current length of the string (15.1). We try to make this clearer with a concrete example. Consider the following instruction: Add to x5 the value of the variable whose index is given by x2 . To get the value of x5 we scan the first tape for the substring ##101#. We copy the substring following this up to #, exclusively, to the second tape. This is easy since we have two separate read-write heads. Then we copy the string from the second tape to x0 . If the new value of x0 is shorter or longer than the old one, we have to shift the rest of the string (15.1) to the left or to the right appropriately. Next we have to search for the variable index that is given by x2 . To do this, we first copy x2 to the second tape. Then we scan the first tape, checking each variable index (comparing it with the string on the second tape bitwise). When we have found the correct variable index, we copy the value of this variable to the second tape. Now we add the number stored in x0 to that on the second tape. A Turing machine for this task, using the standard method, is not hard to design. We can overwrite the number on the second tape by the result while computing it. Finally we have the result on the second tape and copy it back to x5 . If necessary we shift the substring to the right of x5 appropriately. All the above can be done by a two-tape Turing machine in O.l 2 / computation steps (in fact all but shifting the string (15.1) can be done in O.l/ steps). It should be clear that the same holds for all other standard operations, including multiplication and division. By Definition 1.4 an algorithm is said to run in polynomial time if there is a k 2 N such that the number of elementary steps is bounded by O.nk / and any number in intermediate computation can be stored with O.nk / bits, where n is the input size. Moreover, we store at most O.nk / numbers at any time. Hence we can bound the length of each of the two strings in a two-tape Turing machine simulating such an algorithm by l D O.nk nk / D O.n2k /, and hence its running time by O.nk .n2k /2 / D O.n5k /. This is still polynomial in the input size. Recalling Theorem 15.5 we may conclude that for any function f there is a polynomial-time algorithm computing f if and only if there is a polynomial-time Turing machine computing f . Hence we will use the terms algorithm and Turing machine interchangeably in the rest of this chapter. Hopcroft and Ullman [1979], Lewis and Papadimitriou [1981], and van Emde Boas [1990] provide more details about the equivalence of different machine models. Another common model (which is close to our informal model of Section 1.2) is the RAM machine (cf. Exercise 3) which allows arithmetic operations on integers in constant time. Other models allow only operations on bits (or integers of fixed length) which is more realistic when dealing with large numbers. Obviously, addition and comparison of natural numbers with n bits can be done with O.n/

384

15 NP-Completeness

bit operations. For multiplication (and division) the obvious method takes O.n2 / bit operations, but the algorithm of Schönhage and Strassen [1971] needs only O.n log n log log n/ bit operations for multiplying two n-bit integers, and this was improved further by Fürer [2009]. This of course implies algorithms for the addition and comparison of rational numbers with the same time complexity. As far as polynomial-time computability is concerned all models are equivalent, but of course the running time measures are quite different. The model of encoding the entire input by 0-1-strings (or strings over any fixed alphabet) does not in principle exclude certain types of real numbers, e.g. algebraic numbers (if x 2 R is the k-th smallest root of a polynomial p, then x can be coded by listing k and the degree and the coefficients of p). However, there is no way of representing arbitrary real numbers in a digital computer since there are uncountably many real numbers but only countably many 0-1-strings. We take the classical approach and restrict ourselves to rational input in this chapter. We close this section by giving a formal definition of oracle algorithms, based on two-tape Turing machines. We may call an oracle at any stage of the computation; we use the second tape for writing the oracle’s input and reading its output. We introduce a special instruction 2 for oracle calls: Definition 15.6. Let A be an alphabet and AN WD A [ ftg. Let .X; R/ be a computational problem with X A . An oracle Turing machine using .X; R/ is a function ˆ W f0; : : : ; N g AN2 ! f2; : : : ; N g AN2 f1; 0; 1g2 for some N 2 ZC . Its computation is defined as for a two-tape Turing machine, but .0/ with the following differences: initially we set time WD 0. If, for some computation .i / .i / .i / step i , ˆ n ; s .i / ; t.i / D .2; ; ; ı; / for some ; ; ı; , then consider the n o string on the second tape x 2 Ak , k WD min j 2 N W tj.i / D t 1, given by xj WD tj.i / for j D 1; : : : ; k. If x 2 X , then the second tape is overwritten by tj.i C1/ D yj

.i C1/ for j D 1; : : : ; size.y/ and tsize.y/C1 D t for some y 2 A with .x; y/ 2 R, and we set time.iC1/ WD time.i/ C 1 C size.y/. The rest remains unchanged, and in all other cases we set time.iC1/ WD time.i/ C 1. The computation continues with n.i C1/ WD n.i / C 1 until n.i / D 1. We then finally set time.´L; x/ WD time.i/ . The output is defined as with the two-tape Turing machine.

All definitions with respect to Turing machines can be extended to oracle Turing machines. The output of an oracle is not necessarily unique; hence there can be several possible computations for the same input. When proving the correctness or estimating the running time of an oracle algorithm we have to consider all possible computations, i.e. all choices of the oracle. By the results of this section the existence of a polynomial-time (oracle) algorithm is equivalent to the existence of a polynomial-time (oracle) Turing machine.

15.3

P and NP

385

15.3 P and NP Most of complexity theory is based on decision problems. Decision problems are special computational problems. Any language L f0; 1g can be interpreted as decision problem: given a 0-1-string, decide whether it belongs to L. However, we are more interested in problems like the following:

HAMILTONIAN CIRCUIT Instance:

An undirected graph G.

Question: Has G a Hamiltonian circuit? We will always assume a fixed efficient encoding of the input as a binary string; occasionally we extend our alphabet by other symbols. For example we assume that a graph is given by an adjacency list, and such a list can be coded as a binary string of length O.n log m C m log n/, where n and m denote the number of vertices and edges. We always assume an efficient encoding, i.e. one whose length is polynomially bounded by the minimum possible encoding length. Not all binary strings are instances of HAMILTONIAN CIRCUIT but only those representing an undirected graph. For most interesting decision problems the instances are a proper subset of the 0-1-strings. We require that we can decide in polynomial time whether an arbitrary string is an instance or not: Definition 15.7. A decision problem is a pair P D .X; Y /, where X is a language decidable in polynomial time and Y X . The elements of X are called instances of P; the elements of Y are yes-instances, those of X n Y are no-instances. A decision problem .X; Y / can be regarded as the computational problem .X; f.x; 1/ W x 2 Y g [ f.x; 0/ W x 2 X n Y g/. Hence an algorithm for a decision problem .X; Y / is an algorithm computing the function f W X ! f0; 1g, defined by f .x/ D 1 for x 2 Y and f .x/ D 0 for x 2 X n Y . We give two more examples, the decision problems corresponding to LINEAR PROGRAMMING and INTEGER PROGRAMMING:

LINEAR INEQUALITIES Instance:

A matrix A 2 Zmn and a vector b 2 Zm .

Question: Is there a vector x 2 Qn such that Ax b?

INTEGER LINEAR INEQUALITIES Instance:

A matrix A 2 Zmn and a vector b 2 Zm .

Question: Is there a vector x 2 Zn such that Ax b? Definition 15.8. The class of all decision problems for which there is a polynomial-time algorithm is denoted by P.

386

15 NP-Completeness

In other words, a member of P is a pair .X; Y / with Y X f0; 1g where both X and Y are languages decidable in polynomial time. To prove that a problem is in P one usually describes a polynomial-time algorithm. By the results of Section 15.2 there is a polynomial-time Turing machine for each problem in P. By Khachiyan’s Theorem 4.18, LINEAR INEQUALITIES belongs to P. It is not known whether I NTEGER LINEAR INEQUALITIES or HAMILTONIAN CIRCUIT belong to P. We shall now introduce another class, called NP, which contains these problems, and in fact most decision problems discussed in this book. We do not insist on a polynomial-time algorithm, but we require that for each yes-instance there is a certificate which can be checked in polynomial time. For example, for the HAMILTONIAN CIRCUIT problem a possible certificate is simply a Hamiltonian circuit. It is easy to check whether a given string is the binary encoding of a Hamiltonian circuit. Note that we do not require a certificate for no-instances. Formally we define: Definition 15.9. A decision problem P D .X; Y / belongs to NP if there is a polynomial p and a decision problem P 0 D .X 0 ; Y 0 / in P, where o n X 0 WD x#c W x 2 X; c 2 f0; 1gbp.size.x//c ; such that Y D

n

o y 2 X W there exists a string c 2 f0; 1gbp.size.y//c with y#c 2 Y 0 :

Here x#c denotes the concatenation of the string x, the symbol # and the string c. A string c with y#c 2 Y 0 is called a certificate for y (since c proves that y 2 Y ). An algorithm for P 0 is called a certificate-checking algorithm. Proposition 15.10. P NP. Proof: One can choose p to be identically zero. An algorithm for P 0 just deletes the last symbol of the input “x#” and then applies an algorithm for P. It is not known whether P D NP. In fact, this is the most important open problem in complexity theory. As an example for problems in NP that are not known to be in P we have: Proposition 15.11. HAMILTONIAN CIRCUIT belongs to NP. Proof: For each yes-instance G we take any Hamiltonian circuit of G as a certificate. To check whether a given edge set is in fact a Hamiltonian circuit of a given graph is obviously possible in polynomial time. Proposition 15.12. INTEGER LINEAR INEQUALITIES belongs to NP. Proof: As a certificate we just take a solution vector. If there exists a solution, there exists one of polynomial size by Corollary 5.7.

15.3

P and NP

387

The name NP stands for “nondeterministic polynomial”. To explain this we have to define what a nondeterministic algorithm is. This is a good opportunity to define randomized algorithms in general, a concept which has already been mentioned before. The common feature of randomized algorithms is that their computation does not only depend on the input but also on some random bits. Definition 15.13. A randomized algorithm for computing a function f W S ! T is an algorithm computing a function g W fs#r W s 2 S; r 2 f0; 1gk.s/g ! T , where k W S ! ZC . So for each instance s 2 S the algorithm can use k.s/ 2 ZC random bits. We measure the running time dependency on size.s/ only; thus randomized algorithms running in polynomial time can read only a polynomial number of random bits. Naturally we are interested in such a randomized algorithm only if f and g are related. In the ideal case, if g.s#r/ D f .s/ for all s 2 S and all r 2 f0; 1gk.s/, we speak of a Las Vegas algorithm. A Las Vegas algorithm always computes the correct result, but the running time may vary for different runs on the same input s. Sometimes even less reliable algorithms are interesting: if there is at least a positive probability p of a correct answer, independent of the instance, i.e. p WD inf

s2S

jfr 2 f0; 1gk.s/ W g.s#r/ D f .s/gj > 0; 2k.s/

then we have a Monte Carlo algorithm. If T D f0; 1g, and for each s 2 S with f .s/ D 0 we have g.s#r/ D 0 for all r 2 f0; 1gk.s/, then we have a randomized algorithm with one-sided error. If in addition for each s 2 S with f .s/ D 1 there is at least one r 2 f0; 1gk.s/ with g.s#r/ D 1, then the algorithm is called a nondeterministic algorithm. Alternatively a randomized algorithm can be regarded as an oracle algorithm where the oracle produces a random bit (0 or 1) whenever called. A nondeterministic algorithm for a decision problem always answers “no” for a no-instance, and for each yes-instance there is a chance that it answers “yes”. The following observation is easy: Proposition 15.14. A decision problem belongs to NP if and only if it has a polynomial-time nondeterministic algorithm. Proof: Let P D .X; Y / be a decision problem in NP, and let P 0 D .X 0 ; Y 0 / be defined as in Definition 15.9. Then a polynomial-time algorithm for P 0 is in fact also a nondeterministic algorithm for P: the unknown certificate is simply replaced by random bits. Since the number of random bits is bounded by a polynomial in size.x/, x 2 X , so is the running time of the algorithm. Conversely, if P D .X; Y / has a polynomial-time nondeterministic algorithm using k.x/ random bits for instance x, then there˚is a polynomial p such that k.x/ p.size.x// for each instance x. We define X 0 WD x#c W x 2 X; c 2 f0; 1gbp.size.x//c and Y 0 WD fx#c 2 X 0 W g.x#r/ D 1; r consists of the first k.x/ bits of cg.

388

15 NP-Completeness

Then by the definition of nondeterministic algorithms we have .X 0 ; Y 0 / 2 P and n o Y D y 2 X W there exists a string c 2 f0; 1gbp.size.y//c with y#c 2 Y 0 : Most decision problems encountered in combinatorial optimization belong to NP. For many of them it is not known whether they have a polynomial-time algorithm. However, one can say that certain problems are not easier than others. To make this precise we introduce the important concept of polynomial reductions, which works for general computational problems. Definition 15.15. Let P1 and P2 be computational problems. We say that P1 polynomially reduces to P2 if there exists a polynomial-time oracle algorithm for P1 using P2 . The following observation is the main reason for this concept: Proposition 15.16. If P1 polynomially reduces to P2 and there is a polynomialtime algorithm for P2 , then there is a polynomial-time algorithm for P1 . Proof: Let A2 be an algorithm for P2 with time.A2 ; y/ p2 .size.y// for all instances y of P2 . Let A1 be an oracle algorithm for P1 using P2 with time.A1 ; x/ p1 .size.x// for all instances x of P1 . Then replacing the oracle calls in A1 by subroutines equivalent to A2 yields an algorithm A3 for P1 . For any instance x of P1 with size.x/ D n we have time.A3 ; x/ p1 .n/ p2 .p1 .n//: there can be at most p1 .n/ oracle calls in A1 , and none of the instances of P2 produced by A1 can be longer than p1 .n/. Since we can choose p1 and p2 to be polynomials we conclude that A3 is a polynomial-time algorithm. The theory of NP-completeness is based on a special kind of polynomial-time reduction, which is defined only for decision problems: Definition 15.17. Let P1 D .X1 ; Y1 / and P2 D .X2 ; Y2 / be decision problems. We say that P1 polynomially transforms to P2 if there is a function f W X1 ! X2 computable in polynomial time such that f .x1 / 2 Y2 for all x1 2 Y1 and f .x1 / 2 X2 n Y2 for all x1 2 X1 n Y1 . In other words, yes-instances are transformed to yes-instances, and no-instances are transformed to no-instances. Obviously, if a problem P1 polynomially transforms to P2 , then P1 also polynomially reduces to P2 . Polynomial transformations are sometimes called Karp reductions, while general polynomial reductions are also known as Turing reductions. Both are easily seen to be transitive. Definition 15.18. A decision problem P 2 NP is called NP-complete if all other problems in NP polynomially transform to P.

15.4

Cook’s Theorem

389

By Proposition 15.16 we know that if there is a polynomial-time algorithm for any NP-complete problem, then P D NP. Of course, the above definition would be meaningless if no NP-complete problems existed. The next section consists of a proof that there is an NP-complete problem.

15.4 Cook’s Theorem In his pioneering work, Cook [1971] proved that a certain decision problem, called SATISFIABILITY, is in fact NP-complete. We need some definitions: Definition 15.19. Let X be a finite set of Boolean variables. A truth assignment : for X is a function T W X ! ftrue; falseg. We extend T to the set L WD X [ fx W x 2 X g by setting T .x/ WD true if T .x/ WD false and vice versa (x can be regarded as the negation of x). The elements of L are called the literals over X . A clause over X is a set of literals over X . A clause represents the disjunction of those literals and is satisfied by a truth assignment iff at least one of its members is true. A family of clauses over X is satisfiable iff there is some truth assignment simultaneously satisfying all of its clauses. Since we consider the conjunction of disjunctions of literals, we also speak of Boolean formulas (cf. Exercise 21) in conjunctive normal form. For example, the family ffx1 ; x2 g, fx2 ; x3 g, fx1 ; x2 ; x3 g, fx1 ; x3 gg corresponds to the Boolean formula .x1 _ x2 / ^ .x2 _ x3 / ^ .x1 _ x2 _ x3 / ^ .x1 _ x3 /. It is satisfiable as the truth assignment T .x1 / WD true, T .x2 / WD false and T .x3 / WD true shows. We are now ready to specify the satisfiability problem:

SATISFIABILITY Instance:

A set X of variables and a family Z of clauses over X .

Question: Is Z satisfiable? Theorem 15.20. (Cook [1971]) SATISFIABILITY is NP-complete. Proof: SATISFIABILITY belongs to NP because a satisfying truth assignment serves as a certificate for any yes-instance, which of course can be checked in polynomial time. Let now P D .X; Y / be any other problem in NP. We have to show that P polynomially transforms to SATISFIABILITY. 0 By Definition 15.9 there a decision problem P D ˚ is a polynomial p and 0 0 0 bp.size.x//c .X ; Y / in P, where X WD x#c W x 2 X; c 2 f0; 1g and o n Y D y 2 X W there exists a string c 2 f0; 1gbp.size.y//c with y#c 2 Y 0 :

390

15 NP-Completeness

Let ˆ W f0; : : : ; N g AN ! f1; : : : ; N g AN f1; 0; 1g be a polynomial-time Turing machine for P 0 with alphabet A; let AN WD A [ ftg. Let q be a polynomial such that time.´L; x#c/ q.size.x#c// for all instances x#c 2 X 0 . Note that size.x#c/ D size.x/ C 1 C bp.size.x//c. We will now construct a collection Z.x/ of clauses over some set V .x/ of Boolean variables for each x 2 X , such that Z.x/ is satisfiable if and only if x 2 Y . We abbreviate Q WD q.size.x/ C 1 C bp.size.x//c/. Q is an upper bound on the length of any computation of ˆ on input x#c, for any c 2 f0; 1gbp.size.x//c . V .x/ contains the following Boolean variables: N a variable vij for all 0 i Q, Q j Q and 2 A; a variable wij n for all 0 i Q, Q j Q and 1 n N . The intended meaning is: vij indicates whether at time i (i.e. after i steps of the computation) the j -th position of the string contains the symbol . wij n indicates whether at time i the j -th position of the string is scanned and the n-th instruction is executed. So if .n.i / ; s .i / ; .i / /i D0;1;::: is a computation of ˆ then we intend to set vij to .i / true iff sj D and wij n to true iff .i / D j and n.i / D n. The collection Z.x/ of clauses to be constructed will be satisfiable if and only if there is a string c with output.´L; x#c/ D 1. Z.x/ contains the following clauses to model the following conditions: At any time each position of the string contains a unique symbol: N fvij W 2 Ag for 0 i Q and Q j Q; fvij ; vij g for 0 i Q, Q j Q and ; 2 AN with 6D . At any time a unique position of the string is scanned and a single instruction is executed: fwij n W Q j Q; 1 n N g for 0 i Q; fwij n ; wij 0 n0 g for 0 i Q, Q j; j 0 Q and 1 n; n0 N with .j; n/ 6D .j 0 ; n0 /. The algorithm starts correctly with input x#c for some c 2 f0; 1gbp.size.x//c :

fv0;j;xj g for 1 j size.x/; fv0;size.x/C1;# g; fv0;size.x/C1Cj;0 ; v0;size.x/C1Cj;1 g for 1 j bp.size.x//c; fv0;j;t g for Q j 0 and size.x/ C 2 C bp.size.x//c j Q; fw010 g. The algorithm works correctly:

fvij ; wij n ; vi C1;j; g, fvij ; wij n ; wi C1;j Cı;m g for 0 i < Q, Q j Q, 2 AN and 0 n N , where ˆ.n; / D .m; ; ı/.

15.4

Cook’s Theorem

391

When the algorithm reaches instruction 1, it stops: fwi;j;1 ; wi C1;j;1 g, fwi;j;1 ; vi;j; ; vi C1;j; g N for 0 i < Q, Q j Q and 2 A. Positions not being scanned remain unchanged: fvij ; wij 0 n ; vi C1;j; g N 1 n N , and Q j; j 0 Q with j 6D j 0 . for 0 i Q, 2 A, The output of the algorithm is 1: fvQ;1;1 g; fvQ;2;t g. The encoding length of Z.x/ is O.Q 3 log Q/: there are O.Q3 / occurrences of literals, whose indices require O.log Q/ space. Since Q depends polynomially on size.x/ we conclude that there is a polynomial-time algorithm which, given x, constructs Z.x/. Note that p, ˆ and q are fixed and not part of the input of this algorithm. It remains to show that Z.x/ is satisfiable if and only if x 2 Y . If Z.x/ is satisfiable, consider a truth assignment T satisfying all clauses. Let c 2 f0; 1gbp.size.x//c with cj D 1 for all j with T .v0;size.x/C1Cj;1 / D true and cj D 0 otherwise. By the above construction the variables reflect the computation of ˆ on input x#c. Hence we may conclude that output.´L; x#c/ D 1. Since ˆ is a certificate-checking algorithm, this implies that x is a yes-instance. Conversely, if x 2 Y , let c be any certificate for x. Let .n.i / ; s .i / ; .i / /i D0;1;:::;m be the computation of ˆ on input x#c. Then we define T .vi;j; / WD true iff sj.i / D and T .wi;j;n/ D true iff .i / D j and n.i / D n. For i WD m C 1; : : : ; Q we set T .vi;j; / WD T .vi 1;j; / and T .wi;j;n/ WD T .wi 1;j;n / for all j , n and . Then T is a truth assignment satisfying Z.x/, completing the proof. SATISFIABILITY is not the only NP-complete problem; we will encounter many others in this book. Now that we already have one NP-complete problem at hand, it is much easier to prove NP-completeness for another problem. To show that a certain decision problem P is NP-complete, we shall just prove that P 2 NP and that SATISFIABILITY (or any other problem which we know already to be NP-complete) polynomially transforms to P. Since polynomial transformability is transitive, this will be sufficient. The following restriction of SATISFIABILITY will prove very useful for several NP-completeness proofs:

3SAT A set X of variables and a collection Z of clauses over X , each containing exactly three literals. Question: Is Z satisfiable? Instance:

To show NP-completeness of 3SAT we observe that any clause can be replaced equivalently by a set of 3SAT-clauses:

392

15 NP-Completeness

Proposition 15.21. Let X be a set of variables and Z a clause over X with k literals. Then there is a set Y of at most maxfk 3; 2g new variables and a family : Z 0 of at most maxfk 2; 4g clauses over X [ Y such that each element of Z 0 has exactly three literals, and for each family W of clauses over X we have that W [ fZg is satisfiable if and only if W [ Z 0 is satisfiable. Moreover, such a family Z 0 can be computed in O.k/ time. Proof: If Z has three literals, we set Z 0 WD fZg. If Z has more than three literals, say Z D f 1 ; : : : ; k g, we choose a set Y D fy1 ; : : : ; yk3 g of k 3 new variables and set ˚ Z 0 WD f 1 ; 2 ; y1 g; fy1 ; 3 ; y2 g; fy2 ; 4 ; y3 g; : : : ; fyk4 ; k2 ; yk3 g; fyk3 ; k1 ; k g : If Z D f 1 ; 2 g, we choose a new variable y1 (Y WD fy1 g) and set Z 0 WD ff 1 ; 2 ; y1 g; f 1 ; 2 ; y1 gg : If Z D f 1 g, we choose a set Y D fy1 ; y2 g of two new variables and set Z 0 WD ff 1 ; y1 ; y2 g; f 1 ; y1 ; y2 g; f 1 ; y1 ; y2 g; f 1 ; y1 ; y2 gg: Observe that in each case Z can be equivalently replaced by the clauses in Z 0 in any instance of SATISFIABILITY. Theorem 15.22. (Cook [1971]) 3SAT is NP-complete. Proof: As a restriction of SATISFIABILITY, 3SAT is certainly in NP. We now show that SATISFIABILITY polynomially transforms to 3SAT. Consider any collection Z of clauses Z1 ; : : : ; Zm . We shall construct a new collection Z 0 of clauses with three literals per clause such that Z is satisfiable if and only if Z 0 is satisfiable. To do this, we replace each clause Zi by an equivalent set of clauses, each with three literals. This is possible in linear time by Proposition 15.21. If we restrict each clause to consist of just two literals, the problem (called 2SAT) can be solved in linear time (Exercise 8).

15.5 Some Basic NP-Complete Problems Karp [1972] discovered the wealth of consequences of Cook’s work for combinatorial optimization problems. As a start, we consider the following problem:

STABLE SET Instance:

A graph G and an integer k.

Question: Is there a stable set of k vertices?

15.5

Some Basic NP-Complete Problems

393

Theorem 15.23. (Karp [1972]) STABLE SET is NP-complete. Proof: Obviously, STABLE SET 2 NP. We show that SATISFIABILITY polynomially transforms to STABLE SET. Let Z be a collection of clauses Z1 ; : : : ; Zm with Zi D f i1 ; : : : ; i ki g (i D 1; : : : ; m), where the ij are literals over some set X of variables. We shall construct a graph G such that G has a stable set of size m if and only if there is a truth assignment satisfying all m clauses. x1

x3

x1

x1

x2

x2

x3

x3

x2

x3

Fig. 15.1.

For each clause Zi , we introduce a clique of ki vertices according to the literals in this clause. Vertices corresponding to different clauses are connected by an edge if and only if the literals contradict each other. Formally, let V .G/ WD fvij W 1 i m; 1 j ki g and ˚ E.G/ WD fvij ; vkl g W .i D k and j 6D l/ or . ij D x and kl D x for some x 2 X / : See Figure 15.1 for an example (m D 4, Z1 D fx1 ; x2 ; x3 g, Z2 D fx1 ; x3 g, Z3 D fx2 ; x3 g and Z4 D fx1 ; x2 ; x3 g). Suppose G has a stable set of size m. Then its vertices specify pairwise compatible literals belonging to different clauses. Setting each of these literals to be true (and setting variables not occurring there arbitrarily) we obtain a truth assignment satisfying all m clauses. Conversely, if some truth assignment satisfies all m clauses, then we choose a literal which is true out of each clause. The set of corresponding vertices then defines a stable set of size m in G. It is essential that k is part of the input: for each fixed k it can be decided in O.nk / time whether a given graph with n vertices has a stable set of size k (simply

394

15 NP-Completeness

by testing all vertex sets with k elements). Two interesting related problems are the following:

VERTEX COVER Instance:

A graph G and an integer k.

Question: Is there a vertex cover of cardinality k?

CLIQUE Instance:

A graph G and an integer k.

Question: Has G a clique of cardinality k? Corollary 15.24. (Karp [1972]) VERTEX COVER and CLIQUE are NP-complete. Proof: By Proposition 2.2, STABLE SET polynomially transforms to both VERTEX COVER and CLIQUE . We now turn to the famous Hamiltonian circuit problem (already defined in Section 15.3). Theorem 15.25. (Karp [1972]) HAMILTONIAN CIRCUIT is NP-complete. Proof: Membership in NP is obvious. We prove that 3SAT polynomially transforms to HAMILTONIAN CIRCUIT. Given a collection Z of clauses Z1 ; : : : ; Zm over X D fx1 ; : : : ; xn g, each clause containing three literals, we shall construct a graph G such that G is Hamiltonian iff Z is satisfiable.

a u

u

b u

u

A

Fig. 15.2.

We first define two gadgets which will appear several times in G. Consider the graph shown in Figure 15.2(a), which we call A. We assume that it is a subgraph of G and no vertex of A except u; u0 ; v; v 0 is incident to any other edge of G. Then any Hamiltonian circuit of G must traverse A in one of the ways shown in

15.5

a u

u

Some Basic NP-Complete Problems

b u

395 u

Fig. 15.3.

Figure 15.3(a) and (b). So we can replace A by two edges with the additional restriction that any Hamiltonian circuit of G must contain exactly one of them (Figure 15.2(b)).

a

b

u

u

e1

e2

B

e3

u

u

Fig. 15.4.

Now consider the graph B shown in Figure 15.4(a). We assume that it is a subgraph of G, and no vertex of B except u and u0 is incident to any other edge of G. Then no Hamiltonian circuit of G traverses all of e1 ; e2 ; e3 . Moreover, one easily checks that for any S fe1 ; e2 ; e3 g there is a Hamiltonian path from u to u0 in B that contains S but none of fe1 ; e2 ; e3 g n S . We represent B by the symbol shown in Figure 15.4(b). We are now able to construct G. For each clause, we introduce a copy of B, joined one after another. Between the first and the last copy of B, we insert two vertices for each variable, all joined one after another. We then double the edges between the two vertices of each variable x; these two edges will correspond to x and x, respectively.

396

15 NP-Completeness

B

A

A A

A B

A A

A A

B

A

Fig. 15.5.

The edges e1 , e2 , and e3 in each copy of B are now connected via a copy of A to the edges corresponding to the first, second, and third literal of the corresponding clause, respectively. These constructions are done consecutively: when introducing a copy of subgraph A at an edge e D fu; vg corresponding to a literal, the edge incident to u in Figure 15.2(a) takes the role of e: it is now the edge corresponding to that literal. The overall construction is illustrated by Figure 15.5 with the example ffx1 ; x2 ; x3 g; fx1 ; x2 ; x3 g; fx1 ; x2 ; x3 gg. Now we claim that G is Hamiltonian if and only if Z is satisfiable. Let C be a Hamiltonian circuit. We define a truth assignment by setting a literal true iff C contains the corresponding edge. By the properties of the gadgets A and B each clause contains a literal that is true. Conversely, any satisfying truth assignment defines a set of edges corresponding to literals that are true. Since each clause contains a literal that is true this set of edges can be completed to a tour in G.

15.5

Some Basic NP-Complete Problems

397

This proof is essentially due to Papadimitriou and Steiglitz [1982]. The problem of deciding whether a given graph contains a Hamiltonian path is also NP-complete (Exercise 17(a)). Moreover, one can easily transform the undirected versions to the directed Hamiltonian circuit or Hamiltonian path problem by replacing each undirected edge by a pair of oppositely directed edges. Thus the directed versions are also NP-complete. There is another fundamental NP-complete problem:

3-DIMENSIONAL MATCHING (3DM) Disjoint sets U; V; W of equal cardinality and T U V W .

Instance:

Question: Is there a subset M of T with jM j D jU j such that for distinct .u; v; w/; .u0 ; v 0 ; w 0 / 2 M one has u 6D u0 , v 6D v 0 and w 6D w 0 ? Theorem 15.26. (Karp [1972]) 3DM is NP-complete. Proof: Membership in NP is obvious. We shall polynomially transform SATISFIABILITY to 3DM. Given a collection Z of clauses Z1 ; : : : ; Zm over X D fx1 ; : : : ; xn g, we construct an instance .U; V; W; T / of 3DM which is a yes-instance if and only if Z is satisfiable. We define: j

U WD fxi ; xi j W i D 1; : : : ; nI j D 1; : : : ; mg

V WD faij W i D 1; : : : ; nI j D 1; : : : ; mg [ fv j W j D 1; : : : ; mg [ fckj W k D 1; : : : ; n 1I j D 1; : : : ; mg

W WD fbij W i D 1; : : : ; nI j D 1; : : : ; mg [ fw j W j D 1; : : : ; mg j

j

[ fdk W k D 1; : : : ; n 1I j D 1; : : : ; mg j

j

j C1

T1 WD f.xi ; ai ; bi /; .xi j ; ai

where aimC1 WD ai1

j

; bi / W i D 1; : : : ; nI j D 1; : : : ; mg;

T2 WD f.xij ; v j ; w j / W i D 1; : : : ; nI j D 1; : : : ; mI xi 2 Zj g

[ f.xi j ; v j ; w j / W i D 1; : : : ; nI j D 1; : : : ; mI xi 2 Zj g

j

j

j

j

j

T3 WD f.xi ; ck ; dk /; .xi j ; ck ; dk / W i D 1; : : : ; nI j D 1; : : : ; mI k D 1; : : : ; n1g T WD T1 [ T2 [ T3 : For an illustration of this construction, see Figure 15.6. Here m D 2, Z1 D fx1 ; x2 g, Z2 D fx1 ; x2 g. Each triangle corresponds to an element of T1 [ T2 . The elements ckj , dkj and the triples in T3 are not shown. Suppose .U; V; W; T / is a yes-instance, so let M T be a solution. Since the j ai ’s and bij ’s appear only in elements of T1 , for each i we have either M \ T1 f.xij ; aij ; bij / W j D 1; : : : ; mg or M \ T1 f.xi j ; aij C1 ; bij / W j D 1; : : : ; mg. In the first case we set xi to false, in the second case to true.

398

15 NP-Completeness

x1 1

x2 1 b 11

a 21

a 22 x 11

x 21

x 22

a 11

b 21

b 12 x 12

b 22

a 12 x2 2

x1 2

Fig. 15.6.

Furthermore, for each clause Zj we have . j ; v j ; w j / 2 M for some literal 2 Zj . Since j does not appear in any element of M \ T1 this literal is true; hence we have a satisfying truth assignment. Conversely, a satisfying truth assignment suggests a set M1 T1 of cardinality nm and a set M2 T2 of cardinality m such that for distinct .u; v; w/; .u0 ; v 0 ; w 0 / 2 M1 [ M2 we have u 6D u0 , v 6D v 0 and w 6D w 0 . It is easy to complete M1 [ M2 by .n 1/m elements of T3 to a solution of the 3DM instance. A problem which looks simple but is not known to be solvable in polynomial time is the following:

SUBSET-SUM Instance:

Natural numbers c1 ; : : : ; cn ; K.

Question: Is there a subset S f1; : : : ; ng such that

P

j 2S cj

DK?

Corollary 15.27. (Karp [1972]) SUBSET-SUM is NP-complete. Proof: It is obvious that SUBSET-SUM is in NP. We prove that 3DM polynomially transforms to SUBSET-SUM. So let .U; V; W; T / be an instance of 3DM. W.l.o.g. let U [ V [ W D fu1 ; : : : ; u3m g. We write S WD ffa; b; cg W .a; b; c/ 2 T g and S D fs1 ; : : : ; sn g. Define

15.5

cj WD

X

.n C 1/i 1

Some Basic NP-Complete Problems

399

.j D 1; : : : ; n/; and

ui 2sj

K WD

3m X .n C 1/i 1 : i D1

Written in .n C 1/-ary form, the number cj can be regarded as the incidence vector of sj (j D 1; : : : ; n), and K consists of 1’s only. Therefore P each solution to the 3DM instance corresponds to a subset R of S such that sj 2R cj D K, and vice versa. Moreover, size.cj / size.K/ D O.m log n/, so the above is indeed a polynomial transformation. An important special case is the following problem:

PARTITION Instance:

Natural numbers c1 ; : : : ; cn .

Question: Is there a subset S f1; : : : ; ng such that

P

j 2S cj

D

P

j …S cj

?

Corollary 15.28. (Karp [1972]) PARTITION is NP-complete. Proof: We show that SUBSET-SUM polynomially transforms to PARTITION. So c1 ; : : : ; cn ; Kˇ be an instance of SUBSET-SUM. We add an element cnC1 WD ˇlet ˇPn ci 2K ˇ (unless this number is zero) and have an instance c1 ; : : : ; cnC1 of i D1 PARTITION. P Case 1: 2K niD1 ci . Then for any I f1; : : : ; ng we have X X X ci D K if and only if ci D ci : i 2I

Case 2:

2K > X

i 2I [fnC1g

Pn

i D1 ci .

ci D K

i 2I

i 2f1;:::;ngnI

Then for any I f1; : : : ; ng we have X X if and only if ci D ci : i 2I

i 2f1;:::;nC1gnI

In both cases we have constructed a yes-instance of PARTITION if and only if the original instance of SUBSET-SUM is a yes-instance. We finally note: Theorem 15.29. INTEGER LINEAR INEQUALITIES is NP-complete. Proof: We already mentioned the membership in NP in Proposition 15.12. Any of the above problems can easily be formulated as an instance of I NTEGER LINEAR INEQUALITIES. For example a PARTITION instance c1 ; : : : ; cn is a yes-instance if and only if fx 2 Zn W 0 x 1l; 2c > x D c > 1lg is nonempty.

400

15 NP-Completeness

15.6 The Class coNP The definition of NP is not symmetric with respect to yes-instances and noinstances. For example, it is an open question whether the following problem belongs to NP: given a graph G, is it true that G is not Hamiltonian? We introduce the following definitions: Definition 15.30. For a decision problem P D .X; Y / we define its complement to be the decision problem .X; X nY /. The class coNP consists of all problems whose complements are in NP. A decision problem P 2 coNP is called coNP-complete if all other problems in coNP polynomially transform to P. Trivially, the complement of a problem in P is also in P. On the other hand, NP 6D coNP is commonly conjectured (though not proved). For this conjecture the NP-complete problems play a special role: Theorem 15.31. A decision problem is coNP-complete if and only if its complement is NP-complete. Unless NP D coNP, no coNP-complete problem is in NP. Proof: The first statement follows directly from the definition. Suppose P D .X; Y / 2 NP is a coNP-complete problem. Let Q D .V; W / be an arbitrary problem in coNP. We show that Q 2 NP. Since P is coNP-complete, Q polynomially transforms to P. So there is a polynomial-time algorithm which transforms any instance v of Q to an instance x D f .v/ of P such that x 2 Y if and only if v 2 W . Note that size.x/ p.size.v// for some fixed polynomial p. Since P 2 NP, there exists a polynomial q and a decision problem P 0 D ˚ 0 0 0 bq.size.x//c .X ; Y / in P, where X WD x#c W x 2 X; c 2 f0; 1g , such that o n Y D y 2 X W there exists a string c 2 f0; 1gbq.size.y//c with y#c 2 Y 0 ˚ (cf. Definition 15.9). We define a decision problem .V 0 ; W 0 / by V 0 WD v#c W v 2 V; c 2 f0; 1gbq.p.size.v///c , and v#c 2 W 0 if and only if f .v/#c 0 2 Y 0 where c 0 consists of the first bq.size.f .v///c components of c. Observe that .V 0 ; W 0 / 2 P. Therefore, by definition, Q 2 NP. We conclude coNP NP and hence, by symmetry, NP D coNP. If one can show that a problem is in NP \ coNP, we say that the problem has a good characterization (Edmonds [1965]). This means that for yes-instances as well as for no-instances there are certificates that can be checked in polynomial time. Theorem 15.31 indicates that a problem with a good characterization is probably not NP-complete. To give examples, Proposition 2.9, Theorem 2.24, and Proposition 2.27 provide good characterizations for the problems of deciding whether a given graph is acyclic, whether it has an Eulerian walk, and whether it is bipartite, respectively. Of course, this is not very interesting since all these problems can be solved easily in polynomial time. But consider the decision version of LINEAR PROGRAMMING:

15.6

The Class coNP

401

Theorem 15.32. LINEAR INEQUALITIES is in NP \ coNP. Proof: This immediately follows from Theorem 4.4 and Corollary 3.24.

Of course, this theorem also follows from any polynomial-time algorithm for LINEAR PROGRAMMING, e.g. Theorem 4.18. However, before the E LLIPSOID METHOD had been discovered, Theorem 15.32 was the only theoretical evidence that LINEAR INEQUALITIES is probably not NP-complete. This gave hope to find a polynomial-time algorithm for LINEAR PROGRAMMING (which can be reduced to LINEAR INEQUALITIES by Proposition 4.16); a justified hope as we know today. The following famous problem has a similar history:

PRIME Instance:

A number n 2 N (in its binary representation).

Question: Is n a prime? It is obvious that PRIME belongs to coNP. Pratt [1975] proved that PRIME also belongs to NP. Finally, Agrawal, Kayal and Saxena [2004] proved that P RIME 2 P by finding a surprisingly simple O.log7:5C n/-algorithm (for any > 0). Before, the best known deterministic algorithm for PRIME wasdue to Adleman, Pomerance and Rumely [1983], running in O .log n/c log log log n time for some constant c. Since the input size is O.log n/, this is not polynomial.

NP-complete

coNP-complete

NP ∩ coNP NP

coNP

P

Fig. 15.7.

We close this section by sketching the inclusions of NP and coNP (Figure 15.7). Ladner [1975] showed that, unless P D NP, there are problems in NPnP that are not NP-complete. However, until the P 6D NP conjecture is resolved, it is still possible that all regions drawn in Figure 15.7 collapse to one.

402

15 NP-Completeness

15.7 NP-Hard Problems Now we extend our results to general computational problems, and in particular to optimization problems. Definition 15.33. A computational problem P is called NP-hard if all problems in NP polynomially reduce to P. Note that the definition also applies to decision problems, and it is symmetric (in contrast to NP-completeness): a decision problem is NP-hard if and only if its complement is. NP-hard problems are at least as hard as the hardest problems in NP. But some may be harder than any problem in NP. A problem which polynomially reduces to some problem in NP is called NP-easy. A problem which is both NPhard and NP-easy is NP-equivalent. In other words, a problem is NP-equivalent if and only if it is polynomially equivalent to SATISFIABILITY, where two problems P and Q are called polynomially equivalent if P polynomially reduces to Q, and Q polynomially reduces to P. We note: Proposition 15.34. Let P be an NP-equivalent computational problem. Then P has an exact polynomial-time algorithm if and only if P D NP. Of course, all NP-complete problems and all coNP-complete problems are NPequivalent. Almost all problems discussed in this book are NP-easy since they polynomially reduce to I NTEGER PROGRAMMING; this is usually a trivial observation which we do not even mention. We now formally define the type of optimization problems we are interested in: Definition 15.35. An NP optimization problem is a quadruple P D .X; .Sx /x2X ; c; goal/, where X is a language over f0; 1g decidable in polynomial time; Sx is a nonempty subset of f0; 1g for each x 2 X ; there exists a polynomial p with size.y/ p.size.x// for all x 2 X and y 2 Sx , and the language f.x; y/ W x 2 X; y 2 Sx g is decidable in polynomial time; c W f.x; y/ W x 2 X; y 2 Sx g ! Q is a function computable in polynomial time; and goal 2 fmax; ming. The elements of X are called instances of P. For each instance x, the elements of Sx are called feasible solutions of x. We write OPT.x/ WD goalfc.x; y/ W y 2 Sx g. An optimum solution of x is a feasible solution y of x with c.x; y/ D OPT.x/. A heuristic for P is an algorithm A which computes for each input x 2 X with Sx 6D ; a feasible solution y 2 Sx . We sometimes write A.x/ WD c.x; y/. If A.x/ D OPT.x/ for all x 2 X with Sx 6D ;, then A is an exact algorithm for P.

15.7

NP-Hard Problems

403

Depending on the context, c.x; y/ is often called the cost, the weight, the profit or the length of y. If c is nonnegative, then we say that the optimization problem has nonnegative weights. The values of c are rational numbers; we assume an encoding into binary strings as usual. Most interesting optimization problems fall into this class, but there are some exceptions (e.g., Exercise 24). An optimization problem .X; .Sx /x2X ; c, goal/ can be regarded as the computational problem .X; f.x; y/ W x 2 X; y 2 Sx ; c.x; y/ D OPT.x/g/. Hence polynomial reductions also apply to optimization problems. Theorem 15.36. Every NP optimization problem is NP-easy. Proof: Let P D .X; .Sx /x2X ; c; goal/ be an NP optimization problem. We polynomially reduce P to a decision problem Q 2 NP. As usual we call a string y 2 f0; 1gp , p 2 ZC , lexicographically greater than a string s 2 f0; 1gq , q 2 ZC , iff y 6D s and yj > sj for j D minfi 2 N W yi 6D si g, where yi WD 1 for i > p and si WD 1 for i > q. If goal D max, then Q is defined as follows: Given x 2 X , 2 Q, and s 2 f0; 1g, is there a y 2 Sx such that c.x; y/ and y is equal to or lexicographically greater than s? If goal D min, then c.x; y/ is replaced by c.x; y/ . Observe that Q belongs to NP (y serves as certificate). We polynomially reduce P to Q as follows. As c is computable in polynomial time, there is a constant d 2 N such that size.c.x; y// .size.x/ C p.size.x///d DW k.x/ for all x 2 X and y 2 Sx . Hence OPT.x/ 2 Œ2k.x/ ; 2k.x/ , and jc.x; y/ c.x; y 0 /j is an integral multiple of 2k.x/ for all x 2 X and y; y 0 2 Sx . Given an instance x 2 X , we first compute k.x/ and then determine OPT.x/ by binary search. We start with ˛ WD 2k.x/ and ˇ WD 2k.x/ . In each iteration we apply and s0 is the empty string. If the answer is the oracle to .x; ; s0 /, where D ˛Cˇ 2 yes, we set ˛ WD , otherwise ˇ WD . After 2k C 2 iterations we have ˇ ˛ < 2k.x/ . Then we fix WD ˛ and use another 2p.size.x// oracle calls to compute a solution y 2 Sx with c.x; y/ ˛. For i WD 1; : : : ; p.size.x// we call the oracle to .x; ˛; si01 / and .x; ˛; si11 /, where s j results from the string s by appending the symbol j 2 f0; 1g. If the both answers are yes, then we set si WD si11 , if only the first answer is yes, then we set si WD si01 , and if both answers are no, then we set si WD si 1 . We conclude that sp.size.x// is the lexicographically maximal string y with y 2 Sx and c.x; y/ D OPT.x/. Most problems that we discuss from now on are also NP-hard, and we shall usually prove this by describing a polynomial reduction from an NP-complete problem. As a first example we consider MAX-2SAT: given an instance of SATISFIABILITY with exactly two literals per clause, find a truth assignment that maximizes the number of satisfied clauses. Theorem 15.37. (Garey, Johnson and Stockmeyer [1976]) MAX-2SAT is NPhard.

404

15 NP-Completeness

Proof: By reduction from 3SAT. Given an instance I of 3SAT with clauses C1 ; : : : ; Cm , we construct an instance I 0 of MAX-2SAT by adding new variables y1 ; ´1 ; : : : ; ym ; ´m and replacing each clause Ci D f 1 ; 2 ; 3 g by the fourteen clauses f 1 ; ´i g; f 1 ; ´N i g; f 2 ; ´i g; f 2 ; ´N i g; f 3 ; ´i g; f 3 ; ´N i g; fyi ; ´i g; fyi ; ´N i g; f 1 ; yNi g; f 2 ; yNi g; f 3 ; yNi g; f N 1 ; N 2 g; f N 1 ; N 3 g; f N 2 ; N 3 g: Note that no truth assignment satisfies more than 11 of these 14 clauses. Moreover, if 11 of these clauses are satisfied, then at least one of 1 ; 2 ; 3 must be true. On the other hand, if one of 1 ; 2 ; 3 is true we can set yi WD 1 ^ 2 ^ 3 and ´i WD true in order to satisfy 11 of these clauses. We conclude that I has a truth assignment satisfying all m clauses if and only if I 0 has a truth assignment that satisfies 11m clauses. It is an open question whether each NP-hard decision problem P 2 NP is NPcomplete (recall the difference between polynomial reduction and polynomial transformation; Definitions 15.15 and 15.17). Exercises 22 and 23 discuss two NP-hard decision problems that appear not to be in NP. See also Exercise 2 of Chapter 19. Unless P D NP there is no exact polynomial-time algorithm for any NP-hard problem. There might, however, be a pseudopolynomial algorithm: Definition 15.38. Let P be a decision problem or an optimization problem such that each instance x consists of a list of nonnegative integers. We denote by largest.x/ the largest of these integers. An algorithm for P is called pseudopolynomial if its running time is bounded by a polynomial in size.x/ and largest.x/. For example there is a trivial pseudopolynomial algorithm for PRIME which divides the natural number n to be tested for primality by each integer from 2 to p b nc. Another example is: Theorem 15.39. There is a pseudopolynomial algorithm for SUBSET-SUM. Proof: Given an instance c1 ; : : : ; cn ; K of SUBSET-SUM, we construct a digraph G with vertex set f0; : : : ; ng f0; 1; 2; : : : ; Kg. For each j 2 f1; : : : ; ng we add edges ..j 1; i /; .j; i // (i D 0; 1; : : : ; K) and ..j 1; i /; .j; i C cj // (i D 0; 1; : : : ; K cj ). Observe thatPany path from .0; 0/ to .j; i / corresponds to a subset S f1; : : : ; j g with k2S ck D i , and vice versa. Therefore we can solve our SUBSETSUM instance by checking whether G contains a path from .0; 0/ to .n; K/. With the GRAPH SCANNING ALGORITHM this can be done in O.nK/ time, so we have a pseudopolynomial algorithm. above is also a pseudopolynomial algorithm for PARTITION because PThe n n c i D1 i 2 largest.c1 ; : : : ; cn /. We shall discuss an extension of this algorithm in Section 17.2. If the numbers are not too large, a pseudopolynomial algorithm can be quite efficient. Therefore the following definition is useful: 1 2

15.7

NP-Hard Problems

405

Definition 15.40. For a decision problem P D .X; Y / or an optimization problem P D .X; .Sx /x2X ; c; goal/, and a subset X 0 X of instances we define the restriction of P to X 0 by P 0 D .X 0 ; X 0 \ Y / or P 0 D .X 0 ; .Sx /x2X 0 ; c; goal/, respectively. Let P be a decision or optimization problem such that each instance consists of a list of numbers. For a polynomial p let Pp be the restriction of P to instances x consisting of nonnegative integers with largest.x/ p.size.x//. P is called strongly NP-hard if there is a polynomial p such that Pp is NP-hard. P is called strongly NP-complete if P 2 NP and there is a polynomial p such that Pp is NP-complete. Proposition 15.41. Unless P D NP there is no exact pseudopolynomial algorithm for any strongly NP-hard problem. We give some famous examples: Theorem 15.42. INTEGER PROGRAMMING is strongly NP-hard. Proof: For an undirected graph G the integer program maxf1lx W x 2 ZV .G/ ; 0 x 1l; xv C xw 1 for fv; wg 2 E.G/g has optimum value at least k if and only if G contains a stable set of cardinality k. Since k jV .G/j for all nontrivial instances .G; k/ of STABLE SET, the result follows from Theorem 15.23.

TRAVELING SALESMAN PROBLEM (TSP) Instance: Task:

A complete graph Kn (n 3) and weights c W E.Kn / ! RC . P Find a Hamiltonian circuit T whose weight e2E.T / c.e/ is minimum.

The vertices of a TSP-instance are often called cities, the weights are also referred to as distances. Theorem 15.43. The TSP is strongly NP-hard. Proof: We show that the TSP is NP-hard even when restricted to instances where all distances are 1 or 2. We describe a polynomial reduction from the H AMILTONIAN CIRCUIT problem. Given a graph G on n 3 vertices, we construct the following instance of TSP: Take one city for each vertex of G, and let the distances be 1 whenever the edge is in E.G/ and 2 otherwise. It is then obvious that G is Hamiltonian if and only if the length of an optimum TSP tour is n. The proof also shows that the following decision problem is not easier than the TSP itself: Given an instance of the TSP and an integer k, is there a tour of length k or less? A similar statement is true for a large class of discrete optimization problems: Proposition 15.44. Let F and F 0 be (infinite) families of finite sets, and let P be the following optimization problem: given a set E 2 F and a function c W E ! Z, find a set F E with F 2 F 0 and c.F / minimum (or decide that no such F exists).

406

15 NP-Completeness

Then P can be solved in polynomial time if and only if the following decision problem can be solved in polynomial time: given an instance .E; c/ of P and an integer k, is OPT..E; c// k? If the optimization problem is NP-hard, then so is this decision problem. Proof: It suffices to show that there is an oracle algorithm for the optimization problem using the decision problem (the converse is trivial). Let .E; c/ be an instance of P. P We first determine OPT..E; c// by binary search. Since there are at most 1 C e2E jc.e/j 2size.c/ possible values we can do this with O.size.c// iterations, each including one oracle call. Then we successively check for each element of E whether there exists an optimum solution without this element. This can be done by increasing its weight (say by one) and checking whether this also increases the value of an optimum solution. If so, we keep the old weight, otherwise we indeed increase the weight. After checking all elements of E, those elements whose weight we did not change constitute an optimum solution. Examples where this result applies are the TSP, the MAXIMUM WEIGHT CLIQUE PROBLEM, the SHORTEST PATH PROBLEM, the KNAPSACK PROBLEM, and many others. Schulz [2009] and Orlin, Punnen and Schulz [2009] proved similar results for INTEGER PROGRAMMING.

Exercises 1. Observe that there are more languages than Turing machines. Conclude that there are languages that cannot be decided by a Turing machine. Turing machines can also be encoded by binary strings. Consider the famous HALTING PROBLEM: given two binary strings x and y, where x encodes a Turing machine ˆ, is time.´L; y/ < 1? Prove that the HALTING PROBLEM is undecidable (i.e. there is no algorithm for it). Hint: Assuming that there is such an algorithm A, construct a Turing machine which, on input x, first runs the algorithm A on input .x; x/ and then terminates if and only if output.A; .x; x// D 0. 2. Describe a Turing machine which compares two strings: it should accept as input a string a#b with a; b 2 f0; 1g and output 1 if a D b and 0 if a 6D b. 3. A well-known machine model is the RAM machine. It works with an infinite sequence of registers x1 ; x2 ; : : : and one special register, the accumulator Acc. Each register can store an arbitrarily large integer, possibly negative. A RAM program is a sequence of instructions. There are ten types of instructions (the meaning is illustrated on the right-hand side):

Exercises

WRITE k

Acc WD k:

LOAD k LOADI k

Acc WD xk : Acc WD xxk :

STORE k STOREI k

xk WD Acc: xxk WD Acc:

ADD k SUBTR k

Acc WD Acc C xk : Acc WD Acc xk :

HALF

Acc WD bAcc=2c:

IFPOS HALT

i

407

If Acc > 0 then go to . i Stop.

A RAM program is a sequence of m instructions; each is one of the above, where k 2 Z and i 2 f1; : : : ; mg. The computation starts with instruction 1; it then proceeds as one would expect; we do not give a formal definition. The above list of instructions may be extended. We say that a command can be simulated by a RAM program in time n if it can be substituted by RAM commands so that the total number of steps in any computation increases by at most a factor of n. (a) Show that the following commands can be simulated by small RAM programs in constant time: IFNEG i IFZERO i

If Acc < 0 then go to . i If Acc D 0 then go to . i

(b) Show that the SUBTR and HALF commands can be simulated by RAM programs using only the other eight commands in O.size.xk // time and O.size.Acc// time, respectively. (c) Show that the following commands can be simulated by RAM programs in O.n/ time, where n D maxfsize.xk /; size.Acc/g: MULT k DIV k MOD k

Acc WD Acc xk : Acc WD bAcc=xk c: Acc WD Acc mod xk :

4. Let f W f0; 1g ! f0; 1g be a mapping. Show that if there is a Turing machine ˆ computing f , then there is a RAM program (cf. Exercise 3) such that the computation on input x (in Acc) terminates after O.size.x/ C time.´L; x// steps with Acc D f .x/. Show that if there is a RAM machine which, given x in Acc, computes f .x/ in Acc in at most g.size.x// steps, then there is a Turing machine computing f with time.´L; x/ D O.g.size.x//3 /. 5. Prove that the following decision problems are in NP: (a) Given two graphs G and H , is G isomorphic to a subgraph of H ?

408

6. 7. 8.

9. 10.

11.

12.

13.

14.

15.

15 NP-Completeness

(b) Given a natural number n (in binary encoding), is there a prime number p with n D p p ? (c) Given a matrix A 2 Zmn and a vector b 2 Zm , is the polyhedron P D fx W Ax bg bounded? (d) Given a matrix A 2 Zmn and a vector b 2 Zm , is the polyhedron P D fx W Ax bg unbounded? Prove: If P 2 NP, then there exists a polynomial p suchthat P can be solved by a (deterministic) algorithm having time complexity O 2p.n/ . Prove that the set of decision problems in NP is countable. Let Z be a 2SAT instance, i.e. a collection of clauses over X with two literals each. Consider a digraph G.Z/ as follows: V .G/ n is theoset of literals over X . There is an edge . 1 ; 2 / 2 E.G/ iff the clause 1 ; 2 is a member of Z. (a) Show that if, for some variable x, x and x are in the same strongly connected component of G.Z/, then Z is not satisfiable. (b) Show the converse of (a). (c) Give a linear-time algorithm for 2SAT. Describe a linear-time algorithm which for any instance of SATISFIABILITY finds a truth assignment satisfying at least half of the clauses. Consider instances of SATISFIABILITY in which each clause has one of the forms fxg, fxg, N or fx; N yg, where x and y are variables. Given such an instance and a nonnegative weight for each clause, find (in polynomial time) a truth assignment that maximizes the total weight of the satisified clauses. Hint: Reduce this to the M INIMUM CAPACITY CUT PROBLEM. Consider 3-OCCURRENCE SAT, which is SATISFIABILITY restricted to instances where each clause contains at most three literals and each variable occurs in at most three clauses. Prove that even this restricted version is NP-complete. Let W f0; 1gm ! f0; 1gm be a (not necessarily bijective) mapping, m 2. For x D .x1 ; : : : ; xn / 2 f0; 1gm f0; 1gm D f0; 1gnm let .x/ WD . .x n //, and for a decision problem P D .X; Y / with X S 1 /; : : : ; .x nm f0; 1g let .P/ WD .f .x/ W x 2 X g; f .x/ W x 2 Y g/. Prove: n2ZC (a) For all codings and all P 2 NP we have also .P/ 2 NP. (b) If .P/ 2 P for all codings and all P 2 P, then P D NP. (Papadimitriou [1994]) Prove that STABLE SET is NP-complete even if restricted to graphs whose maximum degree is 4. Hint: Use Exercise 11. Prove that the following problem, called DOMINATING SET, is NP-complete. Given an undirected graph G and a number k 2 N, is there a set X V .G/ with jX j k such that X [ .X / D V .G/ ? Hint: Transformation from VERTEX COVER. The decision problem CLIQUE is NP-complete. Is it still NP-complete (provided that P 6D NP) if restricted to (a) bipartite graphs,

Exercises

16.

17.

18.

19.

20.

21.

409

(b) planar graphs, (c) 2-connected graphs? Show for each of the following decision problems either membership in P or NP-completeness. Given an undirected graph G, does G contain (a) a circuit of length at least 17? (b) a circuit containing at least half of the vertices? (c) a circuit of odd length? (d) a clique containing at least half of the vertices? (e) two cliques such that each vertex belongs to at least one of them? Prove that the following problems are NP-complete: (a) HAMILTONIAN PATH and DIRECTED HAMILTONIAN PATH Given a graph G (directed or undirected), does G contain a Hamiltonian path? (b) SHORTEST PATH Given a graph G (directed or undirected), weights c W E.G/ ! Z, two vertices s; t 2 V .G/, and an integer k. Is there an s-t-path of weight at most k? (c) 3-MATROID INTERSECTION Given three matroids .E; F1 /; .E; F2 /; .E; F3 / (by independence oracles) and a number k 2 N, decide whether there is a set F 2 F1 \ F2 \ F3 with jF j k. (d) CHINESE POSTMAN PROBLEM Given undirected graphs G and H with V .G/ D V .H /, weights c W E.H / ! ZC and an integer k. Is there a subset F E.H / with c.F / k : such that .V .G/; E.G/ [ F / is connected and Eulerian? Either find a polynomial-time algorithm or prove NP-completeness for the following decision problems: (a) Given an undirected graph G and some T V .G/, is there a spanning tree in G such that all vertices in T are leaves? (b) Given an undirected graph G and some T V .G/, is there a spanning tree in G such that all leaves are elements of T ? (c) Given a digraph G, weights c W E.G/ ! R, a set T V .G/ and a number k, is there a branching B with jıBC .x/j 1 for all x 2 T and c.B/ k? Prove that the following decision problem belongs to coNP: given a matrix A 2 Qmn and a vector b 2 Qn , is the polyhedron fx W Ax bg integral? Hint: Use Proposition 3.9, Lemma 5.11, and Theorem 5.13. Note: The problem is not known to be in NP. Prove that the following problem belongs to coNP: given a matrix A 2 Zmn and a vector b 2 Zm , decide whether the polyhedron P D fx 2 Rn W Ax bg is integral. Note: In fact the problem is coNP-complete, as was shown by Papadimitriou and Yannakakis [1990]. Let us define Boolean formulas. Let X be a set of variables. Then true and false are the Boolean formulas over X of length zero, the literals are the Boolean

410

15 NP-Completeness

formulas over X of length one, and the Boolean formulas over X of length k 2 are the strings . ^ 0 / and . _ 0 / for all Boolean formulas of length l 2 N and 0 of length l 0 2 N with l C l 0 D k. Given a truth assignment T W X ! ftrue; falseg, we extend it to the Boolean formulas over X by setting T .. ^ 0 // WD T . / ^ T . 0 / and T .. _ 0 // WD T . / _ T . 0 /. Two Boolean formulas and 0 over X are equivalent if T . / D T . 0 / for all truth assignments T W X ! ftrue; falseg. Prove that the following problem, called BOOLEAN EQUIVALENCE , is coNPcomplete: given two Boolean formulas over a variable set X , are they equivalent? 22. Show that the following problem is NP-hard (it is not known to be in NP): given an instance of SATISFIABILITY, does the majority of all truth assignments satisfy all the clauses? 23. Show that PARTITION polynomially transforms to the following problem (which is thus NP-hard; it is not known to be in NP):

K-TH HEAVIEST SUBSET Instance:

Integers c1 ; : : : ; cn ; K; L.

Question: Are P there K distinct subsets S1 ; : : : ; SK f1; : : : ; ng such that j 2Si cj L for i D 1; : : : ; K ? 24. Prove that the following problem, called L OGIC MINIMIZATION, can be solved in polynomial time if and only if P D NP: given a set X of variables and a Boolean formula over X , find an equivalent Boolean formula over X with minimum length. Hint: Use Exercise 21. Note: The problem is not known to be NP-easy.

References General Literature: Aho, A.V., Hopcroft, J.E., and Ullman, J.D. [1974]: The Design and Analysis of Computer Algorithms. Addison-Wesley, Reading 1974 Arora, S., and Barak, B. [2009]: Computational Complexity: A Modern Approach. Cambridge University Press, New York 2009 Ausiello, G., Crescenzi, P., Gambosi, G., Kann, V., Marchetti-Spaccamela, A., and Protasi, M. [1999]: Complexity and Approximation: Combinatorial Optimization Problems and Their Approximability Properties. Springer, Berlin 1999 Bovet, D.B., and Crescenzi, P. [1994]: Introduction to the Theory of Complexity. PrenticeHall, New York 1994 Garey, M.R., and Johnson, D.S. [1979]: Computers and Intractability: A Guide to the Theory of NP-Completeness. Freeman, San Francisco 1979, Chapters 1–3, 5, and 7 Goldreich, O. [2008]: Computational Complexity: A Conceptual Perspective. Cambrige University Press, New York 2008

References

411

Horowitz, E., and Sahni, S. [1978]: Fundamentals of Computer Algorithms. Computer Science Press, Potomac 1978, Chapter 11 Johnson, D.S. [1981]: The NP-completeness column: an ongoing guide. Journal of Algorithms starting with Vol. 4 (1981) Karp, R.M. [1975]: On the complexity of combinatorial problems. Networks 5 (1975), 45–68 Papadimitriou, C.H. [1994]: Computational Complexity. Addison-Wesley, Reading 1994 Papadimitriou, C.H., and Steiglitz, K. [1982]: Combinatorial Optimization: Algorithms and Complexity. Prentice-Hall, Englewood Cliffs 1982, Chapters 15 and 16 Wegener, I. [2005]: Complexity Theory: Exploring the Limits of Efficient Algorithms. Springer, Berlin 2005

Cited References: Adleman, L.M., Pomerance, C., and Rumely, R.S. [1983]: On distinguishing prime numbers from composite numbers. Annals of Mathematics 117 (1983), 173–206 Agrawal, M., Kayal, N., and Saxena, N. [2004]: PRIMES is in P. Annals of Mathematics 160 (2004), 781–793 Cook, S.A. [1971]: The complexity of theorem proving procedures. Proceedings of the 3rd Annual ACM Symposium on the Theory of Computing (1971), 151–158 Edmonds, J. [1965]: Minimum partition of a matroid into independent subsets. Journal of Research of the National Bureau of Standards B 69 (1965), 67–72 van Emde Boas, P. [1990]: Machine models and simulations. In: Handbook of Theoretical Computer Science; Volume A; Algorithms and Complexity (J. van Leeuwen, ed.), Elsevier, Amsterdam 1990, pp. 1–66 Fürer, M. [2009]: Faster integer multiplication. SIAM Journal on Computing 39 (2009), 979–1005 Garey, M.R., Johnson, D.S., and Stockmeyer, L. [1976]: Some simplified NP-complete graph problems. Theoretical Computer Science 1 (1976), 237–267 Hopcroft, J.E., and Ullman, J.D. [1979]: Introduction to Automata Theory, Languages, and Computation. Addison-Wesley, Reading 1979 Karp, R.M. [1972]: Reducibility among combinatorial problems. In: Complexity of Computer Computations (R.E. Miller, J.W. Thatcher, eds.), Plenum Press, New York 1972, pp. 85–103 Ladner, R.E. [1975]: On the structure of polynomial time reducibility. Journal of the ACM 22 (1975), 155–171 Lewis, H.R., and Papadimitriou, C.H. [1981]: Elements of the Theory of Computation. Prentice-Hall, Englewood Cliffs 1981 Orlin, J.B., Punnen, A.P., and Schulz, A.S. [2009]: Integer programming: optimization and evaluation are equivalent. In: Algorithms and Data Structures – Proceedings of the 11th Algorithms and Data Structures Symposium; LNCS 5664 (F. Dehne, M. Gavrilova, J.-R. Sack, C.D. Tóth, eds.), Springer, Berlin 2009, pp. 519–529 Papadimitriou, C.H., and Yannakakis, M. [1990]: On recognizing integer polyhedra. Combinatorica 10 (1990), 107–109 Pratt, V. [1975]: Every prime has a succinct certificate. SIAM Journal on Computing 4 (1975), 214–220 Schönhage, A., and Strassen, V. [1971]: Schnelle Multiplikation großer Zahlen. Computing 7 (1971), 281–292

412

15 NP-Completeness

Schulz, A.S. [2009]: On the relative complexity of 15 problems related to 0/1-integer programming. In: Research Trends in Combinatorial Optimization (W.J. Cook, L. Lovász, J. Vygen, eds.), Springer, Berlin 2009, pp. 399–428 Turing, A.M. [1936]: On computable numbers, with an application to the Entscheidungsproblem. Proceedings of the London Mathematical Society (2) 42 (1936), 230–265 and 43 (1937), 544–546

16 Approximation Algorithms

In this chapter we introduce the important concept of approximation algorithms. So far we have dealt mostly with polynomially solvable problems. In the remaining chapters we shall indicate some strategies to cope with NP-hard combinatorial optimization problems. Here approximation algorithms must be mentioned in the first place. The ideal case is when the solution is guaranteed to differ from the optimum solution by a constant only: Definition 16.1. An absolute approximation algorithm for an optimization problem P is a polynomial-time algorithm A for P for which there exists a constant k such that jA.I / OPT.I /j k for all instances I of P. Unfortunately, an absolute approximation algorithm is known for very few classical NP-hard optimization problems. We shall discuss two major examples, the EDGE-COLOURING PROBLEM and the VERTEX-COLOURING PROBLEM in planar graphs in Section 16.3. In most cases we must be satisfied with relative performance guarantees. Here we have to restrict ourselves to problems with nonnegative weights. Definition 16.2. Let P be an optimization problem with nonnegative weights and k 1. A k-factor approximation algorithm for P is a polynomial-time algorithm A for P such that 1 OPT.I / A.I / kOPT.I / k for all instances I of P. We also say that A has performance ratio (or performance guarantee) k. The first inequality applies to maximization problems, the second one to minimization problems. Note that for instances I with OPT.I / D 0 we require an exact solution. The 1-factor approximation algorithms are precisely the exact polynomialtime algorithms. Sometimes the above definition is extended to the case where k is a function of the instance I , rather than a constant. We will see an example in the next section. B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__16, c Springer-Verlag Berlin Heidelberg 2012

413

414

16 Approximation Algorithms

In Section 13.4 we saw that the BEST-IN-GREEDY ALGORITHM for the MAXIMIZATION PROBLEM for an independence system .E; F / has performance 1 ratio q.E;F / (Theorem 13.19). In the following sections and chapters we shall illustrate the above definitions and analyse the approximability of various NP-hard problems. We start with covering problems.

16.1 Set Covering In this section we focus on the following quite general problem:

MINIMUM WEIGHT SET COVER PROBLEM S

S D U , weights c W S ! RC .

Instance:

A set system .U; S/ with

Task:

Find a minimum weight set cover of .U; S/, i.e. a subfamily R S S such that R2R R D U .

S2S

For c 1, the problem is called MINIMUM SET COVER PROBLEM. Another interesting special case arises if jfS 2 S W x 2 S gj D 2 for all x 2 U ; this is the MINIMUM WEIGHT VERTEX COVER PROBLEM: given a graph G and cWV .G/ ! RC , the corresponding set covering instance is defined by U WDE.G/, S WD fı.v/ W v 2 V .G/g and c.ı.v// WD c.v/ for all v 2 V .G/. As the MINIMUM WEIGHT VERTEX COVER PROBLEM is NP-hard even for unit weights (Theorem 15.24), so is the MINIMUM SET COVER PROBLEM. Johnson [1974] and Lovász [1975] proposed a simple greedy algorithm for the MINIMUM SET COVER PROBLEM: in each iteration, pick a set which covers a maximum number of elements not already covered. Chvátal [1979] generalized this algorithm to the weighted case:

GREEDY ALGORITHM FOR SET COVER Input:

A set system .U; S/ with

Output:

A set cover R of .U; S/.

S

S2S

S D U , weights c W S ! RC .

1

Set R WD ; and W WD ;.

2

While W 6D U do: Choose a set R 2 S n R for which R n W 6D ; and Set R WD R [ fRg and W WD W [ R.

c.R/ jRnW j

is minimum.

The running time is obviously O.jU jjSj/. The following performance guarantee can be proved: Theorem 16.3. (Chvátal [1979]) For any instance .U; S; c/ of the MINIMUM WEIGHT SET COVER PROBLEM, the GREEDY ALGORITHM FOR SET COVER finds a set cover whose weight is at most H.r/OPT.U; S; c/, where r WD maxS2S jS j and H.r/ D 1 C 12 C C 1r .

16.1

Set Covering

415

Proof: Let .U; S; c/ be an instance of the MINIMUM WEIGHT SET COVER PROBLEM, and let R D fR1 ; : : : ; Rk g be the solution found by the above algorithm, where Ri is the set chosen in the i -th iteration. For j D 0; : : : ; k let Wj WD Sj i D1 Ri . For each e 2 U let j.e/ WD minfj 2 f1; : : : ; kg W e 2 Rj g be the iteration where e is covered. Let c.Rj.e/ / : y.e/ WD jRj.e/ n Wj.e/1 j Let S 2 S be fixed, and let k 0 WD maxfj.e/ W e 2 S g. We have X

0

y.e/ D

k X

X

y.e/

i D1 e2SWj.e/Di

e2S

0

D

k X i D1 0

D

k X i D1 0

k X i D1

c.Ri / jS \ .Wi n Wi 1 /j jRi n Wi 1 j c.Ri / .jS n Wi 1 j jS n Wi j/ jRi n Wi 1 j c.S / .jS n Wi 1 j jS n Wi j/ jS n Wi 1 j

by the choice of the Ri in 2 (observe that S n Wi 1 6D ; for i D 1; : : : ; k 0 ). By writing si WD jS n Wi 1 j we get X e2S

0

k X si si C1 y.e/ c.S / si i D1

k X 1 0

c.S /

i D1

1 1 CC C si si 1 si C1 C 1

0

k X D c.S / .H.si / H.si C1 // i D1

D c.S /.H.s1 / H.sk 0 C1 // c.S /H.s1 /: Since s1 D jS j r, we conclude that X y.e/ c.S /H.r/: e2S

416

16 Approximation Algorithms

We sum over all S 2 O for an optimum set cover O and obtain XX y.e/ c.O/H.r/ S2O e2S

X

y.e/

e2U

D

k X

X

y.e/

i D1 e2U Wj.e/Di

D

k X

c.Ri / D c.R/:

i D1

For a slightly tighter analysis of the non-weighted case, see Slavík [1997]. Raz and Safra [1997] discovered that there exists a constant c > 0 such that, unless P D NP, no performance ratio of c ln jU j can be achieved. Indeed, a performance ratio of c ln jU j cannot be achieved for any c < 1 unless each problem in NP can be solved in O nO.log log n/ time (Feige [1998]). The MINIMUM WEIGHT EDGE COVER PROBLEM is obviously a special case of the MINIMUM WEIGHT SET COVER PROBLEM. Here we have r D 2 in Theorem 16.3, hence the above algorithm is a 32 -factor approximation algorithm in this special case. However, the problem can also be solved optimally in polynomial time; cf. Exercise 12 of Chapter 11. For the MINIMUM VERTEX COVER PROBLEM, the above algorithm reads as follows:

GREEDY ALGORITHM FOR VERTEX COVER Input:

A graph G.

Output:

A vertex cover R of G.

1

Set R WD ;.

2

While E.G/ 6D ; do: Choose a vertex v 2 V .G/ n R with maximum degree. Set R WD R [ fvg and delete all edges incident to v.

This algorithm looks reasonable, so one might ask for which k it is a k-factor approximation algorithm. It may be surprising that there is no such k. Indeed, the bound given in Theorem 16.3 is almost best possible: Theorem 16.4. (Johnson [1974], Papadimitriou and Steiglitz [1982]) For all n3 there is an instance G of the MINIMUM VERTEX COVER PROBLEM such that nH.n 1/ C 2 jV .G/j nH.n 1/ C n, the maximum degree of G is n 1, OPT.G/ D n, and the above algorithm can find a vertex cover containing all but n vertices.

16.1

Proof: For each n 3 and i n we define Ain WD o n V .Gn / WD a1 ; : : : ; aAn1 : ; b ; : : : ; b ; c ; : : : ; c 1 n 1 n n

Pi

j D2

Set Covering

417

j k n j

and

E.Gn / WD ffbi ; ci g W i D 1; : : : ; ng [ i

An [

n1 [

˚ faj ; bk g W .j Ani 1 1/i C 1 k .j Ani 1 /i :

i D2 j DAin1 C1 n1 nH.n 1/ n and An1 nH.n Observe that jV .Gn /j D 2n C An1 n , An n 1/ n .n 2/. Figure 16.1 shows G6 .

c1

c2

c3

c4

c5

c6

b1

b2

b3

b4

b5

b6

a1

a2

a3

a4

a5

a6

a7

Fig. 16.1.

If we apply our algorithm to Gn , it may first choose vertex aAn1 (because it has n maximum degree), and subsequently the vertices aAn1 ; a ; n1 1 An 2 : : : ; a1 . After n this there are n pairwise disjoint edges left, so n more vertices are needed. Hence the constructed vertex cover consists of An1 C n vertices, while the optimum vertex n cover fb1 ; : : : ; bn g has size n. There are, however, 2-factor approximation algorithms for the MINIMUM VERCOVER PROBLEM. The simplest one is due to Gavril (see Garey and Johnson [1979]): just find any maximal matching M and take the ends of all edges in M . This is obviously a vertex cover and contains 2jM j vertices. Since any vertex cover must contain jM j vertices (no vertex covers two edges of M ), this is a 2-factor approximation algorithm. This performance guarantee is tight: simply think of a graph consisting of many pairwise disjoint edges. It may be surprising that the above is the best known approximation algorithm for the MINIMUM VERTEX COVER PROBLEM. Later we shall show that there is a number k > 1 such that no k-factor approximation algorithm exists unless P D NP (Theorem 16.46). Indeed, a 1:36-factor approximation algorithm does not exist unless P D NP (Dinur and Safra [2002]). See also Khot and Regev [2008]. TEX

418

16 Approximation Algorithms

At least Gavril’s algorithm can be extended to the weighted case. We present the algorithm of Bar-Yehuda and Even [1981], which is applicable to the general MINIMUM WEIGHT SET COVER PROBLEM:

BAR-YEHUDA-EVEN ALGORITHM Input:

A set system .U; S/ with

Output:

A set cover R of .U; S/.

1 2

S

S2S

S D U , weights c W S ! RC .

Set R WD ; and W WD ;. Set y.e/ WD 0 for all e 2 U . Set c 0 .S / WD c.S / for all S 2 S. While W 6D U do: Choose an element e 2 U n W . Let R 2 S with e 2 R and c 0 .R/ minimum. Set y.e/ WD c 0 .R/. Set c 0 .S / WD c 0 .S / y.e/ for all S 2 S with e 2 S . Set R WD R [ fRg and W WD W [ R.

Theorem 16.5. (Bar-Yehuda and Even [1981]) For any instance .U; S; c/ of the MINIMUM WEIGHT SET COVER PROBLEM, the BAR-YEHUDA-EVEN ALGORITHM finds a set cover whose weight is at most pOPT.U; S; c/, where p WD maxe2U jfS 2 S W e 2 S gj. Proof: The MINIMUM WEIGHT SET COVER PROBLEM can be written as the integer linear program ˚ min cx W Ax 1l; x 2 f0; 1gS ; where A is the matrix whose rows correspond to the elements of U and whose columns are the incidence vectors of the sets in S. The optimum of the LP relaxation min fcx W Ax 1l; x 0g is a lower bound for OPT.U; S; c/ (the omission of the constraints x 1l does not change the optimum value of this LP). Hence, by Proposition 3.13, the optimum of the dual LP maxfy1l W yA c; y 0g is also a lower bound for OPT.U; S; c/. Now observe that c 0 .S / 0 for all S 2 S at any P stage of the algorithm. Let yN be the vector y at termination. We have yN 0 and e2S y.e/ N c.S / for all S 2 S, i.e. yN is a feasible solution of the dual LP and y1 N l maxfy1l W yA c; y 0g OPT.U; S; c/:

16.2

The Max-Cut Problem

419

Finally observe that c.R/ D

X

c.R/

R2R

D

XX

y.e/ N

R2R e2R

X

p y.e/ N

e2U

D p y1 Nl pOPT.U; S; c/:

Since we have p D 2 in the vertex cover case, this is a 2-factor approximation algorithm for the M INIMUM WEIGHT VERTEX COVER PROBLEM. The first 2-factor approximation algorithm was due to Hochbaum [1982]. She proposed finding an optimum solution y of the dual LP in the above proof and taking all sets S with P e2S y.e/ D c.S /. Alternatively, one could find an optimum solution x of the primal LP and take all sets S with xS p1 . The advantage of the BAR-YEHUDA-EVEN ALGORITHM is that it does not explicitly use linear programming. In fact it can easily be implemented with P O jS j time. It is our first example of a primal-dual approximation S2S algorithm; more complicated examples will follow in Sections 20.4 and 22.3.

16.2 The Max-Cut Problem In this section we consider another basic problem:

MAXIMUM WEIGHT CUT PROBLEM Instance:

An undirected graph G and weights c W E.G/ ! RC .

Task:

Find a cut in G with maximum total weight.

This problem is often called MAX-CUT for short. In contrast to minimum weight cuts, discussed in Section 8.7, this is a difficult problem. It is strongly NP-hard; even the special case where c 1 (the MAXIMUM CUT PROBLEM) is hard: Theorem 16.6. (Garey, Johnson and Stockmeyer [1976]) The MAXIMUM CUT PROBLEM is NP-hard. Proof: By reduction from MAX-2SAT (cf. Theorem 15.37). Given an instance of MAX-2SAT with n variables and m clauses, we construct a graph G whose vertices are the literals plus an extra vertex ´. For each variable x we add 3m parallel edges between x and x. N For each clause f; 0 g we add three edges f; 0 g, f; ´g and 0 f ; ´g. So G has 2n C 1 vertices and 3m.n C 1/ edges.

420

16 Approximation Algorithms

We claim that the maximum cardinality of a cut in G is 3mn C 2t, where t is the maximum number of clauses satisfied by any truth assignment. Indeed, given a truth assignment satisfying t clauses, let X be the set of true literals. Then jıG .X /j D 3mn C 2t. Conversely, if there is a set X V .G/ with jıG .X /j 3mn C a, then w.l.o.g. ´ … X (otherwise replace X by V .G/ n X ), and for each variable x we have jX \ fx; xgj N D 1 (otherwise replace X by X 4fxg and increase the cut). Thus we can set all literals in X to be true and get a truth assignment satisfying at least a2 clauses. It is very easy to find a 2-factor approximation algorithm for the MAXWEIGHT CUT PROBLEM: If V .G/ D fv P1 ; : : : ; vn g, start with X WD fv g, and for i D 3; : : : ; n add v to X if i e2E.vi ;fv1 ;:::;vi 1 g\X/ c.e/ < P1 c.e/. (The simple analysis of this algorithm is left as Exere2E.vi ;fv1 ;:::;vi 1 gnX/ cise 9.) For a long time no better approximation algorithm was known. Then Goemans and Williamson [1995] found a much better one using semidefinite programming; the rest of this section is based on their paper. Let G be an undirected graph and c W E.G/ ! RC . W.l.o.g., V .G/ D f1; : : : ; ng. For 1 i; j n let cij WD c.fi; j g/ if fi; j g 2 E.G/ and cij WD 0 otherwise. Then the MAXIMUM P WEIGHT CUT PROBLEM consists of finding a subset S f1; : : : ; ng maximizing i 2S; j 2f1;:::;ngnS cij . Expressing S by y 2 f1; 1gn with yi D 1 iff i 2 S , we can formulate the problem as follows: IMUM

1 2

max s.t.

X

cij .1 yi yj /

1i <j n

yi 2 f1; 1g

.i D 1; : : : ; n/

The variables yi can be regarded as one-dimensional vectors of unit norm. By relaxing them to multidimensional vectors of unit Euclidean norm we get a very interesting relaxation:

max s.t.

1 2

X

cij .1 yi> yj /

1i <j n

yi 2 Sm

(16.1)

.i D 1; : : : ; n/

where m 2 N and Sm D fx 2 Rm W jjxjj2 D 1g denotes the unit sphere in Rm . For example, for the triangle (n D 3, c12 D c13 D c23 D 1) the optimum is obtained by points on the unit sphere in R2 that arepvertices of an equilateral p triangle, e.g. y1 D .0; 1/, y2 D . 23 ; 12 /, and y3 D . 23 ; 12 /, giving an optimum value of 94 , in contrast to the maximum weight of a cut, which is 2. However, the interesting fact is that we can solve (16.1) almost optimally in polynomial time. The trick is not to consider the variables yi directly, not even their dimension. Instead, we consider the n n-matrix .yi> yj /i;j D1;:::;n . As a matrix X is symmetric

16.2

The Max-Cut Problem

421

and positive semidefinite if and only if it can be written as B > B for some matrix B, we can write equivalently max s.t.

1 2

X

cij .1 xij /

1i <j n

(16.2)

xi i D 1 .i D 1; : : : ; n/ X D .xij /1i;j n symmetric and positive semidefinite

From a solution to (16.2) we can obtain a solution to (16.1) with m n and almost the same objective function value by Cholesky factorization in O.n3 / time (we have to accept an arbitrarily small rounding error; cf. Exercise 6 of Chapter 4). Problem (16.2) is called a semidefinite programming relaxation. It can be solved approximately in polynomial time by the ELLIPSOID METHOD, applying Theorem 4.19, as we shall show now. First observe that we optimize a linear objective function over the convex set ˚ P WD X D .xij /1i;j n 2 Rnn W X symmetric and positive semidefinite; xi i D 1 .i D 1; : : : ; n/ : 2

By projecting P to the n 2n free variables we obtain ˚ P 0 WD .xij /1i <j n W .xij /1i;j n 2 P with xi i WD 1 and xj i WD xij for i < j : Note that neither P nor P 0 is a polyhedron. However, P 0 is convex, bounded, and full-dimensional: Proposition 16.7. P 0 is convex. Moreover, B.0; n1 / P 0 B.0; n/. Proof: Convexity follows from the simple fact that convex combinations of positive semidefinite matrices are positive semidefinite. For the first inclusion, observe that for a symmetric n n-matrix X whose diagonal entries are 1 and whose off-diagonal entries have absolute value at most n1 we have, for any d 2 Rn , d > Xd D

n X

xij di dj

i;j D1

1 X .xi i di2 C xjj dj2 .2n 2/jxij jjdi dj j/ 2n 2 i 6Dj n

1 X 2 .di C dj2 2jdi dj j/ 2n 2 i 6Dj n

1 X .jdi j jdj j/2 D 2n 2 i 6Dj

0; i.e. X is positive semidefinite.

422

16 Approximation Algorithms

For the second inclusion, note that all off-diagonal entries of a matrix in P have absolute value at most 1, and thus the Euclidean norm of the vector of upper diagonal entries is at most n. It remains to show that the SEPARATION PROBLEM for P 0 can be solved in polynomial time. This is achieved by GAUSSIAN ELIMINATION: Theorem 16.8. Given a symmetric matrix X 2 Qnn , we can decide in polynomial time whether X is positive semidefinite, and find a vector d 2 Qn with d > Xd < 0 if one exists. Proof: If xnn < 0, then we set d D .0; : : : ; 0; 1/ and have d > Xd < 0. If xnn D 0 x and xnj 6D 0 for some j < n, then we can define d by dj WD 1, dn WD 2xjjnj C xnj , x

and di WD 0 for i 2 f1; : : : ; n1gnfj g, and have d > Xd D xjj 2xnj . 2xjjnj Cxnj / D

2.xnj /2 < 0, again proving that X is not positive semidefinite. In the other cases we reduce the dimension. If xnj D 0 for all j , then the last row and column can be deleted: X is positive semidefinite if and only if X 0 WD .xij /i;j D1;:::;n1 is positive semidefinite. Moreover, if c 2 Qn1 satisfies c > X 0 c < 0, we set d WD . 0c / and have d > Xd < 0. Hence let us now assume that xnn > 0. Then we consider X 0 WD .xij xni xnj /i;j D1;:::;n1 ; this corresponds to one iteration of GAUSSIAN ELIMINATION. xnn Note that X 0 is positive semidefinite if and only if X is positive semidefinite. c For a vector c 2 Qn1 with c > X 0 c < 0 we set d WD . x 1 Pn1 /. Then i D1 ci xni nn

>

d Xd D

n1 X i;j D1

n1 X xni 0 di xij C xnj dj C 2 dn xnj dj C dn2 xnn xnn

D c> X 0c C

j D1

n1 X i;j D1

>

ci

xni xnj cj .1 2 C 1/ xnn

0

Dc Xc < 0: This defines a polynomial-time algorithm. To see that the numbers involved in the computation of d are not too large, let X .n/ ; X .n1/ ; : : : ; X .k/ be the considered matrices (X .i / 2 Qi i ), and assume that we observe in iteration n C 1 k that the matrix X .k/ D .yij /i;j D1;:::;k is not positive semidefinite (i.e. ykk < 0 or ykk D 0 and ykj 6D 0 for some j < k). We have a vector c 2 Qk with c > X .k/ c < 0 and size.c/ 2size.X .k/ /. Now a vector d 2 Qn with d > Xd < 0 can be constructed as above; note that d is a solution of the linear equation system M d D . 0c /, where the j -th row of M is

the j -th unit vector if j k,

the j -th unit vector if j > k and the j -th row of X .j / is zero,

the j -th row of X .j / , followed by zeros, otherwise.

16.2

The Max-Cut Problem

423

Hence, with Theorem 4.4, we have size.d / 4n.size.M / C size.c//, which is polynomial by Theorem 4.10. Corollary 16.9. The SEPARATION PROBLEM for P 0 can be solved in polynomial time. Proof: Let .yij /1i <j n be given, and let Y D .yij /1i;j n be the symmetric matrix defined by yi i D 1 for all i and yj i WD yij for i < j . Apply Theorem 16.8. If Y is positive semidefinite, we are done. P 2 Otherwise we findPa vector d 2 Qn with P d > Yd < 0. Then niP D1 di > P n n > 2 d Yd i D1 di D 1i <j n 2di dj yij , but 1i <j n 2di dj ´ij i D1 di2 for all ´ 2 P 0 . Thus .di dj /1i <j n constitutes a separating hyperplane. We can now conclude: Theorem 16.10. For any instance of the MAXIMUM WEIGHT CUT PROBLEM, we can find a matrix Y D .yij /1i;j n 2 P with 8 9 < X = X cij .1 yij / max cij .1 xij / W .xij /1i;j n 2 P : ; 1i <j n

1i <j n

in time polynomial in n, size..cij /1i <j n /, and size./. Proof: We apply Theorem 4.19, using Proposition 16.7 and Corollary 16.9.

Semidefinite programs such as (16.2) can also be solved approximately by interior point algorithms, which are more efficient than the ELLIPSOID METHOD. See Alizadeh [1995] for details. As mentioned above, from an almost optimum solution to (16.2) we can derive a solution to (16.1) with almost the same objective function value by Cholesky factorization. This solution consists of a set of vectors yi 2 Rm (i D 1; : : : ; n) for some m n. As (16.1) P is a relaxation of our original problem, we have that the optimum is at most 12 1i <j n cij .1 yi> yj / C . The vectors yi lie on a unit sphere. The idea is now to take a random hyperplane through the origin, and define S to be the set of indices i for which yi is on one side of this hyperplane. A random hyperplane through the origin is given by a random point on the .m 1/-dimensional sphere. This can be chosen by drawing m real numbers independently from the standard normal distribution, which in turn can be done using independent random numbers uniformly distributed in Œ0; 1. See Knuth [1969] (Section 3.4.1) for details. The algorithm by Goemans and Williamson now reads as follows.

424

16 Approximation Algorithms

GOEMANS-WILLIAMSON MAX-CUT-ALGORITHM Input:

A number n 2 N, numbers cij 0 for 1 i < j n.

Output:

A set S f1; : : : ; ng.

1

Solve (16.2) approximately; i.e. find a symmetric positive semidefinite matrix X D .xij /1i;j n with xi i D 1 for i D 1; : : : ; n, such that P 1i <j n cij .1 xij / 0:9995 OPT.16.2/.

2

Apply Cholesky factorization to X in order to obtain vectors y1 ; : : : ; yn 2 Rm with m n and yi> yj xij for all i; j 2 f1; : : : ; ng.

3

Choose a random point a on the unit sphere fx 2 Rm W jjxjj2 D 1g.

4

Set S WD fi 2 f1; : : : ; ng W a> yi 0g.

Theorem 16.11. The GOEMANS-WILLIAMSON MAX-CUT-ALGORITHM runs in polynomial time. Proof: See the preceding discussion. The most difficult step, , 1 canPbe solved in polynomial time by Theorem 16.10. Here we can choose D 0:00025 1i <j n cij P as 12 1i <j n cij is a lower bound on the optimum objective value (attained by randomly choosing S f1; : : : ; ng) and thus on the optimum value of (16.2). We now prove the performance guarantee: Theorem 16.12. (Goemans and Williamson [1995]) The GoemansWilliamson Max-Cut-Algorithm returns a set S for which the expected value of P i 2S; j …S cij is at least 0:878 times the maximum possible value. Proof: Let Sm again denote the unit sphere in Rm , and let H.y/ WD fx 2 Sm W x > y 0g be the hemisphere with pole y, for y 2 Sm . For a subset volume .A/ A Sm let .A/ WD volume .Sm / ; this defines a probability measure on Sm . We have jS \ fi; j gj D 1 with probability .H.yi /4H.yj //, where 4 denotes the symmetric difference. Note that H.yi /4H.yj / is the union of two spherical digons, each with angle arccos.yi> yj /. As the volume is proportional to the angle, we have .H.yi /4H.yj // D 1 arccos.yi> yj /. Claim: 1 arccos ˇ 0:8785 1ˇ 2 for all ˇ 2 Œ1; 1. For ˇ D 1 we have equality. Moreover, elementary calculus yields min

1ˇ 1:38. As 1:38 > 0:8785 , this proves the claim. 2 P Thus the expected value of i 2S; j …S cij is

16.3

X

X

cij .H.yi /4H.yj // D

1i <j n

cij

1i <j n

0:8785

1 2

1 0:8785 2

Colouring

425

1 arccos.yi> yj / X

cij .1 yi> yj /

1i <j n

X

cij .1 xij /

1i <j n

0:8785 0:9995 OPT.16.2/ > 0:878 OPT.16.2/ 9 8 = < X cij W S f1; : : : ; ng : 0:878 max ; : i 2S; j …S

Therefore we have a randomized approximation algorithm with performance 1 < 1:139. Mahajan and Ramesh [1999] showed how to derandomize ratio 0:878 this algorithm, thus obtaining a deterministic 1:139-factor approximation algorithm. However, there is no 1:062-factor approximation algorithm unless P D NP (Hastad [2001], Papadimitriou and Yannakakis [1991]). See Lovász [2003] for other interesting connections of semidefinite programming and combinatorial optimization.

16.3 Colouring In this section we briefly discuss two more well-known special cases of the MINIMUM SET COVER PROBLEM : we want to partition the vertex set of a graph into stable sets, or the edge set of a graph into matchings: Definition 16.13. Let G be an undirected graph. A vertex-colouring of G is a mapping f W V .G/ ! N with f .v/ 6D f .w/ for all fv; wg 2 E.G/. An edgecolouring of G is a mapping f W E.G/ ! N with f .e/ 6D f .e 0 / for all e; e 0 2 E.G/ with e 6D e 0 and e \ e 0 6D ;. The number f .v/ or f .e/ is called the colour of v or e. In other words, the set of vertices or edges with the same colour (f -value) must be a stable set, or a matching, respectively. Of course we are interested in using as few colours as possible:

VERTEX-COLOURING PROBLEM Instance:

An undirected graph G.

Task:

Find a vertex-colouring f W V .G/ ! f1; : : : ; kg of G with minimum k.

426

16 Approximation Algorithms

EDGE-COLOURING PROBLEM Instance:

An undirected graph G.

Task:

Find an edge-colouring f W E.G/ ! f1; : : : ; kg of G with minimum k.

Reducing these problems to the MINIMUM SET COVER PROBLEM is not very useful: for the VERTEX-COLOURING PROBLEM we would have to list the maximal stable sets, and for the EDGE-COLOURING PROBLEM the maximal matchings; in both cases we would have to reckon with exponentially many. The optimum value of the VERTEX-COLOURING PROBLEM (i.e. the minimum number of colours) is called the chromatic number of the graph. The optimum value of the EDGE-COLOURING PROBLEM is called the edge-chromatic number or sometimes the chromatic index. Both colouring problems are NP-hard: Theorem 16.14. The following decision problems are NP-complete: (a) (Holyer [1981]) Decide whether a given simple graph has edge-chromatic number 3. (b) (Stockmeyer [1973]) Decide whether a given planar graph has chromatic number 3. The problems remain NP-hard even when the graph has maximum degree three in (a), and maximum degree four in (b). Proposition 16.15. For any given graph we can decide in linear time whether the chromatic number is less than 3, and if so, find an optimum colouring. The same holds for the edge-chromatic number. Proof: A graph has chromatic number 1 iff it has no edges. By definition, the graphs with chromatic number at most 2 are precisely the bipartite graphs. By Proposition 2.27 we can check in linear time whether a graph is bipartite and in the positive case find a bipartition, i.e. a vertex-colouring with two colours. To check whether the edge-chromatic number of a graph G is less than 3 (and, if so, find an optimum edge-colouring) we simply consider the VERTEX-COLOURING PROBLEM in the line graph of G. This is obviously equivalent. For bipartite graphs, the EDGE-COLOURING PROBLEM can be solved, too: Theorem 16.16. (König [1916]) The edge-chromatic number of a bipartite graph G equals the maximum degree of a vertex in G. Proof: By induction on jE.G/j. Let G be a graph with maximum degree k, and let e D fv; wg be an edge. By the induction hypothesis, G e has an edge-colouring f with k colours. There are colours i; j 2 f1; : : : ; kg such that f .e 0 / 6D i for all e 0 2 ı.v/ and f .e 0 / 6D j for all e 0 2 ı.w/. If i D j , we are done since we can extend f to G by giving e colour i .

16.3

Colouring

427

The graph H D .V .G/; fe 0 2 E.G/ n feg W f .e 0 / 2 fi; j gg/ has maximum degree 2, and v has degree at most 1 in H . Consider the maximal path P in H with endpoint v. The colours alternate on P ; hence the other endpoint of P cannot be w. Exchange the colours i and j on P and extend the edge-colouring to G by giving e colour j . The maximum degree of a vertex is an obvious lower bound on the edgechromatic number of any graph. It is not always attained as the triangle K3 shows. The following theorem shows how to find an edge-colouring of a given simple graph which needs at most one more colour than necessary: Theorem 16.17. (Vizing [1964]) Let G be an undirected simple graph with maximum degree k. Then G has an edge-colouring with at most k C 1 colours, and such a colouring can be found in polynomial time. Proof: By induction on jE.G/j. If G has no edges, the assertion is trivial. Otherwise let e D fx; y0 g be any edge; by the induction hypothesis there exists an edge-colouring f of G e with k C 1 colours. For each vertex v choose a colour n.v/ 2 f1; : : : ; k C 1g n ff .w/ W w 2 ıGe .v/g missing at v. Starting from y0 , construct a maximal sequence y0 ; y1 ; : : : ; y t of distinct neighbours of x such that n.yi 1 / D f .fx; yi g/ for i D 1; : : : ; t. If no edge incident to x is coloured n.y t /, then we construct an edge-colouring f 0 of G from f by setting f 0 .fx; yi 1 g/ WD f .fx; yi g/ (i D 1; : : : ; t) and f 0 .fx; y t g/ WD n.y t /. So we assume that there is an edge incident to x with colour n.y t /; by the maximality of t we have f .fx; ys g/ D n.y t / for some s 2 f1; : : : ; t 1g. ys−1

y2

n(ys−2)

n(y1)

y1

n(ys−1)=n(yt)

n(y0) y0

ys

x n(yt−1)

yt n(x)

P

n(yt)

n(x)

n(yt)

Fig. 16.2.

Consider the maximum path P starting at y t in the graph .V .G/; fe 0 2 E.G e/ W f .e 0 / 2 fn.x/; n.y t /gg/ (this graph has maximum degree 2; cf. Figure 16.2). We distinguish three cases. In each case we construct an edge-colouring f 0 of G.

428

16 Approximation Algorithms

If P ends in x, then fys ; xg is the last edge of P . We construct f 0 from f by exchanging colours n.x/ and n.y t / on P , and setting f 0 .fx; yi 1 g/ WD f .fx; yi g/ (i D 1; : : : ; s). If P ends in ys1 , then the last edge of P has colour n.x/, since colour n.y t / D f .fx; ys g/ D n.ys1 / is missing at ys1 . We construct f 0 from f as follows: exchange colours n.x/ and n.y t / on P , set f 0 .fx; yi 1 g/ WD f .fx; yi g/ (i D 1; : : : ; s 1) and f 0 .fx; ys1 g/ WD n.x/. If P ends neither in x nor in ys1 , then we can construct f 0 from f by exchanging colours n.x/ and n.y t / on P , and setting f 0 .fx; yi 1 g/ WD f .fx; yi g/ (i D 1; : : : ; t) and f 0 .fx; y t g/ WD n.x/. Vizing’s Theorem implies an absolute approximation algorithm for the E DGECOLOURING PROBLEM in simple graphs. If we allow parallel edges the statement of Vizing’s Theorem is no longer true: by replacing each edge of the triangle K3 by r parallel edges we obtain a 2r-regular graph with edge-chromatic number 3r. We now turn to the VERTEX-COLOURING PROBLEM. The maximum degree also gives an upper bound on the chromatic number: Theorem 16.18. Let G be an undirected graph with maximum degree k. Then G has an vertex-colouring with at most k C 1 colours, and such a colouring can be found in linear time. Proof: The following GREEDY COLOURING ALGORITHM obviously finds such a colouring.

GREEDY COLOURING ALGORITHM Input:

An undirected graph G.

Output:

A vertex-colouring of G.

1

Let V .G/ D fv1 ; : : : ; vn g.

2

For i WD 1 to n do: Set f .vi / WD minfk 2 N W k 6D f .vj / for all j < i with vj 2 .vi /g.

For complete graphs and for odd circuits one evidently needs k C 1 colours, where k is the maximum degree. For all other connected graphs k colours suffice, as Brooks [1941] showed. However, the maximum degree is not a lower bound on the chromatic number: any star K1;n (n 2 N) has chromatic number 2. Therefore these results do not lead to an approximation algorithm. In fact, no algorithms for the VERTEX-COLOURING PROBLEM with a reasonable performance guarantee for general graphs are known; see Khanna, Linial and Safra [2000]. Zuckerman [2007] showed that, unless P D NP, no polynomial-time algorithm computes the chromatic number of any graph with n vertices up to a factor of n1 for any fixed > 0. Since the maximum degree is not a lower bound for the chromatic number one can consider the maximum size of a clique. Obviously, if a graph G contains

16.3

Colouring

429

a clique of size k, then the chromatic number of G is at least k. As the pentagon (circuit of length five) shows, the chromatic number can exceed the maximum clique size. Indeed, there are graphs with arbitrarily large chromatic number that contain no K3 . This motivates the following definition, which is due to Berge [1961,1962]: Definition 16.19. A graph G is perfect if .H / D !.H / for every induced subgraph H of G, where .H / is the chromatic number and !.H / is the maximum cardinality of a clique in H . It follows immediately that the decision problem whether a given perfect graph has chromatic number k has a good characterization (belongs to NP \ coNP). Some examples of perfect graphs can be found in Exercise 15. A polynomial-time algorithm for recognizing perfect graphs has been found by Chudnovsky et al. [2005]. Berge [1961] conjectured that a graph is perfect if and only if it contains neither an odd circuit of length at least five nor the complement of such a circuit as an induced subgraph. This so-called strong perfect graph theorem has been proved by Chudnovsky et al. [2006]. Long before, Lovász [1972] proved the weaker assertion that a graph is perfect iff its complement is perfect. This is known as the weak perfect graph theorem; to prove it we need a lemma: Lemma 16.20. Let G be a perfect graph and x 2 V .G/. Then the graph G 0 WD : : .V .G/ [ fyg; E.G/ [ ffy; vg W v 2 fxg [ .x/g/, resulting from G by adding a new vertex y which is joined to x and to all neighbours of x, is perfect. Proof: By induction on jV .G/j. The case jV .G/j D 1 is trivial since K2 is perfect. Now let G be a perfect graph with at least two vertices. Let x 2 V .G/, and let G 0 arise by adding a new vertex y adjacent to x and all its neighbours. It suffices to prove that !.G 0 / D .G 0 /, since for proper subgraphs H of G 0 this follows from the induction hypothesis: either H is a subgraph of G and thus perfect, or it arises from a proper subgraph of G by adding a vertex y as above. Since we can colour G 0 with .G/ C 1 colours easily, we may assume that !.G 0 / D !.G/. Then x is not contained in any maximum clique of G. Let f be a vertex-colouring of G with .G/ colours, and let X WD fv 2 V .G/ W f .v/ D f .x/g. We have !.G X / D .G X / D .G/ 1 D !.G/ 1 and thus !.G .X n fxg// D !.G/ 1 (as x does not belong to any maximum clique of G). Since .X n fxg/ [ fyg D V .G 0 / n V .G .X n fxg// is a stable set, we have .G 0 / D .G .X n fxg// C 1 D !.G .X n fxg// C 1 D !.G/ D !.G 0 /: Theorem 16.21. (Lovász [1972], Fulkerson [1972], Chvátal [1975]) For a simple graph G the following statements are equivalent: (a) G is perfect.

430

16 Approximation Algorithms

(b) The complement of G is perfect. (c) The stable set polytope, i.e. the convex hull of the incidence vectors of the stable sets of G, is given by: ( x2

RVC.G/

W

X

) xv 1 for all cliques S in G :

(16.3)

v2S

Proof: We prove (a))(c))(b). This suffices, since applying (a))(b) to the complement of G yields (b))(a). (a))(c): Evidently the stable set polytope is contained in (16.3). To prove the other inclusion, let x be a rational vector in the polytope (16.3); we may write xv D pv q , where q 2 N and pv 2 ZC for v 2 V .G/. Replace each vertex v by a clique of size pv ; i.e. consider G 0 defined by V .G 0 / WD f.v; i / W v 2 V .G/; 1 i pv g; E.G 0 / WD ff.v; i /; .v; j /g W v 2 V .G/; 1 i < j pv g [ ff.v; i /; .w; j /g W fv; wg 2 E.G/; 1 i pv ; 1 j pw g: Lemma 16.20 implies that G 0 is perfect. For an arbitrary clique X 0 in G 0 let X WD fv 2 V .G/ W .v; i / 2 X 0 for some i g be its projection to G (also a clique); we have X X jX 0 j pv D q xv q: v2X 0

v2X

0

So !.G / q. Since G is perfect, it thus has a vertex-colouring f with at most q colours. For v 2 V .G/ and i DP1; : : : ; q let ai;v WD 1 if f ..v; j // D i for some j q and ai;v WD 0 otherwise. Then i D1 ai;v D pv for all v 2 V .G/ and hence x D

pv q

D v2V .G/

q 1X ai q i D1

is a convex combination of incidence vectors of stable sets, where ai D .ai;v /v2V .G/ . (c))(b): We show by induction on jV .G/j that if (16.3) is integral then the complement of G is perfect. Since graphs with less than three vertices are perfect, let G be a graph with jV .G/j 3 where (16.3) is integral. We have to show that the vertex set of any induced subgraph H of G can be partitioned into ˛.H / cliques, where ˛.H / is the size of a maximum stable set in H . For proper subgraphs H this follows from the induction hypothesis, since (by Theorem 5.13) every face of the integral polytope (16.3) is integral, in particular the face defined by the supporting hyperplanes xv D 0 (v 2 V .G/ n V .H /). So it remains to prove that V .G/ can be partitioned into ˛.G/ cliques. The equation 1lx D ˛.G/ defines a supporting hyperplane of (16.3), so 8 9 < = X X V .G/ x 2 RC W xv 1 for all cliques S in G; xv D ˛.G/ (16.4) : ; v2S

v2V .G/

16.3

Colouring

431

is a face of (16.3). This face is contained in some facets, which cannot all be of the form fx 2 .16.3/ W xv D 0g for some v (otherwise the origin P would belong to the intersection). Hence there is some clique S in G such that v2S xv D 1 for all x in (16.4). Hence this clique S intersects each maximum stable set of G. Now by the induction hypothesis, the vertex set of G S can partitioned into ˛.G S / D ˛.G/ 1 cliques. Adding S concludes the proof. This proof is due to Lovász [1979b]. Indeed, the inequality system defining (16.3) is TDI for perfect graphs (Exercise 16). With some more work one can prove that for perfect graphs the VERTEX-COLOURING PROBLEM, the MAXIMUM WEIGHT STABLE SET PROBLEM and the MAXIMUM WEIGHT CLIQUE PROBLEM can be solved in strongly polynomial time. Although these problems are all NPhard for general graphs (Theorem 15.23, Corollary 15.24, Theorem 16.14(b)), there is a number (the so-called theta-function of the complement graph, introduced by Lovász [1979a]) which is always between the maximum clique size and the chromatic number, and which can be computed in polynomial time for general graphs using the ELLIPSOID METHOD. The details are a bit involved; see Grötschel, Lovász and Schrijver [1988]. One of the best-known problems in graph theory has been the four colour problem: is it true that every planar map can be coloured with four colours such that no two countries with a common border have the same colour? If we consider the countries as regions and switch to the planar dual graph, this is equivalent to asking whether every planar graph has a vertex-colouring with four colours. Appel and Haken [1977] and Appel, Haken and Koch [1977] proved that this is indeed true: every planar graph has chromatic number at most 4. For a simpler proof of this Four Colour Theorem (which nevertheless is based on a case checking by a computer) see Robertson et al. [1997]. We prove the following weaker result, known as the Five Colour Theorem: Theorem 16.22. (Heawood [1890]) Any planar graph has a vertex-colouring with at most five colours, and such a colouring can be found in polynomial time. Proof: By induction on jV .G/j.We may assume that G is simple, and we fix an arbitrary planar embedding ˆ D ; .Je /e2E.G/ of G. By Corollary 2.33, G has a vertex v of degree five or less. By the induction hypothesis, G v has a vertexcolouring f with at most 5 colours. We may assume that v has degree 5 and all neighbours have different colours; otherwise we can easily extend the colouring to G. Let w1 ; w2 ; w3 ; w4 ; w5 be the neighbours of v in the cyclic order in which the polygonal arcs Jfv;wi g leave v. We first claim that there are no vertex-disjoint paths P from w1 to w3 and Q from w2 to w4 in G v. To prove this, let P be a w1 -w3 -path, and let C be the circuit in G consisting of P and the edges fv; w1 g; fv; w3 g. By Theorem 2.30 R2 n S e2E.C / Je splits into two connected regions, and v is on the boundary of both regions. Hence w2 and w4 belong to different regions of that set, implying that every w2 -w4 -path in G v must contain a vertex of C .

432

16 Approximation Algorithms

Let X be the connected component of the graph GŒfx 2 V .G/ n fvg W f .x/ 2 ff .w1 /; f .w3 /gg which contains w1 . If X does not contain w3 , we can exchange the colours in X and afterwards extend the colouring to G by colouring v with the old colour of w1 . So we may assume that there is a w1 -w3 -path P containing only vertices coloured with f .w1 / or f .w3 /. Analogously, we are done if there is no w2 -w4 -path Q containing only vertices coloured with f .w2 / or f .w4 /. But the contrary assumption means that there are vertex-disjoint paths P from w1 to w3 and Q from w2 to w4 in G v, a contradiction. Hence this is a second NP-hard problem which has an absolute approximation algorithm. Indeed, the Four Colour Theorem implies that the chromatic number of a non-bipartite planar graph can only be 3 or 4. Using the polynomial-time algorithm of Robertson et al. [1996], which colours any given planar graph with four colours, one obtains an absolute approximation algorithm which uses at most one colour more than necessary. Fürer and Raghavachari [1994] detected a third natural problem which can be approximated up to an additive error of one: Given an undirected graph, they look for a spanning tree whose maximum degree is minimum among all the spanning trees (the problem is a generalization of the HAMILTONIAN PATH PROBLEM and thus NP-hard). Their algorithm also extends to a general case corresponding to the STEINER TREE PROBLEM: given a set T V .G/, find a tree S in G with V .T / V .S / such that the maximum degree of S is minimum. Singh and Lau [2007] found an extension to minimum weight spanning trees with bounded degrees. On the other hand, the following theorem tells that many problems do not have absolute approximation algorithms unless P D NP: Proposition 16.23. Let F and F 0 be (infinite) families of finite sets, and let P be the following optimization problem: Given a set E 2 F and a function c W E ! Z, find a set F E with F 2 F 0 and c.F / minimum (or decide that no such F exists). Then P has an absolute approximation algorithm if and only if P can be solved in polynomial time. Proof: Suppose there is a polynomial-time algorithm A and an integer k such that jA..E; c// OPT..E; c//j k for all instances .E; c/ of P. We show how to solve P exactly in polynomial time. Given an instance .E; c/ of P, we construct a new instance .E; c 0 /, where 0 c .e/ WD .k C 1/c.e/ for all e 2 E. Obviously the optimum solutions remain the same. But if we now apply A to the new instance, jA..E; c 0 // OPT..E; c 0 //j k and thus A..E; c 0 // D OPT..E; c 0 //.

16.4

Approximation Schemes

433

Examples are the MINIMIZATION PROBLEM FOR INDEPENDENCE SYSTEMS and the MAXIMIZATION PROBLEM FOR INDEPENDENCE SYSTEMS (multiply c by 1), and thus all problems in the list of Section 13.1.

16.4 Approximation Schemes Recall the absolute approximation algorithm for the EDGE-COLOURING PROBLEM discussed in the previous section. This also implies a relative performance guarantee: Since one can easily decide if the edge-chromatic number is 1 or 2 (Proposition 16.15), Vizing’s Theorem yields a 43 -factor approximation algorithm. On the other hand, Theorem 16.14(a) implies that no k-factor approximation algorithm exists for any k < 43 (unless P D NP). Hence the existence of an absolute approximation algorithm does not imply the existence of a k-factor approximation algorithm for all k > 1. We shall meet a similar situation with the BIN-PACKING PROBLEM in Chapter 18. This consideration suggests the following definition: Definition 16.24. Let P be an optimization problem with nonnegative weights. An asymptotic k-factor approximation algorithm for P is a polynomial-time algorithm A for P for which there exists a constant c such that 1 OPT.I / c A.I / kOPT.I / C c k for all instances I of P. We also say that A has asymptotic performance ratio k. The (asymptotic) approximation ratio of an optimization problem P with nonnegative weights is defined to be the infimum of all numbers k for which there exists an (asymptotic) k-factor approximation algorithm for P, or 1 if there is no (asymptotic) approximation algorithm at all. For example, the above-mentioned EDGE-COLOURING PROBLEM has approximation ratio 43 (unless P D NP), but asymptotic approximation ratio 1 (not only in simple graphs; see Sanders and Steurer [2008]). Optimization problems with (asymptotic) approximation ratio 1 are of particular interest. For these problems we introduce the following notion: Definition 16.25. Let P be an optimization problem with nonnegative weights. An approximation scheme for P is an algorithm A accepting as input an instance I of P and an > 0 such that, for each fixed , A is a .1 C /-factor approximation algorithm for P. An asymptotic approximation scheme for P is a pair of algorithms .A; A0 / with the following properties: A0 is a polynomial-time algorithm accepting a number > 0 as input and computing a number c . A accepts an instance I of P and an > 0 as input, and its output consists of a feasible solution for I satisfying

434

16 Approximation Algorithms

1 OPT.I / c A.I; / .1 C / OPT.I / C c : 1C For each fixed , the running time of A is polynomially bounded in size.I /. An (asymptotic) approximation scheme is called a fully polynomial (asymptotic) approximation scheme if the running time as well as the maximum size of any number occurring in the computation is bounded by a polynomial in size.I / C size./ C 1 . In some other texts one finds the abbreviations PTAS for (polynomial-time) approximation scheme and FPAS or FPTAS for fully polynomial approximation scheme. Apart from absolute approximation algorithms, a fully polynomial approximation scheme can be considered the best we may hope for when faced with an NPhard optimization problem, at least if the cost of any feasible solution is a nonnegative integer (which can be assumed in many cases without loss of generality): Proposition 16.26. Let P D .X; .Sx /x2X ; c; goal/ be an optimization problem where the values of c are nonnegative integers. Let A be an algorithm which, given an instance I of P and a number > 0, computes a feasible solution of I with 1 OPT.I / A.I; / .1 C /OPT.I / 1C and whose running time is bounded by a polynomial in size.I / C size./. Then P can be solved exactly in polynomial time. 1 Proof: Given an instance I , we first run A on .I; 1/. We set WD 1C2A.I;1/ and observe that OPT.I / < 1. Now we run A on .I; /. Since size./ is polynomially bounded in size.I /, this procedure constitutes a polynomial-time algorithm. If P is a minimization problem, we have

A.I; / .1 C /OPT.I / < OPT.I / C 1; which, since c is integral, implies optimality. Similarly, if P is a maximization problem, we have A.I; /

1 OPT.I / > .1 /OPT.I / > OPT.I / 1: 1C

Unfortunately, a fully polynomial approximation scheme exists only for very few problems (see Theorem 17.11). Moreover we note that even the existence of a fully polynomial approximation scheme does not imply an absolute approximation algorithm; the KNAPSACK PROBLEM is an example. In Chapters 17 and 18 we shall discuss two problems (KNAPSACK and BINPACKING) which have a fully polynomial approximation scheme and a fully polynomial asymptotic approximation scheme, respectively. For many problems the two types of approximation schemes coincide:

16.5

Maximum Satisfiability

435

Theorem 16.27. (Papadimitriou and Yannakakis [1993]) Let P be an optimization problem with nonnegative weights. Suppose that for each constant k there is a polynomial-time algorithm which decides whether a given instance has optimum value at most k, and, if so, finds an optimum solution. Then P has an approximation scheme if and only if P has an asymptotic approximation scheme. Proof: The only-if-part is trivial, so suppose that P has an asymptotic approximation scheme .A; A0 /. We describe an approximation scheme for P. 2 Let a fixed > 0 be given; we may assume < 1. We set 0 WD 2CC 2 < 2 0 0 and first run A on the input , yielding a constant c0 . 2c For a given instance I we next test whether OPT.I / is at most 0 . This is a constant for each fixed , so we can decide this in polynomial time and find an 2c optimum solution if OPT.I / 0 . Otherwise we apply A to I and 0 and obtain a solution of value V , with 1 OPT.I / c0 V .1 C 0 / OPT.I / C c0 : 1 C 0 We claim that this solution is good enough. Indeed, we have c0 < 2 OPT.I / which implies V .1 C 0 / OPT.I / C c0 < 1 C OPT.I / C OPT.I / D .1 C /OPT.I / 2 2 and 1 OPT.I / OPT.I / 0 .1 C / 2 2 2CC OPT.I / OPT.I / D 2 C 2 2 1 C OPT.I / OPT.I / D 1C 2 2 1 D OPT.I /: 1C

V

So the definition of an asymptotic approximation scheme is meaningful only for problems (such as bin-packing or colouring problems) whose restriction to a constant optimum value is still difficult. For many problems this restriction can be solved in polynomial time by some kind of complete enumeration.

16.5 Maximum Satisfiability The SATISFIABILITY Problem was our first NP-complete problem. In this section we analyse the corresponding optimization problem:

436

16 Approximation Algorithms

MAXIMUM SATISFIABILITY (MAX-SAT) Instance: Task:

A set X of variables, a family Z of clauses over X , and a weight function c W Z ! RC . Find a truth assignment T of X such that the total weight of the clauses in Z that are satisfied by T is maximum.

As we shall see, approximating MAX-SAT is a nice example (and historically one of the first) for the algorithmic use of the probabilistic method. Let us first consider the following trivial randomized algorithm: set each variable independently true with probability 12 . Obviously this algorithm satisfies each clause Z with probability 1 2jZj . Let us write r for random variables which are true with probability 12 and false otherwise, and let R D .r; r; : : : ; r/ be the random variable uniformly distributed over all truth assignments (several copies of r are independent of each other). If we write c.T / for the total weight of the clauses satisfied by the truth assignment T , the expected total weight of the clauses satisfied by R is X Exp .c.R// D c.Z/Prob.R satisfies Z/ Z2Z

D

X

c.Z/ 1 2jZj

Z2Z

.1 2p /

X

(16.5)

c.Z/;

Z2Z

where p WD minZ2Z jZj; Exp and ProbPdenote expectation and probability. Since the optimum cannot exceed Z2Z c.Z/, R is expected to yield a solution within a factor 121p of the optimum. But what we would really like to have is a deterministic approximation algorithm. In fact, we can turn our (trivial) randomized algorithm into a deterministic algorithm while preserving the performance guarantee. This step is often called derandomization. Let us fix the truth assignment step by step. Suppose X D fx1 ; : : : ; xn g, and we have already fixed a truth assignment T for x1 ; : : : ; xk (0 k < n). If we now set xkC1 ; : : : ; xn randomly, setting each variable independently true with probability 12 , we will satisfy clauses of expected total weight e0 D Exp.c.T .x1 /; : : : ; T .xk /; r; : : : ; r//. If we set xkC1 true (false), and then set xkC2 ; : : : ; xn randomly, the satisfied clauses will have some expected total weight e1 (e2 , respectively). e1 and e2 can be thought of as conditional expectations. Triv2 ially e0 D e1 Ce , so at least one of e1 ; e2 must be at least e0 . We set xkC1 to be true 2 if e1 e2 and false otherwise. This is sometimes called the method of conditional probabilities.

16.5

Maximum Satisfiability

437

JOHNSON’S ALGORITHM FOR MAX-SAT Input: Output:

A set X D fx1 ; : : : ; xn g of variables, a family Z of clauses over X , and a weight function c W Z ! RC . A truth assignment T W X ! ftrue; falseg.

For k WD 1 to n do: If Exp.c.T .x1 /; : : : ; T .xk1 /; true; r; : : : ; r// Exp.c.T .x1 /; : : : ; T .xk1 /; false; r; : : : ; r// then set T .xk / WD true else set T .xk / WD false.

1

The expectations can be easily computed with (16.5). Theorem 16.28. (Johnson [1974]) JOHNSON’S ALGORITHM FOR MAX-SAT is a 121p -factor approximation algorithm for MAX-SAT, where p is the minimum cardinality of a clause. Proof: Let us define the conditional expectation sk WD Exp.c.T .x1 /; : : : ; T .xk /; r; : : : ; r// for k D 0; : : : ; n. Observe that sn D c.T / is the total weight P of the clauses satisfied by our algorithm, while s0 D Exp.c.R// .1 2p / Z2Z c.Z/ by (16.5). Furthermore, si Psi 1 by the choice of T .xi / in D 1; : : : ; n). So 1 (for i P sn s0 .1 2p / Z2Z c.Z/. Since the optimum is at most Z2Z c.Z/, the proof is complete. Since p 1, we have a 2-factor approximation algorithm. However, this is not too interesting as there is a much simpler 2-factor approximation algorithm: either set all variables true or all false, whichever is better. However, Chen, Friesen and Zheng [1999] showed that JOHNSON’S ALGORITHM FOR MAX-SAT is indeed a 3 -factor approximation algorithm. 2 If there are no one-element clauses (p 2), it is a 43 -factor approximation algorithm (by Theorem 16.28), for p 3 it is an 87 -factor approximation algorithm. Yannakakis [1994] found a 43 -factor approximation algorithm for the general case using network flow techniques. We shall describe a simpler 43 -factor approximation algorithm due to Goemans and Williamson [1994]. It is straightforward to translate MAX-SAT into an integer linear program: If we have variables X D fx1 ; : : : ; xn g, clauses Z D fZ1 ; : : : ; Zm g, and weights c1 ; : : : ; cm , we can write max

m X

cj ´j

j D1

s.t.

´j

X i Wxi 2Zj

yi ; ´j 2 f0; 1g

yi C

X

.1 yi / .j D 1; : : : ; m/

i Wxi 2Zj

.i D 1; : : : ; n; j D 1; : : : ; m/:

438

16 Approximation Algorithms

Here yi D 1 means that variable xi is true, and ´j D 1 means that clause Zj is satisfied. Now consider the LP relaxation: max

m X

cj ´j

j D1

s.t.

X

´j

i Wxi 2Zj

yi yi ´j ´j

yi C

X

.1 yi /

.j D 1; : : : ; m/ (16.6)

i Wxi 2Zj

1 0 1 0

.i D 1; : : : ; n/ .i D 1; : : : ; n/ .j D 1; : : : ; m/ .j D 1; : : : ; m/:

Let .y ; ´ / be an optimum solution of (16.6). Now independently set each variable xi true with probability yi . This step is known as randomized rounding, a technique which has been introduced by Raghavan and Thompson [1987]. The above method constitutes another randomized algorithm for MAX-SAT, which can be derandomized as above. Let rp be the random variable which is true with probability p and false otherwise.

GOEMANS-WILLIAMSON ALGORITHM FOR MAX-SAT Input: Output:

A set X D fx1 ; : : : ; xn g of variables, a family Z of clauses over X , and a weight function c W Z ! RC . A truth assignment T W X ! ftrue; falseg.

1

Solve the linear program (16.6); let .y ; ´ / be an optimum solution.

2

For k WD 1 to n do: If Exp.c.T .x1 /; : : : ; T .xk1 /; true; rykC1 ; : : : ; ryn / Exp.c.T .x1 /; : : : ; T .xk1 /; false; rykC1 ; : : : ; ryn / then set T .xk / WD true else set T .xk / WD false.

Theorem 16.29. (Goemans and Williamson [1994]) The GOEMANS-WILLIAM 1 q -factor approximation algorithm, SON A LGORITHM FOR M AX -SAT is a 1 1 1 q

where q is the maximum cardinality of a clause. Proof: Let us write sk WD Exp.c.T .x1 /; : : : ; T .xk /; rykC1 ; : : : ; ryn //

for k D 0; : : : ; n. We again have si si 1 for i D 1; : : : ; n and sn D c.T / is the total weight of clauses satisfied by our algorithm. So it remains to estimate s0 D Exp.c.Ry //, where Ry D .ry1 ; : : : ; ryn /. For j D 1; : : : ; m, the probability that the clause Zj is satisfied by Ry is

16.5

0 1@

1 0

Y

.1 yi /A @

i Wxi 2Zj

Maximum Satisfiability

Y

439

1 yi A :

i Wxi 2Zj

Since the geometric mean is always less than or equal to the arithmetic mean, this probability is at least 0

0

1@

1 @ jZj j

0

X

.1 yi / C

i Wxi 2Zj

X

11jZj j yi AA

i Wxi 2Zj

11jZj j X X 1 @ D 1 @1 yi C .1 yi /AA jZj j 0

i Wxi 2Zj

1 1

´j

i Wxi 2Zj

!jZj j

jZj j ! 1 jZj j ´j : 1 1 jZj j

To prove the last inequality, observe that for any 0 a 1 and any k 2 N ! a k 1 k 1 1 a 1 1 k k holds: both sides of the inequality are equal for a 2 f0; 1g, and the left-hand side (as a function of a) is concave, while the right-hand side is linear. So we have s0 D Exp.c.Ry // D

m X

cj Prob.Ry satisfies Zj /

j D1

! 1 jZj j ´j cj 1 1 jZj j j D1 m 1 q X 1 1 cj ´j q m X

j D1

(observe that the sequence

1

1 k k k2N

is monotonously increasing and conP verges to 1e ). Since the optimum is less than or equal to jmD1 ´j cj , the optimum value of the LP relaxation, the proof is complete. q e e Since 1 q1 < 1e , we have an e1 -factor approximation algorithm ( e1 is about 1:582).

440

16 Approximation Algorithms

We now have two similar algorithms that behave differently: the first one is better for long clauses, while the second is better for short clauses. Hence it is natural to combine them: Theorem 16.30. (Goemans and Williamson [1994]) The following is a 43 -factor approximation algorithm for MAX-SAT: run both JOHNSON’S ALGORITHM FOR MAX-SAT and the GOEMANS-WILLIAMSON ALGORITHM FOR MAX-SAT and choose the better of the two solutions. Proof: We use the notation of the above proofs. The algorithm returns a truth assignment satisfying clauses of total weight at least maxfExp.c.R//; Exp.c.Ry //g 1 Exp.c.R// C Exp.c.Ry // 2 ! jZj j ! m 1 1X 1 2jZj j cj C 1 1 ´j cj 2 jZj j j D1 jZj j ! m 1 1X 2 2jZj j 1 ´j cj 2 jZj j j D1 m

3X ´j cj : 4 j D1

k 32 for all k 2 N: for For the last inequality observe that 2 2k 1 k1 1 k 1 1 3 k k 2 f1; 2g we have equality; for Pkm 3we have 22 1 k 2 8 e > 2 . Since the optimum is at least j D1 ´j cj , the theorem is proved. Slightly better approximation algorithms for MAX-SAT (using semidefinite programming) have been found; see Goemans and Williamson [1995], Mahajan and Ramesh [1999], Feige and Goemans [1995], and Asano [2006]. The currently best known algorithm achieves a performance ratio of 1:256 (Avidor, Berkovitch and Zwick [2006]). Indeed, Bellare and Sudan [1994] showed that approximating MAX-SAT to within a factor of 74 is NP-hard. Even for MAX-3SAT (which is MAX-SAT restricted 73 to instances where each clause has exactly three literals) no approximation scheme exists (unless P D NP), as we shall show in the next section.

16.6 The PCP Theorem Many non-approximability results are based on a deep theorem which gives a new characterization of the class NP. Recall that a decision problem belongs to NP if and

16.6

The PCP Theorem

441

only if there is a polynomial-time certificate-checking algorithm. Now we consider randomized certificate-checking algorithms that read the complete instance but only a small part of the certificate to be checked. They always accept yes-instances with correct certificates but sometimes also accept no-instances. Which bits of the certificate are read is decided randomly in advance; more precisely this decision depends on the instance x and on O.log.size.x/// random bits. We now formalize this concept. If s is a string and t 2 Nk , then s t denotes the string of length k whose i -th component is the ti -th component of s (i D 1; : : : ; k). Definition 16.31. A decision problem .X; Y / belongs to the class PCP(log n,1) if there is a polynomial p and a constant k 2 N, a function n o f W .x; r/ W x 2 X; r 2 f0; 1gblog.p.size.x///c ! Nk computable in polynomial time, with f .x; r/ 2 f1; : : : ; bp.size.x//cgk for all x and r, and a decision problem .X 0 ; Y 0 / in P, where X 0 WD f.x; ; / W x 2 X; 2 f1; : : : ; bp.size.x//cgk ; 2 f0; 1gk g, such that for any instance x 2 X: If x 2 Y then there exists a c 2 f0; 1gbp.size.x//c with Prob .x; f .x; r/; cf .x;r/ /2Y 0 D 1. If x … Y then Prob .x; f .x; r/; cf .x;r/ / 2 Y 0 < 12 for all c 2 f0; 1gbp.size.x//c . Here the probability is taken over the uniform distribution of random strings r 2 f0; 1gblog.p.size.x///c . The letters “PCP” stand for “probabilistically checkable proof ”. The parameters log n and 1 reflect that, for an instance of size n, O.log n/ random bits are used and O.1/ bits of the certificate are read. For any yes-instance there is a certificate which is always accepted; while for no-instances no string is accepted as a certificate with probability 12 or more. Note that this error probability 12 can be replaced equivalently by any number between zero and one (Exercise 19). Proposition 16.32. PCP.log n; 1/ NP. Proof: Let .X; Y / 2 PCP.log n; 1/, and let p; k; f; .X 0 ; Y 0/ be given as in Defi˚ 00 nition 16.31. Let X WD .x; c/ W x 2 X; c 2 f0; 1gbp.size.x//c , and let ˚ Y 00 WD .x; c/ 2 X 00 W Prob .x; f .x; r/; cf .x;r/ / 2 Y 0 D 1 : To show that .X; Y / 2 NP it suffices to show that .X 00 ; Y 00 / 2 P. But since there are only 2blog.p.size.x///c , i.e. at most p.size.x// many strings r 2 f0; 1gblog.p.size.x///c , we can try them all. For each one we compute f .x; r/ and test whether .x; f .x; r/, cf .x;r/ / 2 Y 0 (we use that .X 0 ; Y 0 / 2 P). The overall running time is polynomial in size.x/. Now the surprising result is that these randomized verifiers, which read only a constant number of bits of the certificate, are as powerful as the standard (deterministic) certificate-checking algorithms which have the full information. This is the so-called PCP Theorem:

442

16 Approximation Algorithms

Theorem 16.33. (Arora et al. [1998]) NP D PCP.log n; 1/:

The proof of NP PCP.log n; 1/ is very difficult and beyond the scope of this book. It is based on earlier (and weaker) results of Feige et al. [1996] and Arora and Safra [1998]. For a self-contained proof of the PCP Theorem 16.33, see also Arora [1994], Hougardy, Prömel and Steger [1994], or Ausiello et al. [1999]. Stronger results were found subsequently by Bellare, Goldreich and Sudan [1998] and Hastad [2001]. For example, the number k in Definition 16.31 can be chosen to be 9. A new proof of the PCP Theorem was proposed by Dinur [2007]. We show some of its consequences for the non-approximability of combinatorial optimization problems. We start with the MAXIMUM CLIQUE PROBLEM and the MAXIMUM STABLE SET PROBLEM: given an undirected graph G, find a clique, or a stable set, of maximum cardinality in G. Recall Proposition 2.2 (and Corollary 15.24): The problems of finding a maximum clique, a maximum stable set, or a minimum vertex cover are all equivalent. However, the 2-factor approximation algorithm for the M INIMUM VERTEX COVER PROBLEM (Section 16.1) does not imply an approximation algorithm for the MAXIMUM STABLE SET PROBLEM or the M AXIMUM CLIQUE PROBLEM . Namely, it can happen that the algorithm returns a vertex cover C of size n 2, while the optimum is n2 1 (where n D jV .G/j). The complement V .G/ n C is then a stable set of cardinality 2, but the maximum stable set has cardinality n2 C 1. This example shows that transferring an algorithm to another problem via a polynomial transformation does not in general preserve its performance guarantee. We shall consider a restricted type of transformation in the next section. Here we deduce a non-approximability result for the MAXIMUM CLIQUE PROBLEM from the PCP Theorem: Theorem 16.34. (Arora and Safra [1998]) Unless P D NP there is no 2-factor approximation algorithm for the MAXIMUM CLIQUE PROBLEM. Proof: Let P D .X; Y / be some NP-complete problem. By the PCP Theorem 16.33, P 2 PCP.log n; 1/, so let p, k, f , P 0 WD .X 0 ; Y 0 / be as in Definition 16.31. For any given x 2 X we construct a graph Gx as follows. Let o n V .Gx / WD .r; a/ W r 2 f0; 1gblog.p.size.x///c ; a 2 f0; 1gk ; .x; f .x; r/; a/ 2 Y 0 (representing all “accepting runs” of the randomized certificate checking algorithm). Two vertices .r; a/ and .r 0 ; a0 / are joined by an edge if ai D aj0 whenever the i -th component of f .x; r/ equals the j -th component of f .x; r 0 /. Since P 0 2 P and there are only a polynomial number of random strings, Gx can be computed in polynomial time (and has polynomial size).

16.6

The PCP Theorem

443

If x 2 Y then by definition there exists a certificate c 2 f0; 1gbp.size.x//c such that .x; f .x; r/; cf .x;r/ / 2 Y 0 for all r 2 f0; 1gblog.p.size.x///c . Hence there is a clique of size 2blog.p.size.x///c in Gx . On the other hand, if x … Y then there is no clique of size 12 2blog.p.size.x///c in Gx : Suppose .r .1/ ; a.1/ /; : : : ; .r .t / ; a.t / / are the vertices of a clique. Then r .1/ ; : : : ; r .t / are pairwise different. We set ci WD ak.j / whenever the k-th component of f .x; r .j / / equals i , and set the remaining components of c (if any) arbitrarily. This way we obtain a certificate c with .x; f .x; r .i / /; cf .x;r .i / / / 2 Y 0 for all i D 1; : : : ; t. If x … Y we have t < 12 2blog.p.size.x///c . So any 2-factor approximation algorithm for the MAXIMUM CLIQUE PROBLEM is able to decide if x 2 Y , i.e. to solve P. Since P is NP-complete, this is possible only if P D NP. The reduction in the above proof is due to Feige et al. [1996]. Since the error probability 12 in Definition 16.31 can be replaced by any number between 0 and 1 (Exercise 19), we get that there is no -factor approximation algorithm for the MAXIMUM CLIQUE PROBLEM for any 1 (unless P D NP). With more effort Zuckerman [2007] showed that, unless P D NP, no polynomial-time algorithm computes the maximum size of a clique in any graph with n vertices up to a factor of n1 , for any fixed > 0. The best known algorithm k log3 n guarantees to find a clique of size n.log in this case (Feige [2004]). Of course, log n/2 all this also holds for the MAXIMUM STABLE SET PROBLEM (by considering the complement of the given graph). Now we turn to the following restriction of MAX-SAT:

MAX-3SAT Instance: Task:

A set X of variables and a family Z of clauses over X , each with exactly three literals. Find a truth assignment T of X such that the number of clauses in Z that are satisfied by T is maximum.

In Section 16.5 we had a simple 87 -factor approximation algorithm for M AX3SAT, even for the weighted form (Theorem 16.28). Hastad [2001] showed that this is best possible: no -factor approximation algorithm for M AX-3SAT can exist for any < 87 unless P D NP. Here we prove the following weaker result: Theorem 16.35. (Arora et al. [1998]) Unless P D NP there is no approximation scheme for MAX-3SAT. Proof: Let P D .X; Y / be some NP-complete problem. By the PCP Theorem 16.33, P 2 PCP.log n; 1/, so let p, k, f , P 0 WD .X 0 ; Y 0 / be as in Definition 16.31. For any given x 2 X we construct a 3SAT-instance Jx . Namely, for each random string r 2 f0; 1gblog.p.size.x///c we define a family Zr of 3SAT-clauses (the union of all these families will be Jx ). We first construct a family Zr0 of clauses with an arbitrary number of literals and then apply Proposition 15.21.

444

16 Approximation Algorithms

So let r 2 f0; 1gblog.p.size.x///c and f .x; r/ D .t1 ; : : : ; tk /. Let fa.1/ ; : : : ; a.sr / g be the set of strings a 2 f0; 1gk for which .x; f .x; r/; a/ 2 Y 0 . If sr D 0 then we simply set Z 0 WD ffyg; fygg, N where y is some variable not used anywhere else. Otherwise let c 2 f0; 1gbp.size.x//c . We have that .x; f .x; r/; cf .x;r/ / 2 Y 0 if and only if ! sr k _ ^ .j / c ti D ai : j D1

i D1

This is equivalent to ^ .i1 ;:::;isr /2f1;:::;kgsr

0

1 sr _ / A @ c tij D ai.j : j j D1

This conjunction of clauses can be constructed in polynomial time because P 0 2 P and k is a constant. By introducing Boolean variables 1 ; : : : ; bp.size.x//c representing the bits c1 ; : : : ; cbp.size.x//c we obtain a family Zr0 of k sr clauses (each with sr literals) such that Zr0 is satisfied if and only if .x; f .x; r/; cf .x;r/ / 2 Y 0 . By Proposition 15.21, we can rewrite each Zr0 equivalently as a conjunction of 3SAT-clauses, where the number of clauses increases by at most a factor of maxfsr 2; 4g. Let this family of clauses be Zr . Since sr 2k , each Zr consists of at most k l WD k 2 maxf2k 2; 4g 3SAT-clauses. Our 3SAT-instance Jx is the union of all the families Zr for all r. Note that Jx can be computed in polynomial time. Now if x is a yes-instance, then there exists a certificate c as in Definition 16.31. This c immediately defines a truth assignment satisfying Jx . On the other hand, if x is a no-instance, then only 12 of the formulas Zr are simultaneously satisfiable. So in this case any truth assignment leaves at least a 1 fraction of 2l of the clauses unsatisfied. 2l So any k-factor approximation algorithm for M AX-3SAT with k < 2l1 satisfies 2l1 1 more than a fraction of 2l D 1 2l of the clauses of any satisfiable instance. Hence such an algorithm can decide whether x 2 Y or not. Since P is NP-complete, such an algorithm cannot exist unless P D NP.

16.7 L-Reductions Our goal is to show, for other problems than M AX-3SAT, that they have no approximation scheme unless P D NP. As with the NP-completeness proofs (Section 15.5), it is not necessary to have a direct proof using the definition of PCP.log n; 1/ for each problem. Rather we use a certain type of reduction which preserves approximability (general polynomial transformations do not): Definition 16.36. Let PD.X; .Sx /x2X ; c; goal/ and P 0 D.X 0 ; .Sx0 /x2X 0 ; c 0 ; goal0 / be two optimization problems with nonnegative weights. An L-reduction from P to

16.7

L-Reductions

445

P 0 is a pair of functions f and g, both computable in polynomial time, and two constants ˛; ˇ > 0 such that for any instance x of P: (a) f .x/ is an instance of P 0 with OPT.f .x// ˛OPT.x/; (b) For any feasible solution y 0 of f .x/, g.x; y 0 / is a feasible solution of x such that jc.x; g.x; y 0 // OPT.x/j ˇjc 0 .f .x/; y 0 / OPT.f .x//j. We say that P is L-reducible to P 0 if there is an L-reduction from P to P 0 . The letter “L” in the term L-reduction stands for “linear”. L-reductions were introduced by Papadimitriou and Yannakakis [1991]. The definition immediately implies that L-reductions can be composed: Proposition 16.37. Let P, P 0 , P 00 be optimization problems with nonnegative weights. If .f; g; ˛; ˇ/ is an L-reduction from P to P 0 and .f 0 ; g 0 ; ˛ 0 ; ˇ 0 / is an Lreduction from P 0 to P 00 , then their composition .f 00 ; g 00 ; ˛˛ 0 ; ˇˇ 0 / is an L-reduction from P to P 00 , where f 00 .x/ D f 0 .f .x// and g 00 .x; y 00 / D g.x; g 0 .x 0 ; y 00 //. The decisive property of L-reductions is that they preserve approximability: Theorem 16.38. (Papadimitriou and Yannakakis [1991]) Let P and P 0 be two optimization problems with nonnegative weights. Let .f; g; ˛; ˇ/ be an L-reduction from P to P 0 . If there is an approximation scheme for P 0 , then there is an approximation scheme for P. Proof: Given an instance x of P and a number 0 < < 1, we apply the approx imation scheme for P 0 to f .x/ and 0 WD 2˛ˇ . We obtain a feasible solution y 0 of 0 f .x/ and finally return y WD g.x; y /, a feasible solution of x. Since jc.x; y/ OPT.x/j ˇjc 0 .f .x/; y 0 / OPT.f .x//j n ˇ max .1 C 0 /OPT.f .x// OPT.f .x//; o 1 OPT.f .x// OPT.f .x// 0 1C ˇ 0 OPT.f .x// ˛ˇ 0 OPT.x/ D OPT.x/ 2 we get c.x; y/ OPT.x/ C jc.x; y/ OPT.x/j and c.x; y/ OPT.x/ jOPT.x/ c.x; y/j

OPT.x/ 1C 2

1 1 OPT.x/ > OPT.x/; 2 1C

so this constitutes an approximation scheme for P.

This theorem together with Theorem 16.35 motivates the following definition:

446

16 Approximation Algorithms

Definition 16.39. An optimization problem P with nonnegative weights is called MAXSNP-hard if MAX-3SAT is L-reducible to P. The name MAXSNP refers to a class of optimization problems introduced by Papadimitriou and Yannakakis [1991]. Here we do not need this class, so we omit its (nontrivial) definition. Corollary 16.40. Unless P D NP there is no approximation scheme for any MAXSNP-hard problem. Proof: Directly from Theorems 16.35 and 16.38.

We shall show MAXSNP-hardness for several problems by describing Lreductions. We start with a restricted version of MAX-3SAT:

3-OCCURRENCE MAX-SAT PROBLEM Instance:

Task:

A set X of variables and a family Z of clauses over X , each with at most three literals, such that no variable occurs in more than three clauses. Find a truth assignment T of X such that the number of clauses in Z that are satisfied by T is maximum.

That this problem is NP-hard can be proved by a simple transformation from 3SAT (or MAX-3SAT), cf. Exercise 11 of Chapter 15. Since this transformation is not an L-reduction, it does not imply MAXSNP-hardness. We need a more complicated construction, using so-called expander graphs: Definition 16.41. Let G be an undirected graph and > 0 a constant. G is a -expander if for each A V .G/ with jAj jV .G/j we have j.A/j jAj. 2 For example, a complete graph is a 1-expander. However, one is interested in expanders with a small number of edges. We cite the following theorem without its quite complicated proof: Theorem 16.42. (Ajtai [1994]) There exists a positive constant such that for any given even integer n 4, a 3-regular -expander with n vertices can be constructed in O.n3 log3 n/ time. The following corollary was mentioned (and used) by Papadimitriou [1994], and a correct proof was given by Fernández-Baca and Lagergren [1998]: Corollary 16.43. For any given integer n 3, a digraph G with O.n/ vertices and a set S V .G/ of cardinality n with the following properties can be constructed in O.n3 log3 n/ time: jı .v/j C jı C .v/j 3 for each v 2 V .G/; jı .v/j C jı C .v/j D 2 for each v 2 S ; and jı C .A/j minfjS \ Aj; jS n Ajg for each A V .G/.

16.7

L-Reductions

447

l m Proof: Let > 0 be the constant of Theorem 16.42, and let k WD 1 . We first construct a 3-regular -expander H with n or n C 1 vertices, using Theorem 16.42. We replace each edge fv; wg by k parallel edges .v; w/ and k parallel edges .w; v/. Let the resulting digraph be H 0 . Note that for any A V .H 0 / with jAj jV .H 0 /j we have 2 C jıH 0 .A/j D kjıH .A/j kjH .A/j kjAj jAj:

Similarly we have for any A V .H 0 / with jAj >

jV .H 0 /j : 2

C 0 0 jıH 0 .A/j D kjıH .V .H / n A/j kjH .V .H / n A/j

kjV .H 0 / n Aj jV .H 0 / n Aj:

C 0 So in both cases we have jıH 0 .A/j minfjAj; jV .H / n Ajg. 0 Now we split up each vertex v 2 V .H / into 6kC1 vertices xv;i (i D 0; : : : ; 6k) such that each vertex except xv;0 has degree 1. For each vertex xv;i we now add vertices wv;i;j and yv;i;j (j D 0; : : : ; 6k) connected by a path of length 12k C 2 with vertices wv;i;0 ; wv;i;1 ; : : : ; wv;i;6k ; xv;i ; yv;i;0 ; : : : ; yv;i;6k in this order. Finally we add edges .yv;i;j ; wv;j;i / for all v 2 V .H 0 /, all i 2 f0; : : : ; 6kg and all j 2 f0; : : : ; 6kg n fi g. Altogether we have a vertex set Zv of cardinality .6k C 1/.12k C 3/ for each v 2 V .H 0 /. The overall resulting graph G has jV .H 0 /j.6k C 1/.12k C 3/ D O.n/ vertices, each of degree two or three. By the construction, GŒZv contains minfjX1 j; jX2 jg vertex-disjoint paths from X1 to X2 for any pair of disjoint subsets X1 ; X2 of fxv;i W i D 0; : : : ; 6kg. We choose S to be an n-element subset of fxv;0 W v 2 V .H 0 /g; note that each of these vertices has one entering and one leaving edge. It remains to prove that jı C .A/j minfjS \ Aj; jS n Ajg for each A V .G/. We prove this byS induction on jfv 2 V .H 0 / W ; 6D A \ Zv 6D Zv gj. If this number is zero, i.e. A D v2B Zv for some B V .H 0 /, then we have C C 0 jıG .A/j D jıH 0 .B/j minfjBj; jV .H / n Bjg minfjS \ Aj; jS n Ajg:

Otherwise let v 2 V .H 0 / with ; 6D A \ Zv 6D Zv . Let P WD fxv;i W i D 0; : : : ; 6kg \ A and Q WD fxv;i W i D 0; : : : ; 6kg n A. If jP j 3k, then by the property of GŒZv we have C .Zv \ A; Zv n A/j jP j D jP n S j C jP \ S j jEG

C jEG .A n Zv ; A \ Zv /j C jP \ S j:

By applying the induction hypothesis to A n Zv we therefore get C C .A/j jıG .A n Zv /j C jP \ S j jıG

minfjS \ .A n Zv /j; jS n .A n Zv /jg C jP \ S j minfjS \ Aj; jS n Ajg:

448

16 Approximation Algorithms

Similarly, if jP j 3k C 1, then jQj 3k and by the property of GŒZv we have C jEG .Zv \ A; Zv n A/j jQj D jQ n S j C jQ \ S j

C jEG .Zv n A; V .G/ n .A [ Zv //j C jQ \ S j:

By applying the induction hypothesis to A [ Zv we therefore get C C jıG .A/j jıG .A [ Zv /j C jQ \ S j

minfjS \ .A [ Zv /j; jS n .A [ Zv /jg C jQ \ S j minfjS \ Aj; jS n Ajg: Now we can prove: Theorem 16.44. (Papadimitriou and Yannakakis [1991], Papadimitriou [1994], Fernández-Baca and Lagergren [1998]) The 3-OCCURRENCE MAX-SAT PROBLEM is MAXSNP-hard. Proof: We describe an L-reduction .f; g; ˛; ˇ/ from MAX-3SAT. To define f , let .X; Z/ be an instance of MAX-3SAT. For each variable x 2 X which occurs in more than three, say in k clauses, we modify the instance as follows. We replace x by a new and distinct variable in each clause. This way we introduce new variables x1 ; : : : ; xk . We introduce additional constraints (and further variables) which ensure, roughly speaking, that it is favourable to assign the same truth value to all the variables x1 ; : : : ; xk . We construct G and S as in Corollary 16.43 and rename the vertices such that S D f1; : : : ; kg. Now for each vertex v 2 V .G/ n S we introduce a new variable xv , and for each edge .v; w/ 2 E.G/ we introduce a clause fxv ; xw g. In total we have added at most

2 3 1 1 1 .k C 1/ 6 C1 12 C 3 315 k 2 new clauses, where is again the constant of Theorem 16.42. Applying the above substitution for each variable we obtain an instance .X 0 ; Z 0 / D f .X; Z/ of the 3-OCCURRENCE MAX-SAT PROBLEM with jZ 0 j jZj C 315

2 2 1 1 3jZj 946 jZj:

Hence 2 2 1 1 OPT.X ; Z / jZ j 946 jZj 1892 OPT.X; Z/; 0

0

0

16.7

L-Reductions

449

because at least half of the clauses of a MAX-SAT-instance can be satisfied (either l m2 by setting all variables true or all false). So we can set ˛ WD 1892 1 . To describe g, let T 0 be a truth assignment of X 0 . We first construct a truth assignment T 00 of X 0 satisfying at least as many clauses of Z 0 as T 0 , and satisfying all new clauses (corresponding to edges of the graphs G above). Namely, for any variable x occurring more than three times in .X; Z/, let G be the graph constructed above, and let A WD fv 2 V .G/ W T 0 .xv / D trueg. If jS \ Aj jS n Aj then we set T 00 .xv / WD true for all v 2 V .G/, otherwise we set T 00 .xv / WD false for all v 2 V .G/. It is clear that all new clauses (corresponding to edges) are satisfied. There are at most minfjS \ Aj; jS n Ajg old clauses satisfied by T 0 but not by 00 T . On the other hand, T 0 does not satisfy any of the clauses fxv ; xw g for .v; w/ 2 C ıG .A/. By the properties of G, the number of these clauses is at least minfjS \ Aj; jS n Ajg. Now T 00 yields a truth assignment T D g.X; Z; T 0 / of X in the obvious way: Set T .x/ WD T 00 .x/ D T 0 .x/ for x 2 X \ X 0 and T .x/ WD T 00 .xi / if xi is any variable replacing x in the construction from .X; Z/ to .X 0 ; Z 0 /. T violates as many clauses as T 00 . So if c.X; Z; T / denotes the number of clauses in instance .X; Z/ that are satisfied by T , we conclude jZj c.X; Z; T / D jZ 0 j c.X 0 ; Z 0 ; T 00 / jZ 0 j c.X 0 ; Z 0 ; T 0 /:

(16.7)

On the other hand, any truth assignment T of X leads to a truth assignment T 0 of X 0 violating the same number of clauses (by setting the variables xv (v 2 V .G/) uniformly to T .x/ for each variable x and the corresponding graph G in the above construction). Hence jZj OPT.X; Z/ jZ 0 j OPT.X 0 ; Z 0 /:

(16.8)

Combining (16.7) and (16.8) we get jOPT.X; Z/ c.X; Z; T /j D .jZj c.X; Z; T // .jZj OPT.X; Z// OPT.X 0 ; Z 0 / c.X 0 ; Z 0 ; T 0 / D jOPT.X 0 ; Z 0 / c.X 0 ; Z 0 ; T 0 /j; where T D g.X; Z; T 0 /. So .f; g; ˛; 1/ is indeed an L-reduction.

This result is the starting point of several MAXSNP-hardness proofs. For example: Corollary 16.45. (Papadimitriou and Yannakakis [1991]) The MAXIMUM STABLE SET PROBLEM restricted to graphs with maximum degree 4 is MAXSNP-hard. Proof: The construction of the proof of Theorem 15.23 defines an L-reduction from the 3-OCCURRENCE MAX-SAT PROBLEM to the MAXIMUM STABLE SET PROBLEM restricted to graphs with maximum degree 4: for each instance .X; Z/

450

16 Approximation Algorithms

a graph G is constructed such that from each truth assignment satisfying k clauses one easily obtains a stable set of cardinality k, and vice versa. Indeed, the MAXIMUM STABLE SET PROBLEM is MAXSNP-hard even when restricted to 3-regular graphs (Berman and Fujito [1999]). On the other hand, a simple greedy algorithm, which in each step chooses a vertex v of minimum degree and deletes v and all its neighbours, is a .kC2/ 3 -factor approximation algorithm for the MAXIMUM STABLE SET PROBLEM in graphs with maximum degree k (Halldórsson and Radhakrishnan [1997]). For k D 4 this gives a performance ratio of 2 which is better than the ratio 8 we get from the following proof (using the 2-factor approximation algorithm for the MINIMUM VERTEX COVER PROBLEM). Theorem 16.46. (Papadimitriou and Yannakakis [1991]) The MINIMUM VERTEX COVER PROBLEM restricted to graphs with maximum degree 4 is MAXSNPhard. Proof: Consider the trivial transformation from the MAXIMUM STABLE SET PROBLEM (Proposition 2.2) with f .G/ WD G and g.G; X / WD V .G/ n X for all graphs G and all X V .G/. Although this is not an L-reduction in general, it is an L-reduction if restricted to graphs with maximum degree 4, as we shall show. If G has maximum degree 4, there exists a stable set of cardinality at least jV .G/j . 5 So if we denote by ˛.G/ the maximum cardinality of a stable set and by .G/ the minimum cardinality of a vertex cover we have ˛.G/

1 1 .jV .G/j ˛.G// D .G/ 4 4

and ˛.G/ jX j D jV .G/ n X j .G/ for any stable set X V .G/. Hence .f; g; 4; 1/ is an L-reduction. See Clementi and Trevisan [1999] and Chlebík and Chlebíková [2006] for stronger statements. In particular, there is no approximation scheme for the M INIMUM V ERTEX COVER PROBLEM (unless P D NP). We shall prove MAXSNPhardness of other problems in later chapters; see also Exercise 22.

Exercises 1. Formulate a 2-factor approximation algorithm for the following problem. Given a digraph with edge weights, find an acyclic subgraph of maximum weight. Note: No k-factor approximation algorithm for this problem is known for k R. (b) Use (a) to describe a 2-factor approximation algorithm for the k-CENTER PROBLEM. (Hochbaum and Shmoys [1985]) (c) Show that there is no r-factor approximation algorithm for the k-CENTER PROBLEM for any r < 2. Hint: Use Exercise 14 of Chapter 15. (Hsu and Nemhauser [1979]) Can one find a minimum vertex cover (or a maximum stable set) in a bipartite graph in polynomial time? Show that the performance guarantee in Theorem 16.5 is tight. Show that the following is a 2-factor approximation algorithm for the M INIMUM V ERTEX COVER PROBLEM : compute a DFS-tree and output all its vertices with nonzero out-degree. (Bar-Yehuda [unpublished]) Show that the LP relaxation minfcx W M > x 1l; x 0g of the MINIMUM WEIGHT VERTEX COVER PROBLEM, where M is the incidence matrix of an undirected graph and c 2 RVC.G/ , always has a half-integral optimum solution (i.e. one with entries 0; 12 ; 1 only). Derive another 2-factor approximation algorithm from this fact. Consider the MINIMUM WEIGHT FEEDBACK VERTEX SET PROBLEM: given an undirected graph G and weights c W V .G/ ! RC , find a vertex set X V .G/ of minimum weight such that G X is a forest. Consider the following recursive algorithm A: If E.G/ D ;, then return A.G; c/ WD ;. If jıG .x/j 1 for some x 2 V .G/, then return A.G; c/ WD A.G x; c/. If c.x/ D 0 for some x 2 V .G/, then return A.G; c/ WD fxg [ A.G x; c/. Otherwise let WD

c.v/ x2V .G/ jı.v/j min

and c 0 .v/ WD c.v/ jı.v/j (v 2 V .G/). Let X WD A.G; c 0 /. For each x 2 X do: If G .X n fxg/ is a forest, then set X WD X n fxg. Return A.G; c/ WD x. Prove that this is a 2-factor approximation algorithm for the M INIMUM WEIGHT FEEDBACK VERTEX SET PROBLEM. (Becker and Geiger [1996]) 8. Show that the MAXIMUM CUT PROBLEM is NP-hard even for simple graphs. 9. Prove that the simple greedy algorithm for MAX-CUT described at the beginning of Section 16.2 is a 2-factor approximation algorithm. 10. Consider the following local search algorithm for the MAXIMUM CUT PROBLEM. Start with any nonempty proper subset S of V .G/. Now check iteratively if some vertex can be added to S or deleted from S such that jı.S /j increases. Stop if no such improvement is possible. (a) Prove that the above is a 2-factor approximation algorithm. (Recall Exercise 13 of Chapter 2.)

452

16 Approximation Algorithms

(b) Can the algorithm be extended to the MAXIMUM WEIGHT CUT PROBLEM, where we have nonnegative edge weights? (c) Does the algorithm always find an optimum solution for planar graphs, or for bipartite graphs? For both classes there is a polynomial-time algorithm (Exercise 7 of Chapter 12 and Proposition 2.27). 11. In the DIRECTED MAXIMUM WEIGHT CUT PROBLEM we are given a digraph G with P weights c W E.G/ ! RC , and we look for a set X V .G/ such that e2ı C .X/ c.e/ is maximum. Show that there is a 4-factor approximation algorithm for this problem. Hint: Use Exercise 10. Note: There is a 1.165-factor but no 1.09-factor approximation algorithm unless P D NP (Feige and Goemans [1995], Hastad [2001]). 12. Show that . 1 arccos.yi> yj //1i;j n is a convex combination of cut semimetrics R R D 1 if jR \ fi; j gj D 1 and ıi;j D 0 otherwise. ı R , R f1; : : : ; ng, where ıi;j Hint: Write 0 1 X \ [ ..H.yi /4H.yj ///1i;j n D @ H.yi / n H.yi /A ı R : Rf1;:::;ng

i 2R

i …R

Note: See Deza and Laurent [1997] for a lot of related information. 13. Show that for each n 2 N there is a bipartite graph on 2n vertices for which the GREEDY COLOURING ALGORITHM needs n colours. So the algorithm may give arbitrarily bad results. However, show that there always exists an order of the vertices for which the algorithm finds an optimum colouring. p 14. Show that one can colour any 3-colourable graph G with at most 2 2n colours in polynomial time, where n WD jV .G/j. p Hint: As long as there is a vertex v of degree at least 2n, colour .v/ optimally with at most two colours (not to be used again), and delete these vertices. Finally use the GREEDY COLOURING ALGORITHM. (Wigderson [1983]) 15. Show that the following graphs are perfect: (a) bipartite graphs; (b) interval graphs: .fv1 ; : : : ; vn g; ffvi ; vj g W i 6D j; Œai ; bi \ Œaj ; bj 6D ;g/, where Œa1 ; b1 ; : : : ; Œan ; bn is a set of closed intervals; (c) chordal graphs (see Exercise 36 of Chapter 8). 16. Let G be an undirected graph. Prove that the following statements are equivalent: (a) G is perfect. (b) For any weight function c W V .G/ ! ZC the maximum weight of a clique in G equals the minimum number of stable sets such that each vertex v is contained in c.v/ of them. (c) For any weight function c W V .G/ ! ZC the maximum weight of a stable set in G equals the minimum number of cliques such that each vertex v is contained in c.v/ of them. (d) The inequality system defining (16.3) is TDI.

Exercises

453

(e) The clique polytope of G, i.e. the convex hull of the incidence vectors of all cliques in G, is given by ( ) X V .G/ x 2 RC W xv 1 for all stable sets S in G : (16.9) v2S

(f) The inequality system defining (16.9) is TDI. Note: The polytope (16.9) is called the antiblocker of the polytope (16.3). 17. An instance of MAX-SAT is called k-satisfiable if any k of its clauses can be simultaneously satisfied. Let rk be the infimum of the fraction of clauses that one can satisfy in any k-satisfiable instance. (a) Prove that r1 D 12 . p

18.

19.

20.

21. 22.

(b) Prove that r2 D 51 2 . (Hint: Some variables occur in one-element clauses (w.l.o.g. all oneelement clauses are positive), set them true with probability a (for some 1 1 2 < a < 1), and set the other variables true with probability 2 . Apply the derandomization technique and choose a appropriately.) (c) Prove that r3 23 . (Lieberherr and Specker [1981]) Erd˝os [1967] showed the following: for each constant k 2 N, the (asymptotically) best fraction of the edges that we can guarantee to be in a maximum cut is 12 , even if we restrict attention to graphs without odd circuits of length k or less. (Compare Exercise 10(a).) (a) What about k D 1? (b) Show how the MAXIMUM CUT PROBLEM can be reduced to MAX-SAT. Hint: Use a variable for each vertex and two clauses fx; yg; fx; N yg N for each edge fx; yg. (c) Use (b) and Erd˝os’ Theorem in order to prove that rk 34 for all k. (For a definition of rk , see Exercise 17.) Note: Trevisan [2004] proved that limk!1 rk D 34 . Prove that the error probability 12 in Definition 16.31 can be replaced equivalently by any number between 0 and 1. Deduce from this (and the proof of Theorem 16.34) that there is no -factor approximation algorithm for the M AXIMUM CLIQUE PROBLEM for any 1 (unless P D NP). Prove that the MAXIMUM CLIQUE PROBLEM is L-reducible to the SET PACKING PROBLEM : given a set system .U; S/, find a maximum cardinality subfamily R S whose elements are pairwise disjoint. Prove that the M INIMUM VERTEX COVER PROBLEM has no absolute approximation algorithm (unless P D NP). Prove that MAX-2SAT is MAXSNP-hard. Hint: Use Corollary 16.45. (Papadimitriou and Yannakakis [1991])

454

16 Approximation Algorithms

References General Literature: Asano, T., Iwama, K., Takada, H., and Yamashita, Y. [2000]: Designing high-quality approximation algorithms for combinatorial optimization problems. IEICE Transactions on Communications/Electronics/Information and Systems E83-D (2000), 462–478 Ausiello, G., Crescenzi, P., Gambosi, G., Kann, V., Marchetti-Spaccamela, A., and Protasi, M. [1999]: Complexity and Approximation: Combinatorial Optimization Problems and Their Approximability Properties. Springer, Berlin 1999 Garey, M.R., and Johnson, D.S. [1979]: Computers and Intractability; A Guide to the Theory of NP-Completeness. Freeman, San Francisco 1979, Chapter 4 Hochbaum, D.S. [1996]: Approximation Algorithms for NP-Hard Problems. PWS, Boston, 1996 Horowitz, E., and Sahni, S. [1978]: Fundamentals of Computer Algorithms. Computer Science Press, Potomac 1978, Chapter 12 Shmoys, D.B. [1995]: Computing near-optimal solutions to combinatorial optimization problems. In: Combinatorial Optimization; DIMACS Series in Discrete Mathematics and Theoretical Computer Science 20 (W. Cook, L. Lovász, P. Seymour, eds.), AMS, Providence 1995 Papadimitriou, C.H. [1994]: Computational Complexity, Addison-Wesley, Reading 1994, Chapter 13 Vazirani, V.V. [2001]: Approximation Algorithms. Springer, Berlin, 2001 Williamson, D.P., and Shmoys, D.B. [2011]: The Design of Approximation Algorithms. Cambridge University Press, Cambridge 2011

Cited References: Ajtai, M. [1994]: Recursive construction for 3-regular expanders. Combinatorica 14 (1994), 379–416 Alizadeh, F. [1995]: Interior point methods in semidefinite programming with applications to combinatorial optimization. SIAM Journal on Optimization 5 (1995), 13–51 Appel, K., and Haken, W. [1977]: Every planar map is four colorable; Part I; Discharging. Illinois Journal of Mathematics 21 (1977), 429–490 Appel, K., Haken, W., and Koch, J. [1977]: Every planar map is four colorable; Part II; Reducibility. Illinois Journal of Mathematics 21 (1977), 491–567 Arora, S. [1994]: Probabilistic checking of proofs and the hardness of approximation problems, Ph.D. thesis, U.C. Berkeley, 1994 Arora, S., Lund, C., Motwani, R., Sudan, M., and Szegedy, M. [1998]: Proof verification and hardness of approximation problems. Journal of the ACM 45 (1998), 501–555 Arora, S., and Safra, S. [1998]: Probabilistic checking of proofs. Journal of the ACM 45 (1998), 70–122 Asano, T. [2006]: An improved analysis of Goemans and Williamson’s LP-relaxation for MAX SAT. Theoretical Computer Science 354 (2006), 339–353 Avidor, A., Berkovitch, I., and Zwick, U. [2006]: Improved approximation algorithms for MAX NAE-SAT and MAX SAT. Approximation and Online Algorithms – Proceedings of the 3rd WAOA workshop (2005); LNCS 3879 (Erlebach, T., Persiano, G., eds.), Springer, Berlin 2006, pp. 27–40 Bar-Yehuda, R., and Even, S. [1981]: A linear-time approximation algorithm for the weighted vertex cover problem. Journal of Algorithms 2 (1981), 198–203

References

455

Becker, A., and Geiger, D. [1996]: Optimization of Pearl’s method of conditioning and greedy-like approximation algorithms for the vertex feedback set problem. Artificial Intelligence Journal 83 (1996), 1–22 Bellare, M., and Sudan, M. [1994]: Improved non-approximability results. Proceedings of the 26th Annual ACM Symposium on the Theory of Computing (1994), 184–193 Bellare, M., Goldreich, O., and Sudan, M. [1998]: Free bits, PCPs and nonapproximability – towards tight results. SIAM Journal on Computing 27 (1998), 804–915 Berge, C. [1961]: Färbung von Graphen, deren sämtliche bzw. deren ungerade Kreise starr sind. Wissenschaftliche Zeitschrift, Martin Luther Universität Halle-Wittenberg, Mathematisch-Naturwissenschaftliche Reihe (1961), 114–115 Berge, C. [1962]: Sur une conjecture relative au problème des codes optimaux. Communication, 13ème assemblée générale de l’URSI, Tokyo 1962 Berman, P., and Fujito, T. [1999]: On approximation properties of the independent set problem for low degree graphs. Theory of Computing Systems 32 (1999), 115–132 Brooks, R.L. [1941]: On colouring the nodes of a network. Proceedings of the Cambridge Philosophical Society 37 (1941), 194–197 Chen, J., Friesen, D.K., and Zheng, H. [1999]: Tight bound on Johnson’s algorithm for maximum satisfiability. Journal of Computer and System Sciences 58 (1999), 622–640 Chlebík, M. and Chlebíková, J. [2006]: Complexity of approximating bounded variants of optimization problems. Theoretical Computer Science 354 (2006), 320-338 Chudnovsky, M., Cornuéjols, G., Liu, X., Seymour, P., and Vu˘skovi´c, K. [2005]: Recognizing Berge graphs. Combinatorica 25 (2005), 143–186 Chudnovsky, M., Robertson, N., Seymour, P., and Thomas, R. [2006]: The strong perfect graph theorem. Annals of Mathematics 164 (2006), 51–229 Chvátal, V. [1975]: On certain polytopes associated with graphs. Journal of Combinatorial Theory B 18 (1975), 138–154 Chvátal, V. [1979]: A greedy heuristic for the set cover problem. Mathematics of Operations Research 4 (1979), 233–235 Clementi, A.E.F., and Trevisan, L. [1999]: Improved non-approximability results for minimum vertex cover with density constraints. Theoretical Computer Science 225 (1999), 113–128 Deza, M.M., and Laurent, M. [1997]: Geometry of Cuts and Metrics. Springer, Berlin 1997 Dinur, I. [2007]: The PCP theorem by gap amplification. Journal of the ACM 54 (2007), Article 12 Dinur, I., and Safra, S. [2002]: On the hardness of approximating minimum vertex cover. Annals of Mathematics 162 (2005), 439–485 Erd˝os, P. [1967]: On bipartite subgraphs of graphs. Mat. Lapok. 18 (1967), 283–288 Feige, U. [1998]: A threshold of ln n for approximating set cover. Journal of the ACM 45 (1998), 634–652 Feige, U. [2004]: Approximating maximum clique by removing subgraphs. SIAM Journal on Discrete Mathematics 18 (2004), 219–225 Feige, U., and Goemans, M.X. [1995]: Approximating the value of two prover proof systems, with applications to MAX 2SAT and MAX DICUT. Proceedings of the 3rd Israel Symposium on Theory of Computing and Systems (1995), 182–189 Feige, U., Goldwasser, S., Lovász, L., Safra, S., and Szegedy, M. [1996]: Interactive proofs and the hardness of approximating cliques. Journal of the ACM 43 (1996), 268–292 Fernández-Baca, D., and Lagergren, J. [1998]: On the approximability of the Steiner tree problem in phylogeny. Discrete Applied Mathematics 88 (1998), 129–145

456

16 Approximation Algorithms

Fulkerson, D.R. [1972]: Anti-blocking polyhedra. Journal of Combinatorial Theory B 12 (1972), 50–71 Fürer, M., and Raghavachari, B. [1994]: Approximating the minimum-degree Steiner tree to within one of optimal. Journal of Algorithms 17 (1994), 409–423 Garey, M.R., and Johnson, D.S. [1976]: The complexity of near-optimal graph coloring. Journal of the ACM 23 (1976), 43–49 Garey, M.R., Johnson, D.S., and Stockmeyer, L. [1976]: Some simplified NP-complete graph problems. Theoretical Computer Science 1 (1976), 237–267 Goemans, M.X., and Williamson, D.P. [1994]: New 3/4-approximation algorithms for the maximum satisfiability problem. SIAM Journal on Discrete Mathematics 7 (1994), 656–666 Goemans, M.X., and Williamson, D.P. [1995]: Improved approximation algorithms for maximum cut and satisfiability problems using semidefinite programming. Journal of the ACM 42 (1995), 1115–1145 Grötschel, M., Lovász, L., and Schrijver, A. [1988]: Geometric Algorithms and Combinatorial Optimization. Springer, Berlin 1988 Halldórsson, M.M., and Radhakrishnan, J. [1997]: Greed is good: approximating independent sets in sparse and bounded degree graphs. Algorithmica 18 (1997), 145–163 Hastad, J. [2001]: Some optimal inapproximability results. Journal of the ACM 48 (2001), 798–859 Heawood, P.J. [1890]: Map colour theorem. Quarterly Journal of Pure Mathematics 24 (1890), 332–338 Hochbaum, D.S. [1982]: Approximation algorithms for the set covering and vertex cover problems. SIAM Journal on Computing 11 (1982), 555–556 Hochbaum, D.S., and Shmoys, D.B. [1985]: A best possible heuristic for the k-center problem. Mathematics of Operations Research 10 (1985), 180–184 Holyer, I. [1981]: The NP-completeness of edge-coloring. SIAM Journal on Computing 10 (1981), 718–720 Hougardy, S., Prömel, H.J., and Steger, A. [1994]: Probabilistically checkable proofs and their consequences for approximation algorithms. Discrete Mathematics 136 (1994), 175–223 Hsu, W.L., and Nemhauser, G.L. [1979]: Easy and hard bottleneck location problems. Discrete Applied Mathematics 1 (1979), 209–216 Johnson, D.S. [1974]: Approximation algorithms for combinatorial problems. Journal of Computer and System Sciences 9 (1974), 256–278 Khanna, S., Linial, N., and Safra, S. [2000]: On the hardness of approximating the chromatic number. Combinatorica 20 (2000), 393–415 Khot, S., and Regev, O. [2008]: Vertex cover might be hard to approximate to within 2 . Journal of Computer and System Sciences 74 (2008), 335–349 Knuth, D.E. [1969]: The Art of Computer Programming; Vol. 2. Seminumerical Algorithms. Addison-Wesley, Reading 1969 (third edition: 1997) König, D. [1916]: Über Graphen und ihre Anwendung auf Determinantentheorie und Mengenlehre. Mathematische Annalen 77 (1916), 453–465 Lieberherr, K., and Specker, E. [1981]: Complexity of partial satisfaction. Journal of the ACM 28 (1981), 411–421 Lovász, L. [1972]: Normal hypergraphs and the perfect graph conjecture. Discrete Mathematics 2 (1972), 253–267 Lovász, L. [1975]: On the ratio of optimal integral and fractional covers. Discrete Mathematics 13 (1975), 383–390

References

457

Lovász, L. [1979a]: On the Shannon capacity of a graph. IEEE Transactions on Information Theory 25 (1979), 1–7 Lovász, L. [1979b]: Graph theory and integer programming. In: Discrete Optimization I; Annals of Discrete Mathematics 4 (P.L. Hammer, E.L. Johnson, B.H. Korte, eds.), NorthHolland, Amsterdam 1979, pp. 141–158 Lovász, L. [2003]: Semidefinite programs and combinatorial optimization. In: Recent Advances in Algorithms and Combinatorics (B.A. Reed, C. Linhares Sales, eds.), Springer, New York 2003, pp. 137–194 Mahajan, S., and Ramesh, H. [1999]: Derandomizing approximation algorithms based on semidefinite programming. SIAM Journal on Computing 28 (1999), 1641–1663 Papadimitriou, C.H., and Steiglitz, K. [1982]: Combinatorial Optimization; Algorithms and Complexity. Prentice-Hall, Englewood Cliffs 1982, pp. 406–408 Papadimitriou, C.H., and Yannakakis, M. [1991]: Optimization, approximation, and complexity classes. Journal of Computer and System Sciences 43 (1991), 425–440 Papadimitriou, C.H., and Yannakakis, M. [1993]: The traveling salesman problem with distances one and two. Mathematics of Operations Research 18 (1993), 1–12 Raghavan, P., and Thompson, C.D. [1987]: Randomized rounding: a technique for provably good algorithms and algorithmic proofs. Combinatorica 7 (1987), 365–374 Raz, R., and Safra, S. [1997]: A sub constant error probability low degree test, and a sub constant error probability PCP characterization of NP. Proceedings of the 29th Annual ACM Symposium on Theory of Computing (1997), 475–484 Robertson, N., Sanders, D.P., Seymour, P., and Thomas, R. [1996]: Efficiently four-coloring planar graphs. Proceedings of the 28th Annual ACM Symposium on the Theory of Computing (1996), 571–575 Robertson, N., Sanders, D.P., Seymour, P., and Thomas, R. [1997]: The four colour theorem. Journal of Combinatorial Theory B 70 (1997), 2–44 Sanders, P., and Steurer, D. [2008]: An asymptotic approximation scheme for multigraph edge coloring. ACM Transactions on Algorithms 4 (2008), Article 21 Singh, M. and Lau, L.C. [2007]: Approximating minimum bounded degree spanning trees to within one of optimal. Proceedings of the 39th Annual ACM Symposium on Theory of Computing (2007), 661–670 Slavík, P. [1997]: A tight analysis of the greedy algorithm for set cover. Journal of Algorithms 25 (1997), 237–254 Stockmeyer, L.J. [1973]: Planar 3-colorability is polynomial complete. ACM SIGACT News 5 (1973), 19–25 Trevisan, L. [2004]: On local versus global satisfiability. SIAM Journal on Discrete Mathematics 17 (2004), 541–547 Vizing, V.G. [1964]: On an estimate of the chromatic class of a p-graph. Diskret. Analiz 3 (1964), 23–30 [in Russian] Wigderson, A. [1983]: Improving the performance guarantee for approximate graph coloring. Journal of the ACM 30 (1983), 729–735 Yannakakis, M. [1994]: On the approximation of maximum satisfiability. Journal of Algorithms 17 (1994), 475–502 Zuckerman, D. [2007]: Linear degree extractors and the inapproximability of Max Clique and Chromatic Number. Theory of Computing 3 (2007), 103–128

•

17 The Knapsack Problem

The MINIMUM WEIGHT PERFECT MATCHING PROBLEM and the WEIGHTED MATROID INTERSECTION PROBLEM discussed in earlier chapters are among the “hardest" problems for which a polynomial-time algorithm is known. In this chapter we deal with the following problem which turns out to be, in a sense, the “easiest" NP-hard problem:

KNAPSACK PROBLEM Instance: Task:

Nonnegative integers n, c1 ; : : : ; cn , w1 ; : : : ; wn and W . P P Find a subset S f1; : : : ; ng such that j 2S wj W and j 2S cj is maximum.

Applications arise whenever we want to select an optimum subset of bounded weight from a set of elements each of which has a weight and a profit. We start by considering the fractional version in Section 17.1, which turns out to be solvable in linear time. The integral knapsack problem is NP-hard as shown in Section 17.2, but a pseudopolynomial algorithm solves it optimally. Combined with a rounding technique this can be used to design a fully polynomial approximation scheme, which is the subject of Section 17.3. In Section 17.4 we discuss a multidimensional generalization.

17.1 Fractional Knapsack and Weighted Median Problem We consider the following problem:

FRACTIONAL KNAPSACK PROBLEM Instance: Task:

Nonnegative integers n, c1 ; : : : ; cn , w1 ; : : : ; wn and W . P Find numbers x1 ; : : : ; xn 2 Œ0; 1 such that jnD1 xj wj W and Pn j D1 xj cj is maximum.

The following observation suggests a simple algorithm which requires sorting the elements appropriately: Proposition 17.1. (Dantzig P [1957]) Let c1 ; : : : ; cn , w1 ; : : : ; wn and W be nonnegative integers with niD1 wi > W , f1 i n W wi D 0g D f1; : : : ; hg, B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__17, c Springer-Verlag Berlin Heidelberg 2012

459

460

17 The Knapsack Problem

and

chC2 cn chC1 ; whC1 whC2 wn

and let

( k WD min j 2 f1; : : : ; ng W

j X

) wi > W

:

i D1

Then an optimum solution of the given instance of the FRACTIONAL KNAPSACK PROBLEM is defined by xj WD 1 xk WD

W

Pk1 j D1

for j D 1; : : : ; k 1; wj

wk

xj WD 0

; for j D k C 1; : : : ; n:

Sorting the elements takes O.n log n/ time (Theorem 1.5), and computing k can be done in O.n/ time by simple linear scanning. Although this algorithm is quite fast, one can do even better. Observe that the problem reduces to a weighted median search: DefinitionP 17.2. Let n 2 N, ´1 ; : : : ; ´n 2 R, w1 ; : : : ; wn 2 RC and W 2 R with 0 < W niD1 wi . Then the .w1 ; : : : ; wn I W /-weighted median with respect to .´1 ; : : : ; ´n / is defined to be the unique number ´ for which X X wi < W wi : i W´i ´m for i D l C 1; : : : ; n.

4

If

k X i D1

If

l X

wi < W

l X

wi then stop (´ WD ´m ).

i D1

l X wi < W then find recursively the wlC1 ; : : : ; wn I W wi -

i D1

i D1

weighted median with respect to .´lC1 ; : : : ; ´n /. Stop. k X If wi W then find recursively the w1 ; : : : ; wk I W -weighted i D1

median with respect to .´1 ; : : : ; ´k /. Stop. Theorem 17.3. The WEIGHTED MEDIAN ALGORITHM works correctly and takes O.n/ time only. Proof: The correctness is easily checked. Let us denote the worst-case running time for n elements by f .n/. We obtain l m l n m 1 lnm 1 n f .n/ D O.n/ C f C O.n/ C f 5C 2 ; 5 2 5 2 5 because the recursive call in 4 omits at least three elements out of at least half of the five-element blocks. The above recursion formula yields f .n/ D O.n/: ˙n as 9 9 7 9 n for all n 37, one obtains f .n/ cn C f n C f n for a 5 41 41 2 41 suitable c and n 37. Given this, f .n/ .82c C f .36//n can be verified easily by induction. So indeed the overall running time is linear. We immediately obtain the following corollaries: Corollary 17.4. (Blum et al. [1973]) The SELECTION PROBLEM can be solved in O.n/ time.

462

17 The Knapsack Problem

Proof: Set wi WD 1 for i D 1; : : : ; n and W WD k and apply Theorem 17.3.

Corollary 17.5. The FRACTIONAL KNAPSACK PROBLEM can be solved in linear time. Proof: Setting ´i WD wcii (i D 1; : : : ; n) reduces the FRACTIONAL KNAPSACK PROBLEM to the WEIGHTED MEDIAN PROBLEM.

17.2 A Pseudopolynomial Algorithm We now turn to the (integral) KNAPSACK PROBLEM. The techniques of the previous section are also of some use here: Proposition 17.6. Let c1 ; :P : : ; cn , w1 ; : : : ; wn and W be nonnegative integers with wj W for j D 1; : : : ; n, niD1 wi > W , and c1 c2 cn : w1 w2 wn Let

( k WD min j 2 f1; : : : ; ng W

j X

) wi > W

:

i D1

Then choosing the better of the two feasible solutions f1; : : : ; k 1g and fkg constitutes a 2-factor approximation algorithm for the KNAPSACK PROBLEM with running time O.n/. Proof: Given any instance of the KNAPSACK PROBLEM, elementsPi 2 f1; : : : ; ng with wi > W are of no use and can be deleted beforehand. Now if niD1 wi W , then f1; : : : ; ng is an optimum solution. Otherwise we compute the number k in O.n/ time without sorting: this is just a WEIGHTED MEDIAN PROBLEM as above (Theorem 17.3). P By Proposition 17.1, kiD1 ci is an upper bound on the optimum value of the FRACTIONAL KNAPSACK PROBLEM, hence also for the integral KNAPSACK PROBLEM. Therefore the better of the two feasible solutions f1; : : : ; k 1g and fkg achieves at least half the optimum value. But we are more interested in an exact solution of the KNAPSACK PROBLEM. However, we have to make the following observation: Theorem 17.7. (Karp [1972]) The KNAPSACK PROBLEM is NP-hard. Proof: We prove that the related decision problem defined as follows is NPcomplete: given nonnegative integers ; : : : ; wn , W and K, is there P n, c1 ; : : : ; cn , w1P a subset S f1; : : : ; ng such that j 2S wj W and j 2S cj K ? This decision problem obviously belongs to NP. To show that it is NPcomplete, we transform SUBSET-SUM (see Corollary 15.27) to it. Given an instance

17.2

A Pseudopolynomial Algorithm

463

c1 ; : : : ; cn ; K of SUBSET-SUM, define wj WD cj .j D 1; : : : ; n/ and W WD K. Obviously this yields an equivalent instance of the above decision problem. Since we have not shown the KNAPSACK PROBLEM to be strongly NP-hard there is hope for a pseudopolynomial algorithm. Indeed, the algorithm given in the proof of Theorem 15.39 can easily be generalized by introducing weights on the edges and solving a shortest path problem. This leads to an algorithm with running time O.nW / (Exercise 3). By a similar P trick we can also get an algorithm with an O.nC / running time, where C WD jnD1 cj . We describe this algorithm in a direct way, without constructing a graph and referring to shortest paths. Since the algorithm is based on simple recursion formulas we speak of a dynamic programming algorithm. It is basically due to Bellman [1956,1957] and Dantzig [1957].

DYNAMIC PROGRAMMING KNAPSACK ALGORITHM Input: Output:

Nonnegative integers n, c1 ; : : : ; cn , w1 ; : : : ; wn and W . P P A subset S f1; : : : ; ng such that j 2S wj W and j 2S cj is maximum.

1

Let C bePany upper bound on the value of the optimum solution, e.g. C WD jnD1 cj .

2

Set x.0; 0/ WD 0 and x.0; k/ WD 1 for k D 1; : : : ; C .

3

For j WD 1 to n do: For k WD 0 to C do: Set s.j; k/ WD 0 and x.j; k/ WD x.j 1; k/. For k WD cj to C do: If x.j 1; k cj / C wj minfW; x.j; k/g then: Set x.j; k/ WD x.j 1; k cj / C wj and s.j; k/ WD 1.

4

Let k D maxfi 2 f0; : : : ; C g W x.n; i / < 1g. Set S WD ;. For j WD n down to 1 do: If s.j; k/ D 1 then set S WD S [ fj g and k WD k cj .

Theorem 17.8. The DYNAMIC PROGRAMMING KNAPSACK ALGORITHM finds an optimum solution in O.nC / time. Proof: The running time is obvious. The variablePx.j; k/ denotes thePminimum total weight of a subset S f1; : : : ; j g with i 2S wi W and i 2S ci D k. The algorithm correctly computes these values using the recursion formulas 8 ˆ <x.j 1; k cj / C wj if cj k and x.j; k/ D x.j 1; k cj / C wj minfW; x.j 1; k/g ˆ : x.j 1; k/ otherwise

464

17 The Knapsack Problem

for j D 1; : : : ; n and k D 0; : : : ; C . The variables s.j; k/ indicate which of these two cases applies. So the algorithm enumerates all subsets S f1; : : : ; ng except those that are infeasible or those by others: P P that are dominated P P S is said to be dominated by S 0 if j 2S cj D j 2S 0 cj and j 2S wj j 2S 0 wj . In 4 the best feasible subset is chosen. P Of course it is desirable to have a better upper bound C than niD1 ci . For example, the 2-factor approximation algorithm of Proposition 17.6 can be run; multiplying the value of the returned solution by 2 yields an upper bound on the optimum value. We shall use this idea later. The O.nC /-bound is not polynomial in the size of the input, because the input size can only be bounded by O.n log C C n log W / (we may assume that wj W for all j ). But we have a pseudopolynomial algorithm which can be quite efficient if the numbers involved are not too large. If both the weights w1 ; : : : ; wn and the profits c1 ; : : : ; cn are small, the O.ncmax wmax /-algorithm of Pisinger [1999] is the fastest one (cmax WD maxfc1 ; : : : ; cn g, wmax WD maxfw1 ; : : : ; wn g).

17.3 A Fully Polynomial Approximation Scheme In this section we investigate approximation algorithms for the KNAPSACK PROBLEM. By Proposition 16.23, the KNAPSACK PROBLEM has no absolute approximation algorithm unless P D NP. However, we shall prove that the KNAPSACK PROBLEM has a fully polynomial approximation scheme. The first such algorithm was found by Ibarra and Kim [1975]. Since the running time of the DYNAMIC PROGRAMMING KNAPSACK ALGORITHM depends on C , it is a natural idea to divide all numbers c1 ; : : : ; cn by 2 and round them down. This will reduce the running time, but may lead to inaccurate solutions. More generally, setting jc k j cNj WD .j D 1; : : : ; n/ t will reduce the running time by a factor t. Trading accuracy for runningPtime is typical for approximation schemes. For S f1; : : : ; ng we write c.S / WD i 2S ci .

KNAPSACK APPROXIMATION SCHEME Input: Output:

1

Nonnegative integers n, c1 ; : : : ; cn , w1 ; : : : ; wn and W . A number > 0. P A subset S f1; : : : ; ng such that j 2S wj W and c.S / P 1 0 0 j 2S 0 wj W . 1C c.S / for all S f1; : : : ; ng with

Run the 2-factor approximation algorithm of Proposition 17.6. Let S1 be the solution obtained. If c.S1 / D 0 then set S WD S1 and stop.

17.3

n

2 3

4

A Fully Polynomial Approximation Scheme

465

o

1/ . Set t WD max 1; c.S n cj ˘ Set cNj WD t for j D 1; : : : ; n.

Apply the DYNAMIC PROGRAMMING KNAPSACK ALGORITHM to the 1/ . Let S2 be the instance .n; cN1 ; : : : ; cNn ; w1 ; : : : ; wn ; W /; set C WD 2c.S t solution obtained. If c.S1 / > c.S2 / then set S WD S1 , else set S WD S2 .

Theorem 17.9. (Ibarra and Kim [1975], Sahni [1976], Gens and Levner [1979]) The KNAPSACK APPROXIMATION SCHEME is a fully polynomial approximation scheme for the KNAPSACK PROBLEM; its running time is O n2 1 . Proof: If the algorithm stops in 1 then S1 is optimal by Proposition 17.6. So we now assume c.S1 / > 0. Let S be an optimum solution of the original instance. Since 2c.S1 / c.S / by Proposition 17.6, C in 3 is a correct upper bound on the value of the optimum solution of the rounded instance. So by Theorem 17.8, S2 is an optimum solution of the rounded instance. Hence we have: X X X X X X cj t cNj D t cNj t cNj D t cNj > .cj t/ j 2S2

j 2S2

j 2S2

j 2S

j 2S

j 2S

c.S / nt: If t D 1, then S2 is optimal by Theorem 17.8. Otherwise the above inequality implies c.S2 / c.S / c.S1 /, and we conclude that .1 C /c.S / c.S2 / C c.S1 / c.S /: So we have a .1 C /-factor approximation algorithm for any fixed > 0. By Theorem 17.8 the running time of 3 can be bounded by nc.S1 / 2 1 O.nC / D O D O n : t The other steps can easily be done in O.n/ time.

Lawler [1979] found a similar fully polynomial approximation scheme whose running time is O n log 1 C 14 . This was improved by Kellerer and Pferschy [2004]. Unfortunately there are not many problems that have a fully polynomial approximation scheme. To state this more precisely, we consider the MAXIMIZATION PROBLEM FOR I NDEPENDENCE SYSTEMS . What we have used in our construction of the DYNAMIC PROGRAMMING KNAPSACK ALGORITHM and the KNAPSACK APPROXIMATION SCHEME is a certain dominance relation. We generalize this concept as follows:

466

17 The Knapsack Problem

Definition 17.10. Given an independence system .E; F/, a cost function c W E ! ZC , subsets S1 ; S2 E, and > 0. S1 -dominates S2 if 1 c.S1 / c.S2 / .1 C / c.S1 / 1C and there is a basis B1 with S1 B1 such that for each basis B2 with S2 B2 we have .1 C / c.B1 / c.B2 /:

-DOMINANCE PROBLEM An independence system .E; F/, a cost function c W E ! ZC , a number > 0, and two subsets S1 ; S2 E. Question: Does S1 -dominate S2 ?

Instance:

Of course the independence system is given by some oracle, e.g. an independence oracle. The DYNAMIC PROGRAMMING KNAPSACK ALGORITHM made frequent use of 0-dominance. It turns out that the existence of an efficient algorithm for the -DOMINANCE PROBLEM is essential for a fully polynomial approximation scheme. Theorem 17.11. (Korte and Schrader [1981]) Let I be a family of independence systems. Let I 0 be the family of instances .E; F ; c/ of the MAXIMIZATION PROBLEM FOR I NDEPENDENCE SYSTEMS with .E; F / 2 I and c W E ! ZC , and let I 00 be the family of instances .E; F ; c; ; S1 ; S2 / of the -DOMINANCE PROBLEM with .E; F / 2 I. Then there exists a fully polynomial approximation scheme for the MAXIMIZATION PROBLEM FOR I NDEPENDENCE SYSTEMS restricted to I 0 if and only if there exists an algorithm for the -DOMINANCE PROBLEM restricted to I 00 whose running time is bounded by a polynomial in the length of the input and 1 . While the sufficiency is proved by generalizing the KNAPSACK APPROXIMASCHEME (Exercise 10), the proof of the necessity is rather involved and not presented here. The conclusion is that if a fully polynomial approximation scheme exists at all, then a modification of the KNAPSACK APPROXIMATION SCHEME does the job. See also Woeginger [2000] for a similar result. To prove that for a certain optimization problem there is no fully polynomial approximation scheme, the following theorem is often more useful: TION

Theorem 17.12. (Garey and Johnson [1978]) A strongly NP-hard optimization problem with integral objective function satisfying OPT.I / p .size.I /; largest.I // for some polynomial p and all instances I has a fully polynomial approximation scheme only if P D NP.

17.4

Multi-Dimensional Knapsack

467

Proof: Suppose it has a fully polynomial approximation scheme. Then we apply it with 1 D p.size.I /; largest.I // C 1 and obtain an exact pseudopolynomial algorithm. By Proposition 15.41 this is impossible unless P D NP. In the next section we consider a problem that has a pseudopolynomial algorithm but no fully polynomial approximation scheme.

17.4 Multi-Dimensional Knapsack Throughout this section let m 2 N be fixed. We consider the following problem.

m-DIMENSIONAL KNAPSACK PROBLEM Instance: Task:

A number n 2 N and nonnegative integers ci , wij , and Wj for i D 1; : : : ; n and j D 1; : : : ; m. P Find a subset S P f1; : : : ; ng such that i 2S wij Wj for all j D 1; : : : ; m and i 2S ci is maximum.

Even for this generalization of the KNAPSACK PROBLEM (which is the case m D 1) there is a pseudopolynomial algorithm; see Exercise 11. However, this does not lead to a fully polynomial approximation scheme: Proposition 17.13. (Korte and Schrader [1981]) The m-DIMENSIONAL KNAPSACK PROBLEM has no fully polynomial approximation scheme for any m 2, unless P D NP. Proof: It suffices to consider the case m D 2. Given an instance .P; Q; R; T / of 3DM, let T D ft1 ; : : : ; tn g P Q R, k WD jP j D jQj D jRj and w.l.o.g. P [Q [R D f1; : : : ; 3kg. We use a similar construction as in the proof of Corollary 15.27. For i D 1; : : : ; n let ti D .p; q; r/ 2 P Q R; then we set ci D 1, wi1 D .n C 1/p C .n C 1/q C .n C 1/r , and wi 2 D .n C 1/3kC1 wi1 . Moreover, P3k let W1 D pD1 .n C 1/p and W2 D k.n C 1/3kC1 W1 . This defines an instance of the 2-DIMENSIONAL KNAPSACK PROBLEM. If there is a 3-dimensional matching fti W i P 2 S g (where S f1; : : : ; ng), P then jS j D k and i 2S wi1 D W1 and hence i 2S wi 2 D W2 . On the other hand, any feasible solution S f1; : : : ; ng with P jS j D k of this instance of the 2-DIMENSIONAL KNAPSACK PROBLEM satisfies i 2S wi1 W1 and X X wi1 D k.n C 1/3kC1 wi 2 k.n C 1/3kC1 W2 D W1 : i 2S

i 2S

Therefore there is a feasible solution S with jS j D k if and only if the 3DM instance .U; V; W; T / is a yes-instance.

468

17 The Knapsack Problem

We conclude that the optimum value of this instance of the 2-DIMENSIONAL KNAPSACK PROBLEM is k if I is a yes-instance and at most k 1 otherwise. If we had a fully polynomial approximation scheme, we could get a .1C/-approximation for D k1 in polynomial time, and thus distinguish between the two cases. Thus we could solve 3DM in polynomial time. As 3DM is NP-complete (Theorem 15.26), this would imply P D NP. At least there is an approximation scheme: Theorem 17.14. (Frieze and Clarke [1984]) For any fixed m 2 N and > 0, there is a .1 C /-factor approximation algorithm for the m-DIMENSIONAL KNAPSACK PROBLEM. Proof: We set k WD d m e; note that k is a constant. We enumerate all subsets of f1; : : : ; ng with less than k elements. Moreover, for each S f1; : : : ; ng with jS j D k, we set S > WD fi 2 f1; : : : ; ng n S W ci > minfcj W j 2 S gg and solve the LP n n X max cx W wij xi Wj .j D 1; : : : ; m/; 0 x 1; i D1

o xi D 1 .i 2 S /; xi D 0 .i 2 S > / : Let x be an optimum basic solution. As x satisfies at least n constraints of the LP with equality, it has at most m fractional components. Let S 0 WD fi 2 f1; : : : ; ng W xi D 1g. Among all sets S and S 0 that we find, we output the best feasible solution. The running time is dominated by solving O.nk / linear programs with O.n/ variables and constraints. The optimum solution either has at most k 1 elements (then we find it) or corresponds to a feasible 0-1-solution ´ to one of these LPs, namely where S contains k of its elements with the largest profit. Then we find a solution S 0 (by rounding downPan optimumPbasic solution x) whichPis not much worse because n c´ cx D 0 ci C m maxfci W i 2 i D1 ci .xi bxi c/ i 2S 0 ci C i 2SP P m P > f1; : : : ; ngn.S [S /g 0 ci Cm minfci W i 2 S g i 2S i 2S 0 ci C k i 2S ci P P m i 2S 0 ci .1 C k / i 2S 0 ci .1 C /.

Exercises 1. Consider the fractional multi-knapsack problem defined as follows. An instance consists of nonnegative integers m and n, numbers wj , cijP and Wi (1 i m, m 1jP n). The task is to find numbers xij P 2 Œ0; 1 with i D1 xij D 1 for all n m Pn j and j D1 xij wj Wi for all i such that i D1 j D1 xij cij is minimum. Can one find a combinatorial polynomial-time algorithm for this problem (without using LINEAR PROGRAMMING)? Hint: Reduction to a MINIMUM COST FLOW PROBLEM.

References

469

2. Consider the following greedy algorithm for the KNAPSACK PROBLEM (similar to the one in Proposition 17.6). Sort the indices such that wc11 wcnn . Set P S WD ;. For i WD 1 to n do: If j 2S[fi g wj W then set S WD S [ fi g. Show that this is not a k-factor approximation algorithm for any k. 3. Find an exact O.nW /-algorithm for the KNAPSACK PROBLEM. 4. Consider the following problem: given nonnegative integers P n, c1 ; : : : ; cn , w ; : : : ; w and W , find a subset S f1; : : : ; ng such that 1 n j 2S wj W and P j 2S cj is minimum. How can this problem be solved by a pseudopolynomial algorithm? 5. Can one solve the integral multi-knapsack problem (see Exercise 1) in pseudopolynomial time if m is fixed? m 6. Let c 2 f0; :˚: : ; kgm and s 2 Œ0; 1

. How can one decide in O.mk/ time m whether max cx W x 2 ZC ; sx 1 k? 7. Consider the two Lagrangean relaxations of Exercise 21 of Chapter 5. Show that one of them can be solved in linear time while the other one reduces to m instances of the KNAPSACK PROBLEM. 8. Let m 2 N be a constant. Consider the following scheduling problem: given n jobs and m machines, costs cij 2 ZC (i D 1; : : : ; n, j D 1; : : : ; m), and capacities Tj 2 ZC (j D 1; : : : ; m), find an assignment f W f1; : : : ; ng ! f1; : : : ; mg such P that jfi 2 f1; : : : ; ng W f .i / D j gj Tj for j D 1; : : : ; m, and the total cost niD1 cif .i / is minimum. Show that this problem has a fully polynomial approximation scheme. 9. Give a polynomial-time algorithm for the -DOMINANCE PROBLEM restricted to matroids. 10. Prove the if-part of Theorem 17.11. 11. Find a pseudopolynomial algorithm for the m-DIMENSIONAL KNAPSACK PROBLEM for any fixed m 2 N. Note: This generalizes Exercise 3.

References General Literature: Garey, M.R., and Johnson, D.S. [1979]: Computers and Intractability; A Guide to the Theory of NP-Completeness. Freeman, San Francisco 1979, Chapter 4 Kellerer, H., Pferschy, U., and Pisinger, D. [2004]: Knapsack Problems. Springer, Berlin 2004 Martello, S., and Toth, P. [1990]: Knapsack Problems; Algorithms and Computer Implementations. Wiley, Chichester 1990 Papadimitriou, C.H., and Steiglitz, K. [1982]: Combinatorial Optimization; Algorithms and Complexity. Prentice-Hall, Englewood Cliffs 1982, Sections 16.2, 17.3, and 17.4

Cited References: Bellman, R. [1956]: Notes on the theory of dynamic programming IV – maximization over discrete sets. Naval Research Logistics Quarterly 3 (1956), 67–70

470

17 The Knapsack Problem

Bellman, R. [1957]: Comment on Dantzig’s paper on discrete variable extremum problems. Operations Research 5 (1957), 723–724 Blum, M., Floyd, R.W., Pratt, V., Rivest, R.L., and Tarjan, R.E. [1973]: Time bounds for selection. Journal of Computer and System Sciences 7 (1973), 448–461 Dantzig, G.B. [1957]: Discrete variable extremum problems. Operations Research 5 (1957), 266–277 Frieze, A.M. and Clarke, M.R.B. [1984]: Approximation algorithms for the m-dimensional 0-1 knapsack problem: worst case and probablistic analyses. European Journal of Operations Research 15 (1984), 100–109 Garey, M.R., and Johnson, D.S. [1978]: Strong NP-completeness results: motivation, examples, and implications. Journal of the ACM 25 (1978), 499–508 Gens, G.V., and Levner, E.V. [1979]: Computational complexity of approximation algorithms for combinatorial problems. In: Mathematical Foundations of Computer Science; LNCS 74 (J. Becvar, ed.), Springer, Berlin 1979, pp. 292–300 Ibarra, O.H., and Kim, C.E. [1975]: Fast approximation algorithms for the knapsack and sum of subset problem. Journal of the ACM 22 (1975), 463–468 Karp, R.M. [1972]: Reducibility among combinatorial problems. In: Complexity of Computer Computations (R.E. Miller, J.W. Thatcher, eds.), Plenum Press, New York 1972, pp. 85–103 Kellerer, H., and Pferschy, U. [2004]: Improved dynamic programming in connection with an FPTAS for the knapsack problem. Journal on Combinatorial Optimization 8 (2004), 5–11 Korte, B., and Schrader, R. [1981]: On the existence of fast approximation schemes. In: Nonlinear Programming; Vol. 4 (O. Mangaserian, R.R. Meyer, S.M. Robinson, eds.), Academic Press, New York 1981, pp. 415–437 Lawler, E.L. [1979]: Fast approximation algorithms for knapsack problems. Mathematics of Operations Research 4 (1979), 339–356 Pisinger, D. [1999]: Linear time algorithms for knapsack problems with bounded weights. Journal of Algorithms 33 (1999), 1–14 Sahni, S. [1976]: Algorithms for scheduling independent tasks. Journal of the ACM 23 (1976), 114–127 Vygen, J. [1997]: The two-dimensional weighted median problem. Zeitschrift für Angewandte Mathematik und Mechanik 77 (1997), Supplement, S433–S436 Woeginger, G.J. [2000]: When does a dynamic programming formulation guarantee the existence of a fully polynomial time approximation scheme (FPTAS)? INFORMS Journal on Computing 12 (2000), 57–74

18 Bin-Packing

Suppose we have n objects, each of a given size, and some bins of equal capacity. We want to assign the objects to the bins, using as few bins as possible. Of course the total size of the objects assigned to one bin should not exceed its capacity. Without loss of generality, the capacity of the bins is 1. Then the problem can be formulated as follows:

BIN-PACKING PROBLEM Instance:

A list of nonnegative numbers a1 ; : : : ; an 1.

Task:

Find P a k 2 N and an assignment f W f1; : : : ; ng ! f1; : : : ; kg with i Wf .i /Dj ai 1 for all j 2 f1; : : : ; kg such that k is minimum.

There are not many combinatorial optimization problems whose practical relevance is more obvious. For example, the simplest version of the cutting stock problem is equivalent: We are given many beams of equal length (say 1 meter) and numbers a1 ; : : : ; an . We want to cut as few of the beams as possible into pieces such that at the end we have beams of lengths a1 ; : : : ; an . Although an instance I is some ordered list where numbers may appear more than once, we write x 2 I for some element in the list I which is equal to x. By jI j we mean the number of elements in the list I . We shall also use the Pn abbreviation SUM.a1 ; : : : ; an / WD i D1 ai . This is an obvious lower bound: dSUM.I /e OPT.I / holds for any instance I . In Section 18.1 we prove that the BIN-PACKING PROBLEM is strongly NP-hard and discuss some simple approximation algorithms. We shall see that no algorithm can achieve a performance ratio better than 32 (unless P D NP). However, one can achieve an arbitrarily good performance ratio asymptotically: in Sections 18.2 and 18.3 we describe a fully polynomial asymptotic approximation scheme. This uses the ELLIPSOID METHOD and results of Chapter 17.

18.1 Greedy Heuristics In this section we shall analyse some greedy heuristics for the BIN-PACKING PROBLEM. There is no hope for an exact polynomial-time algorithm as the problem is NP-hard: B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__18, c Springer-Verlag Berlin Heidelberg 2012

471

472

18 Bin-Packing

Theorem 18.1. The following problem is NP-complete: given an instance I of the BIN-PACKING PROBLEM, decide whether I has a solution with two bins. Proof: Membership in NP is trivial. We transform the PARTITION problem (which is NP-complete by Corollary 15.28) to the above decision problem. Given an instance c1 ; : : : ; cn of PARTITION, consider the instance a1 ; : : : ; an of the BINPACKING PROBLEM, where 2ci ai D Pn : j D1 cj Obviously two P bins suffice if and only if there is a subset S f1; : : : ; ng such that P j 2S cj D j …S cj . Corollary 18.2. Unless P D NP, there is no -factor approximation algorithm for the BIN-PACKING PROBLEM for any < 32 . For any fixed k, there is a pseudopolynomial algorithm which decides for a given instance I whether k bins suffice (Exercise 1). However, in general this problem is strongly NP-complete: Theorem 18.3. (Garey and Johnson [1975]) The following problem is strongly NP-complete: given an instance I of the BIN-PACKING PROBLEM and a number B, decide whether I can be solved with B bins. Proof: Transformation from 3-DIMENSIONAL MATCHING (Theorem 15.26). Given an instance U; V; W; T of 3DM, we construct a bin-packing instance I with 4jT j items. Namely, the set of items is [ S WD ft; .u; t/; .v; t/; .w; t/g: t D.u;v;w/2T :

Let U Dfu1 ; : : : ; un g, V D fv1 ; : : : ; vn g and W D fw1 ; : : : ; wn g. For each x2U [ : V [ W we choose some tx 2 T such that .x; tx / 2 S . For each tD.ui ; vj ; wk / 2 T , the sizes of the items are now defined as follows: 1 .10N 4 C 8 iN jN 2 kN 3 / C ( 1 .10N 4 C iN C 1/ if t D tui .ui ; t/ has size C1 .11N 4 C iN C 1/ if t 6D tui C ( 1 .10N 4 C jN 2 C 2/ if t D tvj .vj ; t/ has size C1 4 2 if t 6D tvj C .11N C jN C 2/ ( 1 .10N 4 C kN 3 C 4/ if t D twk .wk ; t/ has size C1 4 3 if t 6D twk C .8N C kN C 4/ t has size

where N WD100n and C WD40N 4 C 15. This defines an instance I D .a1 ; : : : ; a4jT j / of the BIN-PACKING PROBLEM. We set B WD jT j and claim that I has a solution

18.1

Greedy Heuristics

473

with at most B bins if and only if the initial 3DM instance is a yes-instance, i.e. there is a subset M of T with jM j D n such that for distinct .u; v; w/; .u0 ; v 0 ; w 0 / 2 M one has u 6D u0 , v 6D v 0 and w 6D w 0 . First assume that there is such a solution M of the 3DM instance. Since the solvability of I with B bins is independent of the choice of the tx (x 2 U [ V [ W ), we may redefine them such that tx 2 M for all x. Now for each t D .u; v; w/ 2 T we pack t; .u; t/; .v; t/; .w; t/ into one bin. This yields a solution with jT j bins. Conversely, let f be a solution of I with B D jT j bins. Since SUM.I / D jT j, each bin must be completely full. Since all the item sizes are strictly between 15 and 1 , each bin must contain four items. 3 P Consider one bin k 2 f1; : : : ; Bg. Since C i Wf .i /Dk ai D C 15 .mod N /, the bin must contain one t D .u; v; w/ 2 T , P one .u0 ; t 0 / 2 U T , one .v 0 ; t 00 / 2 0 000 V T , and one .w ; t / 2 W T . Since C i Wf .i /Dk ai D C 15 .mod N 2 /, we have u D u0 . Similarly, by considering the sum modulo N 3 and modulo N 4 , we obtain v D v 0 and w D w 0 . Furthermore, either t 0 D tu and t 00 D tv and t 000 D tw (case 1) or t 0 6D tu and t 00 6D tv and t 000 6D tw (case 2). We define M to consist of those t 2 T for which t is assigned to a bin where case 1 holds. Obviously M is a solution to the 3DM instance. Note that all the numbers in the constructed bin-packing instance I are polynomially large, more precisely O.n4 /. Since 3DM is NP-complete (Theorem 15.26), the theorem is proved. This proof is due to Papadimitriou [1994]. Even with the assumption P 6D NP the above result does not exclude the possibility of an absolute approximation algorithm, for example one which needs at most one more bin than the optimum solution. Whether such an algorithm exists is an open question. The simplest heuristic for bin-packing may be the following:

NEXT-FIT ALGORITHM (NF) Input:

An instance a1 ; : : : ; an of the BIN-PACKING PROBLEM.

Output:

A solution .k; f /.

1

Set k WD 1 and S WD 0.

2

For i WD 1 to n do: If S C ai > 1 then set k WD k C 1 and S WD 0. Set f .i / WD k and S WD S C ai . Let us denote by NF .I / the number k of bins this algorithm uses for instance I .

Theorem 18.4. The NEXT-FIT ALGORITHM runs in O.n/ time. For any instance I D a1 ; : : : ; an we have NF .I / 2dSUM.I /e 1 2OPT.I / 1:

474

18 Bin-Packing

Proof: The time bound is obvious. Let k WD NF .I /,jandk let f be the assignment found by the NEXT-FIT ALGORITHM. For j D 1; : : : ; k2 we have X

ai > 1:

i Wf .i /2f2j 1;2j g

Adding these inequalities we get k < SUM.I /: 2 Since the left-hand side is an integer, we conclude that k1 k dSUM.I /e 1: 2 2 This proves k 2dSUM.I /e 1. The second inequality is trivial.

The instances 2; 1 ; 2; 1 ; : : : ; 2 for very small > 0 show that this bound is best possible. So the NEXT-FIT ALGORITHM is a 2-factor approximation algorithm. Naturally the performance ratio becomes better if the numbers involved are small: Proposition 18.5. Let 0 < < 1. For any instance I D a1 ; : : : ; an with ai for all i 2 f1; : : : ; ng we have SUM.I / : NF .I / 1 P Proof: We have i Wf .i /Dj ai > 1 for j D 1; : : : ; NF .I /1. By adding these inequalities we get .NF .I / 1/.1 / < SUM.I / and thus SUM.I / 1: NF .I / 1 1 A second approach in designing an efficient approximation algorithm could be the following:

FIRST-FIT ALGORITHM (FF) Input:

An instance a1 ; : : : ; an of the BIN-PACKING PROBLEM.

Output:

A solution .k; f /.

1

2

For i WD 1 to n do: 8 < Set f .i / WD min j 2 N W : Set k WD

max f .i /.

i 2f1;:::;ng

X h 12 , then each bin with smaller index did not have space for this item, thus has been assigned an item before. As the items are considered in nonincreasing order, there are at least j items of size > 12 . Thus OPT.I / j 23 k. Otherwise the j -th bin, and thus each bin with greater index, contains no item of size > 12 . Hence the bins j; j C 1; : : : ; k contain at least 2.k j / C 1 items, none of which fits into bins 1; : : : ; j 1. Note that 2.k j / C 1 2.k . 32 k C 23 // C 1 D 2 k 13 j 1. Thus OPT.I / SUM.I / > j 1, i.e. OPT.I / j 23 k. 3

476

18 Bin-Packing

By Corollary 18.2 this is best possible (for FFD, consider the instance 0.4, 0.4, 0.3, 0.3, 0.3, 0.3). However, the asymptotic performance guarantee is better: Johnson [1973] proved that FFD.I / 11 9 OPT.I / C 4 for all instances I (see also Johnson OPT.I / C 3. [1974]). Baker [1985] gave a simpler proof showing FFD.I / 11 9 Yue [1991] improved this to FFD.I / 11 OPT.I / C 1. The question was finally 9 settled by Dósa [2007], who proved the following: Theorem 18.8. (Dósa [2007]) For all instances I of the BIN-PACKING PROBLEM, 2 11 OPT.I / C ; FFD.I / 9 3 and this bound is tight. The proof is too involved to be presented here. However, we present a class of instances I with OPT.I / arbitrarily large and FFD.I / D 11 OPT.I /. (This 9 example is taken from Garey and Johnson [1979].) Namely, let > 0 be small enough and I D fa1 ; : : : ; a30m g with 81 if 1 i 6m, ˆ 2 C ˆ ˆ ˆ ˆ ˆ ˆ ˆ 1 ˆ ˆ < 4 C 2 if 6m < i 12m, ai D ˆ ˆ ˆ1 C if 12m < i 18m, ˆ 4 ˆ ˆ ˆ ˆ ˆ ˆ :1 2 if 18m < i 30m. 4 The optimum solution consists of 1 1 1 C ; C ; 2; 2 4 4 1 1 1 1 3m bins containing C 2; C 2; 2; 2: 4 4 4 4

6m bins containing

The FFD-solution consists of 1 1 C ; C 2; 2 4 1 1 1 2m bins containing C ; C ; C ; 4 4 4 1 1 1 1 3m bins containing 2; 2; 2; 2: 4 4 4 4

6m bins containing

So OPT.I / D 9m and FFD.I / D 11m. There are several other algorithms for the BIN-PACKING PROBLEM, some of them having a better asymptotic performance ratio than 11 . In the next section we 9 show that an asymptotic performance ratio arbitrarily close to 1 can be achieved.

18.2

An Asymptotic Approximation Scheme

477

In some applications one has to pack the items in the order they arrive without knowing the subsequent items. Algorithms that do not use any information about the subsequent items are called online algorithms. For example, N EXT-FIT and FIRSTFIT are online algorithms, but the FIRST-FIT-DECREASING ALGORITHM is not an online algorithm. The best known online algorithm for the BIN-PACKING PROBLEM has an asymptotic performance ratio of 1:59 (Seiden [2002]). On the other hand, van Vliet [1992] proved that there is no online asymptotic 1.54-factor approximation algorithm for the BIN-PACKING PROBLEM. A weaker lower bound is the subject of Exercise 6.

18.2 An Asymptotic Approximation Scheme In this section we show that for any > 0 there is a linear-time algorithm which guarantees to find a solution with at most .1 C /OPT.I / C 12 bins. We start by considering instances with not too many different numbers. We denote the different numbers in our instance I by s1 ; : : : ; sm . Let I contain exactly bi copies of si .i D 1; : : : ; m/. Let T1 ; : : : ; TN be all the possibilities of how a single bin can be packed: ( ) m X m ki si 1 fT1 ; : : : ; TN g WD .k1 ; : : : ; km / 2 ZC W i D1

We write Tj D .tj1 ; : : : ; tj m /. Then our BIN-PACKING PROBLEM is equivalent to the following integer programming formulation (due to Eisemann [1957]): min

N X

xj

j D1

s.t.

N X

(18.1) tj i xj bi

j D1

xj 2 ZC

.i D 1; : : : ; m/ .j D 1; : : : ; N /:

P We actually want jND1 tj i xj D bi , but relaxing this constraint makes no difference. The LP relaxation of (18.1) is: min

N X

xj

j D1

s.t.

N X

(18.2) tj i xj bi

.i D 1; : : : ; m/

j D1

xj 0

.j D 1; : : : ; N /:

478

18 Bin-Packing

The following theorem says that by rounding a solution of the LP relaxation (18.2) one obtains a solution of (18.1), i.e. of the BIN-PACKING PROBLEM, which is not much worse: Theorem 18.9. (Fernandez de la Vega and Lueker [1981]) Let I be an instance of the BIN-PACKING PROBLEM with only m different numbers. Let x be a feasible (not necessarily optimum) solution of (18.2) with at most m lnonzero components. m ˘ PN m1 Then a solution of the BIN-PACKING PROBLEM with at most j D1 xj C 2 bins can be found in O.jI j/ time. Proof: Consider bxc, which results from x by rounding down each component. bxc does not in general pack I completely (it might pack some numbers more often than necessary, but this does not matter). The remaining pieces form an instance I 0 . Observe that SUM.I 0 /

N m N N X X X X xj bxj c tj i si xj bxj c: j D1

i D1

j D1

j D1

m1 ˘

bins, because then So it is sufficient to pack I 0 into at most dSUM.I 0 /e C 2 the total number of bins used is no more than 2 3 N N X X ˙ m 1 7C m1 : 6 bxj c C SUM.I 0 / C x j 6 7 2 2 6j D1 7 j D1 We consider two packing methods for I 0 . Firstly, the vector dxe bxc certainly packs at least the elements of I 0 . The number of bins used is at most m since x has at most m nonzero components. Secondly, we can obtain a packing of I 0 using at most 2dSUM.I 0 /e 1 bins by applying the NEXT-FIT ALGORITHM (Theorem 18.4). Both packings can be obtained in linear time. The better of these two packings uses at most minfm; 2dSUM.I 0 /e 1g dSUM.I 0 /e C m1 bins. The theorem is proved. 2 Corollary 18.10. (Fernandez de la Vega and Lueker [1981]) Let m and > 0 be fixed constants. Let I be an instance of the BIN-PACKING PROBLEM with only m different numbers, none˘ of which is less than . Then we can find a solution with at most OPT.I / C m1 bins in O.jI j/ time. 2 Proof: By the SIMPLEX ALGORITHM (Theorem 3.14) we can find an optimum basic solution x of (18.2), i.e. a vertex of the polyhedron. Since any vertex satisfies N of the constraints with equality (Proposition 3.9), x has at most m nonzero components. The time needed to determine x depends on m and N only. Observe that N 1 .m C 1/ , because there can be at most 1 elements in each bin. So x can be found in constant time.

18.2

Since proof.

lP N

j D1 xj

An Asymptotic Approximation Scheme

479

m OPT.I /, an application of Theorem 18.9 completes the

Using the ELLIPSOID METHOD (Theorem 4.18) leads to the same result. This is not best possible: one can even determine the exact optimum in polynomial time for fixed m and , since INTEGER PROGRAMMING with a constant number of variables can be solved in polynomial time (Lenstra [1983]). A simpler exact algorithm for fixed m is discussed in Exercise 7. However, we do not need these stronger results here. We shall apply Theorem 18.9 again in the next section and obtain the same performance guarantee in polynomial time even if m and are not fixed (in the proof of Theorem 18.14). We are now able to formulate the algorithm of Fernandez de la Vega and Lueker [1981]. Roughly it proceeds as follows. First we partition the n numbers into m C 2 groups according to their size. We pack the group with the largest ones using one bin for each number. Then we pack the m middle groups by first rounding the size of each number to the largest number in its group and then applying Corollary 18.10. Finally we pack the group with the smallest numbers.

FERNANDEZ-DE-LA-VEGA-LUEKER ALGORITHM Input: Output:

An instance I D a1 ; : : : ; an of the BIN-PACKING PROBLEM. A number > 0. A solution .k; f / for I . C1

and h WD d SUM.I /e.

1

Set WD

2

Let I1 D L; M; R be a rearrangement of the list I , where M D K0 ; y1 ; K1 ; y2 ; : : : ; Km1 ; ym and L; K0 ; K1 ; : : : ; Km1 and R are again lists, such that the following properties hold: (a) For all x 2 L: x < . (b) For all x 2 K0 : x y1 . (c) For all x 2 Ki : yi x yi C1 (i D 1; : : : ; m 1). (d) For all x 2 R: ym x. (e) jK1 j D D jKm1 j D jRj D h 1 and jK0 j h 1. .k; f / is now determined by the following three packing steps: Find a packing SR of R using jRj bins.

3 4

5

Consider the instance Q consisting of the numbers y1 ; y2 ; : : : ; ym , each appearing h times. Find a packing SQ of Q using at most mC1 2 more bins than necessary (using Corollary 18.10). Transform SQ into a packing SM of M . As long as a bin of SR or SM has room amounting to at least , fill it with elements of L. Finally, find a packing of the rest of L using the NEXT-FIT ALGORITHM.

480

18 Bin-Packing

In 4 we used a slightly weaker bound than the one obtained in Corollary 18.10. This does not hurt here, and we shall need the above form in Section 18.3. The above algorithm is an asymptotic approximation scheme. More precisely: Theorem 18.11. (Fernandez de la Vega and Lueker [1981]) For each 0 < 1 and each instance I of the BIN-PACKING PROBLEM, the FERNANDEZ-DE-LA2 VEGA-LUEKER ALGORITHM returns a solution using at most .1 C /OPT.I / C 12 bins. The running time is O.n 12 / plus the time needed to solve (18.2). For fixed , the running time is O.n/. k j jI jjLj Proof: In , . 2 we first determine L in O.n/ time. Then we set m WD h Since .jI j jLj/ SUM.I /, we have m

jI j jLj 1 C1 jI j jLj D : h SUM.I / 2

We know that yi must be the .jI j C 1 .m i C 1/h/-th smallest element (i D 1; : : : ; m). So by Corollary 17.4 we can find each yi in O.n/ time. We finally determine K0 ; K1 ; : : : ; Km1 ; R, each in O.n/ time. So 2 can be done in O.mn/ time. Note that m D O. 12 /. Steps , 3 4 and 5 – except the solution of (18.2) – can easily be implemented to run in O.n/ time. For fixed , (18.2) can also be solved optimally in O.n/ time (Corollary 18.10). We now prove the performance guarantee. Let k be the number of bins that the algorithm uses. We write jSR j and jSM j for the number of bins used in the packing of R and M , respectively. We have jSR j jRj D h 1 < SUM.I / OPT.I /: Secondly, observe that OPT.Q/ OPT.I /: the i -th largest element of I is greater than or equal to the i -th largest element of Q for all i D 1; : : : ; hm. Hence by 4 (Corollary 18.10) we have jSM j D jSQ j OPT.Q/ C

mC1 mC1 OPT.I / C : 2 2

In 5 we can pack some elements of L into bins of SR and SM . Let L0 be the list of the remaining elements in L. Case 1: L0 is nonempty. Then the total size of the elements in each bin, except possibly for the last one, exceeds 1 , so we have .1 /.k 1/ < SUM.I / OPT.I /. We conclude that k Case 2:

1 OPT.I / C 1 D .1 C /OPT.I / C 1: 1

L0 is empty. Then

18.3

The Karmarkar-Karp Algorithm

481

k jSR j C jSM j mC1 2 C 1 C 2 .1 C /OPT.I / C 2 2 1 .1 C /OPT.I / C 2 ; < OPT.I / C OPT.I / C

because 12 .

Of course the running time grows exponentially in 1 . However, Karmarkar and Karp showed how to obtain a fully polynomial asymptotic approximation scheme. This is the subject of the next section.

18.3 The Karmarkar-Karp Algorithm The algorithm of Karmarkar and Karp [1982] works just as the algorithm in the preceding section, but instead of solving the LP relaxation (18.2) optimally as in Corollary 18.10, they solve it with a constant absolute error. The fact that the number of variables grows exponentially in 1 might not prevent us from solving the LP: Gilmore and Gomory [1961] developed the column generation technique and obtained a variant of the SIMPLEX ALGORITHM which solves (18.2) quite efficiently in practice. Similar ideas lead to a theoretically efficient algorithm if one uses the GRÖTSCHEL-LOVÁSZ-SCHRIJVER ALGORITHM instead. In both above-mentioned approaches the dual LP plays a major role. The dual of (18.2) is: max yb

s.t.

m X i D1

tj i yi 1

.j D 1; : : : ; N /

yi 0

.i D 1; : : : ; m/:

(18.3)

It has only m variables, but an exponential number of constraints. However, the number of constraints does not matter as long as we can solve the SEPARATION PROBLEM in polynomial time. It will turn out that the S EPARATION PROBLEM is equivalent to a KNAPSACK PROBLEM. Since we can solve KNAPSACK PROBLEMs with an arbitrarily small error, we can also solve the WEAK SEPARATION PROBLEM in polynomial time. This idea enables us to prove: Lemma 18.12. (Karmarkar and Karp [1982]) Let I be an instance of the BINPACKING PROBLEM with only m different numbers, none of which is less than .

482

18 Bin-Packing

Let ı > 0. Then a feasible solution y of the dual LP (18.3) differing from the m5 n mn optimum by at most ı can be found in O m6 log2 mn time. C log ı ı ı Proof: We may assume that ı D p1 for some natural number p. We apply the GRÖTSCHEL-LOVÁSZ-SCHRIJVER ALGORITHM (Theorem 4.19). Let D be the polyhedron of (18.3). We have

p B x0 ; Œ0; m D Œ0; 1m B.x0 ; m/; 2 where x0 is the vector all of whose components are 2 . We shall prove that we can solve the WEAK SEPARATION PROBLEM for (18.3), i.e. D and b, and 2ı in O nm time, independently of the size of the input vecı tor y. By Theorem 4.19, this implies that the WEAK OPTIMIZATION PROBLEM mjjbjj m5 n time, proving the lemma since can be solved in O m6 log2 mjjbjj C log ı ı ı jjbjjn. To show how to solve the WEAK SEPARATION PROBLEM, let y 2 Qm be given. We may assume 0 y 1 since otherwise the task is trivial. Now observe that y is feasible if and only if maxfyx W x 2 Zm C ; xs 1g 1;

(18.4)

where s D .s1 ; : : : ; sm / is the vector of the item sizes. (18.4) is a kind of KNAPSACK PROBLEM, so we cannot hope to solve it exactly. But this is not necessary, as the WEAK SEPARATION PROBLEM only calls for an approximate solution. Write y 0 WD b 2n yc (the rounding is done componentwise). The problem ı maxfy 0 x W x 2 Zm C ; xs 1g

(18.5)

can be solved optimally by dynamic programming, very similarly to the DYNAMIC PROGRAMMING KNAPSACK ALGORITHM in Section 17.2 (see Exercise 6 of Chapter 17): let F .0/ WD 0 and F .k/ WD minfF .k yi0 / C si W i 2 f1; : : : ; mg; yi0 kg . F .k/ is the minimum size of a set of items with total cost k for k D 1; : : : ; 4n ı (with respect to y 0 ). Now the maximum in (18.5) is less than or equal to 2n if and only if F .k/ > 1 ı 4n for all k 2 f 2n C 1; : : : ; g. The total time needed to decide this is O mn ı ı ı . There are two cases: ı 0 Case 1: The maximum in (18.5) is less than or equal to 2n . Then 2n y is a feaı ı 0 ı ı sible solution of (18.3). Furthermore, by b 2n y b 2n 1l D 2 . The task of the WEAK SEPARATION PROBLEM is done. Case 2: There exists an x 2 Zm 1 and y 0 x > 2n . Such an x can easily C with xs ı mn ı 0 be computed from the numbers F .k/ in O ı time. We have yx 2n y x > 1.

18.3

The Karmarkar-Karp Algorithm

483

Thus x corresponds to a bin configuration that proves that y is infeasible. Since we have ´x 1 for all ´ 2 D, this is a separating hyperplane, and thus we are done. Lemma 18.13. (Karmarkar and Karp [1982]) Let I be an instance of the BINPACKING PROBLEM with only m different numbers, none of which is less than . Let ı > 0. Then a feasible solution x of the primal LP (18.2) differing from the optimum by at most ı and having at most m nonzero components can be found in time polynomial in n, 1ı and 1 . Proof: We first solve the dual LP (18.3) approximately, using Lemma 18.12. We obtain a vector y with y b OPT.18.3/ ı. Now let Tk1 ; : : : ; TkN 0 be those bin configurations that appeared as a separating hyperplane in Case 2 of the previous proof, plus the unit vectors (the bin configurations containing just one element). Note that N 0 is bounded by the number of iterations in the GRÖTSCHEL -LOVÁSZ mn 0 2 SCHRIJVER ALGORITHM (Theorem 4.19), so N D O m log ı . Consider the LP max yb

s.t.

m X

tkj i yi 1

i D1

yi 0

.j D 1; : : : ; N 0 /

(18.6)

.i D 1; : : : ; m/:

Observe that the above procedure for (18.3) (in the proof of Lemma 18.12) is also a valid application of the G RÖTSCHEL-LOVÁSZ-SCHRIJVER ALGORITHM for (18.6): the oracle for the WEAK SEPARATION PROBLEM can always give the same answer as above. Therefore we have y b OPT.18.6/ ı. Consider 0

min

N X

xkj

j D1 0

s.t.

N X

(18.7) tkj i xkj bi

j D1

xkj 0

.i D 1; : : : ; m/ .j D 1; : : : ; N 0 /

which is the dual of (18.6). The LP (18.7) arises from (18.2) by eliminating the variables xj for j 2 f1; : : : ; N g n fk1 ; : : : ; kN 0 g (forcing them to be zero). In other words, only N 0 of the N bin configurations can be used. We have OPT.18.7/ ı D OPT.18.6/ ı y b OPT.18.3/ D OPT.18.2/: So it is sufficient to solve (18.7). But (18.7) is an LP of polynomial size: it has N 0 variables and m constraints; none of the entries of the matrix is larger than 1 ,

484

18 Bin-Packing

and none of the entries of the right-hand side is larger than n. So by Khachiyan’s Theorem 4.18, it can be solved in polynomial time. We obtain an optimum basic solution x (x is a vertex of the polyhedron, so x has at most m nonzero components). Now we apply the FERNANDEZ-DE-LA-VEGA-LUEKER ALGORITHM with just one modification: we replace the exact solution of (18.2) by an application of Lemma 18.13. We summarize: Theorem 18.14. (Karmarkar and Karp [1982]) There is a fully polynomial asymptotic approximation scheme for the BIN-PACKING PROBLEM. Proof: We apply Lemma 18.13 with ı D 1, obtaining an optimum solution x of (18.7) with at most m nonzero components. We have 1lx OPT.18.2/ C 1. An application of Theorem 18.9 yields an integral solution using at most dOPT.18.2/eC 1 C m1 4 of the FERNANDEZ - DE - LA-VEGA-L UEKER ALGO2 bins, as required in RITHM. So the statement of Theorem 18.11 remains valid. Since m 22 and 1 2 (we may assume 1), the running time for finding x is polynomial in n and 1 . The running time obtained in this way is worse than O 40 and completely out of the question for practical purposes. Karmarkar and Karp [1982] showed how to reduce the number of variables in (18.7) to m (while changing the optimum value only slightly) and thereby improve the running time (see Exercise 12). Plotkin, Shmoys and Tardos [1995] achieved a running time of O.n log 1 C 6 log 1 /. Many generalizations have been considered. The two-dimensional bin packing problem, asking for packing a given set of axis-parallel rectangles into a minimum number of unit squares without rotation, does not have an asymptotic approximation scheme unless P D NP (Bansal et al. [2006]). See Caprara [2008], Zhang [2005], Jansen, Prädel and Schwarz [2009], and the references therein, for related results.

Exercises 1. Let k be fixed. Describe a pseudopolynomial algorithm which – given an instance I of the BIN-PACKING PROBLEM – finds a solution for this instance using no more than k bins or decides that no such solution exists. 2. Consider the BIN-PACKING PROBLEM restricted to instances a1 ; : : : ; an with ai > 13 for i D 1; : : : ; n. (a) Reduce the problem to the CARDINALITY MATCHING PROBLEM. (b) Show how to solve the problem in O.n log n/ time. 3. Consider the QUADRATIC ASSIGNMENT PROBLEM Pn: given matrices A; B 2 Rnn , find a permutation on f1; : : : ; ng such that i;j D1 ai;j b.i /;.j / is minC imum. Show that this problem has no constant-factor approximation algorithm unless P D NP, even for the case that A is a 0-1-matrix and the entries of B

Exercises

4. 5. 6.

7.

8. 9.

10.

11.

485

define a metric. Hint: Use Theorem 18.3. (Queyranne [1986]) Find an instance I of the BIN-PACKING PROBLEM, where FF .I / D 17 while OPT.I / D 10. Implement the FIRST-FIT ALGORITHM and the FIRST-FIT-DECREASING ALGORITHM to run in O.n log n/ time. Show that there is no online algorithm for the BIN-PACKING PROBLEM with performance ratio less than 43 . Hint: Note that we do not assume P 6D NP. There is no such algorithm, regardless of the running time. Consider the list consisting of n elements of size 12 followed by n elements of size 12 C . Show that BIN PACKING with fixed number of different item sizes can be solved in polynomial time. Hint: Compute which subsets of items can be packed into i bins, for i D 1; 2 : : :, using dynamic programming. Show that 2 of the FERNANDEZ -DE-LA-VEGA-LUEKER ALGORITHM can be implemented to run in O n log 1 time. Consider the LP (18.3), which has a variable yi for each i D 1; : : : ; m (i.e., each item size). Assume s1 > > sm . Show that then there exists an optimum solution with y1 ym . (Caprara [2008]) Prove that for any > 0 there exists a polynomial-time algorithm which for any instance I D .a1 ; : : : ; an / of the BIN-PACKING PROBLEM finds a packing using the optimum number of bins but may violateP the capacity constraints by , i.e. an f W f1; : : : ; ng ! f1; : : : ; OPT.I /g with f .i /Dj ai 1 C for all j 2 f1; : : : ; OPT.I /g. Hint: Use ideas of Section 18.2. (Hochbaum and Shmoys [1987]) Consider the following MULTIPROCESSOR SCHEDULING PROBLEM. Given a finite set A of tasks, a positive number t.a/ for each a 2 A (the processing : : : time), and a number m of processors. Find a partition A D A1 [ A2 [ [ P Am of A into m pairwise disjoint sets such that maxm a2Ai t.a/ is minii D1 mum. (a) Show that this problem is strongly NP-hard. (b) Show that a greedy algorithm which successively assigns jobs (in arbitrary order) to the currently least used machine is a 2-factor approximation algorithm. (c) Show that for each fixed m the problem has a fully polynomial approximation scheme. (Horowitz and Sahni [1976]) (d) Use Exercise 10 to show that the MULTIPROCESSOR SCHEDULING PROBLEM has an approximation scheme. (Hochbaum and Shmoys [1987])

486

18 Bin-Packing

Note: This problem has been the subject of the first paper on approximation algorithms (Graham [1966]). Many variations of scheduling problems have been studied; see e.g. Graham et al. [1979] or Lawler et al. [1993].

12. Consider the LP (18.6) in the proof of Lemma 18.13. All but m constraints can be omitted without changing its optimum value. We are not able to find these m constraints in polynomial time, but we can find m constraints such that deleting all the others does not increase the optimum value too much (e.g., by at most one). How? Hint: Let D .0/ be the LP (18.6) and iteratively construct LPs D .1/ ; D .2/ ; : : : by deleting more and more constraints. At each iteration, a solution y .i / of D .i / is .i / .i / given with by OPT D ı. The set of constraints is partitioned into mC 1 sets of approximately equal size, and for each of the sets we test whether the set can be deleted. This test is performed by considering the LP after deletion, say D, and applying the GRÖTSCHEL-L -SCHRIJVER ALGORITHM. Let OVÁSZ y be a solution of D with by OPT D ı. If by by .i / C ı, the test is successful, and we set D .i C1/ WD D and y .i C1/ WD y. Choose ı appropriately. (Karmarkar and Karp [1982])

13. Find an appropriate choice of as a function of SUM.I /, such that the resulting modification of the KARMARKAR-KARP ALGORITHM is a polynomialtime

algorithm which guarantees to find a solution with at most OPT.I / C / log log OPT.I / O OPT.Ilog bins. OPT.I / (Johnson [1982])

References General Literature: Coffman, E.G., Garey, M.R., and Johnson, D.S. [1996]: Approximation algorithms for binpacking; a survey. In: Approximation Algorithms for NP-Hard Problems (D.S. Hochbaum, ed.), PWS, Boston, 1996

Cited References: Baker, B.S. [1985]: A new proof for the First-Fit Decreasing bin-packing algorithm. Journal of Algorithms 6 (1985), 49–70 Bansal, N., Correa, J.R., Kenyon, C., and Sviridenko, M. [2006]: Bin packing in multiple dimensions: inapproximability results and approximation schemes. Mathematics of Operations Research 31 (2006), 31–49 Caprara, A. [2008]: Packing d -dimensional bins in d stages. Mathematics of Operations Research 33 (2008), 203–215 Dósa, G. [2007]: The tight bound of first fit decreasing bin-packing algorithm is FFD.I / ˘ C âAL’6=9. ˘ 11=9OP T .I /âAL’ In: Combinatorics, Algorithms, Probabilistic and Experimental Methodologies; LNCS 4614 (Chen, B., Paterson, M., Zhang, G., eds.), Springer, Berlin 2007, pp. 1–11 Eisemann, K. [1957]: The trim problem. Management Science 3 (1957), 279–284

References

487

Fernandez de la Vega, W., and Lueker, G.S. [1981]: Bin packing can be solved within 1 C in linear time. Combinatorica 1 (1981), 349–355 Garey, M.R., Graham, R.L., Johnson, D.S., and Yao, A.C. [1976]: Resource constrained scheduling as generalized bin packing. Journal of Combinatorial Theory A 21 (1976), 257–298 Garey, M.R., and Johnson, D.S. [1975]: Complexity results for multiprocessor scheduling under resource constraints. SIAM Journal on Computing 4 (1975), 397–411 Garey, M.R., and Johnson, D.S. [1979]: Computers and Intractability; A Guide to the Theory of NP-Completeness. Freeman, San Francisco 1979, p. 127 Gilmore, P.C., and Gomory, R.E. [1961]: A linear programming approach to the cutting-stock problem. Operations Research 9 (1961), 849–859 Graham, R.L. [1966]: Bounds for certain multiprocessing anomalies. Bell Systems Technical Journal 45 (1966), 1563–1581 Graham, R.L., Lawler, E.L., Lenstra, J.K., and Rinnooy Kan, A.H.G. [1979]: Optimization and approximation in deterministic sequencing and scheduling: a survey. In: Discrete Optimization II; Annals of Discrete Mathematics 5 (P.L. Hammer, E.L. Johnson, B.H. Korte, eds.), North-Holland, Amsterdam 1979, pp. 287–326 Hochbaum, D.S., and Shmoys, D.B. [1987]: Using dual approximation algorithms for scheduling problems: theoretical and practical results. Journal of the ACM 34 (1987), 144–162 Horowitz, E., and Sahni, S.K. [1976]: Exact and approximate algorithms for scheduling nonidentical processors. Journal of the ACM 23 (1976), 317–327 Jansen, K., Prädel, L., and Schwarz, U.M. [2009]: Two for one: tight approximation of 2D bin packing. In: Algorithms and Data Structures – Proceedings of the 11th Algorithms and Data Structures Symposium; LNCS 5664 (F. Dehne, M. Gavrilova, J.-R. Sack, C.D. Tóth, eds.), Springer, Berlin 2009, pp. 399–410 Johnson, D.S. [1973]: Near-Optimal Bin Packing Algorithms. Doctoral Thesis, Dept. of Mathematics, MIT, Cambridge, MA, 1973 Johnson, D.S. [1974]: Fast algorithms for bin-packing. Journal of Computer and System Sciences 8 (1974), 272–314 Johnson, D.S. [1982]: The NP-completeness column; an ongoing guide. Journal of Algorithms 3 (1982), 288–300, Section 3 Johnson, D.S., Demers, A., Ullman, J.D., Garey, M.R., and Graham, R.L. [1974]: Worst-case performance bounds for simple one-dimensional packing algorithms. SIAM Journal on Computing 3 (1974), 299–325 Karmarkar, N., and Karp, R.M. [1982]: An efficient approximation scheme for the onedimensional bin-packing problem. Proceedings of the 23rd Annual IEEE Symposium on Foundations of Computer Science (1982), 312–320 Lawler, E.L., Lenstra, J.K., Rinnooy Kan, A.H.G., and Shmoys, D.B. [1993]: Sequencing and scheduling: algorithms and complexity. In: Handbooks in Operations Research and Management Science; Vol. 4 (S.C. Graves, A.H.G. Rinnooy Kan, P.H. Zipkin, eds.), Elsevier, Amsterdam 1993 Lenstra, H.W. [1983]: Integer Programming with a fixed number of variables. Mathematics of Operations Research 8 (1983), 538–548 Papadimitriou, C.H. [1994]: Computational Complexity. Addison-Wesley, Reading 1994, pp. 204–205 Plotkin, S.A., Shmoys, D.B., and Tardos, É. [1995]: Fast approximation algorithms for fractional packing and covering problems. Mathematics of Operations Research 20 (1995), 257–301

488

18 Bin-Packing

Queyranne, M. [1986]: Performance ratio of polynomial heuristics for triangle inequality quadratic assignment problems. Operations Research Letters 4 (1986), 231–234 Seiden, S.S. [2002]: On the online bin packing problem. Journal of the ACM 49 (2002), 640–671 Simchi-Levi, D. [1994]: New worst-case results for the bin-packing problem. Naval Research Logistics 41 (1994), 579–585 van Vliet, A. [1992]: An improved lower bound for on-line bin packing algorithms. Information Processing Letters 43 (1992), 277–284 Xia, B., and Tan, Z. [2010]: Tighter bounds of the First Fit algorithm for the bin-packing problem. Discrete Applied Mathematics 158 (2010), 1668–1675 Yue, M. [1991]: A simple proof of the inequality FFD.L/ 11 9 OPT.L/ C 1; 8L, for the FFD bin-packing algorithm. Acta Mathematicae Applicatae Sinica 7 (1991), 321–331 Zhang, G. [2005]: A 3-approximation algorithm for two-dimensional bin packing. Operations Research Letters 33 (2005), 121–126

19 Multicommodity Flows and Edge-Disjoint Paths

The MULTICOMMODITY FLOW PROBLEM is a generalization of the MAXIMUM FLOW PROBLEM. Given a digraph with edge capacities, we now ask for an s-tflow for several pairs .s; t/ (we speak of several commodities), such that the total flow through any edge does not exceed the capacity. We specify the pairs .s; t/ by a second digraph; for technical reasons we have an edge from t to s when we ask for an s-t-flow. Formally we have:

DIRECTED MULTICOMMODITY FLOW PROBLEM Instance:

A pair .G; H / of digraphs on the same vertices. Capacities u W E.G/ ! RC and demands b W E.H / ! RC .

Task:

Find a family .x f /f 2E.H / , where x f is an s-t-flow of value b.f / in G for each f D .t; s/ 2 E.H /, and X x f .e/ u.e/ for all e 2 E.G/: f 2E.H /

There is also an undirected version which we shall discuss later. The edges of G are called supply edges, the edges of H demand edges or commodities. Endpoints of demand edges are called terminals. If u 1, b 1 and x is forced to be integral, we have the E DGE-DISJOINT PATHS PROBLEM. Sometimes one also has edge weights and asks for a minimum cost multicommodity flow. But here we are only interested in feasible solutions. Of course, the problem can be solved in polynomial time by means of L INEAR PROGRAMMING (cf. Theorem 4.18). However the LP formulations are quite large, so it is also interesting that we have a combinatorial algorithm for solving the problem approximately; see Section 19.2. This algorithm uses an LP formulation as a motivation. Moreover, LP duality yields a useful good characterization of our problem as shown in Section 19.1. However, in contrast to single-commodity flows, the dual LP does not correspond to a minimum cut problem. We will study the max-flow min-cut ratio in Sections 19.3 and 19.4. In many applications one is interested in integral flows, or paths, and the E DGEDISJOINT PATHS PROBLEM is the proper formulation. We have considered a special case of this problem in Section 8.2, where we had a necessary and sufficient condition for the existence of k edge-disjoint (or internally disjoint) paths from s to t B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__19, c Springer-Verlag Berlin Heidelberg 2012

489

490

19 Multicommodity Flows and Edge-Disjoint Paths

for two given vertices s and t (Menger’s Theorems 8.9 and 8.10). We shall prove that the general E DGE-DISJOINT PATHS PROBLEM is NP-hard, both in the directed and undirected case. Nevertheless there are some interesting special cases that can be solved in polynomial time, as we shall see in Sections 19.5 and 19.6.

19.1 Multicommodity Flows We concentrate on the DIRECTED MULTICOMMODITY FLOW PROBLEM but mention that all results of this section also hold for the undirected version:

UNDIRECTED MULTICOMMODITY FLOW PROBLEM Instance:

A pair .G; H / of undirected graphs on the same vertices. Capacities u W E.G/ ! RC and demands b W E.H / ! RC .

Task:

Find a family .x f /f 2E.H / , where x f is an s-t-flow of value b.f / in .V .G/; f.v; w/; .w; v/ W fv; wg 2 E.G/g/ for each f D ft; sg 2 E.H /, and X x f ..v; w// C x f ..w; v// u.e/ f 2E.H /

for all e D fv; wg 2 E.G/. Both versions of the MULTICOMMODITY FLOW PROBLEM have a natural formulation as an LP (cf. the LP formulation of the M AXIMUM FLOW PROBLEM in Section 8.1). Hence they can be solved in polynomial time (Theorem 4.18). Today exact polynomial-time algorithms which do not use LINEAR PROGRAMMING are known only for some special cases. We shall now mention a different LP formulation of the MULTICOMMODITY FLOW PROBLEM which will prove useful: Lemma 19.1. Let .G; H; u; b/ be an instance of the (DIRECTED or UNDIRECTED) MULTICOMMODITY FLOW PROBLEM. Let C be the set of circuits of G C H that contain exactly one demand edge. Let M be a 0-1-matrix whose columns correspond to the elements of C and whose rows correspond to the edges of G, where Me;C D 1 iff e 2 C . Similarly, let N be a 0-1-matrix whose columns correspond to the elements of C and whose rows correspond to the edges of H , where Nf;C D 1 iff f 2 C. Then each solution of the MULTICOMMODITY FLOW PROBLEM corresponds to at least one point in the polytope ˚ y 2 RC W y 0; My u; Ny D b ; (19.1) and each point in this polytope corresponds to a unique solution of the MULTICOMMODITY FLOW PROBLEM .

19.1

Multicommodity Flows

491

Proof: To simplify our notation we consider the directed case only; the undirected case follows by substituting each undirected edge by the subgraph shown in Figure 8.2. Let .x f /f 2E.H / be a solution of the MULTICOMMODITY FLOW PROBLEM. For each f D .t; s/ 2 E.H / the s-t-flow x f can be decomposed into a set P of s-tpaths and a set Q of circuits (Theorem 8.8): for each demand edge f we can write X x f .e/ D w.P / P 2P[QW e2E.P /

for e 2 E.G/, where w W P [ Q ! RC . We set yP Cf WD w.P / for P 2 P and yC WD 0 for f 2 C 2 C with C f 62 P. This obviously yields a vector y 0 with My u and Ny D b. Conversely, let y 0 with My u and Ny D b. Setting X x f .e/ WD yC C 2CW e;f 2E.C /

yields a solution of the MULTICOMMODITY FLOW PROBLEM.

With the help of LP duality we can now derive a necessary and sufficient condition for the solvability of the MULTICOMMODITY FLOW PROBLEM. We shall also mention the connection to the EDGE-DISJOINT PATHS PROBLEM. Definition 19.2. An instance .G; H / of the (DIRECTED or UNDIRECTED) EDGEDISJOINT PATHS PROBLEM satisfies the distance criterion if for each ´ W E.G/ ! RC X X dist.G;´/ .s; t/ ´.e/: (19.2) f D.t;s/2E.H /

e2E.G/

An instance .G; H; u; b/ of the MULTICOMMODITY FLOW PROBLEM satisfies the distance criterion if for each ´ W E.G/ ! RC X X b.f / dist.G;´/ .s; t/ u.e/´.e/: f D.t;s/2E.H /

e2E.G/

(In the undirected case, .t; s/ must be replaced by ft; sg.) The left-hand side of the distance criterion can be interpreted as a lower bound on the cost of a solution (with respect to edge costs ´), while the right-hand side is an upper bound on the maximum possible cost. Theorem 19.3. The distance criterion is necessary and sufficient for the solvability of the MULTICOMMODITY FLOW PROBLEM (in both the directed and the undirected case). Proof: We again consider only the directed case, the undirected case follows via the substitution of Figure 8.2. By Lemma 19.1, the MULTICOMMODITY FLOW

492

19 Multicommodity Flows and Edge-Disjoint Paths

˚ PROBLEM has a solution if and only if the polyhedron y 2 RCC W My u; Ny D b is nonempty. By Corollary 3.25, this polyhedron is empty if and only if there are vectors ´; w with ´ 0, ´M C wN 0 and ´u C wb < 0. (M and N are defined as above.) The inequality ´M C wN 0 implies X wf ´e e2P

for each demand edge f D .t; s/ and each s-t-path P in G, so wf dist.G;´/ .s; t/. Hence there exist vectors ´; w with ´ 0, ´M C wN 0 and ´u C wb < 0 if and only if there exists a vector ´ 0 with X ´u dist.G;´/ .s; t/ b.f / < 0: f D.t;s/2E.H /

This completes the proof.

In Section 19.2 we shall show how the LP description of Lemma 19.1 and its dual can be used to design an algorithm for the MULTICOMMODITY FLOW PROBLEM. Theorem 19.3 implies that the distance criterion is necessary for the solvability of the EDGE-DISJOINT PATHS PROBLEM, since this can be considered as a MULTICOMMODITY FLOW PROBLEM with b 1, u 1 and with integrality constraints. Another important necessary condition is the following: Definition 19.4. An instance .G; H / of the (DIRECTED or UNDIRECTED) EDGEDISJOINT PATHS PROBLEM satisfies the cut criterion if for each X V .G/ C jıG .X /j jıH .X /j jıG .X /j jıH .X /j

in the directed case, or in the undirected case.

An instance .G; H; u; b/ of the (DIRECTED or UNDIRECTED) MULTICOMMODITY FLOW PROBLEM satisfies the cut criterion if for each X V .G/ C u.ıG .X // b.ıH .X // u.ıG .X // b.ıH .X //

in the directed case, or in the undirected case.

Corollary 19.5. For an instance .G; H / of the (DIRECTED or UNDIRECTED) EDGE-DISJOINT PATHS PROBLEM, the following implications hold: .G; H / has a solution ) .G; H / satisfies the distance criterion ) .G; H / satisfies the cut criterion. Proof: The first implication follows from Theorem 19.3. For the second implication observe that the cut criterion is just a special case of the distance criterion, where weight functions of the type ( 1 if e 2 ı C .X / (directed case) or e 2 ı.X / (undirected case) ´.e/ WD 0 otherwise

19.1

a

1

2

2

1

b

Multicommodity Flows

1

2

2

1

493

Fig. 19.1.

for X V .G/ are considered.

None of the implications can be reversed in general. Figure 19.1 shows examples where there is no (integral) solution but there is a fractional solution, i.e. a solution of the multicommodity flow relaxation. So here the distance criterion is satisfied. In the figures of this section demand edges are indicated by equal numbers at their endpoints. In the directed case, one should orient the demand edges so that they are realizable. (A demand edge .t; s/ or ft; sg is called realizable if t is reachable from s in the supply graph.)

a

b

2,4

1,3

1

2 3

1

4

5

1 2

5

4

2,3

3,4

Fig. 19.2.

The two examples shown in Figure 19.2 satisfy the cut criterion (this is easily checked), but not the distance criterion: in the undirected example choose ´.e/ D 1 for all e 2 E.G/, in the directed example choose ´.e/ D 1 for the bold edges and ´.e/ D 0 otherwise. We remark that it is NP-hard to check whether a given instance of the UNDIRECTED E DGE -D ISJOINT PATHS PROBLEM satisfies the cut criterion (Exercise 2). This is in contrast to the distance criterion, which can be checked in polynomial time by linear programming. For some classes of instances of the E DGE-DISJOINT PATHS PROBLEM the cut criterion is sufficient for the existence of a solution. We will see some examples later

494

19 Multicommodity Flows and Edge-Disjoint Paths

in this chapter. A first example is Menger’s Theorem. To generalize this slightly, we use the following construction. Lemma 19.6. Let .G; H / be an instance of the (DIRECTED or UNDIRECTED) EDGE-DISJOINT PATHS PROBLEM and v 2 V .G/. Let .G 0 ; H 0 / result from .G; H / by adding a new vertex x and doing the following for each demand edge f incident to v: If f D fv; wg, then replace f by fv; xg and add a supply edge fw; xg. If f D .v; w/, then replace f by .v; x/ and add a supply edge .x; w/. If f D .w; v/, then replace f by .x; v/; and add a supply edge .w; x/. Then .G 0 ; H 0 / has a solution if and only if .G; H / has a solution. Moreover, 0 .G ; H 0 / satisfies the cut criterion if and only if .G; H / does. Proof: Any solution to .G 0 ; H 0 / yields a solution to .G; H / by omitting the new supply edges. Conversely, any solution to .G; H / can be transformed into a solution to .G 0 ; H 0 / by appending the new supply edges. For the cut criterion, we observe that for any set X V .G 0 / D V .G/ [ fxg we have C C jıG 0 .X /j jıH 0 .X /j jıG .X n fxg/j jıH .X n fxg/j or jıG 0 .X /j jıH 0 .X /j jıG .X n fxg/j jıH .X n fxg/j; respectively, with equality if jX \ fv; xgj D 1.

Theorem 19.7. Let .G; H / be an instance of the (DIRECTED or UNDIRECTED) EDGE-DISJOINT PATHS PROBLEM with a vertex v such that (a) f 2 ı C .v/ for all f 2 E.H /, or (b) f 2 ı .v/ for all f 2 E.H / in the directed case, or (c) f 2 ı.v/ for all f 2 E.H / in the undirected case. Then .G; H / has a solution if and only if the cut criterion holds. Proof: By Lemma 19.6 we can reduce this to the case where H contains only one set of parallel edges. In this case the sufficiency of the cut criterion is a reformulation of Menger’s Theorem 8.9.

19.2 Algorithms for Multicommodity Flows The definition of the MULTICOMMODITY FLOW PROBLEM directly gives rise to an LP formulation of polynomial size. Although this yields a polynomial-time algorithm it cannot be used for solving large instances: the number of variables is enormous. The LP description (19.1) given by Lemma 19.1 looks even worse since it has an exponential number of variables. Nevertheless this description proves much more useful in practice. We shall explain this now. Since we are interested in a feasible solution only, we consider the LP

19.2

Algorithms for Multicommodity Flows

495

maxf0y W y 0; My u; Ny D bg and its dual minf´u C wb W ´ 0; ´M C wN 0g which we can rewrite as minf´u C wb W ´ 0; dist.G;´/ .s; t/ w.f / for all f D .t; s/ 2 E.H /g: (In the undirected case replace .t; s/ by ft; sg.) This dual LP has only jE.G/j C jE.H /j variables but an exponential number of constraints. However, this is not important since the SEPARATION PROBLEM can be solved by jE.H /j shortest path computations; as only nonnegative vectors ´ have to be considered, we can use DIJKSTRA’S ALGORITHM here. If the dual LP is unbounded, then this proves infeasibility of the primal LP. Otherwise we can solve the dual LP, but this does not provide a primal solution in general. Ford and Fulkerson [1958] suggested to use the above consideration to solve the primal LP directly, in combination with the SIMPLEX ALGORITHM. Since most variables are zero at each iteration of the SIMPLEX ALGORITHM, one only keeps track of those variables for which the nonnegativity constraint yC 0 does not belong to the current set J of active rows. The other variables are not stored explicitly but “generated” when they are needed (when the nonnegativity constraint becomes inactive). The decision of which variable has to be generated in each step is equivalent to the SEPARATION PROBLEM for the dual LP, so in our case it reduces to a SHORTEST PATH PROBLEM. This column generation technique can be quite efficient in practice. Even with these techniques there are many practical instances that cannot be solved optimally. However, the above scheme also gives rise to an approximation algorithm. Let us first formulate our problem as an optimization problem:

MAXIMUM MULTICOMMODITY FLOW PROBLEM Instance:

A pair .G; H / of digraphs on the same vertices. Capacities u W E.G/ ! RC .

Task:

Find a family .x f /f 2E.H / , where x f is an s-t-flow in G for each P f D .t; s/ 2 E.H /, f 2E.H / x f .e/ u.e/ for all e 2 E.G/, and P the total flow value f 2E.H / value .x f / is maximum.

There are other interesting formulations. For example one can look for flows satisfying the greatest possible fraction of given demands (the CONCURRENT FLOW PROBLEM), or for flows satisfying given demands but violating capacities as slightly as possible. Moreover one can consider costs on edges. We consider only the MAXIMUM M ULTICOMMODITY FLOW PROBLEM ; other problems can be attacked with similar techniques. We again consider our LP formulation 8 9 <X = X max y.P / W y 0; y.P / u.e/ for all e 2 E.G/ ; : ; P 2P

P 2PWe2E.P /

496

19 Multicommodity Flows and Edge-Disjoint Paths

where P is the family of the s-t-paths in G for all .t; s/ 2 E.H /, and its dual 9 8 = < X ´.e/ 1 for all P 2 P : min ´u W ´ 0; ; : e2E.P /

We shall describe a primal-dual algorithm based on these formulations which turns out to be a fully polynomial approximation scheme. This algorithm always has a primal vector y 0 that is not necessarily a feasible primal solution since capacity constraints might be violated. Initially y D 0. At the end we shall multiply y by a constant in order to meet all constraints. To store y efficiently we keep track of the family P 0 P of those paths P with y.P / > 0; in contrast to P the cardinality of P 0 will be polynomially bounded. The algorithm also has a dual vector ´ 0. Initially, ´.e/ D ı for all e 2 E.G/, where ı depends on n and the error parameter . In each iteration, it finds a maximally violated dual constraint (corresponding to a shortest s-t-path for .t; s/ 2 E.H /, with respect to edge lengths ´) and increases ´ and y along this path:

MULTICOMMODITY FLOW APPROXIMATION SCHEME Input: Output: 1 2 3

4

A pair .G; H / of digraphs on the same vertices. Capacities u W E.G/ ! RC n f0g. A number with 0 < 12 . P Numbers y W P ! RC with P 2PWe2E.P / y.P / u.e/ for all e 2 E.G/.

Set y.P / WD 0 for all P 2 P. 5 Set ı WD .n.1 C //d e .1 C / and ´.e/ WD ı for all e 2 E.G/. Let P 2 P such that ´.E.P // is minimum. If ´.E.P // 1, then go to . 4 Let WD min u.e/. e2E.P /

Set y.P / WD y.P/ C . for all e 2 E.P /. Set ´.e/ WD ´.e/ 1 C u.e/ Go to . 2 X 1 y.P /. Let WD max e2E.G/ u.e/ Set y.P / WD

y.P /

P 2PWe2E.P /

for all P 2 P.

This algorithm is due to Young [1995] and Garg and Könemann [2007], based on earlier work of Shahrokhi and Matula [1990], Shmoys [1996], and others. Theorem 19.8. (Garg and Könemann [2007]) The MULTICOMMODITY FLOW APPROXIMATION SCHEME produces a feasible solution with total flow value at 1 least 1C OPT.G; H; u/. Its running time is O 12 km.m C n log n/ log n , where

19.2

Algorithms for Multicommodity Flows

497

k D jE.H /j, n D jV .G/j and m D jE.G/j, so it is a fully polynomial approximation scheme. Proof: In each iteration the value ´.e/ increases by a factor 1 C for at least one edge e (the bottleneck edge). Since an edge e with ´.e/ 1 is never used anymore in any path, the total number of iterations is t mdlog1C . 1ı /e. In each iteration we have to solve k instances of the SHORTEST PATH PROBLEM with nonnegative weights to determine P . Using DIJKSTRA’S ALGORITHM (Theorem 7.4) we get an overall running time of O.tk.m C n log n// D O km.m C n log n/ log1C . 1ı / . The stated running time now follows from observing that, for 0 < 1, ˙5 log. 1ı / log.2n/ 1 log n log1C D I D O ı log.1 C / 2 2 here we used log.1 C / 2 for 0 < 1. We also have to check that the maximum number of bits needed to store any number occurring in the computation is bounded by a polynomial in log n C size.u/ C size./ C 1 . This is clear for the y-variables. The number ı can be stored with O. 1 size.n.1 C // C size.// D O. 1 .log n C size./// bits. To deal with the ´-variables we assume that u is integral; otherwise we multiply all capacities by the product of the denominators in the beginning (cf. Proposition 4.1). Then the denominator of the ´-variables is bounded at any time by the product of all capacities and the denominator of ı. Since the numerator is at most twice the denominator we have shown that the size of all numbers is indeed polynomial in the input size and 1 . The feasibility of the solution is guaranteed by . 4 Note that every increase the weight time we add units of flow on edge e we ´.e/ by a factor 1 C u.e/ . This value is at least .1 C / u.e/ because 1 C a .1 C /a holds for 0 a 1 (both sides of this inequality are equal for a 2 f0; 1g, and the left-hand side is linear in a while the right-hand side is convex). Since e is not used once ´.e/ 1, we cannot add more than u.e/.1 C log1C . 1ı // units of flow on edge e. Hence 1 1C 1 C log1C D log1C : (19.3) ı ı Let ´.i / denote the vector ´ after iteration i , and let Pi and P i be the path P and the number in iteration i . We have ´.i / u D ´.i 1/ u C i e2E.Pi / ´.i 1/ .e/, P so .´.i / ´.0/ /u D ji D1 j ˛.´.j 1/ /, where ˛.´/ WD minP 2P ´.E.P //. Let us n o write ˇ WD min ´u W ´ 2 RE.G/ ; ˛.´/ 1 . Then .´.i / ´.0/ /u ˇ˛.´.i / ´.0/ / C and thus .˛.´.i / / ın/ˇ ˛.´.i / ´.0/ /ˇ .´.i / ´.0/ /u. We obtain ˛.´.i / / ın C

i X j ˛.´.j 1/ /: ˇ j D1

(19.4)

498

19 Multicommodity Flows and Edge-Disjoint Paths

We now prove ın C

P i i X j ˛.´.j 1/ / ıne ˇ j D1 j : ˇ

(19.5)

j D1

by induction on i (here e denotes the base of the natural logarithm). The case i D 0 is trivial. For i > 0 we have ın C

i i 1 X X j ˛.´.j 1/ / D ın C j ˛.´.j 1/ / C i ˛.´.i 1/ / ˇ ˇ ˇ j D1 j D1 P i 1 j D1 j ˇ 1 C i ıne ; ˇ

using (19.4) and the induction hypothesis. Using 1 C x < e x for all x > 0 the proof of (19.5) is complete. In particular we conclude from (19.4), (19.5) and the stopping criterion that .t /

ˇ

Pt

j D1 j

1 ˛.´ / ıne ; P 1 hence jt D1 j ˇ ln ın . Now observe that the total flow value that the algoP P rithm computes is P 2P y.P / D 1 jt D1 j . By the above and (19.3) this is at least 1 1 ˇ ln ın ˇ ln.1 C / ln ın D log1C . 1C ln. 1C ı / ı / D

ˇ ln.1 C / .d 5 e 1/ ln.n.1 C // d 5 e ln.n.1 C //

ˇ.1 5 / ln.1 C /

by the choice of ı. Recall that ˇ is the optimum value of the dual LP, and hence, by the LP Duality Theorem 3.20, the optimum value of a primal solution. Moreover, 2 ln.1 C / 2 (this inequality is trivial for D 0 and the derivative of the left-hand side is greater than that of the right-hand side for every > 0). Hence 1C .1 5 / ln.1 C / 1 1 D 5 2

3 10

6 2 10 C 1C

1 3 10

1 1C

for 12 . We conclude that the algorithm finds a solution whose total flow value is 1 at least 1C OPT.G; H; u/. A different algorithm which gives the same running time (by a more complicated analysis) was published before by Grigoriadis and Khachiyan [1996]. Fleischer [2000] improved the running time of the above algorithm by a factor of k. She

19.3

Sparsest Cut and Max-Flow Min-Cut Ratio

499

observed that it is sufficient to compute an approximate shortest path in , 2 and used this fact to show that it is not necessary to do a shortest path computation for each .t; s/ 2 E.H / in each iteration. See also Karakostas [2008], Müller, Radke and Vygen [2011], Bienstock and Iyengar [2006], and Chudak and Eleutério [2005].

19.3 Sparsest Cut and Max-Flow Min-Cut Ratio Consider the following problem:

GENERALIZED SPARSEST CUT PROBLEM Instance:

An instance .G; H; u; b/ of the UNDIRECTED MULTICOMMODITY FLOW PROBLEM.

Task:

Find a set X V .G/ with b.ıH .X // > 0 and

u.ıG .X// b.ıH .X//

minimum.

The special case where H is the complete undirected graph and b.f / D 1 for all f 2 E.H / is called the SPARSEST CUT PROBLEM: here we ask for a nonempty u.ıG .X// proper subset X of the vertex set such that jXjjV .G/nXj is minimum. The corresponding special case of the UNDIRECTED MULTICOMMODITY FLOW PROBLEM is called the UNIFORM MULTICOMMODITY FLOW PROBLEM. u.ıG .X// The minimum value of b.ı is clearly an upper bound on the optimum value H .X// of the instance .G; H; u; b/ of the CONCURRENT FLOW PROBLEM, which can be written as ( X max W y.P / 0 .P 2 P/; y.P / b.f / .f 2 E.H //; X

P 2Pf

)

(19.6)

y.P / u.e/ .e 2 E.G// ;

P 2PWe2E.P /

whereSPf denotes the family of the s-t-paths in G, for f D ft; sg 2 E.H /, and P D f 2E.H / Pf . If we introduce decision variables ´e 2 f0; 1g for e 2 E.G/, with the intended meaning that ´ is the incidence vector of ıG .X /, we can write the GENERALIZED SPARSEST CUT PROBLEM as an integer nonlinear program ( u> ´ min > W ´ 2 f0; 1gE.G/ ; w 2 f0; 1gE.H /; b > w > 0; b w ) (19.7) X ´.e/ w.f / .P 2 Pf ; f 2 E.H // : e2E.P /

Proposition 19.9. The GENERALIZED SPARSEST CUT PROBLEM is equivalent to (19.7): the optimum values are the same, and from a solution to the latter we can obtain in linear time an at least as good solution of the former (and vice versa).

500

19 Multicommodity Flows and Edge-Disjoint Paths

Proof: For a set X V .G/ vectors of ıG .X / and ıH .X /, > u.ıG .X// (19.7) and bu> w´ D b.ı . H .X// Conversely, if .´; w/ is a be the connected components P p

mini D1

u.ıG .Xi // b.ıH .Xi //

p

i D1 Pp

with b.ıH .X // > 0 let ´ and w be the incidence respectively. Then .´; w/ is a feasible solution of feasible solution of (19.7), then let X1 ; : : : ; Xp of .V .G/; fe 2 E.G/ W ´.e/ D 0g/. We have

u.ıG .Xi //

b.ıH .Xi // i D1

2u> ´ 2b > w

D

u> ´ . b>w

Any feasible solution to (19.7) can be scaled (by multiplying all variables with an appropriate positive constant) to a feasible solution of ( E.G/

min u> ´ W ´ 2 RC X

E.H /

; w 2 RC

; b > w D 1; )

(19.8)

´.e/ w.f / .P 2 Pf ; f 2 E.H // ;

e2E.P /

of course with the same objective function value. So (19.8) can be viewed as an LP relaxation. Lemma 19.10. The linear program (19.8) can be solved in polynomial time. Proof: If t is not reachable from s in G for some f D ft; sg 2 E.H / with b.f / > 0, the LP is easy to solve, and the optimum value is zero. Otherwise there is an optimum solution .´; w/ with w.f / D dist.G;´/ .s; t/ for all f D ft; sg 2 E.H P /. We add new variables d.fa; bg/ for a; b 2 V .G/ and replace the constraints e2E.P / ´.e/ w.f / for P 2 Pf and f 2 E.H / equivalently by d.e/ ´.e/ for e 2 E.G/, w.f / d.f / for f 2 E.H /, and d.fa; cg/ d.fa; bg/ C d.fb; cg/ for a; b; c 2 V .G/. We obtain an LP of polynomial size and can apply Theorem 4.18. But there is also a combinatorial fully polynomial approximation scheme similar to the one in Section 19.2, because (19.8) is the dual LP of (19.6), the CONCURRENT FLOW PROBLEM (cf. Exercise 5). The maximum ratio of the optimum values of (19.7) and (19.8) is called the max-flow min-cut ratio of the multicommodity flow instance. It can be as large as ‚.log n/, where n D jV .G/j, even in the uniform case (i.e., when H is the complete graph and b 1). This is demonstrated by an expander graph with unit capacities (cf. Exercise 6). In the next section we show that it is never worse.

19.4 The Leighton-Rao Theorem We will use a solution .´; w/ to the LP (19.8) in order to compute a sparse cut. If .´; w/ is an optimum solution, then W WD u> ´ is a lower bound on the sparsity u.ıG .X// minXV .G/ jXjjV .G/nXj . We will not need w in the following. Following Leighton and Rao [1999], we first partition our graph into low diameter sets such that the capacity of the multicut is rather small.

19.4

The Leighton-Rao Theorem

501

Lemma 19.11. (Leighton and Rao [1999]) Let G be an undirected graph with edge weights ´ W E.G/ ! RC and capacities u W E.G/ ! RC . The diameter of a nonempty set X V .G/ is defined as maxv;v0 2X dist.G;´/ .v; v 0 /. Let d > 0. Then V .G/ can be partitioned into sets V1 ; : : : ; Vk , each with diameter at most d , suchPthat the total capacity of edges in the multicut is at most 8W dlog n , where W WD e2E.G/ u.e/´.e/. Moreover, such a partition can be computed in O.m log n/ time, where n WD jV .G/j and m WD jE.G/j. Proof: We first deal with some trivial cases. Let U WD u.E.G//. If U D 0 or d 8WUlog n , the partition into singletons does the job. If W D 0, then we take the connected components of .V .G/; fe 2 E.G/ W ´.e/ D 0g/. log n Otherwise we have WP> 0 and WD 2WUd < 14 . Set ´0 .e/ WD dU ´.e/=W e 0 for e 2 E.G/. Note that e2E.G/ ´ .e/u.e/ < 2U . Then we apply the following procedure, starting P with i WD 1 and G1 WD G. x1 2U Choose vi 2 V .Gi /. For x 2 ZC let Uxi WD n1 C D0 u.ıGi .Bi //, where Bi denotes the set of vertices at distance at most from vi in .Gi ; ´0 /. Choose ri 0 smallest such that Urii C1 < 2 Urii . Set Vi WD Brii . Set Gi C1 WD Gi Vi , increment i , and iterate until no vertices are left. : : We get a partition V .G/ D V1 [ [ Vk . For each i we have Urii 2ri U0i D P 2U 2U 2U n 2ri n1 and hence 2ri n1 Urii n1 C e2E.G/ ´0 .e/u.e/ 2U n1 . Thus ri log n . For any two vertices v; v 0 2 Vi we have dist.G;´/ .v; v 0 / W dist.G;´0 / .v; v 0 / U 2W log n W .dist.G;´0 / .vi ; v/ C dist.G;´0 / .vi ; v 0 // W 2ri U D d . U U We have u.ıGi .Vi // D Urii C1 Urii < .2 1/Urii Urii for i D 1; : : : ; k. Summation yields u.ıG .V1 ; : : : ; Vk // D

k X

u.ıGi .Vi //

i D1

k X i D1

Urii

0

D @

2U k C n1

0 @2U C

k rX i 1 X i D1 D0

X

1 u.ıGi .Bi //A 1

´0 .e/u.e/A

e2E.G/

< 4U: This procedure can be implemented similarly to DIJKSTRA’S ALGORITHM. In each iteration we only need to consider x D 0 and the values x > 0 for which i ıGi .Bxi / 6D ıGi .Bx1 /. After each of these steps we check whether ri D x. Otherwise we compute the value x 0 D x C1 Cb1=.2 1/Uxi =u.ıGi .Bxi //c. If ıGi .Bi /

502

19 Multicommodity Flows and Edge-Disjoint Paths

remains constant for D x; x C 1; : : : ; x 0 , then x 0 is the smallest integer for which u.ıGi .Bxi 0 // D u.ıGi .Bxi // < .2 1/.Uxi C .x 0 x/u.ıGi .Bxi /// D .2 1/Uxi 0 , and thus the number ri P that we look for. Hence we have O. w2Bri .1 C jı.w/j// operations in iteration i , and O.m C i n log n/ total time with Fibonacci heaps. Now we can prove the main theorem of Leighton and Rao [1999]: Theorem 19.12. Let G be a graph with P edge weights ´ W E.G/ ! RC and capacities u W E.G/ ! RC . Suppose that fv;v0 g2.V .G// dist.G;´/ .v; v 0 / D 1. Let 2 n WD jV .G/j. Then we can find a nonempty proper subset X V .G/ with u.ı.X // 36 W log n; jX jjV .G/ n X j where again W WD

P e2E.G/

u.e/´.e/.

Proof: We first apply Lemma 19.11 with d D :

:

1 . n2

We get a partition V .G/ D

V1 [ [ Vk . If none of the sets V1 ; : : : ; Vk has more than 2n vertices, then we successively 3 unite the two smallest sets until o

For further volumes: http://www.springer.com/series/13

•

Bernhard Korte

Jens Vygen

Combinatorial Optimization Theory and Algorithms Fifth Edition

123

Bernhard Korte Jens Vygen University of Bonn Research Institute for Discrete Mathematics Lennéstr. 2 53113 Bonn Germany [email protected] [email protected]

Algorithms and Combinatorics ISSN 0937-5511 ISBN 978-3-642-24487-2 e-ISBN 978-3-642-24488-9 DOI 10.1007/978-3-642-24488-9 Springer Heidelberg Dordrecht London New York Library of Congress Control Number: 2011945680 Mathematics Subject Classification (2010): 90C27, 68R10, 05C85, 68Q25 c Springer-Verlag Berlin Heidelberg 2000, 2002, 2006, 2008, 2012 This work is subject to copyright. All rights are reserved, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilm or in any other way, and storage in data banks. Duplication of this publication or parts thereof is permitted only under the provisions of the German Copyright Law of September 9, 1965, in its current version, and permission for use must always be obtained from Springer. Violations are liable to prosecution under the German Copyright Law. The use of general descriptive names, registered names, trademarks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use. Printed on acid-free paper Springer is part of Springer Science+Business Media (www.springer.com)

Preface to the Fifth Edition

When preparing the first edition of this book, more than ten years ago, we tried to accomplish two objectives: it should be useful as an advanced graduate textbook, but also as a reference work for research. With each new edition we have to decide how the book can be improved further. Of course, it is less and less possible to describe the growing area comprehensively. If we included everything that we like, the book would grow beyond a single volume. Since the book is used for many courses, now even sometimes at undergraduate level, we thought that adding some classical material might be more useful than including a selection of the latest results. In this edition, we added a proof of Cayley’s formula, more details on blocking flows, the new faster b-matching separation algorithm, an approximation scheme for multidimensional knapsack, and results concerning the multicommodity max-flow min-cut ratio and the sparsest cut problem. There are further small improvements in numerous places and more than 60 new exercises. Of course, we also updated the references to point to the most recent results and corrected some minor errors that were discovered. We would like to thank Takao Asano, Maxim Babenko, Ulrich Brenner, Benjamin Bolten, Christoph Buchheim, Jean Fonlupt, András Frank, Michael Gester, Stephan Held, Stefan Hougardy, Hiroshi Iida, Klaus Jansen, Alexander Karzanov, Levin Keller, Alexander Kleff, Niko Klewinghaus, Stefan Knauf, Barbara Langfeld, Jens Maßberg, Marc Pfetsch, Klaus Radke, Rabe von Randow, Tomás Salles, Jan Schneider, Christian Schulte, András Seb˝o, Martin Skutella, Jácint Szabó, and Simon Wedeking for valuable feedback on the previous edition. We are pleased that this book has been received so well, and further translations are on their way. Editions in Japanese, French, Italian, German, Russian, and Chinese have appeared since 2009 or are scheduled to appear soon. We hope that our book will continue to serve its purpose in teaching and research in combinatorial optimization. Bonn, September 2011

Bernhard Korte and Jens Vygen

V

•

Preface to the Fourth Edition

With four English editions, and translations into four other languages forthcoming, we are very happy with the development of our book. Again, we have revised, updated, and significantly extended it for this fourth edition. We have added some classical material that may have been missed so far, in particular on linear programming, the network simplex algorithm, and the max-cut problem. We have also added a number of new exercises and up-to-date references. We hope that these changes serve to make our book an even better basis for teaching and research. We gratefully acknowledge the continuous support of the Union of the German Academies of Sciences and Humanities and the NRW Academy of Sciences via the long-term research project “Discrete Mathematics and Its Applications”. We also thank those who gave us feedback on the third edition, in particular Takao Asano, Christoph Bartoschek, Bert Besser, Ulrich Brenner, Jean Fonlupt, Satoru Fujishige, Marek Karpinski, Jens Maßberg, Denis Naddef, Sven Peyer, Klaus Radke, Rabe von Randow, Dieter Rautenbach, Martin Skutella, Markus Struzyna, Jürgen Werber, Minyi Yue, and Guochuan Zhang, for their valuable comments. At http://www.or.uni-bonn.de/vygen/co.html we will continue to maintain updated information about this book. Bonn, August 2007

Bernhard Korte and Jens Vygen

VII

•

Preface to the Third Edition

After five years it was time for a thoroughly revised and substantially extended edition. The most significant feature is a completely new chapter on facility location. No constant-factor approximation algorithms were known for this important class of NP-hard problems until eight years ago. Today there are several interesting and very different techniques that lead to good approximation guarantees, which makes this area particularly appealing, also for teaching. In fact, the chapter has arisen from a special course on facility location. Many of the other chapters have also been extended significantly. The new material includes Fibonacci heaps, Fujishige’s new maximum flow algorithm, flows over time, Schrijver’s algorithm for submodular function minimization, and the RobinsZelikovsky Steiner tree approximation algorithm. Several proofs have been streamlined, and many new exercises and references have been added. We thank those who gave us feedback on the second edition, in particular Takao Asano, Yasuhito Asano, Ulrich Brenner, Stephan Held, Tomio Hirata, Dirk Müller, Kazuo Murota, Dieter Rautenbach, Martin Skutella, Markus Struzyna and Jürgen Werber, for their valuable comments. Eminently, Takao Asano’s notes and Jürgen Werber’s proofreading of Chapter 22 helped to improve the presentation at various places. Again we would like to mention the Union of the German Academies of Sciences and Humanities and the Northrhine-Westphalian Academy of Sciences. Their continuous support via the long-term project “Discrete Mathematics and Its Applications” funded by the German Ministry of Education and Research and the State of Northrhine-Westphalia is gratefully acknowledged. Bonn, May 2005

Bernhard Korte and Jens Vygen

IX

•

Preface to the Second Edition

It was more than a surprise to us that the first edition of this book already went out of print about a year after its first appearance. We were flattered by the many positive and even enthusiastic comments and letters from colleagues and the general readership. Several of our colleagues helped us in finding typographical and other errors. In particular, we thank Ulrich Brenner, András Frank, Bernd Gärtner and Rolf Möhring. Of course, all errors detected so far have been corrected in this second edition, and references have been updated. Moreover, the first preface had a flaw. We listed all individuals who helped us in preparing this book. But we forgot to mention the institutional support, for which we make amends here. It is evident that a book project which took seven years benefited from many different grants. We would like to mention explicitly the bilateral HungarianGerman Research Project, sponsored by the Hungarian Academy of Sciences and the Deutsche Forschungsgemeinschaft, two Sonderforschungsbereiche (special research units) of the Deutsche Forschungsgemeinschaft, the Ministère Français de la Recherche et de la Technologie and the Alexander von Humboldt Foundation for support via the Prix Alexandre de Humboldt, and the Commission of the European Communities for participation in two projects DONET. Our most sincere thanks go to the Union of the German Academies of Sciences and Humanities and to the Northrhine-Westphalian Academy of Sciences. Their long-term project “Discrete Mathematics and Its Applications” supported by the German Ministry of Education and Research (BMBF) and the State of Northrhine-Westphalia was of decisive importance for this book. Bonn, October 2001

Bernhard Korte and Jens Vygen

XI

•

Preface to the First Edition

Combinatorial optimization is one of the youngest and most active areas of discrete mathematics, and is probably its driving force today. It became a subject in its own right about 50 years ago. This book describes the most important ideas, theoretical results, and algorithms in combinatorial optimization. We have conceived it as an advanced graduate text which can also be used as an up-to-date reference work for current research. The book includes the essential fundamentals of graph theory, linear and integer programming, and complexity theory. It covers classical topics in combinatorial optimization as well as very recent ones. The emphasis is on theoretical results and algorithms with provably good performance. Applications and heuristics are mentioned only occasionally. Combinatorial optimization has its roots in combinatorics, operations research, and theoretical computer science. A main motivation is that thousands of real-life problems can be formulated as abstract combinatorial optimization problems. We focus on the detailed study of classical problems which occur in many different contexts, together with the underlying theory. Most combinatorial optimization problems can be formulated naturally in terms of graphs and as (integer) linear programs. Therefore this book starts, after an introduction, by reviewing basic graph theory and proving those results in linear and integer programming which are most relevant for combinatorial optimization. Next, the classical topics in combinatorial optimization are studied: minimum spanning trees, shortest paths, network flows, matchings and matroids. Most of the problems discussed in Chapters 6–14 have polynomial-time (“efficient”) algorithms, while most of the problems studied in Chapters 15–21 are NP-hard, i.e. a polynomial-time algorithm is unlikely to exist. In many cases one can at least find approximation algorithms that have a certain performance guarantee. We also mention some other strategies for coping with such “hard” problems. This book goes beyond the scope of a normal textbook on combinatorial optimization in various aspects. For example we cover the equivalence of optimization and separation (for full-dimensional polytopes), O.n3 /-implementations of matching algorithms based on ear-decompositions, Turing machines, the Perfect Graph Theorem, MAXSNP-hardness, the Karmarkar-Karp algorithm for bin packing, recent approximation algorithms for multicommodity flows, survivable network

XIII

XIV

Preface to the First Edition

design and the Euclidean traveling salesman problem. All results are accompanied by detailed proofs. Of course, no book on combinatorial optimization can be absolutely comprehensive. Examples of topics which we mention only briefly or do not cover at all are tree-decompositions, separators, submodular flows, path-matchings, delta-matroids, the matroid parity problem, location and scheduling problems, nonlinear problems, semidefinite programming, average-case analysis of algorithms, advanced data structures, parallel and randomized algorithms, and the theory of probabilistically checkable proofs (we cite the PCP Theorem without proof). At the end of each chapter there are a number of exercises containing additional results and applications of the material in that chapter. Some exercises which might be more difficult are marked with an asterisk. Each chapter ends with a list of references, including texts recommended for further reading. This book arose from several courses on combinatorial optimization and from special classes on topics like polyhedral combinatorics or approximation algorithms. Thus, material for basic and advanced courses can be selected from this book. We have benefited from discussions and suggestions of many colleagues and friends and – of course – from other texts on this subject. Especially we owe sincere thanks to András Frank, László Lovász, András Recski, Alexander Schrijver and Zoltán Szigeti. Our colleagues and students in Bonn, Christoph Albrecht, Ursula Bünnagel, Thomas Emden-Weinert, Mathias Hauptmann, Sven Peyer, Rabe von Randow, André Rohe, Martin Thimm and Jürgen Werber, have carefully read several versions of the manuscript and helped to improve it. Last, but not least we thank Springer Verlag for the most efficient cooperation. Bonn, January 2000

Bernhard Korte and Jens Vygen

Table of Contents

1

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1 Enumeration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 Running Time of Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.3 Linear Optimization Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.4 Sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2

Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1 Basic Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Trees, Circuits, and Cuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4 Eulerian and Bipartite Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5 Planarity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.6 Planar Duality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

13 13 17 24 31 34 41 43 47

3

Linear Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1 Polyhedra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 The Simplex Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3 Implementation of the Simplex Algorithm . . . . . . . . . . . . . . . . . . . . . 3.4 Duality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5 Convex Hulls and Polytopes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

51 52 56 60 63 67 68 70

4

Linear Programming Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1 Size of Vertices and Faces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 Continued Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3 Gaussian Elimination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4 The Ellipsoid Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5 Khachiyan’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6 Separation and Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

73 73 76 79 82 88 90 97 99 XV

XVI

Table of Contents

5

Integer Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 5.1 The Integer Hull of a Polyhedron . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 5.2 Unimodular Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 5.3 Total Dual Integrality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 5.4 Totally Unimodular Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 5.5 Cutting Planes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 5.6 Lagrangean Relaxation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

6

Spanning Trees and Arborescences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 6.1 Minimum Spanning Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 6.2 Minimum Weight Arborescences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 6.3 Polyhedral Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 6.4 Packing Spanning Trees and Arborescences . . . . . . . . . . . . . . . . . . . . 145 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

7

Shortest Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 7.1 Shortest Paths From One Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 7.2 Shortest Paths Between All Pairs of Vertices . . . . . . . . . . . . . . . . . . . 162 7.3 Minimum Mean Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

8

Network Flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 8.1 Max-Flow-Min-Cut Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 8.2 Menger’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 8.3 The Edmonds-Karp Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 8.4 Dinic’s, Karzanov’s, and Fujishige’s Algorithm . . . . . . . . . . . . . . . . . 182 8.5 The Goldberg-Tarjan Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 8.6 Gomory-Hu Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 8.7 The Minimum Capacity of a Cut in an Undirected Graph . . . . . . . . . 196 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

9

Minimum Cost Flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 9.1 Problem Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 9.2 An Optimality Criterion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 9.3 Minimum Mean Cycle-Cancelling Algorithm . . . . . . . . . . . . . . . . . . 216 9.4 Successive Shortest Path Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 9.5 Orlin’s Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 9.6 The Network Simplex Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 9.7 Flows Over Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237

Table of Contents

XVII

10 Maximum Matchings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 10.1 Bipartite Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 10.2 The Tutte Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 10.3 Tutte’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 10.4 Ear-Decompositions of Factor-Critical Graphs . . . . . . . . . . . . . . . . . . 249 10.5 Edmonds’ Matching Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 11 Weighted Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 11.1 The Assignment Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 11.2 Outline of the Weighted Matching Algorithm . . . . . . . . . . . . . . . . . . . 276 11.3 Implementation of the Weighted Matching Algorithm . . . . . . . . . . . . 279 11.4 Postoptimality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 11.5 The Matching Polytope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 12 b-Matchings and T -Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 12.1 b-Matchings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 12.2 Minimum Weight T -Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 12.3 T -Joins and T -Cuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 12.4 The Padberg-Rao Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 13 Matroids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 13.1 Independence Systems and Matroids . . . . . . . . . . . . . . . . . . . . . . . . . . 321 13.2 Other Matroid Axioms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 13.3 Duality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 13.4 The Greedy Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 13.5 Matroid Intersection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 13.6 Matroid Partitioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 13.7 Weighted Matroid Intersection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 14 Generalizations of Matroids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 14.1 Greedoids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 14.2 Polymatroids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359 14.3 Minimizing Submodular Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 14.4 Schrijver’s Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 14.5 Symmetric Submodular Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374

XVIII

Table of Contents

15 NP-Completeness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377 15.1 Turing Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377 15.2 Church’s Thesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380 15.3 P and NP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 15.4 Cook’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 15.5 Some Basic NP-Complete Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 15.6 The Class coNP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400 15.7 NP-Hard Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410 16 Approximation Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413 16.1 Set Covering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414 16.2 The Max-Cut Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419 16.3 Colouring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425 16.4 Approximation Schemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 16.5 Maximum Satisfiability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 16.6 The PCP Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440 16.7 L-Reductions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454 17 The Knapsack Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459 17.1 Fractional Knapsack and Weighted Median Problem . . . . . . . . . . . . . 459 17.2 A Pseudopolynomial Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462 17.3 A Fully Polynomial Approximation Scheme . . . . . . . . . . . . . . . . . . . 464 17.4 Multi-Dimensional Knapsack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469 18 Bin-Packing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471 18.1 Greedy Heuristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471 18.2 An Asymptotic Approximation Scheme . . . . . . . . . . . . . . . . . . . . . . . 477 18.3 The Karmarkar-Karp Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486 19 Multicommodity Flows and Edge-Disjoint Paths . . . . . . . . . . . . . . . . . . 489 19.1 Multicommodity Flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490 19.2 Algorithms for Multicommodity Flows . . . . . . . . . . . . . . . . . . . . . . . . 494 19.3 Sparsest Cut and Max-Flow Min-Cut Ratio . . . . . . . . . . . . . . . . . . . . 499 19.4 The Leighton-Rao Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500 19.5 Directed Edge-Disjoint Paths Problem . . . . . . . . . . . . . . . . . . . . . . . . 503 19.6 Undirected Edge-Disjoint Paths Problem . . . . . . . . . . . . . . . . . . . . . . 507 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517

Table of Contents

XIX

20 Network Design Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521 20.1 Steiner Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522 20.2 The Robins-Zelikovsky Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527 20.3 Survivable Network Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532 20.4 A Primal-Dual Approximation Algorithm . . . . . . . . . . . . . . . . . . . . . . 536 20.5 Jain’s Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553 21 The Traveling Salesman Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557 21.1 Approximation Algorithms for the TSP . . . . . . . . . . . . . . . . . . . . . . . . 557 21.2 Euclidean TSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562 21.3 Local Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569 21.4 The Traveling Salesman Polytope . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575 21.5 Lower Bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581 21.6 Branch-and-Bound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589 22 Facility Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593 22.1 The Uncapacitated Facility Location Problem . . . . . . . . . . . . . . . . . . 593 22.2 Rounding Linear Programming Solutions . . . . . . . . . . . . . . . . . . . . . . 595 22.3 Primal-Dual Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597 22.4 Scaling and Greedy Augmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603 22.5 Bounding the Number of Facilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606 22.6 Local Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609 22.7 Capacitated Facility Location Problems . . . . . . . . . . . . . . . . . . . . . . . . 615 22.8 Universal Facility Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626 Notation Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629 Author Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633 Subject Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645

1 Introduction

Let us start with two examples. A company has a machine which drills holes into printed circuit boards. Since it produces many of these boards it wants the machine to complete one board as fast as possible. We cannot optimize the drilling time but we can try to minimize the time the machine needs to move from one point to another. Usually drilling machines can move in two directions: the table moves horizontally while the drilling arm moves vertically. Since both movements can be done simultaneously, the time needed to adjust the machine from one position to another is proportional to the maximum of the horizontal and the vertical distance. This is often called the `1 -distance. (Older machines can only move either horizontally or vertically at a time; in this case the adjusting time is proportional to the `1 -distance, the sum of the horizontal and the vertical distance.) An optimum drilling path is given by an ordering of the hole positions Pn1 p1 ; : : : ; pn such that i D1 d.pi ; pi C1 / is minimum, where d is the `1 distance: for two points p D .x; y/ and p 0 D .x 0 ; y 0 / in the plane we write d.p; p 0 / WD maxfjx x 0 j; jy y 0 jg. An order of the holes can be represented by a permutation, i.e. a bijection W f1; : : : ; ng ! f1; : : : ; ng. Which permutation is best of course depends on the hole positions; for each list of hole positions we have a different problem instance. We say that one instance of our problem is a list of points in the plane, i.e. the coordinates of the holes to be drilled. Then the problem can be stated formally as follows:

DRILLING PROBLEM Instance:

A set of points p1 ; : : : ; pn 2 R2 .

Task:

Find Pn1a permutation W f1; : : : ; ng ! f1; : : : ; ng such that i D1 d.p.i / ; p.i C1/ / is minimum.

We now explain our second example. We have a set of jobs to be done, each having a specified processing time. Each job can be done by a subset of the employees, and we assume that all employees who can do a job are equally efficient. Several employees can contribute to the same job at the same time, and one employee can contribute to several jobs (but not at the same time). The objective is to get all jobs done as early as possible.

B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__1, c Springer-Verlag Berlin Heidelberg 2012

1

2

1 Introduction

In this model it suffices to prescribe for each employee how long he or she should work on which job. The order in which the employees carry out their jobs is not important, since the time when all jobs are done obviously depends only on the maximum total working time we have assigned to one employee. Hence we have to solve the following problem:

JOB ASSIGNMENT PROBLEM Instance:

Task:

A set of numbers t1 ; : : : ; tn 2 RC (the processing times for n jobs), a number m 2 N of employees, and a nonempty subset Si f1; : : : ; mg of employees for each job i 2 f1; : : : ; ng. Find P numbers xij 2 RC for all i D 1; : : : ; n and j 2PSi such that j 2Si xij D ti for i D 1; : : : ; n and maxj 2f1;:::;mg i Wj 2Si xij is minimum.

These are two typical problems arising in combinatorial optimization. How to model a practical problem as an abstract combinatorial optimization problem is not described in this book; indeed there is no general recipe for this task. Besides giving a precise formulation of the input and the desired output it is often important to ignore irrelevant components (e.g. the drilling time which cannot be optimized or the order in which the employees carry out their jobs). Of course we are not interested in a solution to a particular drilling problem or job assignment problem in some company, but rather we are looking for a way how to solve all problems of these types. We first consider the DRILLING PROBLEM.

1.1 Enumeration How can a solution to the DRILLING PROBLEM look like? There are infinitely many instances (finite sets of points in the plane), so we cannot list an optimum permutation for each instance. Instead, what we look for is an algorithm which, given an instance, computes an optimum solution. Such an algorithm exists: Given a set of n points, just try all possible nŠ orders, and for each compute the `1 -length of the corresponding path. There are different ways of formulating an algorithm, differing mostly in the level of detail and the formal language they use. We certainly would not accept the following as an algorithm: “Given a set of n points, find an optimum path and output it.” It is not specified at all how to find the optimum solution. The above suggestion to enumerate all possible nŠ orders is more useful, but still it is not clear how to enumerate all the orders. Here is one possible way: We enumerate all n-tuples of numbers 1; : : : ; n, i.e. all nn vectors of f1; : : : ; ngn . This can be done similarly to counting: we start with .1; : : : ; 1; 1/, .1; : : : ; 1; 2/ up to .1; : : : ; 1; n/ then switch to .1; : : : ; 1; 2; 1/, and so on. At each step we increment the last entry unless it is already n, in which case we go back to the last entry that is smaller than n, increment it and set all subsequent entries to 1. This technique is

1.1

Enumeration

3

sometimes called backtracking. The order in which the vectors of f1; : : : ; ngn are enumerated is called the lexicographical order: Definition 1.1. Let x; y 2 Rn be two vectors. We say that a vector x is lexicographically smaller than y if there exists an index j 2 f1; : : : ; ng such that xi D yi for i D 1; : : : ; j 1 and xj < yj . Knowing how to enumerate all vectors of f1; : : : ; ngn we can simply check for each vector whether its entries are pairwise distinct and, if so, whether the path represented by this vector is shorter than the best path encountered so far. Since this algorithm enumerates nn vectors it will take at least nn steps (in fact, even more). This is not best possible. There are only nŠ permutations of f1; p: : : ; ng, n and nŠ is significantly smaller than nn . (By Stirling’s formula nŠ 2 n nen (Stirling [1730]); see Exercise 1.) We shall show how to enumerate all paths in approximately n2 nŠ steps. Consider the following algorithm which enumerates all permutations in lexicographical order:

PATH ENUMERATION ALGORITHM Input:

A natural number n 3. A set fp1 ; : : : ; pn g of points in the plane.

Output:

A permutation Pn1W f1; : : : ; ng ! f1; : : : ; ng with cost. / WD i D1 d.p .i / ; p .i C1/ / minimum.

1

Set .i / WD i and .i / WD i for i D 1; : : : ; n. Set i WD n 1.

2

Let k WD min.f.i / C 1; : : : ; n C 1g n f.1/; : : : ; .i 1/g/.

3

If k n then: Set .i / WD k. If i D n and cost./ < cost. / then set WD . If i < n then set .i C 1/ WD 0 and i WD i C 1. If k D n C 1 then set i WD i 1. If i 1 then go to . 2

Starting with ..i //i D1;:::;n D .1; 2; 3; : : : ; n1; n/ and i D n1, the algorithm finds at each step the next possible value of .i / (not using .1/; : : : ; .i 1/). If there is no more possibility for .i / (i.e. k D n C 1), then the algorithm decrements i (backtracking). Otherwise it sets .i / to the new value. If i D n, the new permutation is evaluated, otherwise the algorithm will try all possible values for .i C 1/; : : : ; .n/ and starts by setting .i C 1/ WD 0 and incrementing i . So all permutation vectors ..1/; : : : ; .n// are generated in lexicographical order. For example, the first iterations in the case n D 6 are shown below:

4

1 Introduction

k k k k k k k

WD 6, WD 5, WD 7, WD 7, WD 5, WD 4, WD 6,

WD .1; 2; 3; 4; 5; 6/, i WD 5 WD .1; 2; 3; 4; 6; 0/, i WD 6 WD .1; 2; 3; 4; 6; 5/, cost./ < cost. /? i WD 5 i WD 4 WD .1; 2; 3; 5; 0; 5/, i WD 5 WD .1; 2; 3; 5; 4; 0/, i WD 6 WD .1; 2; 3; 5; 4; 6/, cost./ < cost. /?

Since the algorithm compares the cost of each path to , the best path encountered so far, it indeed outputs the optimum path. But how many steps will this algorithm perform? Of course, the answer depends on what we call a single step. Since we do not want the number of steps to depend on the actual implementation we ignore constant factors. On any reasonable computer, 1 will take at least 2n C 1 steps (this many variable assignments are done) and at most cn steps for some constant c. The following common notation is useful for ignoring constant factors: Definition 1.2. Let f; g W D ! RC be two functions. We say that f is O.g/ (and sometimes write f D O.g/, and also g D .f /) if there exist constants ˛; ˇ > 0 such that f .x/ ˛g.x/ C ˇ for all x 2 D. If f D O.g/ and g D O.f / we also say that f D ‚.g/ (and of course g D ‚.f /). In this case, f and g have the same rate of growth. Note that the use of the equation sign in the O-notation is not symmetric. To illustrate this definition, let D D N, and let f .n/ be the number of elementary steps in 1 and g.n/ D n (n 2 N). Clearly we have f D O.g/ (in fact f D ‚.g/) in this case; we say that 1 takes O.n/ time (or linear time). A single execution of 3 takes a constant number of steps (we speak of O.1/ time or constant time) except in the case k n and i D n; in this case the cost of two paths have to be compared, which takes O.n/ time. What about ? 2 A naive implementation, checking for each j 2 f.i / C 1; : : : ; ng and each h 2 f1; : : : ; i 1g whether j D .h/, takes O..n .i //i / steps, which can be as big as ‚.n2 /. A better implementation of 2 uses an auxiliary array indexed by 1; : : : ; n: For j WD 1 to n do aux.j / WD 0. For j WD 1 to i 1 do aux..j // WD 1. Set k WD .i / C 1. While k n and aux.k/ D 1 do k WD k C 1. Obviously with this implementation a single execution of 2 takes only O.n/ time. Simple techniques like this are usually not elaborated in this book; we assume that the reader can find such implementations himself or herself. Having computed the running time for each single step we now estimate the total amount of work. Since the number of permutations is nŠ we only have to estimate the amount of work which is done between two permutations. The counter i might move back from n to some index i 0 where a new value .i 0 / n is found. Then it moves forward again up to i D n. While the counter i is constant each of 2 and 3 2

1.2

Running Time of Algorithms

5

is performed once, except in the case k n and i D n; in this case 2 and 3 are performed twice. So the total amount of work between two permutations consists of at most 4n times 2 and , 3 i.e. O.n2 /. So the overall running time of the PATH ENUMERATION ALGORITHM is O.n2 nŠ/. One can do slightly better; a more careful analysis shows that the running time is only O.n nŠ/ (Exercise 4). Still the algorithm is too time-consuming if n is large. The problem with the enumeration of all paths is that the number of paths grows exponentially with the number of points; already for 20 points there are 20Š D 2432902008176640000 2:4 1018 different paths and even the fastest computer needs several years to evaluate all of them. So complete enumeration is impossible even for instances of moderate size. The main subject of combinatorial optimization is to find better algorithms for problems like this. Often one has to find the best element of some finite set of feasible solutions (in our example: drilling paths or permutations). This set is not listed explicitly but implicitly depends on the structure of the problem. Therefore an algorithm must exploit this structure. In the case of the DRILLING PROBLEM all information of an instance with n points is given by 2n coordinates. While the naive algorithm enumerates all nŠ paths it might be possible that there is an algorithm which finds the optimum path much faster, say in n2 computation steps. It is not known whether such an algorithm exists (though results of Chapter 15 suggest that it is unlikely). Nevertheless there are much better algorithms than the naive one.

1.2 Running Time of Algorithms One can give a formal definition of an algorithm, and we shall in fact give one in Section 15.1. However, such formal models lead to very long and tedious descriptions as soon as algorithms are a bit more complicated. This is quite similar to mathematical proofs: Although the concept of a proof can be formalized nobody uses such a formalism for writing down proofs since they would become very long and almost unreadable. Therefore all algorithms in this book are written in an informal language. Still the level of detail should allow a reader with a little experience to implement the algorithms on any computer without too much additional effort. Since we are not interested in constant factors when measuring running times we do not have to fix a concrete computing model. We count elementary steps, but we are not really interested in how elementary steps look like. Examples of elementary steps are variable assignments, random access to a variable whose index is stored in another variable, conditional jumps (if – then – go to), and simple arithmetic operations like addition, subtraction, multiplication, division and comparison of numbers. An algorithm consists of a set of valid inputs and a sequence of instructions each of which can be composed of elementary steps, such that for each valid input the

6

1 Introduction

computation of the algorithm is a uniquely defined finite series of elementary steps which produces a certain output. Usually we are not satisfied with finite computation but rather want a good upper bound on the number of elementary steps performed, depending on the input size. The input to an algorithm usually consists of a list of numbers. If all these numbers are integers, we can code them in binary representation, using O.log.jaj C 2// bits for storing an integer a. Rational numbers can be stored by coding the numerator and the denominator separately. The input size size.x/ of an instance x with rational data is the total number of bits needed for the binary representation. Definition 1.3. Let A be an algorithm which accepts inputs from a set X , and let f W N ! RC . If there exist constants ˛; ˇ > 0 such that A terminates its computation after at most ˛f .size.x// C ˇ elementary steps (including arithmetic operations) for each input x 2 X , then we say that A runs in O.f / time. We also say that the running time (or the time complexity) of A is O.f /. Definition 1.4. An algorithm with rational input is said to run in polynomial time if there is an integer k such that it runs in O.nk / time, where n is the input size, and all numbers in intermediate computations can be stored with O.nk / bits. An algorithm with arbitrary input is said to run in strongly polynomial time if there is an integer k such that it runs in O.nk / time for any input consisting of n numbers and it runs in polynomial time for rational input. In the case k D 1 we have a linear-time algorithm. An algorithm which runs in polynomial but not strongly polynomial time is called weakly polynomial. Note that the running time might be different for several instances of the same size (this was not the case with the PATH ENUMERATION ALGORITHM). We consider the worst-case running time, i.e. the function f W N ! N where f .n/ is the maximum running time of an instance with input size n. For some algorithms we do not know the rate of growth of f but only have an upper bound. The worst-case running time might be a pessimistic measure if the worst case occurs rarely. In some cases an average-case running time with some probabilistic model might be appropriate, but we shall not consider this. If A is an algorithm which for each input x 2 X computes the output f .x/2Y , then we say that A computes f W X ! Y . If a function is computed by some polynomial-time algorithm, it is said to be computable in polynomial time. Polynomial-time algorithms are sometimes called “good” or “efficient”. This concept was introduced by Cobham [1964] and Edmonds [1965]. Table 1.1 motivates this by showing hypothetical running times of algorithms with various time complexities. For various input sizes n we show the running time of algorithms that take 100n log n, 10n2 , n3:5 , nlog n , 2n , and nŠ elementary steps; we assume that one elementary step takes one nanosecond. As always in this book, log denotes the logarithm with basis 2.

1.2

Running Time of Algorithms

7

Table 1.1. n 10 20 30 40 50 60 80 100 200 500 1000 104 105 106 107 108 1010 1012

100n log n

10n2

n3:5

nlog n

2n

nŠ

3 s 9 s 15 s 21 s 28 s 35 s 50 s 66 s 153 s 448 s 1 ms 13 ms 166 ms 2s 23 s 266 s 9 hours 46 days

1 s 4 s 9 s 16 s 25 s 36 s 64 s 100 s 400 s 2.5 ms 10 ms 1s 100 s 3 hours 12 days 3 years 3 104 y. 3 108 y.

3 s 36 s 148 s 404 s 884 s 2 ms 5 ms 10 ms 113 ms 3s 32 s 28 hours 10 years 3169 y. 107 y. 3 1010 y.

2 s 420 s 20 ms 340 ms 4s 32 s 1075 s 5 hours 12 years 5 105 y. 3 1013 y.

1 s 1 ms 1s 1100 s 13 days 37 years 4 107 y. 4 1013 y.

4 ms 76 years 8 1015 y.

As Table 1.1 shows, polynomial-time algorithms are faster for large enough instances. The table also illustrates that constant factors of moderate size are not very important when considering the asymptotic growth of the running time. Table 1.2 shows the maximum input sizes solvable within one hour with the above six hypothetical algorithms. In (a) we again assume that one elementary step takes one nanosecond, (b) shows the corresponding figures for a ten times faster machine. Polynomial-time algorithms can handle larger instances in reasonable time. Moreover, even a speedup by a factor of 10 of the computers does not increase the size of solvable instances significantly for exponential-time algorithms, but it does for polynomial-time algorithms. Table 1.2. 100n log n

10n2

n3:5

nlog n

2n

nŠ

(a)

1:19

109

60000

3868

87

41

15

(b)

10:8 109

189737

7468

104

45

16

8

1 Introduction

(Strongly) polynomial-time algorithms, if possible linear-time algorithms, are what we look for. There are some problems where it is known that no polynomialtime algorithm exists, and there are problems for which no algorithm exists at all. (For example, a problem which can be solved in finite time but not in polynomial time is to decide whether a so-called regular expression defines the empty set; see Aho, Hopcroft and Ullman [1974]. A problem for which there exists no algorithm at all, the HALTING PROBLEM, is discussed in Exercise 1 of Chapter 15.) However, almost all problems considered in this book belong to the following two classes. For the problems of the first class we have a polynomial-time algorithm. For each problem of the second class it is an open question whether a polynomial-time algorithm exists. However, we know that if one of these problems has a polynomial-time algorithm, then all problems of this class do. A precise formulation and a proof of this statement will be given in Chapter 15. The JOB ASSIGNMENT PROBLEM belongs to the first class, the DRILLING PROBLEM belongs to the second class. These two classes of problems divide this book roughly into two parts. We first deal with tractable problems for which polynomial-time algorithms are known. Then, starting with Chapter 15, we discuss hard problems. Although no polynomialtime algorithms are known, there are often much better methods than complete enumeration. Moreover, for many problems (including the DRILLING PROBLEM), one can find approximate solutions within a certain percentage of the optimum in polynomial time.

1.3 Linear Optimization Problems We now consider our second example given initially, the JOB ASSIGNMENT PROBLEM, and briefly address some central topics which will be discussed in later chapters. The JOB ASSIGNMENT PROBLEM is quite different to the DRILLING PROBLEM since there are infinitely many feasible solutions for each instance (except for trivial cases). We can reformulate the problem by introducing a variable T for the time when all jobs are done: min T s.t.

X

xij D ti

.i 2 f1; : : : ; ng/

xij 0 xij T

.i 2 f1; : : : ; ng; j 2 Si / .j 2 f1; : : : ; mg/

(1.1)

j 2Si

X i Wj 2Si

The numbers ti and the sets Si (i D 1; : : : ; n) are given, the variables xij and T are what we look for. Such an optimization problem with a linear objective function

1.4

Sorting

9

and linear constraints is called a linear program. The set of feasible solutions of (1.1), a so-called polyhedron, is easily seen to be convex, and one can prove that there always exists an optimum solution which is one of the finitely many extreme points of this set. Therefore a linear program can, theoretically, also be solved by complete enumeration. But there are much better ways as we shall see later. Although there are several algorithms for solving linear programs in general, such general techniques are usually less efficient than special algorithms exploiting the structure of the problem. In our case it is convenient to model the sets Si , i D 1; : : : ; n, by a graph. For each job i and for each employee j we have a point (called vertex), and we connect employee j with job i by an edge if he or she can contribute to this job (i.e. if j 2 Si ). Graphs are a fundamental combinatorial structure; many combinatorial optimization problems are described most naturally in terms of graph theory. Suppose for a moment that the processing time of each job is one hour, and we ask whether we can finish all jobs within one hour. So we look Pfor numbers xij (i 2 f1; : : : ; ng, j P 2 Si ) such that 0 xij 1 for all i and j , j 2Si xij D 1 for i D 1; : : : ; n, and i Wj 2Si xij 1 for j D 1; : : : ; n. One can show that if such a solution exists, then in fact an integral solution exists, i.e. all xij are either 0 or 1. This is equivalent to assigning each job to one employee, such that no employee has to do more than one job. In the language of graph theory we then look for a matching covering all jobs. The problem of finding optimal matchings is one of the best-known combinatorial optimization problems. We review the basics of graph theory and linear programming in Chapters 2 and 3. In Chapter 4 we prove that linear programs can be solved in polynomial time, and in Chapter 5 we discuss integral polyhedra. In the subsequent chapters we discuss some classical combinatorial optimization problems in detail.

1.4 Sorting Let us conclude this chapter by considering a special case of the DRILLING PROBLEM where all holes to be drilled are on one horizontal line. So we are given just one coordinate for each point pi , i D 1; : : : ; n. Then a solution to the drilling problem is easy, all we have to do is sort the points by their coordinates: the drill will just move from left to right. Although there are still nŠ permutations, it is clear that we do not have to consider all of them to find the optimum drilling path, i.e. the sorted list. It is very easy to sort n numbers in nondecreasing order in O.n2 / time. To sort n numbers in O.n log n/ time requires a little more skill. There are several algorithms accomplishing this; we present the well-known MERGE-SORT ALGORITHM. It proceeds as follows. First the list is divided into two sublists of approximately equal size. Then each sublist is sorted (this is done recursively by the same algorithm). Finally the two sorted sublists are merged together. This general strategy, often called “divide and conquer”, can be used quite often. See e.g. Section 17.1 for another example.

10

1 Introduction

We did not discuss recursive algorithms so far. In fact, it is not necessary to discuss them, since any recursive algorithm can be transformed into a sequential algorithm without increasing the running time. But some algorithms are easier to formulate (and implement) using recursion, so we shall use recursion when it is convenient.

MERGE-SORT ALGORITHM Input:

A list a1 ; : : : ; an of real numbers.

Output:

A permutation W f1; : : : ; ng ! f1; : : : ; ng such that a.i / a.i C1/ for all i D 1; : : : ; n 1.

1 2

3

If n D 1 then set .1/ WD 1 and stop (return ). ˘ Set m WD n2 . Let WDMERGE-SORT(a1 ; : : : ; am ). Let WDMERGE-SORT(amC1 ; : : : ; an ). Set k WD 1, l WD 1. While k m and l n m do: If a.k/ amC.l/ then set .k C l 1/ WD .k/ and k WD k C 1 else set .k C l 1/ WD m C .l/ and l WD l C 1. While k m do: Set .k C l 1/ WD .k/ and k WD k C 1. While l n m do: Set .k C l 1/ WD m C .l/ and l WD l C 1.

As an example, consider the list “69,32,56,75,43,99,28”. The algorithm first splits this list into two, “69,32,56” and “75,43,99,28” and recursively sorts each of the two sublists. We get the permutations D .2; 3; 1/ and D .4; 2; 1; 3/ corresponding to the sorted lists “32,56,69” and “28,43,75,99”. Now these lists are merged as shown below: k WD 1; l WD 1 .1/ D 2; .1/ D 4; a.1/ D 32; a.1/ D 28; .1/ WD 7; l WD 2 .1/ D 2; .2/ D 2; a.1/ D 32; a.2/ D 43; .2/ WD 2; k WD 2 .2/ D 3; .2/ D 2; a.2/ D 56; a.2/ D 43; .3/ WD 5; l WD 3 .2/ D 3; .3/ D 1; a.2/ D 56; a.3/ D 75; .4/ WD 3; k WD 3 .3/ D 1; .3/ D 1; a.3/ D 69; a.3/ D 75; .5/ WD 1; k WD 4 .3/ D 1; a.3/ D 75; .6/ WD 4; l WD 4 .4/ D 3; a.4/ D 99; .7/ WD 6; l WD 5 Theorem 1.5. The MERGE-SORT ALGORITHM works correctly and runs in O.n log n/ time. Proof: The correctness is obvious. We denote by T .n/ the running time (number of steps) needed for instances consisting of n numbers and observe that T .1/ D 1 and T .n/ D T .b n2 c/ C T .d n2 e/ C 3n C 6. (The constants in the term 3n C 6 depend on how exactly a computation step is defined; but they do not really matter.)

Exercises

11

We claim that this yields T .n/ 12n log nC1. Since this is trivial for n D 1 we proceed by induction. For n 2, assuming that the inequality is true for 1; : : : ; n1, we get jnk lnm 2 2 T .n/ 12 log n C 1 C 12 log n C 1 C 3n C 6 2 3 2 3 D 12n.log n C 1 log 3/ C 3n C 8 13 12n log n n C 3n C 8 12n log n C 1; 2 because log 3

37 . 24

Of course the algorithm works for sorting the elements of any totally ordered set, assuming that we can compare any two elements in constant time. Can there be a faster, a linear-time algorithm? Suppose that the only way we can get information on the unknown order is to compare two elements. Then we can show that any algorithm needs at least ‚.n log n/ comparisons in the worst case. The outcome of a comparison can be regarded as a zero or one; the outcome of all comparisons an algorithm does is a 0-1-string (a sequence of zeros and ones). Note that two different orders in the input of the algorithm must lead to two different 0-1-strings (otherwise the algorithm could not distinguish between the two orders). For an input of n elements there are nŠ possible orders, so there must be nŠ different 0-1-strings corresponding to the computation. Since the number of 0-1-strings with length less ˘ n n n n n than n2 log n2 is 2b 2 log 2 c 1 < 2 2 log 2 D . n2 / 2 nŠ we conclude that the maximum length of the 0-1-strings, and hence of the computation, must be at least n log n2 D ‚.n log n/. 2 In the above sense, the running time of the MERGE-SORT ALGORITHM is optimal up to a constant factor. However, there is an algorithm for sorting integers (or sorting strings lexicographically) whose running time is linear in the input size; see Exercise 8. An algorithm to sort n integers in O.n log log n/ time was proposed by Han [2004]. Lower bounds like the one above are known only for very few problems (except trivial linear bounds). Often a restriction on the set of operations is necessary to derive a superlinear lower bound.

Exercises 1. Prove that for all n 2 N: e

n n e

nŠ e n

Hint: Use 1 C x e x for all x 2 R. 2. Prove that log.nŠ/ D ‚.n log n/. 3. Prove that n log n D O.n1C / for any > 0.

n n e

:

12

1 Introduction

4. Show that the running time of the PATH ENUMERATION ALGORITHM is O.n nŠ/. 5. Show that there is a polynomial-time algorithm for the DRILLING PROBLEM where d is the `1 -distance if and only if there is one for `1 -distance. Note: Both is unlikely as the problems were proved to be NP-hard (this will be explained in Chapter 15) by Garey, Graham and Johnson [1976]. 6. Suppose we have an algorithm whose running time is ‚.n.t C n1=t //, where n is the input length and t is a positive parameter we can choose arbitrarily. How should t be chosen (depending on n) such that the running time (as a function of n) has a minimum rate of growth? 7. Let s; t be binary strings, both of length m. We say that s is lexicographically smaller than t if there exists an index j 2 f1; : : : ; mg such that si D ti for i D 1; : : : ; j 1 and sj < tj . Now given n strings of length m, we want to sort them lexicographically. Prove that there is a linear-time algorithm for this problem (i.e. one with running time O.nm/). Hint: Group the strings according to the first bit and sort each group. 8. Describe an algorithm which sorts a list of natural numbers a1 ; : : : ; an in linear time; i.e. which finds a permutation with a.i / a.i C1/ (i D 1; : : : ; n 1) and runs in O.log.a1 C 1/ C C log.an C 1// time. Hint: First sort the strings encoding the numbers according to their length. Then apply the algorithm of Exercise 7. Note: The algorithm discussed in this and the previous exercise is often called radix sorting.

References General Literature: Cormen, T.H., Leiserson, C.E., Rivest, R.L., and Stein, C. [2001]: Introduction to Algorithms. Second Edition. MIT Press, Cambridge 2001 Knuth, D.E. [1968]: The Art of Computer Programming; Vol. 1. Fundamental Algorithms. Addison-Wesley, Reading 1968 (third edition: 1997)

Cited References: Aho, A.V., Hopcroft, J.E., and Ullman, J.D. [1974]: The Design and Analysis of Computer Algorithms. Addison-Wesley, Reading 1974 Cobham, A. [1964]: The intrinsic computational difficulty of functions. Proceedings of the 1964 Congress for Logic Methodology and Philosophy of Science (Y. Bar-Hillel, ed.), North-Holland, Amsterdam 1964, pp. 24–30 Edmonds, J. [1965]: Paths, trees, and flowers. Canadian Journal of Mathematics 17 (1965), 449–467 Garey, M.R., Graham, R.L., and Johnson, D.S. [1976]: Some NP-complete geometric problems. Proceedings of the 8th Annual ACM Symposium on the Theory of Computing (1976), 10–22 Han, Y. [2004]: Deterministic sorting in O.n log log n/ time and linear space. Journal of Algorithms 50 (2004), 96–105 Stirling, J. [1730]: Methodus Differentialis. London 1730

2 Graphs

Graphs are a fundamental combinatorial structure used throughout this book. In this chapter we not only review the standard definitions and notation, but also prove some basic theorems and mention some fundamental algorithms. After some basic definitions in Section 2.1 we consider fundamental objects occurring very often in this book: trees, circuits, and cuts. We prove some important properties and relations, and we also consider tree-like set systems in Section 2.2. The first graph algorithms, determining connected and strongly connected components, appear in Section 2.3. In Section 2.4 we prove Euler’s Theorem on closed walks using every edge exactly once. Finally, in Sections 2.5 and 2.6 we consider graphs that can be drawn in the plane without crossings.

2.1 Basic Definitions An undirected graph is a triple .V; E; ‰/, where V and E are finite sets and ‰ W E ! fX V W jX j D 2g. A directed graph or digraph is a triple .V; E; ‰/, where V and E are finite sets and ‰ W E ! f.v; w/ 2 V V W v 6D wg. By a graph we mean either an undirected graph or a digraph. The elements of V are called vertices, the elements of E are the edges. Edges e; e 0 with e 6D e 0 and ‰.e/ D ‰.e 0 / are called parallel. Graphs without parallel edges are called simple. For simple graphs we usually identify an edge e with its image ‰.e/ and write G D .V .G/; E.G//, where E.G/ fX V .G/ W jX j D 2g or E.G/ V .G/ V .G/. We often use this simpler notation even in the presence of parallel edges, then the “set” E.G/ may contain several “identical” elements. jE.G/j denotes the number of edges, and for two edge sets E and F we : always have jE [ F j D jEj C jF j even if parallel edges arise. We write e D fv; wg or e D .v; w/ for each edge e with ‰.e/ D fv; wg or ‰.e/ D .v; w/, respectively. We say that an edge e D fv; wg or e D .v; w/ joins v and w. In this case, v and w are adjacent. v is a neighbour of w (and vice versa). v and w are the endpoints of e. If v is an endpoint of an edge e, we say that v is incident with e. In the directed case we say that e D .v; w/ leaves v (the tail of e) and enters w (the head of e). Two edges which share at least one endpoint are called adjacent. This terminology for graphs is not the only one. Sometimes vertices are called nodes or points, other names for edges are arcs (especially in the directed case) or B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__2, c Springer-Verlag Berlin Heidelberg 2012

13

14

2 Graphs

lines. In some texts, a graph is what we call a simple undirected graph, in the presence of parallel edges they speak of multigraphs. Sometimes edges whose endpoints coincide, so-called loops, are considered. However, unless otherwise stated, we do not use them. For a digraph G we sometimes consider the underlying undirected graph, i.e. the undirected graph G 0 on the same vertex set which contains an edge fv; wg for each edge .v; w/ of G (so jE.G 0 /j D jE.G/j). We also say that G is an orientation of G 0 . A subgraph of a graph G D .V .G/; E.G// is a graph H D .V .H /; E.H // with V .H / V .G/ and E.H / E.G/. We also say that G contains H . H is an induced subgraph of G if it is a subgraph of G and E.H / D ffx; yg 2 E.G/ W x; y 2 V .H /g or E.H / D f.x; y/ 2 E.G/ W x; y 2 V .H /g. Here H is the subgraph of G induced by V .H /. We also write H D GŒV .H /. A subgraph H of G is called spanning if V .H / D V .G/. If v 2 V .G/, we write G v for the subgraph of G induced by V .G/ n fvg. If e 2 E.G/, we define G e WD .V .G/; E.G/ n feg/. We also use this notation for deleting a set X of vertices or edges and write G X . Furthermore, the addition of : a new edge e is abbreviated by G C e WD .V .G/; E.G/ [ feg/. If G and H are two graphs, we denote by G C H the graph with V .G C H / D V .G/ [ V .H / and E.G C H / being the disjoint union of E.G/ and E.H / (parallel edges may arise). A family of graphs is called vertex-disjoint or edge-disjoint if their vertex sets or edge sets are pairwise disjoint, respectively. Two graphs G and H are called isomorphic if there are bijections ˆV W V .G/ ! V .H / and ˆE W E.G/ ! E.H / such that ˆE ..v; w// D .ˆV .v/; ˆV .w// for all .v; w/ 2 E.G/, or ˆE .fv; wg/ D fˆV .v/; ˆV .w/g for all fv; wg 2 E.G/ in the undirected case. We normally do not distinguish between isomorphic graphs; for example we say that G contains H if G has a subgraph isomorphic to H . Suppose we have an undirected graph G and X V .G/. By contracting (or shrinking) X we mean deleting the vertices in X and the edges in GŒX , adding a new vertex x and replacing each edge fv; wg with v 2 X , w … X by an edge fx; wg (parallel edges may arise). Similarly for digraphs. We often call the result G=X . For a graph G and X; Y V .G/ we define E.X; Y / WD ffx; yg 2 E.G/ W x 2 X n Y; y 2 Y n X g if G is undirected and E C .X; Y / WD f.x; y/ 2 E.G/ W x 2 X n Y; y 2 Y n X g if G is directed. For undirected graphs G and X V .G/ we define ı.X / WD E.X; V .G/ n X /. The set of neighbours of X is defined by .X / WD fv 2 V .G/ n X W E.X; fvg/ 6D ;g. For digraphs G and X V .G/ we define ı C .X / WD E C .X; V .G/ n X /, ı .X / WD ı C .V .G/ n X / and ı.X / WD ı C .X /[ı .X /. We use subscripts (e.g. ıG .X /) to specify the graph G if necessary. For singletons, i.e. one-element vertex sets fvg (v 2 V .G/) we write ı.v/ WD ı.fvg/, .v/ WD .fvg/, ı C .v/ WD ı C .fvg/ and ı .v/ WD ı .fvg/. The degree of a vertex v is jı.v/j, the number of edges incident to v. In the directed case, the in-degree is jı .v/j, the out-degree is jı C .v/j, and the degree is jı C .v/j C jı .v/j.

2.1

Basic Definitions

15

A vertex with degree zero is called isolated. A graph where all vertices have degree k is called k-regular. P For any graph, v2V .G/ jı.v/j D 2jE.G/j. In particular, the number of vertices P P with odd degree is even. In a digraph, v2V .G/ jı C .v/j D v2V .G/ jı .v/j. To prove these statements, please observe that each edge is counted twice on each side of the first equation and once on each side of the second equation. With just a little more effort we get the following useful statements: Lemma 2.1. For a digraph G and any two sets X; Y V .G/: (a) jı C .X /jCjı C .Y /j D jı C .X \Y /jCjı C .X [Y /jCjE C .X; Y /jCjE C .Y; X /j; (b) jı .X /jCjı .Y /j D jı .X \Y /jCjı .X [Y /jCjE C .X; Y /jCjE C .Y; X /j. For an undirected graph G and any two sets X; Y V .G/: (c) jı.X /j C jı.Y /j D jı.X \ Y /j C jı.X [ Y /j C 2jE.X; Y /j; (d) jı.X /j C jı.Y /j D jı.X n Y /j C jı.Y n X /j C 2jE.X \ Y; V .G/ n .X [ Y //j; (e) j.X /j C j.Y /j j.X \ Y /j C j.X [ Y /j. Proof: All parts can be proved by simple counting arguments. Let Z WD V .G/ n .X [ Y /. To prove (a), observe that jı C .X /jCjı C .Y /j D jE C .X; Z/jCjE C .X; Y nX /jC C jE .Y; Z/j C jE C .Y; X n Y /j D jE C .X [ Y; Z/j C jE C.X \ Y; Z/j C jE C.X; Y n X /j C jE C .Y; X n Y /j D jı C .X [ Y /j C jı C .X \ Y /j C jE C .X; Y /j C jE C .Y; X /j. (b) follows from (a) by reversing each edge (replace .v; w/ by .w; v/). (c) follows from (a) by replacing each edge fv; wg by a pair of oppositely directed edges .v; w/ and .w; v/. Substituting Y by V .G/ n Y in (c) yields (d). To show (e), observe that j.X /j C j.Y /j D j.X [ Y /j C j.X / \ .Y /j C j.X / \ Y j C j.Y / \ X j j.X [ Y /j C j.X \ Y /j. A function f W 2U ! R (where U is some finite set and 2U denotes its power set) is called submodular if f .X \ Y / C f .X [ Y / f .X / C f .Y / for all X; Y U ; supermodular if f .X \ Y / C f .X [ Y / f .X / C f .Y / for all X; Y U ; modular if f .X \ Y / C f .X [ Y / D f .X / C f .Y / for all X; Y U . So Lemma 2.1 implies that jı C j, jı j, jıj and jj are submodular. This will be useful later. A complete graph is a simple undirected graph where each pair of vertices is adjacent. We denote the complete graph on n vertices by Kn . The complement of a simple undirected graph G is the graph H for which V .G/ D V .H / and G C H is a complete graph. A matching in an undirected graph G is a set of pairwise disjoint edges (i.e. the endpoints are all different). A vertex cover in G is a set S V .G/ of vertices such that every edge of G is incident to at least one vertex in S . An edge cover in G is a set F E.G/ of edges such that every vertex of G is incident to at least one edge in F . A stable set in G is a set of pairwise non-adjacent vertices.

16

2 Graphs

A graph containing no edges is called empty. A clique is a set of pairwise adjacent vertices. Proposition 2.2. Let G be a graph and X V .G/. Then the following three statements are equivalent: (a) X is a vertex cover in G, (b) V .G/ n X is a stable set in G, (c) V .G/ n X is a clique in the complement of G.

If F is a family of sets or graphs, we say that F is a minimal element of F if F contains F but no proper subset/subgraph of F . Similarly, F is maximal in F if F 2 F and F is not a proper subset/subgraph of any element of F. When we speak of a minimum or maximum element, we mean one of minimum/maximum cardinality. For example, a minimal vertex cover is not necessarily a minimum vertex cover (see e.g. the graph in Figure 13.1), and a maximal matching is in general not maximum. The problems of finding a maximum matching, stable set or clique, or a minimum vertex cover or edge cover in an undirected graph will play important roles in later chapters. The line graph of a simple undirected graph G is the graph .E.G/; F /, where F D ffe1 ; e2 g W e1 ; e2 2 E.G/; je1 \ e2 j D 1g. Obviously, matchings in a graph G correspond to stable sets in the line graph of G. For the following notation, let G be a graph, directed or undirected. An edge progression W in G (from v1 to vkC1 ) is a sequence v1 ; e1 ; v2 ; : : : ; vk ; ek ; vkC1 such that k 0, and ei D .vi ; vi C1 / 2 E.G/ or ei D fvi ; vi C1 g 2 E.G/ for i D 1; : : : ; k. If in addition ei 6D ej for all 1 i < j k, W is called a walk in G. W is closed if v1 D vkC1 . A path is a graph P D .fv1 ; : : : ; vkC1 g; fe1 ; : : : ; ek g/ such that vi ¤ vj for 1 i < j k C 1 and the sequence v1 ; e1 ; v2 ; : : : ; vk ; ek ; vkC1 is a walk. P is also called a path from v1 to vkC1 or a v1 -vkC1 -path. v1 and vkC1 are the endpoints of P , v2 ; : : : ; vk are its internal vertices. By PŒx;y with x; y 2 V .P / we mean the (unique) subgraph of P which is an x-y-path. Evidently, there is an edge progression from a vertex v to another vertex w if and only if there is a v-w-path. A circuit or a cycle is a graph .fv1 ; : : : ; vk g; fe1 ; : : : ; ek g/ such that the sequence v1 ; e1 ; v2 ; : : : ; vk ; ek ; v1 is a (closed) walk with k 2 and vi ¤ vj for 1 i < j k. An easy induction argument shows that the edge set of a closed walk can be partitioned into edge sets of circuits. By an undirected path or an undirected circuit in a digraph, we mean a subgraph corresponding to a path or circuit, respectively, in the underlying undirected graph. The length of a path or circuit is the number of its edges. If it is a subgraph of G, we speak of a path or circuit in G. A spanning path in G is called a Hamiltonian path while a spanning circuit in G is called a Hamiltonian circuit or a tour. A graph containing a Hamiltonian circuit is a Hamiltonian graph.

2.2

Trees, Circuits, and Cuts

17

For two vertices v and w we write dist.v; w/ or distG .v; w/ for the length of a shortest v-w-path (the distance from v to w) in G. If there is no v-w-path at all, i.e. w is not reachable from v, we set dist.v; w/ WD 1. In the undirected case, dist.v; w/ D dist.w; v/ for all v; w 2 V .G/. We shall often have a P weight (or cost) function c W E.G/ ! R. Then for F E.G/ we write c.F / WD e2F c.e/ (and c.;/ D 0). This extends c to a modular function c W 2E.G/ ! R. Moreover, dist.G;c/ .v; w/ denotes the minimum c.E.P // over all v-w-paths P in G.

2.2 Trees, Circuits, and Cuts An undirected graph G is called connected if there is a v-w-path for all v; w 2 V .G/; otherwise G is disconnected. A digraph is called connected if the underlying undirected graph is connected. The maximal connected subgraphs of a graph are its connected components. Sometimes we identify the connected components with the vertex sets inducing them. A set of vertices X is called connected if the subgraph induced by X is connected. A vertex v with the property that G v has more connected components than G is called an articulation vertex. An edge e is called a bridge if G e has more connected components than G. An undirected graph without a circuit (as a subgraph) is called a forest. A connected forest is a tree. A vertex of degree at most 1 in a tree is called a leaf. A star is a tree where at most one vertex is not a leaf. In the following we shall give some equivalent characterizations of trees and their directed counterparts, arborescences. We need the following connectivity criterion: Proposition 2.3. (a) An undirected graph G is connected if and only if ı.X / 6D ; for all ; 6D X V .G/. (b) Let G be a digraph and r 2 V .G/. Then there exists an r-v-path for every v 2 V .G/ if and only if ı C .X / 6D ; for all X V .G/ with r 2 X . Proof: (a): If there is a set X V .G/ with r 2 X , v 2 V .G/ n X , and ı.X / D ;, there can be no r-v-path, so G is not connected. On the other hand, if G is not connected, there is no r-v-path for some r and v. Let R be the set of vertices reachable from r. We have r 2 R, v … R and ı.R/ D ;. (b) is proved analogously. Theorem 2.4. Let G be an undirected graph on n vertices. Then the following statements are equivalent: (a) (b) (c) (d)

G is a tree (i.e. is connected and has no circuits). G has n 1 edges and no circuits. G has n 1 edges and is connected. G is connected and every edge is a bridge.

18

2 Graphs

(e) G satisfies ı.X / 6D ; for all ; 6D X V .G/, but deleting any edge would destroy this property. (f) G is a forest, but the addition of an arbitrary edge would create a circuit. (g) G contains a unique path between any pair of vertices. Proof: (a))(g) follows from the fact that the union of two distinct paths with the same endpoints contains a circuit. (g))(e))(d) follows from Proposition 2.3(a). (d))(f) is trivial. (f))(b))(c): This follows from the fact that for forests with n vertices, m edges and p connected components n D m C p holds. (The proof is a trivial induction on m.) (c))(a): Let G be connected with n 1 edges. As long as there are any circuits in G, we destroy them by deleting an edge of the circuit. Suppose we have deleted k edges. The resulting graph G 0 is still connected and has no circuits. G 0 has m D n 1 k edges. So n D m C p D n 1 k C 1, implying k D 0. In particular, (d))(a) implies that a graph is connected if and only if it contains a spanning tree (a spanning subgraph which is a tree). A digraph is a branching if the underlying undirected graph is a forest and each vertex v has at most one entering edge. A connected branching is an arborescence. By Theorem 2.4 an arborescence with n vertices has n 1 edges, hence it has exactly one vertex r with ı .r/ D ;. This vertex is called its root; we also speak of an arborescence rooted at r. For a vertex v in a branching, the vertices w for which .v; w/ is an edge are called the children of v. For a child w of v, v is called the parent or predecessor of w. Vertices without children are called leaves. Theorem 2.5. Let G be a digraph on n vertices. Then the following statements are equivalent: G is an arborescence rooted at r (i.e. a connected branching with ı .r/ D ;). G is a branching with n 1 edges and ı .r/ D ;. G has n 1 edges and every vertex is reachable from r. Every vertex is reachable from r, but deleting any edge would destroy this property. (e) G satisfies ı C .X / 6D ; for all X V .G/ with r 2 X , but deleting any edge would destroy this property. (f) ı .r/ D ;, and there is a unique walk from r to v for each v 2 V .G/ n frg. (g) ı .r/ D ;, jı .v/j D 1 for all v 2 V .G/ n frg, and G contains no circuit. (a) (b) (c) (d)

Proof: (a))(b) and (c))(d) follow from Theorem 2.4. (b))(c): We have that jı .v/j D 1 for all v 2 V .G/ n frg. So for any v we have an r-v-path (start at v and always follow the entering edge until r is reached). (d),(e) is implied by Proposition 2.3(b). (d))(f): Any edge in ı .r/ could be deleted without destroying reachability from r. Suppose that, for some v 2 V .G/, there are two r-v-walks P and Q. Let e

2.2

Trees, Circuits, and Cuts

19

be the last edge of P that does not belong to Q. Then after deleting e, every vertex is still reachable from r. (f))(g): If every vertex is reachable from r and jı .v/j > 1 for some vertex v 2 V .G/ n frg, then we have two walks from r to v. If G contains a circuit C , let v 2 V .C /, consider the r-v-path P , and let x be the first vertex on P belonging to C . Then there are two walks from r to x: PŒr;x , and PŒr;x plus C . (g))(a): If jı .v/j 1, every undirected circuit is a (directed) circuit. A cut in an undirected graph G is an edge set of type ı.X / for some ; 6D X V .G/. In a digraph G, ı C .X / is a directed cut if ; 6D X V .G/ and ı .X / D ;, i.e. no edge enters the set X . We say that an edge set F E.G/ separates two vertices s and t if t is reachable from s in G but not in .V .G/; E.G/ n F /. An s-t-cut in an undirected graph is a cut ı.X / for some X V .G/ with s 2 X and t … X . In a digraph, an s-t-cut is an edge set ı C .X / with s 2 X and t … X . An r-cut in a digraph is an edge set ı C .X / for some X V .G/ with r 2 X . An undirected cut in a digraph is an edge set corresponding to a cut in the underlying undirected graph, i.e., ı.X / for some ; 6D X V .G/. Lemma 2.6. (Minty [1960]) Let G be a digraph and e 2 E.G/. Suppose e is coloured black, while all other edges are coloured red, black or green. Then exactly one of the following statements holds: (a) There is an undirected circuit containing e and only red and black edges such that all black edges have the same orientation. (b) There is an undirected cut containing e and only green and black edges such that all black edges have the same orientation. Proof: Let e D .x; y/. We label the vertices of G by the following procedure. First label y. In case v is already labelled and w is not, we label w if there is a black edge .v; w/, a red edge .v; w/ or a red edge .w; v/. In this case, we write pred.w/ WD v. When the labelling procedure stops, there are two possibilities: Case 1: x has been labelled. Then the vertices x; pred.x/; pred.pred.x//; : : : ; y form an undirected circuit with the property (a). Case 2: x has not been labelled. Then let R consist of all labelled vertices. Obviously, the undirected cut ı C .R/ [ ı .R/ has the property (b). Suppose that an undirected circuit C as in (a) and an undirected cut ı C .X / [ ı .X / as in (b) both exist. All edges in their (nonempty) intersection are black, they all have the same orientation with respect to C , and they all leave X or all enter X . This is a contradiction. A digraph is called strongly connected if there is a path from s to t and a path from t to s for all s; t 2 V .G/. The strongly connected components of a digraph are the maximal strongly connected subgraphs. Corollary 2.7. In a digraph G, each edge belongs either to a (directed) circuit or to a directed cut. Moreover the following statements are equivalent:

20

2 Graphs

(a) G is strongly connected. (b) G contains no directed cut. (c) G is connected and each edge of G belongs to a circuit. Proof: The first statement follows directly from Minty’s Lemma 2.6 by colouring all edges black. This also proves (b))(c). (a))(b) follows from Proposition 2.3(b). (c))(a): Let r 2 V .G/ be an arbitrary vertex. We prove that there is an r-vpath for each v 2 V .G/. Suppose this is not true, then by Proposition 2.3(b) there is some X V .G/ with r 2 X and ı C .X / D ;. Since G is connected, we have ı C .X / [ ı .X / 6D ; (by Proposition 2.3(a)), so let e 2 ı .X /. But then e cannot belong to a circuit since no edge leaves X . Corollary 2.7 and Theorem 2.5 imply that a digraph is strongly connected if and only if it contains for each vertex v a spanning arborescence rooted at v. A digraph is called acyclic if it contains no (directed) circuit. So by Corollary 2.7 a digraph is acyclic if and only if each edge belongs to a directed cut. Moreover, a digraph is acyclic if and only if its strongly connected components are the singletons. The vertices of an acyclic digraph can be ordered in a nice way: Definition 2.8. Let G be a digraph. A topological order of G is an order of the vertices V .G/ D fv1 ; : : : ; vn g such that for each edge .vi ; vj / 2 E.G/ we have i < j. Proposition 2.9. A digraph has a topological order if and only if it is acyclic. Proof: If a digraph has a circuit, it clearly cannot have a topological order. We show the converse by induction on the number of edges. If there are no edges, every order is topological. Otherwise let e 2 E.G/; by Corollary 2.7 e belongs to a directed cut ı C .X /. Then a topological order of GŒX followed by a topological order of G X (both exist by the induction hypothesis) is a topological order of G. Circuits and cuts also play an important role in algebraic graph theory. For a graph G we associate a vector space RE.G/ whose elements are vectors .xe /e2E.G/ with jE.G/j real components. Following Berge [1985] we shall now briefly discuss two linear subspaces which are particularly important. Let G be a digraph. We associate a vector .C / 2 f1; 0; 1gE.G/ with each undirected circuit C in G by setting .C /e D 0 for e … E.C /, and setting .C /e 2 f1; 1g for e 2 E.C / such that reorienting all edges e with .C /e D 1 results in a directed circuit. Similarly, we associate a vector .D/ 2 f1; 0; 1gE.G/ with each undirected cut D D ı.X / in G by setting .D/e D 0 for e … D, .D/e D 1 for e 2 ı .X / and .D/e D 1 for e 2 ı C .X /. Note that these vectors are properly defined only up to multiplication by 1. However, the subspaces of the vector space RE.G/ generated by the set of vectors associated with the undirected circuits and by the set of vectors associated with the undirected cuts in G are properly defined; they are called the cycle space and the cocycle space of G, respectively.

2.2

Trees, Circuits, and Cuts

21

Proposition 2.10. The cycle space and the cocycle space are orthogonal to each other. Proof: Let C be any undirected circuit and D D ı.X / be any undirected cut. We claim that the scalar product of .C / and .D/ is zero. Since reorienting any edge does not change the scalar product we may assume that D is a directed cut. But then the result follows from observing that any circuit enters a set X the same number of times as it leaves X . We shall now show that the sum of the dimensions of the cycle space and the cocycle space is jE.G/j, the dimension of the whole space. A set of undirected circuits (undirected cuts) is called a cycle basis (a cocycle basis) if the associated vectors form a basis of the cycle space (the cocycle space, respectively). Let G be a graph (directed or undirected) and T a maximal subgraph without an undirected circuit. For each e 2 E.G/ n E.T / we call the unique undirected circuit in T C e the fundamental circuit of e with respect to T . Moreover, for each e 2 E.T / there is a set X V .G/ with ıG .X / \ E.T / D feg (consider a component of T e); we call ıG .X / the fundamental cut of e with respect to T . Theorem 2.11. Let G be a digraph and T a maximal subgraph without an undirected circuit. The jE.G/ n E.T /j fundamental circuits with respect to T form a cycle basis of G, and the jE.T /j fundamental cuts with respect to T form a cocycle basis of G. Proof: The vectors associated with the fundamental circuits are linearly independent since each fundamental circuit contains an element not belonging to any other. The same holds for the fundamental cuts. Since the vector spaces are orthogonal to each other by Proposition 2.10, the sum of their dimensions cannot exceed jE.G/j D jE.G/ n E.T /j C jE.T /j. The fundamental cuts have a nice property which we shall exploit quite often and which we shall discuss now. Let T be a digraph whose underlying undirected graph is a tree. Consider the family F WD fCe W e 2 E.T /g, where for e D .x; y/ 2 E.T / we denote by Ce the connected component of T e containing y (so ı.Ce / is the fundamental cut of e with respect to T ). If T is an arborescence, then any two elements of F are either disjoint or one is a subset of the other. In general F is at least cross-free: Definition 2.12. A set system is a pair .U; F /, where U is a nonempty finite set and F a family of subsets of U . .U; F / is cross-free if for any two sets X; Y 2 F , at least one of the four sets X n Y , Y n X , X \ Y , U n .X [ Y / is empty. .U; F / is laminar if for any two sets X; Y 2 F, at least one of the three sets X n Y , Y n X , X \ Y is empty. In the literature set systems are also known as hypergraphs. See Figure 2.1(a) for an illustration of the laminar family ffag; fb; cg; fa; b; cg; fa; b; c; d g; ff g; ff; ggg. Another word used for laminar is nested.

22

2 Graphs

a

b

e

g

d

a

b

c

f

e

d

g f

a

b, c

Fig. 2.1.

Whether a set system .U; F / is laminar does not depend on U , so we sometimes simply say that F is a laminar family. However, whether a set system is cross-free can depend on the ground set U . If U contains an element that does not belong to any set of F , then F is cross-free if and only if it is laminar. Let r 2 U be arbitrary. It follows directly from the definition that a set system .U; F/ is cross-free if and only if F 0 WD fX 2 F W r 62 X g [ fU n X W X 2 F ; r 2 X g is laminar. Hence cross-free families are sometimes depicted similarly to laminar families: for example, Figure 2.2(a) shows the cross-free family ffb; c; d; e; f g; fcg; fa; b; cg; feg; fa; b; c; d; f g; fe; f gg; a square corresponds to the set containing all elements outside.

a

d

b

f

b a

b

c

e

d

f a

c

e

Fig. 2.2.

While oriented trees lead to cross-free families the converse is also true: every cross-free family can be represented by a tree in the following sense:

2.2

Trees, Circuits, and Cuts

23

Definition 2.13. Let T be a digraph such that the underlying undirected graph is a tree. Let U be a finite set and ' W U ! V .T /. Let F WD fSe W e 2 E.T /g, where for e D .x; y/ we define Se WD fs 2 U W '.s/ is in the same connected component of T e as yg: Then .T; '/ is called a tree-representation of .U; F /. See Figures 2.1(b) and 2.2(b) for examples. Proposition 2.14. Let .U; F / be a set system with a tree-representation .T; '/. Then .U; F / is cross-free. If T is an arborescence, then .U; F / is laminar. Moreover, every cross-free family has a tree-representation, and for laminar families, an arborescence can be chosen as T . Proof: If .T; '/ is a tree-representation of .U; F/ and e D .v; w/; f D .x; y/ 2 E.T /, we have an undirected v-x-path P in T (ignoring the orientations). There are four cases: If w; y … V .P / then Se \ Sf D ; (since T contains no circuit). If w … V .P / and y 2 V .P / then Se Sf . If y … V .P / and w 2 V .P / then Sf Se . If w; y 2 V .P / then Se [ Sf D U . Hence .U; F/ is cross-free. If T is an arborescence, the last case cannot occur (otherwise at least one vertex of P would have two entering edges), so F is laminar. : To prove the converse, let F first be a laminar family. We define V .T / WD F [ frg and E.T / WD f.X; Y / 2 F F W X Y 6D ; and there is no Z 2 F with X Z Y g [ f.r; X / W X D ; 2 F or X is a maximal element of F g : We set '.x/ WD X , where X is the minimal set in F containing x, and '.x/ WD r if no set in F contains x. Obviously, T is an arborescence rooted at r, and .T; '/ is a tree-representation of F. Now let F be a cross-free family of subsets of U . Let r 2 U . As noted above, F 0 WD fX 2 F W r 62 X g [ fU n X W X 2 F ; r 2 X g is laminar, so let .T; '/ be a tree-representation of .U; F 0 /. Now for an edge e 2 E.T / there are three cases: If Se 2 F and U n Se 2 F, we replace the edge e D .x; y/ by two edges .x; ´/ and .y; ´/, where ´ is a new vertex. If Se 62 F and U n Se 2 F , we replace the edge e D .x; y/ by .y; x/. If Se 2 F and U n Se 62 F , we do nothing. Let T 0 be the resulting graph. Then .T 0 ; '/ is a tree-representation of .U; F /. The above result is mentioned by Edmonds and Giles [1977] but was probably known earlier. Corollary 2.15. A laminar family of distinct subsets of U has at most 2jU j elements. A cross-free family of distinct subsets of U has at most 4jU j 2 elements.

24

2 Graphs

Proof: We first consider a laminar family F of distinct nonempty proper subsets of U . We prove that jF j 2jU j 2. Let .T; '/ be a tree-representation, where T is an arborescence whose number of vertices is as small as possible. For every w 2 V .T / we have either jı C .w/j 2 or there exists an x 2 U with '.x/ D w or both. (For the root this follows from U … F , for the leaves from ; … F, for all other vertices from the minimality of T .) j There k can be at most jU j vertices w with '.x/ D w for some x 2 U and at most jE.T /j /j vertices w with jı C .w/j 2. So jE.T /j C 1 D jV .T /j jU j C jE.T 2 2 and thus jF j D jE.T /j 2jU j 2. Now let .U; F / be a cross-free family with ;; U … F , and let r 2 U . Since F 0 WD fX 2 F W r 62 X g [ fU n X W X 2 F ; r 2 X g is laminar, we have jF 0 j 2jU j 2. Hence jF j 2jF 0 j 4jU j 4. The proof is concluded by taking ; and U as possible members of F into account.

2.3 Connectivity Connectivity is a very important concept in graph theory. For many problems it suffices to consider connected graphs, since otherwise we can solve the problem for each connected component separately. So it is a fundamental task to detect the connected components of a graph. The following simple algorithm finds a path from a specified vertex s to all other vertices that are reachable from s. It works for both directed and undirected graphs. In the undirected case it builds a maximal tree containing s; in the directed case it constructs a maximal arborescence rooted at s.

GRAPH SCANNING ALGORITHM Input:

A graph G (directed or undirected) and some vertex s.

Output:

The set R of vertices reachable from s, and a set T E.G/ such that .R; T / is an arborescence rooted at s, or a tree.

1

Set R WD fsg, Q WD fsg and T WD ;.

2

If Q D ; then stop, else choose a v 2 Q. Choose a w 2 V .G/ n R with e D .v; w/ 2 E.G/ or e D fv; wg 2 E.G/. If there is no such w then set Q WD Q n fvg and go to . 2 Set R WD R [ fwg, Q WD Q [ fwg and T WD T [ feg. Go to . 2

3 4

Proposition 2.16. The GRAPH SCANNING ALGORITHM works correctly. Proof: At any time, .R; T / is a tree or an arborescence rooted at s. Suppose at the end there is a vertex w 2 V .G/ n R that is reachable from s. Let P be an s-w-path,

2.3

Connectivity

25

and let fx; yg or .x; y/ be an edge of P with x 2 R and y … R. Since x has been added to R, it also has been added to Q at some time during the execution of the algorithm. The algorithm does not stop before removing x from Q. But this is done in 3 only if there is no edge fx; yg or .x; y/ with y … R. Since this is the first graph algorithm in this book we discuss some implementation issues. The first question is how the graph is given. There are several natural ways. For example, one can think of a matrix with a row for each vertex and a column for each edge. The incidence matrix of an undirected graph G is the matrix A D .av;e /v2V .G/; e2E.G/ where ( 1 if v 2 e av;e D : 0 if v 62 e The incidence matrix of a digraph G is the matrix A D .av;e /v2V .G/; e2E.G/ where 8 ˆ l.v/ C 1 (because the vertices are scanned in an order with nondecreasing l-values). Suppose that when the algorithm terminates there is a vertex w 2 V .G/ with distG .s; w/ < dist.R;T / .s; w/; let w have minimum distance from s in G with this property. Let P be a shortest s-w-path in G, and let e D .v; w/ or e D fv; wg be the last edge in P . We have distG .s; v/ D dist.R;T / .s; v/, but e does not belong to T . Moreover, l.w/ D dist.R;T / .s; w/ > distG .s; w/ D distG .s; v/ C 1 D dist.R;T / .s; v/ C 1 D l.v/ C 1. This inequality combined with the above observation proves that w did not belong to R when v was removed from Q. But this contradicts 3 because of edge e. This result will also follow from the correctness of DIJKSTRA’S ALGORITHM for the SHORTEST PATH PROBLEM, which can be thought of as a generalization of BFS to the case where we have nonnegative weights on the edges (see Section 7.1). We now show how to identify the strongly connected components of a digraph. Of course, this can easily be done by using n times DFS (or BFS). However, it is possible to find the strongly connected components by visiting every edge only twice:

STRONGLY CONNECTED COMPONENT ALGORITHM Input:

A digraph G.

Output:

A function comp W V .G/ ! N indicating the membership of the strongly connected components.

1

Set R WD ;. Set N WD 0.

2

For all v 2 V .G/ do: If v … R then VISIT1.v/.

3

Set R WD ;. Set K WD 0.

4

For i WD jV .G/j down to 1 do: If 1 .i / … R then set K WD K C 1 and VISIT2.

VISIT1.v/ 1

Set R WD R [ fvg.

2

For all w with .v; w/ 2 E.G/ do: If w … R then VISIT1.w/.

3

Set N WD N C 1,

.v/ WD N and

1

.N / WD v.

1

.i //.

28

2 Graphs

VISIT2.v/ 1

Set R WD R [ fvg.

2

For all w with .w; v/ 2 E.G/ do: If w … R then VISIT2.w/. Set comp.v/ WD K.

3

Figure 2.3 shows an example: The first DFS scans the vertices in the order a; g; b; d; e; f and produces the arborescence shown in the middle; the numbers are the -labels. Vertex c is the only one that is not reachable from a; it gets the highest label .c/ D 7. The second DFS starts with c but cannot reach any other vertex via a reverse edge. So it proceeds with vertex a because .a/ D 6. Now b, g and f can be reached. Finally e is reached from d . The strongly connected components are fcg, fa; b; f; gg and fd; eg. b

b

c a

a 6

g

5 f 4

e

c 7

c a g

g

d f

b

1

d 3

d f

e 2

e

Fig. 2.3.

In summary, one DFS is needed to find an appropriate numbering, while in the second DFS the reverse graph is considered and the vertices are processed in decreasing order with respect to this numbering. Each connected component of the second DFS-forest is an anti-arborescence, a graph arising from an arborescence by reversing every edge. We show that these anti-arborescences identify the strongly connected components. Theorem 2.19. The STRONGLY CONNECTED COMPONENT ALGORITHM identifies the strongly connected components correctly in linear time. Proof: The running time is obviously O.n C m/. Of course, vertices of the same strongly connected component are always in the same component of any DFSforest, so they get the same comp-value. We have to prove that two vertices u and v with comp.u/ D comp.v/ indeed lie in the same strongly connected component. Let r.u/ and r.v/ be the vertex reachable from u and v with the highest -label, respectively. Since comp.u/ D comp.v/, i.e. u and v lie in the same anti-arborescence of the second DFS-forest, r WD r.u/ D r.v/ is the root of this anti-arborescence. So r is reachable from both u and v.

2.3

Connectivity

29

Since r is reachable from u and .r/ .u/, r has not been added to R after u in the first DFS, and the first DFS-forest contains an r-u-path. In other words, u is reachable from r. Analogously, v is reachable from r. Altogether, u is reachable from v and vice versa, proving that indeed u and v belong to the same strongly connected component. It is interesting that this algorithm also solves another problem: finding a topological order of an acyclic digraph. Observe that contracting the strongly connected components of any digraph yields an acyclic digraph. By Proposition 2.9 this acyclic digraph has a topological order. In fact, such an order is given by the numbers comp.v/ computed by the STRONGLY CONNECTED COMPONENT ALGORITHM: Theorem 2.20. The STRONGLY CONNECTED COMPONENT ALGORITHM determines a topological order of the digraph resulting from contracting each strongly connected component of G. In particular, we can for any given digraph either find a topological order or decide that none exists in linear time. Proof: Let X and Y be two strongly connected components of a digraph G, and suppose the STRONGLY CONNECTED COMPONENT ALGORITHM computes comp.x/ D k1 for x 2 X and comp.y/ D k2 for y 2 Y with k1 < k2 . We claim C that EG .Y; X / D ;. Suppose that there is an edge .y; x/ 2 E.G/ with y 2 Y and x 2 X . All vertices in X are added to R in the second DFS before the first vertex of Y is added. In particular we have x 2 R and y … R when the edge .y; x/ is scanned in the second DFS. But this means that y is added to R before K is incremented, contradicting comp.y/ 6D comp.x/. Hence the comp-values computed by the STRONGLY CONNECTED COMPONENT A LGORITHM determine a topological order of the digraph resulting from contracting the strongly connected components. The second statement of the theorem now follows from Proposition 2.9 and the observation that a digraph is acyclic if and only if its strongly connected components are the singletons. A linear-time algorithm that identifies the strongly connected components was first given by Karzanov [1970] and Tarjan [1972]. The problem of finding a topological order (or deciding that none exists) was solved earlier (Kahn [1962], Knuth [1968]). Both BFS and DFS occur as subroutines in many other combinatorial algorithms. Some examples will appear in later chapters. Sometimes one is interested in higher connectivity. Let k 2. An undirected graph with more than k vertices and the property that it remains connected even if we delete any k 1 vertices, is called k-connected. A graph with at least two vertices is k-edge-connected if it remains connected after deleting any k 1 edges. So a connected graph with at least three vertices is 2-connected (2-edge-connected) if and only if it has no articulation vertex (no bridge, respectively). The largest k and l such that a graph G is k-connected and l-edge-connected are called the vertex-connectivity and edge-connectivity of G. Here we say that

30

2 Graphs

a graph is 1-connected (and 1-edge-connected) if it is connected. A disconnected graph has vertex-connectivity and edge-connectivity zero. The blocks of an undirected graph are its maximal connected subgraphs without articulation vertex. Thus each block is either a maximal 2-connected subgraph, or consists of a bridge or an isolated vertex. Two blocks have at most one vertex in common, and a vertex belonging to more than one block is an articulation vertex. The blocks of an undirected graph can be determined in linear time quite similarly to the STRONGLY CONNECTED COMPONENT ALGORITHM; see Exercise 20. Here we prove a nice structure theorem for 2-connected graphs. We construct graphs from a single vertex by sequentially adding ears: Definition 2.21. Let G be a graph (directed or undirected). An ear-decomposition of G is a sequence r; P1 ; : : : ; Pk with G D .frg; ;/ C P1 C C Pk , such that each Pi is either a path where exactly the endpoints belong to frg[V .P1 /[ [V .Pi 1 /, or a circuit where exactly one of its vertices belongs to frg [ V .P1 / [ [ V .Pi 1 / (i 2 f1; : : : ; kg). P1 ; : : : ; Pk are called ears. If k 1, P1 is a circuit of length at least three, and P2 ; : : : ; Pk are paths, then the ear-decomposition is called proper. Theorem 2.22. (Whitney [1932]) An undirected graph is 2-connected if and only if it has a proper ear-decomposition. Proof: Evidently a circuit of length at least three is 2-connected. Moreover, if G is 2-connected, then so is G C P , where P is an x-y-path, x; y 2 V .G/ and x 6D y: deleting any vertex does not destroy connectivity. We conclude that a graph with a proper ear-decomposition is 2-connected. To show the converse, let G be a 2-connected graph. Let G 0 be the maximal simple subgraph of G; evidently G 0 is also 2-connected. Hence G 0 cannot be a tree; i.e. it contains a circuit. Since it is simple, G 0 , and thus G, contains a circuit of length at least three. So let H be a maximal subgraph of G that has a proper eardecomposition; H exists by the above consideration. Suppose H is not spanning. Since G is connected, we then know that there exists an edge e D fx; yg 2 E.G/ with x 2 V .H / and y … V .H /. Let ´ be a vertex in V .H / n fxg. Since G x is connected, there exists a path P from y to ´ in G x. Let ´0 be the first vertex on this path, when traversed from y, that belongs to V .H /. Then PŒy;´0 C e can be added as an ear, contradicting the maximality of H . Thus H is spanning. Since each edge of E.G/ n E.H / can be added as an ear, we conclude that H D G. See Exercise 21 for similar characterizations of 2-edge-connected graphs and strongly connected digraphs.

2.4

Eulerian and Bipartite Graphs

31

2.4 Eulerian and Bipartite Graphs Euler’s work on the problem of traversing each of the seven bridges of Königsberg exactly once was the origin of graph theory. He showed that the problem had no solution by defining a graph, asking for a walk containing all edges, and observing that more than two vertices had odd degree. Definition 2.23. An Eulerian walk in a graph G is a closed walk containing every edge. An undirected graph G is called Eulerian if the degree of each vertex is even. A digraph G is Eulerian if jı .v/j D jı C .v/j for each v 2 V .G/. Although Euler neither proved sufficiency nor considered the case explicitly in which we ask for a closed walk, the following famous result is usually attributed to him: Theorem 2.24. (Euler [1736], Hierholzer [1873]) A connected (directed or undirected) graph has an Eulerian walk if and only if it is Eulerian. Proof: The necessity of the degree conditions is obvious, as a vertex appearing k times in an Eulerian walk (or k C 1 times if it is the first and the last vertex) must have in-degree k and out-degree k, or degree 2k in the undirected case. For the sufficiency, let W D v1 ; e1 ; v2 ; : : : ; vk ; ek ; vkC1 be a longest walk in G, i.e. one with maximum number of edges. In particular, W must contain all edges leaving vkC1 , which implies vkC1 D v1 by the degree conditions. So W is closed. Suppose that W does not contain all edges. As G is connected, we then conclude that there is an edge e 2 E.G/ for which e does not appear in W , but at least one of its endpoints appears in W , say vi . Then e can be combined with vi ; ei ; vi C1 ; : : : ; ek ; vkC1 D v1 ; e1 ; v2 ; : : : ; ei 1 ; vi to a walk which is longer than W . The algorithm accepts as input only connected Eulerian graphs. Note that one can check in linear time whether a given graph is connected (Theorem 2.17) and Eulerian (trivial). The algorithm first chooses an initial vertex, then calls a recursive procedure. We first describe it for undirected graphs:

EULER’S ALGORITHM Input:

An undirected connected Eulerian graph G.

Output:

An Eulerian walk W in G.

1

Choose v1 2 V .G/ arbitrarily. Return W WD EULER.G; v1 /.

EULER(G; v1 ) 1

Set W WD v1 and x WD v1 .

2

If ı.x/ D ; then go to . 4 Else let e 2 ı.x/, say e D fx; yg.

32

2 Graphs

3

Set W WD W; e; y and x WD y. Set E.G/ WD E.G/ n feg and go to . 2

4

Let v1 ; e1 ; v2 ; e2 ; : : : ; vk ; ek ; vkC1 be the sequence W . For i WD 2 to k do: Set Wi WD EULER.G; vi /. Set W WD W1 ; e1 ; W2 ; e2 ; : : : ; Wk ; ek ; vkC1 . Return W .

5

For digraphs, 2 has to be replaced by: 2

If ı C .x/ D ; then go to . 4 Else let e 2 ı C .x/, say e D .x; y/. We can analyze both versions (undirected and directed) simultaneously:

Theorem 2.25. EULER’S ALGORITHM works correctly. Its running time is O.mC n/, where n D jV .G/j and m D jE.G/j. Proof: We show that EULER.G; v1 /, if called for an Eulerian graph G and v 2 V .G/, returns an Eulerian walk in the connected component G1 of G that contains v1 . We use induction on jE.G/j, the case E.G/ D ; being trivial. Because of the degree conditions, vkC1 D x D v1 when 4 is executed. So at this stage W is a closed walk. Let G 0 be the graph G at this stage. G 0 is also Eulerian. For each edge e 2 E.G1 / \ E.G 0 / there exists a minimum i 2 f2; : : : ; kg such that e is in the same connected component of G 0 as vi (note that v1 D vkC1 is isolated in G 0 ). Then by the induction hypothesis e belongs to Wi . So the closed walk W composed in 5 is indeed an Eulerian walk in G1 . The running time is linear, because each edge is deleted immediately after being examined. EULER’S ALGORITHM will be used several times as a subroutine in later chapters. Sometimes one is interested in making a given graph Eulerian by adding or contracting edges. Let G be an undirected graph and F a family of unordered pairs : of V .G/ (edges or not). F is called an odd join if .V .G/; E.G/ [ F / is Eulerian. F is called an odd cover if the graph which results from G by contracting the vertex set of each connected component of .V .G/; F / is Eulerian. Both concepts are equivalent in the following sense. Theorem 2.26. (Aoshima and Iri [1977]) For any undirected graph we have: (a) Every odd join is an odd cover. (b) Every minimal odd cover is an odd join. Proof: Let G be an undirected graph. To prove (a), let F be an odd join. We build a graph G 0 by contracting the connected components of .V .G/; F / in G. Each of these connected components contains an even number of odd-degree vertices (with respect to F and thus with

2.4

Eulerian and Bipartite Graphs

33

respect to G, because F is an odd join). So the resulting graph has even degrees only. Thus F is an odd cover. To prove (b), let F be a minimal odd cover. Because of the minimality, .V .G/; F / is a forest. We have to show that jıF .v/j jıG .v/j .mod 2/ for each v 2 V .G/. So let v 2 V .G/. Let C1 ; : : : ; Ck be the connected components of .V .G/; F / v that contain a vertex w with fv; wg 2 F . Since F is a forest, k D jıF .v/j. As F is an odd cover, contracting X WD V .C1 / [ [ V .Ck / [ fvg in G yields a vertex of even degree, i.e. jıG .X /j is even. On the other hand, because of the minimality of F , F n ffv; wgg is not an odd cover (for any w with fv; wg 2 F ), so jıG .V .Ci //j is odd for i D 1; : : : ; k. Since k X

jıG .V .Ci //j D jıG .X /j C jıG .v/j

i D1

2jEG .fvg; V .G/ n X /j C 2

X

jEG .Ci ; Cj /j;

1i <j k

we conclude that k has the same parity as jıG .v/j.

We shall return to the problem of making a graph Eulerian in Section 12.2. A bipartition of an undirected graph G is a partition of the vertex set V .G/ D : A [ B such that the subgraphs induced by A and B are both empty. A graph is called bipartite if it has a bipartition. The simple bipartite graph G with V .G/ D : A [ B, jAj D n, jBj D m and E.G/ D ffa; bg W a 2 A; b 2 Bg is denoted : by Kn;m (the complete bipartite graph). When we write G D .A [ B; E.G//, we mean that GŒA and GŒB are both empty. Proposition 2.27. (König [1916]) An undirected graph is bipartite if and only if it contains no odd circuit (circuit of odd length). There is a linear-time algorithm which, given an undirected graph G, either finds a bipartition or an odd circuit. :

Proof: Suppose G is bipartite with bipartition V .G/ D A [ B, and the closed walk v1 ; e1 ; v2 ; : : : ; vk ; ek ; vkC1 defines some circuit in G. W.l.o.g. v1 2 A. But then v2 2 B, v3 2 A, and so on. We conclude that vi 2 A if and only if i is odd. But vkC1 D v1 2 A, so k must be even. To prove the sufficiency, we may assume that G is connected, since a graph is bipartite iff each connected component is (and the connected components can be determined in linear time; Proposition 2.17). We choose an arbitrary vertex s 2 V .G/ and apply BFS to .G; s/ in order to obtain the distances from s to v for all v 2 V .G/ (see Proposition 2.18). Let T be the resulting BFS-tree. Define A WD fv 2 V .G/ W distG .s; v/ is eveng and B WD V .G/ n A. If there is an edge e D fx; yg in GŒA or GŒB, the x-y-path in T together with e forms an odd circuit in G. If there is no such edge, we have a bipartition.

34

2 Graphs

2.5 Planarity We often draw graphs in the plane. A graph is called planar if it can be drawn such that no pair of edges intersect. To formalize this concept we need the following topological terms: Definition 2.28. A simple Jordan curve is the image of a continuous injective function ' W Œ0; 1 ! R2 ; its endpoints are '.0/ and '.1/. A closed Jordan curve is the image of a continuous function ' W Œ0; 1 ! R2 with '.0/ D '.1/ and './ 6D '. 0 / for 0 < 0 < 1. A polygonal arc is a simple Jordan curve which is the union of finitely many intervals (straight line segments). A polygon is a closed Jordan curve which is the union of finitely many intervals. Let R D R2 n J , where J is the union of finitely many intervals. We define the connected regions of R as equivalence classes where two points in R are equivalent if they can be joined by a polygonal arc within R. Definition 2.29. A planar embedding of a graph G consists of an injective mapping W V .G/ ! R2 and for each e D fx; yg 2 E.G/ a polygonal arc Je with endpoints .x/ and .y/, such that for each e D fx; yg 2 E.G/: 0 1 [ .Je n f .x/; .y/g/ \ @f .v/ W v 2 V .G/g [ Je0 A D ;: e 0 2E.G/nfeg

A graph is called planar if it has a planar embedding. Let G be a (planar) graph with some fixed planar embedding ˆ D . ; .Je /e2E.G/ /. After removing the points and polygonal arcs from the plane, the remainder, 0 1 [ R WD R2 n @f .v/ W v 2 V .G/g [ Je A ; e2E.G/

splits into open connected regions, called faces of ˆ. For example, K4 is obviously planar but it will turn out that K5 is not planar. Exercise 28 shows that restricting ourselves to polygonal arcs instead of arbitrary Jordan curves makes no substantial difference. We will show later that for simple graphs it is indeed sufficient to consider straight line segments only. Our aim is to characterize planar graphs. Following Thomassen [1981], we first prove the following topological fact, a version of the Jordan curve theorem: Theorem 2.30. If J is a polygon, then R2 n J splits into exactly two connected regions, each of which has J as its boundary. If J is a polygonal arc, then R2 n J has only one connected region. Proof: Let J be a polygon, p 2 R2 n J and q 2 J . Then there exists a polygonal arc in .R2 n J / [ fqg joining p and q: starting from p, one follows the straight

2.5

Planarity

35

line towards q until one gets close to J , then one proceeds within the vicinity of J . (We use the elementary topological fact that disjoint compact sets, in particular non-adjacent intervals of J , have a positive distance from each other.) We conclude that p is in the same connected region of R2 n J as some points arbitrarily close to q. J is the union of finitely many intervals; one or two of these intervals contain q. Let > 0 such that the ball with center q and radius intersects no other interval of J ; then clearly this ball intersects at most two connected regions. Since p 2 R2 n J and q 2 J were chosen arbitrarily, we conclude that there are at most two regions and each region has J as its boundary. Since the above also holds if J is a polygonal arc and q is an endpoint of J , R2 n J has only one connected region in this case. Returning to the case when J is a polygon, it remains to prove that R2 n J has more than one region. For any p 2 R2 n J and any angle ˛ we consider the ray l˛ starting at p with angle ˛. J \ l˛ is a set of points or closed intervals. Let cr.p; l˛ / be the number of these points or intervals that J enters from a different side of l˛ than to which it leaves (the number of times J “crosses” l˛ ; e.g. in Figure 2.4 we have cr.p; l˛ / D 2).

J

J

p

lα

J

Fig. 2.4.

Note that for any angle ˛, ˇ ˇ ˇ ˇ ˇ ˇ ˇ ˇ ˇ lim cr.p; l˛ / cr.p; l˛ /ˇ and ˇ lim cr.p; l˛C / cr.p; l˛ /ˇ ˇ!0; >0 ˇ ˇ!0; >0 ˇ are even integers: twice the number of points and intervals of J \ l˛ that J enters from the same side to which it leaves (left side and right side, respectively). Therefore g.p; ˛/ WD .cr.p; l˛ / mod 2/ is a continuous function in ˛, so it is constant and we denote it by g.p/. Clearly g.p/ is constant for points p on each straight line not intersecting J , so it is constant within each region. However, g.p/ 6D g.q/ for points p; q such that the straight line segment joining p and q intersects J exactly once. Hence there are indeed two regions. Exactly one of the faces, the outer face, is unbounded.

36

2 Graphs

Proposition 2.31. Let G be a 2-connected graph with a planar embedding ˆ. Then every face is bounded by a circuit, and every edge is on the boundary of exactly two faces. Moreover, the number of faces is jE.G/j jV .G/j C 2. Proof: By Theorem 2.30 both assertions are true if G is a circuit. For general 2connected graphs we use induction on the number of edges, using Theorem 2.22. Consider a proper ear-decomposition of G, and let P be the last ear, a path with endpoints x and y, say. Let G 0 be the graph before adding the last ear, and let ˆ0 be the restriction of ˆ to G 0 . S Let ˆ D . ; .Je /e2E.G/ /. Let F 0 be the face of ˆ0 containing e2E.P / Je n f .x/; .y/g. By induction, F 0 is bounded by a circuit C . C contains x and y, so C is the union of two x-y-paths Q1 ; Q2 in G 0 . Now we apply Theorem 2.30 to each of the circuits Q1 C P and Q2 C P . We conclude that [ : : Je F 0 [ f .x/; .y/g D F1 [ F2 [ e2E.P /

and F1 and F2 are two faces of G bounded by the circuits Q1 C P and Q2 C P , respectively. Hence G has one more face than G 0 . Using jE.G/nE.G 0 /j D jV .G/n V .G 0 /j C 1, this completes the induction step. This proof is due to Tutte. It also implies easily that the circuits bounding the finite faces constitute a cycle basis (Exercise 29). The last statement of Proposition 2.31 is known as Euler’s formula; it holds for general connected graphs: Theorem 2.32. (Euler [1758], Legendre [1794]) For any planar connected graph G with any embedding, the number of faces is jE.G/j jV .G/j C 2. Proof: We have already proved the statement for 2-connected graphs (Proposition 2.31). Moreover, the assertion is trivial if jV .G/j D 1 and follows from Theorem 2.30 if jE.G/j D 1. If jV .G/j D 2 and jE.G/j 2, then we can subdivide one edge e, thereby increasing the number of vertices and the number of edges by one and making the graph 2-connected, and apply Proposition 2.31. So we may now assume that G has an articulation vertex x; we proceed by induction on the number of vertices. Let ˆ be an embedding of G. Let C1 ; : : : ; Ck be the connected components of G x; and let ˆi be the restriction of ˆ to Gi WD GŒV .Ci / [ fxg for i D 1; : : : ; k. The set of inner (bounded) faces of ˆ is the disjoint union of the sets of inner faces of ˆi , i D 1; : : : ; k. By applying the induction hypothesis to .Gi ; ˆi /, i D 1; : : : ; k, we get that the total number of inner faces of .G; ˆ/ is k k X X .jE.Gi /jjV .Gi /jC1/ D jE.G/j jV .Gi /nfxgj D jE.G/jjV .G/jC1: i D1

i D1

Taking the outer face into account concludes the proof.

In particular, the number of faces is independent of the embedding. The average degree of a simple planar graph is less than 6:

2.5

Planarity

37

Corollary 2.33. Let G be a 2-connected simple planar graph whose minimum cirk cuit has length k (we also say that G has girth k). Then G has at most .n 2/ k2 edges. Any simple planar graph with n 3 vertices has at most 3n 6 edges. Proof: First assume that G is 2-connected. Let some embedding ˆ of G be given, and let r be the number of faces. By Euler’s formula (Theorem 2.32), r D jE.G/j jV .G/j C 2. By Proposition 2.31, each face is bounded by a circuit, i.e. by at least k edges, and each edge is on the boundary of exactly two faces. Hence kr 2jE.G/j. Combining the two results we get jE.G/j jV .G/j C 2 k2 jE.G/j, implying k jE.G/j .n 2/ k2 . If G is not 2-connected we add edges between non-adjacent vertices to make it 3 2-connected while preserving planarity. By the first part we have at most .n 2/ 32 edges, including the new ones. Now we show that certain graphs are non-planar: Corollary 2.34. Neither K5 nor K3;3 is planar. Proof: This follows directly from Corollary 2.33: K5 has five vertices but 10 > 4 3 5 6 edges; K3;3 is 2-connected, has girth 4 (as it is bipartite) and 9 > .6 2/ 42 edges.

Fig. 2.5.

Figure 2.5 shows these two graphs, which are the smallest non-planar graphs. We shall prove that every non-planar graph contains, in a certain sense, K5 or K3;3 . To make this precise we need the following notion: Definition 2.35. Let G and H be two undirected graphs. G is a minor of H if : : there exists a subgraph H 0 of H and a partition V .H 0 / D V1 [ [ Vk of its vertex set into connected subsets such that contracting each of V1 ; : : : ; Vk yields a graph which is isomorphic to G. In other words, G is a minor of H if it can be obtained from H by a series of operations of the following type: delete a vertex, delete an edge or contract an edge. Since neither of these operations destroys planarity, any minor of a planar graph is planar. Hence a graph which contains K5 or K3;3 as a minor cannot be

38

2 Graphs

planar. Kuratowski’s Theorem says that the converse is also true. We first consider 3-connected graphs and start with the following lemma (which is the heart of Tutte’s so-called wheel theorem): Lemma 2.36. (Tutte [1961], Thomassen [1980]) Let G be a 3-connected graph with at least five vertices. Then there exists an edge e such that G=e is also 3-connected. Proof: Suppose there is no such edge. Then for each edge e D fv; wg there exists a vertex x such that G fv; w; xg is disconnected, i.e. has a connected component C with jV .C /j < jV .G/j 3. Choose e, x and C such that jV .C /j is minimum. x has a neighbour y in C , because otherwise C is a connected component of G fv; wg (but G is 3-connected). By our assumption, G=fx; yg is not 3-connected, i.e. there exists a vertex ´ such that G fx; y; ´g is disconnected. Since fv; wg 2 E.G/, there exists a connected component D of Gfx; y; ´g which contains neither v nor w. But D contains a neighbour d of y, since otherwise D is a connected component of G fx; ´g (again contradicting the fact that G is 3-connected). So d 2 V .D/ \ V .C /, and thus D is a subgraph of C . Since y 2 V .C / n V .D/, we have a contradiction to the minimality of jV .C /j. Theorem 2.37. (Kuratowski [1930], Wagner [1937]) A 3-connected graph is planar if and only if it contains neither K5 nor K3;3 as a minor. Proof: As the necessity is evident (see above), we prove the sufficiency. Since K4 is obviously planar, we proceed by induction on the number of vertices: let G be a 3-connected graph with more than four vertices but no K5 or K3;3 minor. By Lemma 2.36, there exists an edge e D fv; wg such that G=e is 3-connected. Let ˆ D ; .Je0 /e0 2E.G=e/ be a planar embedding of G=e, which exists by induction. Let x be the vertex in G=e which arises by contracting e. Consider .G=e/ x with the restriction of ˆ as a planar embedding. Since .G=e/ x is 2-connected, every face is bounded by a circuit (Proposition 2.31). In particular, the face containing the point .x/ is bounded by a circuit C . Let y1 ; : : : ; yk 2 V .C / be the neighbours of v that are distinct from w, numbered in cyclic order, and partition C into edge-disjoint paths Pi , i D 1; : : : ; k, such that Pi is a yi -yi C1 -path (ykC1 WD y1 ). Suppose there exists an index i 2 f1; : : : ; kg such that .w/ fvg [ V .Pi /. Then a planar embedding of G can be constructed easily by modifying ˆ. We shall prove that all other cases are impossible. First, if w has three neighbours among y1 ; : : : ; yk , we have a K5 minor (Figure 2.6(a)). Next, if .w/ D fv; yi ; yj g for some i < j , then we must have i C 1 < j and .i; j / 6D .1; k/ (otherwise yi and yj would both lie on Pi or Pj ); see Figure 2.6(b). Otherwise there is a neighbour ´ of w in V .Pi / n fyi ; yi C1 g for some i and another neighbour ´0 … V .Pi / (Figure 2.6(c)). In both cases, there are four vertices y; ´; y 0 ; ´0 on C , in this cyclic order, with y; y 0 2 .v/ and ´; ´0 2 .w/. This implies that we have a K3;3 minor.

2.5

a

Planarity

39

c

b

Fig. 2.6.

The proof implies quite directly that every 3-connected simple planar graph has a planar embedding where each edge is embedded by a straight line and each face, except the outer face, is convex (Exercise 32(a)). The general case of Kuratowski’s Theorem can be reduced to the 3-connected case by gluing together planar embeddings of the maximal 3-connected subgraphs, or by the following lemma: Lemma 2.38. (Thomassen [1980]) Let G be a graph with at least five vertices which is not 3-connected and which contains neither K5 nor K3;3 as a minor. Then there exist two non-adjacent vertices v; w 2 V .G/ such that G C e, where e D fv; wg is a new edge, does not contain a K5 or K3;3 minor either. Proof: We use induction on jV .G/j. Let G be as above. Without loss of generality, G is simple. If G is disconnected, we can simply add an edge e joining two different connected components. So henceforth we assume that G is connected. Since G is not 3-connected, there exists a set X D fx; yg of two vertices such that G X is disconnected. (If G is not even 2-connected we may choose x to be an articulation vertex and y a neighbour of x.) Let C be a connected component of G X , G1 WD GŒV .C / [ X and G2 WD G V .C /. We first prove the following: Claim: Let v; w 2 V .G1 / be two vertices such that adding an edge e D fv; wg to G creates a K3;3 or K5 minor. Then at least one of G1 C e C f and G2 C f contains a K5 or K3;3 minor, where f is a new edge joining x and y. To prove this claim, let v; w 2 V .G1 /, e D fv; wg and suppose that there are pairwise disjoint connected vertex sets Z1 ; : : : ; Z t of G C e such that after contracting each of them we have a K5 (t D 5/ or K3;3 (t D 6) subgraph. Note that it is impossible that Zi V .G1 / n X and Zj V .G2 / n X for some i; j 2 f1; : : : ; tg: in this case the set of those Zk with Zk \ X 6D ; (there are at most two of these) separate Zi and Zj , contradicting the fact that both K5 and K3;3 are 3-connected. Hence there are two cases: If none of Z1 ; : : : ; Z t is a subset of V .G2 / n X , then G1 C e C f also contains a K5 or K3;3 minor: just consider Zi \ V .G1 / (i D 1; : : : ; t).

40

2 Graphs

Analogously, if none of Z1 ; : : : ; Z t is a subset of V .G1 / n X , then G2 C f contains a K5 or K3;3 minor (consider Zi \ V .G2 / (i D 1; : : : ; t)). The claim is proved. Now we first consider the case when G contains an articulation vertex x, and y is a neighbour of x. We choose a second neighbour ´ of x such that y and ´ are in different connected components of G x. W.l.o.g. say that ´ 2 V .G1 /. Suppose that the addition of e D fy; ´g creates a K5 or K3;3 minor. By the claim, at least one of G1 C e and G2 contains a K5 or K3;3 minor (an edge fx; yg is already present). But then G1 or G2 , and thus G, contains a K5 or K3;3 minor, contradicting our assumption. Hence we may assume that G is 2-connected. Recall that x; y 2 V .G/ were chosen such that G fx; yg is disconnected. If fx; yg … E.G/ we simply add an edge f D fx; yg. If this creates a K5 or K3;3 minor, the claim implies that G1 C f or G2 C f contains such a minor. Since there is an x-y-path in each of G1 ; G2 (otherwise we would have an articulation vertex of G), this implies that there is a K5 or K3;3 minor in G which is again a contradiction. Thus we can assume that f D fx; yg 2 E.G/. Suppose now that at least one of the graphs Gi (i 2 f1; 2g) is not planar. Then this Gi has at least five vertices. Since it does not contain a K5 or K3;3 minor (this would also be a minor of G), we conclude from Theorem 2.37 that Gi is not 3-connected. So we can apply the induction hypothesis to Gi . By the claim, if adding an edge within Gi does not introduce a K5 or K3;3 minor in Gi , it cannot introduce such a minor in G either. So we may assume that both G1 and G2 are planar; let ˆ1 and ˆ2 be planar embeddings. Let Fi be a face of ˆi with f on its boundary, and let ´i be another vertex on the boundary of Fi , ´i … fx; yg (i D 1; 2). We claim that adding an edge f´1 ; ´2 g (cf. Figure 2.7) does not introduce a K5 or K3;3 minor.

z1

z2

x

G1

f

G2

y

Fig. 2.7.

Suppose, on the contrary, that adding f´1 ; ´2 g and contracting some pairwise disjoint connected vertex sets Z1 ; : : : ; Z t would create a K5 (t D 5/ or K3;3 (t D 6) subgraph. First suppose that at most one of the sets Zi is a subset of V .G1 / n fx; yg. Then the graph G20 , arising from G2 by adding one vertex w and edges from w to x, y and ´2 , also contains a K5 or K3;3 minor. (Here w corresponds to the contracted set

2.6

Planar Duality

41

Zi V .G1 / n fx; yg.) This is a contradiction since there is a planar embedding of G20 : just supplement ˆ2 by placing w within F2 . So we may assume that Z1 ; Z2 V .G1 /nfx; yg. Analogously, we may assume that Z3 ; Z4 V .G2 / n fx; yg. W.l.o.g. we have ´1 … Z1 and ´2 … Z3 . Then we cannot have a K5 , because Z1 and Z3 are not adjacent. Moreover, the only possible common neighbours of Z1 and Z3 are Z5 and Z6 . Since in K3;3 two vertices are either adjacent or have three common neighbours, a K3;3 minor is also impossible. Theorem 2.37 and Lemma 2.38 yield Kuratowski’s Theorem: Theorem 2.39. (Kuratowski [1930], Wagner [1937]) An undirected graph is planar if and only if it contains neither K5 nor K3;3 as a minor. Indeed, Kuratowski proved a stronger version (Exercise 33). The proof can be turned into a polynomial-time algorithm quite easily (Exercise 32(b)). In fact, a linear-time algorithm exists: Theorem 2.40. (Hopcroft and Tarjan [1974]) There is a linear-time algorithm for finding a planar embedding of a given graph or deciding that it is not planar.

2.6 Planar Duality We shall now introduce an important duality concept. In this section, graphs may contain loops, i.e. edges whose endpoints coincide. In a planar embedding loops are of course represented by polygons instead of polygonal arcs. Note that Euler’s formula (Theorem 2.32) also holds for graphs with loops: this follows from the observation that subdividing a loop e (i.e. replacing e D fv; vg by two parallel edges fv; wg; fw; vg where w is a new vertex) and adjusting the embedding (replacing the polygon Je by two polygonal arcs whose union is Je ) increases the number of edges and vertices each by one but does not change the number of faces. Definition 2.41. Let G be a directed or undirected graph, possibly with loops, and let ˆ D . ; .Je /e2E.G/ / be a planar embedding of G. We define the planar dual G whose vertices are the faces of ˆ and whose edge set is fe W e 2 E.G/g, where e connects the faces that are adjacent to Je (if Je is adjacent to only one face, then e is a loop). In the directed case, say for e D .v; w/, we orient e D .F1 ; F2 / in such a way that F1 is the face “to the right” when traversing Je from .v/ to .w/. G is again planar. In fact, there obviously exists a planar embedding ; .Je /e 2E.G / of G such that .F / 2 F for all faces F of ˆ and, for each e 2 E.G/,

42

2 Graphs

0 Je \ @f .v/ W v 2 V .G/g [

[

1 Jf A D ;;

f 2E.G/nfeg

jJe \ Je j D 1, and if e is a loop then the face bounded by Je contains exactly one endpoint of e. Such an embedding is called a standard embedding of G .

a

b

Fig. 2.8.

The planar dual of a graph really depends on the embedding: consider the two embeddings of the same graph shown in Figure 2.8. The resulting planar duals are not isomorphic, since the second one has a vertex of degree four (corresponding to the outer face) while the first one is 3-regular. Proposition 2.42. Let G be an undirected connected planar graph with a fixed embedding. Let G be its planar dual with a standard embedding. Then .G / D G. Proof: Let ; .Je /e2E.G/ be a fixed embedding of G and ; .Je /e 2E.G / a standard embedding of G . Let F be a face of G . The boundary of F contains Je for at least one edge e , so F must contain .v/ for one endpoint v of e. So every face of G contains at least one vertex of G. By applying Euler’s formula (Theorem 2.32) to G and to G, we get that the number of faces of G is jE.G /j jV .G /j C 2 D jE.G/j .jE.G/j jV .G/j C 2/ C 2 D jV .G/j. Hence each face of G contains exactly one vertex of G. From this we conclude that the planar dual of G is isomorphic to G. The requirement that G is connected is essential here: note that G is always connected, even if G is disconnected. Theorem 2.43. Let G be a connected planar undirected graph with arbitrary embedding. The edge set of any circuit in G corresponds to a minimal cut in G , and any minimal cut in G corresponds to the edge set of a circuit in G . fixed planar embedding of G. Let C be Proof: Let ˆ D . ; .Je /e2E.G/ / be a S a circuit in G. By Theorem 2.30, R2 n e2E.C / Je splits into exactly two connected regions. Let A and B be the set of faces of ˆ in the inner and outer region,

Exercises

43

:

respectively. We have V .G / D A [ B and EG .A; B/ D fe W e 2 E.C /g. Since A and B form connected sets in G , this is indeed a minimal cut. Conversely, let ıG .A/ be a minimal cut in G. Let ˆ D . ; .Je /e2E.G / / be a standard embedding of G . Let a 2 A and b 2 V .G/ n A. Observe that there is no polygonal arc in 0 1 [ R WD R2 n @f .v/ W v 2 V .G /g [ Je A e2ıG .A/

which connects .a/ and .b/: the sequence of faces of G passed by such a polygonal arc would define an edge progression from a to b in G not using any edge of ıG .A/. So R consists of at least two connected regions. Then, obviously, the boundary of each region must contain a circuit. Hence F WD fe W e 2 ıG .A/g contains the edge set of a circuit C in G . We have fe W e 2 E.C /g fe W e 2 F g D ıG .A/, and, by the first part, fe W e 2 E.C /g is a minimal cut in .G / D G (cf. Proposition 2.42). We conclude that fe W e 2 E.C /g D ıG .A/. In particular, e is a loop if and only if e is a bridge, and vice versa. For digraphs the above proof yields: Corollary 2.44. Let G be a connected planar digraph with some fixed planar embedding. The edge set of any circuit in G corresponds to a minimal directed cut in G , and vice versa. Another interesting consequence of Theorem 2.43 is: Corollary 2.45. Let G be a connected undirected graph with arbitrary planar embedding. Then G is bipartite if and only if G is Eulerian, and G is Eulerian if and only if G is bipartite. Proof: Observe that a connected graph is Eulerian if and only if every minimal cut has even cardinality. By Theorem 2.43, G is bipartite if G is Eulerian, and G is Eulerian if G is bipartite. By Proposition 2.42, the converse is also true. An abstract dual of G is a graph G 0 for which there is a bijection W E.G/ ! E.G 0 / such that F is the edge set of a circuit iff .F / is a minimal cut in G 0 and vice versa. Theorem 2.43 shows that any planar dual is also an abstract dual. The converse is not true. However, Whitney [1933] proved that a graph has an abstract dual if and only if it is planar (Exercise 39). We shall return to this duality relation when dealing with matroids in Section 13.3.

Exercises 1. Let G be a simple undirected graph on n vertices which is isomorphic to its complement. Show that n mod 4 2 f0; 1g.

44

2 Graphs

2. Prove that every simple undirected graph G with jı.v/j 12 jV .G/j for all v 2 V .G/ is Hamiltonian. Hint: Consider a longest path in G and the neighbours of its endpoints. (Dirac [1952]) 3. Prove that any simple undirected graph G with jE.G/j > jV .G/j1 is 2 connected. 4. Let G be a simple undirected graph. Show that G or its complement is connected. 5. Prove that every simple undirected graph with more than one vertex contains two vertices that have the same degree. Prove that every tree (except a single vertex) contains at least two leaves. 6. Let T be a tree with k leaves. Show that T contains at most k 2 vertices of degree at least 3. 7. Prove that every tree T contains a vertex v such that no connected component /j of T v contains more than jV .T vertices. Can you find such a vertex in linear 2 time? 8. Let G be a connected undirected graph, and let .V .G/; F / be a forest in G. Prove that there is a spanning tree .V .G/; T / with F T E.G/. 9. Let .V; F1 / and .V; F2 / be two forests with jF1 j < jF2 j. Prove that there exists an edge e 2 F2 n F1 such that .V; F1 [ feg/ is a forest. 10. Let .V; F1 / and .V; F2 / be two branchings with 2jF1 j < jF2 j. Prove that there exists an edge e 2 F2 n F1 such that .V; F1 [ feg/ is a branching. 11. Prove that any cut in an undirected graph is the disjoint union of minimal cuts. 12. Let G be an undirected graph, C a circuit and D a cut. Show that jE.C / \ Dj is even. 13. Show that any undirected graph has a cut containing at least half of the edges. 14. Let .U; F / be a cross-free set system with jU j 2. Prove that F contains at most 4jU j 4 distinct elements. 15. Let G be a connected undirected graph. Show that there exists an orientation G 0 of G and a spanning arborescence T of G 0 such that the set of fundamental circuits with respect to T is precisely the set of directed circuits in G 0 . Hint: Consider a DFS-tree. (Camion [1968], Crestin [1969]) 16. Describe a linear-time algorithm for the following problem: Given an adjacency list of a graph G, compute an adjacency list of the maximal simple subgraph of G. Do not assume that parallel edges appear consecutively in the input. 17. Given a graph G (directed or undirected), show that there is a linear-time algorithm to find a circuit or decide that none exists. 18. Describe a simple linear-time algorithm that finds a topological order in a given acyclic digraph. (Do not use the STRONGLY CONNECTED COMPONENT ALGORITHM). 19. Let G be a connected undirected graph, s 2 V .G/ and T a DFS-tree resulting from running DFS on .G; s/. s is called the root of T . x is an ancestor of y in T if x lies on the (unique) s-y-path in T . x is the parent of y if the edge fx; yg lies

Exercises

45

on the s-y-path in T . y is a child (successor) of x if x is the parent (an ancestor) of y. Note that with this definition each vertex is an ancestor and a successor of itself. Every vertex except s has exactly one parent. Prove: (a) For any edge fv; wg 2 E.G/, v is an ancestor or a successor of w in T . (b) A vertex v is an articulation vertex of G if and only if either v D s and jıT .v/j > 1 or v 6D s and there is a child w of v such that no edge in G connects a proper ancestor of v (that is, excluding v) with a successor of w.

20. Use Exercise 19 to design a linear-time algorithm which finds the blocks of an undirected graph. It will be useful to compute numbers ˛.x/ WD minff .w/ W w D x or fw; yg 2 E.G/ n T for some successor y of xg

21.

22.

23. 24. 25.

26.

27.

recursively during the DFS. Here .R; T / is the DFS-tree (with root s), and the f -values represent the order in which the vertices are added to R (see the GRAPH SCANNING ALGORITHM). If for some vertex x 2 R n fsg we have ˛.x/ f .w/, where w is the parent of x, then w must be either the root or an articulation vertex. Prove: (a) An undirected graph is 2-edge-connected if and only if it has at least two vertices and an ear-decomposition. (b) A digraph is strongly connected if and only if it has an ear-decomposition. (c) The edges of an undirected graph G with at least two vertices can be oriented such that the resulting digraph is strongly connected if and only if G is 2-edge-connected. (Robbins [1939]) A tournament is a digraph such that the underlying undirected graph is a (simple) complete graph. Prove that every tournament contains a Hamiltonian path (Rédei [1934]). Prove that every strongly connected tournament is Hamiltonian (Camion [1959]). Let G be an undirected graph. Prove that there exists an orientation G 0 of G C 0 such that jjıG 0 .v/j jıG 0 .v/jj 1 for all v 2 V .G /. Prove that if a connected undirected simple graph is Eulerian then its line graph is Hamiltonian. What about the converse? Prove that any connected bipartite graph has a unique bipartition. Prove that any non-bipartite undirected graph contains an odd circuit as an induced subgraph. Prove that an undirected graph G is bipartite if and only if E.G/ can be partitioned into cuts. Prove that a strongly connected digraph whose underlying undirected graph is non-bipartite contains a (directed) circuit of odd length. Let G be an undirected graph. A tree-decomposition of G is a pair .T; '/, where T is a tree and ' W V .T / ! 2V .G/ satisfies the following conditions: for each e 2 E.G/ there exists a t 2 V .T / with e '.t/; for each v 2 V .G/ the set ft 2 V .T / W v 2 '.t/g is connected in T .

46

28.

29. 30. 31.

32.

33.

34.

2 Graphs

We say that the width of .T; '/ is maxt 2V .T / j'.t/j 1. The tree-width of a graph G is the minimum width of a tree-decomposition of G. This notion is due to Robertson and Seymour [1986]. Show that the simple graphs of tree-width at most 1 are the forests. Moreover, prove that the following statements are equivalent for an undirected graph G: (a) G has tree-width at most 2; (b) G does not contain K4 as a minor; (c) G can be obtained from an empty graph by successively adding bridges and doubling and subdividing edges. (Doubling an edge e D fv; wg 2 E.G/ means adding another edge with endpoints v and w; subdividing an edge e D fv; wg 2 E.G/ means adding a vertex x and replacing e by two edges fv; xg; fx; wg.) Note: Because of the construction in (c) such graphs are called series-parallel. Show that if a graph G has a planar embedding where the edges are embedded by arbitrary Jordan curves, then it also has a planar embedding with polygonal arcs only. Let G be a 2-connected graph with a planar embedding. Show that the set of circuits bounding the finite faces constitutes a cycle basis of G. Can you generalize Euler’s formula (Theorem 2.32) to disconnected graphs? Show that there are exactly five Platonic graphs (corresponding to the Platonic solids; cf. Exercise 11 of Chapter 4), i.e. 3-connected planar regular graphs whose faces are all bounded by the same number of edges. Hint: Use Euler’s formula (Theorem 2.32). Deduce from the proof of Kuratowski’s Theorem 2.39: (a) Every 3-connected simple planar graph has a planar embedding where each edge is embedded by a straight line and each face, except the outer face, is convex. (b) There is a polynomial-time algorithm for checking whether a given graph is planar. Given a graph G and an edge e D fv; wg 2 E.G/, we say that H results from : G by subdividing e if V .H / D V .G/ [ fxg and E.H / D .E.G/ n feg/ [ ffv; xg; fx; wgg. A graph resulting from G by successively subdividing edges is called a subdivision of G. (a) Trivially, if H contains a subdivision of G then G is a minor of H . Show that the converse is not true. (b) Prove that a graph containing a K3;3 or K5 minor also contains a subdivision of K3;3 or K5 . Hint: Consider what happens when contracting one edge. (c) Conclude that a graph is planar if and only if no subgraph is a subdivision of K3;3 or K5 . (Kuratowski [1930]) Prove that each of the following statements implies the other: (a) For every infinite sequence of graphs G1 ; G2 ; : : : there are two indices i < j such that Gi is a minor of Gj .

References

35.

36.

37. 38. 39.

47

(b) Let G be a class of graphs such that for each G 2 G and each minor H of G we have H 2 G (i.e. membership in G is a hereditary graph property). Then there exists a finite set X of graphs such that G consists of all graphs that do not contain any element of X as a minor. Note: The statements have been proved by Robertson and Seymour [2004]; they are a main result of their series of papers on graph minors. Theorem 2.39 and Exercise 27 give examples of forbidden minor characterizations as in (b). Let G be a planar graph with an embedding ˆ, and let C be a circuit of G bounding some face of ˆ. Prove that then there is an embedding ˆ0 of G such that C bounds the outer face. (a) Let G be disconnected with an arbitrary planar embedding, and let G be the planar dual with a standard embedding. Prove that .G / arises from G by successively applying the following operation, until the graph is connected: Choose two vertices x and y which belong to different connected components and which are adjacent to the same face; contract fx; yg. (b) Generalize Corollary 2.45 to arbitrary planar graphs. Hint: Use (a) and Theorem 2.26. Let G be a connected digraph with a fixed planar embedding, and let G be the planar dual with a standard embedding. How are G and .G / related? Prove that if a planar digraph is acyclic (strongly connected), then its planar dual is strongly connected (acyclic). What about the converse? (a) Show that if G has an abstract dual and H is a minor of G then H also has an abstract dual. (b) Show that neither K5 nor K3;3 has an abstract dual. (c) Conclude that a graph is planar if and only if it has an abstract dual. (Whitney [1933])

References General Literature: Berge, C. [1985]: Graphs. Second Edition. Elsevier, Amsterdam 1985 Bollobás, B. [1998]: Modern Graph Theory. Springer, New York 1998 Bondy, J.A. [1995]: Basic graph theory: paths and circuits. In: Handbook of Combinatorics; Vol. 1 (R.L. Graham, M. Grötschel, L. Lovász, eds.), Elsevier, Amsterdam 1995 Bondy, J.A., and Murty, U.S.R. [2008]: Graph Theory. Springer, New York 2008 Diestel, R. [2010]: Graph Theory. Fourth Edition. Springer, New York 2010 Wilson, R.J. [2010]: Introduction to Graph Theory. Fifth Edition. Addison-Wesley, Reading 2010

Cited References: Aoshima, K., and Iri, M. [1977]: Comments on F. Hadlock’s paper: finding a maximum cut of a planar graph in polynomial time. SIAM Journal on Computing 6 (1977), 86–87 Camion, P. [1959]: Chemins et circuits hamiltoniens des graphes complets. Comptes Rendus Hebdomadaires des Séances de l’Académie des Sciences (Paris) 249 (1959), 2151–2152

48

2 Graphs

Camion, P. [1968]: Modulaires unimodulaires. Journal of Combinatorial Theory A 4 (1968), 301–362 Dirac, G.A. [1952]: Some theorems on abstract graphs. Proceedings of the London Mathematical Society 2 (1952), 69–81 Edmonds, J., and Giles, R. [1977]: A min-max relation for submodular functions on graphs. In: Studies in Integer Programming; Annals of Discrete Mathematics 1 (P.L. Hammer, E.L. Johnson, B.H. Korte, G.L. Nemhauser, eds.), North-Holland, Amsterdam 1977, pp. 185–204 Euler, L. [1736]: Solutio problematis ad geometriam situs pertinentis. Commentarii Academiae Petropolitanae 8 (1736), 128–140 Euler, L. [1758]: Demonstratio nonnullarum insignium proprietatum quibus solida hedris planis inclusa sunt praedita. Novi Commentarii Academiae Petropolitanae 4 (1758), 140–160 Hierholzer, C. [1873]: Über die Möglichkeit, einen Linienzug ohne Wiederholung und ohne Unterbrechung zu umfahren. Mathematische Annalen 6 (1873), 30–32 Hopcroft, J.E., and Tarjan, R.E. [1974]: Efficient planarity testing. Journal of the ACM 21 (1974), 549–568 Kahn, A.B. [1962]: Topological sorting of large networks. Communications of the ACM 5 (1962), 558–562 Karzanov, A.V. [1970]: An efficient algorithm for finding all the bi-components of a graph. In: Trudy 3-˘ı Zimne˘ı Shkoly po Matematicheskomu Programmirovaniyu i Smezhnym Voprosam (Drogobych, 1970), Issue 2, Moscow Institute for Construction Engineering (MISI) Press, Moscow, 1970, pp. 343–347 [in Russian] Knuth, D.E. [1968]: The Art of Computer Programming; Vol. 1. Fundamental Algorithms. Addison-Wesley, Reading 1968 (third edition: 1997) König, D. [1916]: Über Graphen und Ihre Anwendung auf Determinantentheorie und Mengenlehre. Mathematische Annalen 77 (1916), 453–465 König, D. [1936]: Theorie der endlichen und unendlichen Graphen. Teubner, Leipzig 1936; reprint: Chelsea Publishing Co., New York 1950 Kuratowski, K. [1930]: Sur le problème des courbes gauches en topologie. Fundamenta Mathematicae 15 (1930), 271–283 Legendre, A.M. [1794]: Éléments de Géométrie. Firmin Didot, Paris 1794 Minty, G.J. [1960]: Monotone networks. Proceedings of the Royal Society of London A 257 (1960), 194–212 Moore, E.F. [1959]: The shortest path through a maze. Proceedings of the International Symposium on the Theory of Switching; Part II. Harvard University Press 1959, pp. 285–292 Rédei, L. [1934]: Ein kombinatorischer Satz. Acta Litt. Szeged 7 (1934), 39–43 Robbins, H.E. [1939]: A theorem on graphs with an application to a problem of traffic control. American Mathematical Monthly 46 (1939), 281–283 Robertson, N., and Seymour, P.D. [1986]: Graph minors II: algorithmic aspects of tree-width. Journal of Algorithms 7 (1986), 309–322 Robertson, N., and Seymour, P.D. [2004]: Graph minors XX: Wagner’s conjecture. Journal of Combinatorial Theory B 92 (2004), 325–357 Tarjan, R.E. [1972]: Depth first search and linear graph algorithms. SIAM Journal on Computing 1 (1972), 146–160 Thomassen, C. [1980]: Planarity and duality of finite and infinite graphs. Journal of Combinatorial Theory B 29 (1980), 244–271 Thomassen, C. [1981]: Kuratowski’s theorem. Journal of Graph Theory 5 (1981), 225–241 Tutte, W.T. [1961]: A theory of 3-connected graphs. Proceedings of the Koninklijke Nederlandse Akademie van Wetenschappen A 64 (1961), 441–455

References

49

Wagner, K. [1937]: Über eine Eigenschaft der ebenen Komplexe. Mathematische Annalen 114 (1937), 570–590 Whitney, H. [1932]: Non-separable and planar graphs. Transactions of the American Mathematical Society 34 (1932), 339–362 Whitney, H. [1933]: Planar graphs. Fundamenta Mathematicae 21 (1933), 73–84

•

3 Linear Programming

In this chapter we review the most important facts about Linear Programming. Although this chapter is self-contained, it cannot be considered to be a comprehensive treatment of the field. The reader unfamiliar with Linear Programming is referred to the textbooks mentioned at the end of this chapter. The general problem reads as follows:

LINEAR PROGRAMMING Instance:

A matrix A 2 Rmn and column vectors b 2 Rm ; c 2 Rn .

Task:

Find a column vector x 2 Rn such that Ax b and c > x is maximum, decide that fx 2 Rn W Ax bg is empty, or decide that for all ˛ 2 R there is an x 2 Rn with Ax b and c > x > ˛.

Here c > x denotes the scalar product of the vectors. The notion x y for vectors x and y (of equal size) means that the inequality holds in each component. If no sizes are specified, the matrices and vectors are always assumed to be compatible in size. We often omit indicating the transposition of column vectors and write e.g. cx for the scalar product. By 0 we denote the number zero as well as all-zero vectors and all-zero matrices (the order will always be clear from the context). A linear program (LP) is an instance of the above problem. We often write a linear program as maxfcx W Ax bg. A feasible solution of an LP maxfcx W Ax bg is a vector x with Ax b. A feasible solution attaining the maximum is called an optimum solution. As the problem formulation indicates, there are two possibilities when an LP has no solution: The problem can be infeasible (i.e. P WD fx 2 Rn W Ax bg D ;) or unbounded (i.e. for all ˛ 2 R there is an x 2 P with cx > ˛). If an LP is neither infeasible nor unbounded it has an optimum solution: Proposition 3.1. Let P D fx 2 Rn W Ax bg 6D ; and c 2 Rn with ı WD supfc > x W x 2 P g < 1. Then there exists a vector ´ 2 P with c > ´ D ı. Proof: Let U be a matrix whose columns are an orthonormal of the kernel basis of A, i.e. U > U D I , AU D 0, and rank.A0 / D n where A0 WD UA> . Let b 0 WD b0 . We show that for every y 2 P there exists a subsystem A00 x b 00 of A0 x b 0 such that A00 is nonsingular, y 0 WD .A00 /1 b 00 2 P , and c > y 0 c > y. As there are

B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__3, c Springer-Verlag Berlin Heidelberg 2012

51

52

3 Linear Programming

only finitely many such subsystems, one of these y 0 attains the maximum (c > y 0 D ı), and the assertion follows. So let y 2 P , and denote by k.y/ the rank of A00 for the maximal subsystem A00 x b 00 of A0 x b 0 with A00 y D b 00 . Suppose that k.y/ < n. We show how to find a y 0 2 P with c > y 0 c > y and k.y 0 / > k.y/. After at most n steps we have a vector y 0 with k.y 0 / D n as required. If U > y 6D 0, we set y 0 WD y U U > y. Since y C U U > c 2 P for all 2 R we have supfc > .y C U U > c/ W 2 Rg ı < 1 and hence c > U D 0 and c > y 0 D c > y. Moreover, Ay 0 D Ay AU U > y D Ay and U > y 0 D U > y U > U U > y D 0. Now suppose that U > y D 0. Let v 6D 0 with nA00 v D 0. Denote o by ˇi ai y ai x ˇi the i -th row of Ax b. Let WD min a v W ai v > 0 and i n o ˇi ai y WD max ai v W ai v < 0 , where min ; D 1 and max ; D 1. We have

0 , and at least one of and is finite (because A0 v 6D 0 but U > v D 0). For 2 R with we have A00 .y C v/ D A00 y C A00 v D A00 y D b 00 and A.yCv/ D AyCAv b, i.e. yCv 2 P . Thus, as supfc > x W x 2 P g < 1, we have < 1 if c > v > 0 and > 1 if c > v < 0. Moreover, if c > v 0 and < 1, we have ai .y C v/ D ˇi for some i . Analogously, if c > v 0 and > 1, we have ai .y C v/ D ˇi for some i . Thus in each case we have found a vector y 0 2 P with c > y 0 c > y and k.y 0 / k.y/ C 1.

This justifies the notation maxfc > x W Ax bg instead of supfc > x W Ax bg. Many combinatorial optimization problems can be formulated as LPs. To do this, we encode the feasible solutions as vectors in Rn for some n. In Section 3.5 we show that one can optimize a linear objective function over a finite set S of vectors by solving a linear program. Although the feasible set of this LP contains not only the vectors in S but also all their convex combinations, one can show that among the optimum solutions there is always an element of S . In Section 3.1 we compile some terminology and basic facts about polyhedra, the sets P D fx 2 Rn W Ax bg of feasible solutions of LPs. In Sections 3.2 and 3.3 we present the SIMPLEX ALGORITHM, which we also use to derive the Duality Theorem and related results (Section 3.4). LP duality is a most important concept which explicitly or implicitly appears in almost all areas of combinatorial optimization; we shall often refer to the results in Sections 3.4 and 3.5.

3.1 Polyhedra Linear Programming deals with maximizing or minimizing a linear objective function of finitely many variables subject to finitely many linear inequalities. So the set of feasible solutions is the intersection of finitely many halfspaces. Such a set is called a polyhedron:

3.1

Polyhedra

53

Definition 3.2. A polyhedron in Rn is a set of type P D fx 2 Rn W Ax bg for some matrix A 2 Rmn and some vector b 2 Rm . If A and b are rational, then P is a rational polyhedron. A bounded polyhedron is also called a polytope. We denote by rank.A/ the rank of a matrix A. The dimension dim X of a nonempty set X Rn is defined to be n maxfrank.A/ W A is an n n-matrix with Ax D Ay for all x; y 2 X g: A polyhedron P Rn is called full-dimensional if dim P D n. Equivalently, a polyhedron is full-dimensional if and only if there is a point in its interior. For most of this chapter it makes no difference whether we are in the rational or real space. We need the following standard terminology: Definition 3.3. Let P WD fx W Ax bg be a nonempty polyhedron. If c is a nonzero vector for which ı WD maxfcx W x 2 P g is finite, then fx W cx D ıg is called a supporting hyperplane of P . A face of P is P itself or the intersection of P with a supporting hyperplane of P . A point x for which fxg is a face is called a vertex of P , and also a basic solution of the system Ax b. Proposition 3.4. Let P D fx W Ax bg be a polyhedron and F P . Then the following statements are equivalent: (a) F is a face of P . (b) There exists a vector c such that ı WD maxfcx W x 2 P g is finite and F D fx 2 P W cx D ıg. (c) F D fx 2 P W A0 x D b 0 g 6D ; for some subsystem A0 x b 0 of Ax b. Proof: (a) and (b) are obviously equivalent. (c))(b): If F D fx 2 P W A0 x D b 0 g is nonempty, let c be the sum of the rows of A0 , and let ı be the sum of the components of b 0 . Then obviously cx ı for all x 2 P and F D fx 2 P W cx D ıg. (b))(c): Assume that c is a vector, ı WD maxfcx W x 2 P g is finite and F D fx 2 P W cx D ıg. Let A0 x b 0 be the maximal subsystem of Ax b such that A0 x D b 0 for all x 2 F . Let A00 x b 00 be the rest of the system Ax b. We first observe that for each inequality ai00 x ˇi00 of A00 x b 00 (i D 1; : : : ; k) P there is a point xi 2 F such that ai00 xi < ˇi00 . Let x WD k1 kiD1 xi be the center of gravity of these points (if k D 0, we can choose an arbitrary x 2 F ); we have x 2 F and ai00 x < ˇi00 for all i . We have to prove that A0 y D b 0 cannot hold for any y 2 P nF . So let y 2 P nF . We have cy < ı. Now consider ´ WD x C .x y/ for some small > 0; in ˇ 00 a00 x particular let be smaller than a00i .x iy/ for all i 2 f1; : : : ; kg with ai00 x > ai00 y. i

We have c´ > ı and thus ´ … P . So there is an inequality ax ˇ of Ax b such that a´ > ˇ. Thus ax > ay. The inequality ax ˇ cannot belong to A00 x ˇ ax b 00 , since otherwise we have a´ D ax Ca.x y/ < ax C a.x y/ a.x y/ D ˇ

54

3 Linear Programming

(by the choice of ). Hence the inequality ax ˇ belongs to A0 x b 0 . Since ay D a.x C 1 .x ´// < ˇ, this completes the proof. As a trivial but important corollary we remark: Corollary 3.5. If maxfcx W x 2 P g is bounded for a nonempty polyhedron P and a vector c, then the set of points where the maximum is attained is a face of P . The relation “is a face of ” is transitive: Corollary 3.6. Let P be a polyhedron and F a face of P . Then F is again a polyhedron. Furthermore, a set F 0 F is a face of P if and only if it is a face of F . The maximal faces distinct from P are particularly important: Definition 3.7. Let P be a polyhedron. A facet of P is a maximal face distinct from P . An inequality cx ı is facet-defining for P if cx ı for all x 2 P and fx 2 P W cx D ıg is a facet of P . Proposition 3.8. Let P fx 2 Rn W Ax D bg be a nonempty polyhedron of dimension n rank.A/. Let A0 x b 0 be a minimal inequality system such that P D fx W Ax D b; A0 x b 0 g. Then each inequality of A0 x b 0 is facet-defining for P , and each facet of P is defined by an inequality of A0 x b 0 . Proof: If P D fx 2 Rn W Ax D bg, then there are no facets and the statement is trivial. So let A0 x b 0 be a minimal inequality system with P D fx W Ax D b; A0 x b 0 g, let a0 x ˇ 0 be one of its inequalities and A00 x b 00 be the rest of the system A0 x b 0 . Let y be a vector with Ay D b, A00 y b 00 and a0 y > ˇ 0 (such a vector y exists as the inequality a0 x ˇ 0 is not redundant). Let x 2 P such that A0 x < b 0 (such a vector must exist because dim P D n rank.A/). 0 a0 x 0 0 00 00 Consider ´ WD x C aˇ0 ya 0 x .y x/. We have a ´ D ˇ , A ´ < b , and, since 0

0

a x 0 0 0 < aˇ0 ya 0 x < 1, ´ 2 P . Therefore F WD fx 2 P W a x D ˇ g 6D 0 and F 6D P (as x 2 P n F ). We conclude that F is a facet of P . By Proposition 3.4 each facet is defined by an inequality of A0 x b 0 .

The other important class of faces (beside facets) are minimal faces (i.e. faces not containing any other face). Here we have: Proposition 3.9. (Hoffman and Kruskal [1956]) Let P D fx W Ax bg be a polyhedron. A nonempty subset F P is a minimal face of P if and only if F D fx W A0 x D b 0 g for some subsystem A0 x b 0 of Ax b. Proof: If F is a minimal face of P , by Proposition 3.4 there is a subsystem A0 x b 0 of Ax b such that F D fx 2 P W A0 x D b 0 g. We choose A0 x b 0 maximal. Let A00 x b 00 be a minimal subsystem of Ax b such that F D fx W A0 x D b 0 ; A00 x b 00 g. We claim that A00 x b 00 does not contain any inequality.

3.1

Polyhedra

55

Suppose, on the contrary, that a00 x ˇ 00 is an inequality of A00 x b 00 . Since it is not redundant for the description of F , Proposition 3.8 implies that F 0 WD fx W A0 x D b 0 ; A00 x b 00 ; a00 x D ˇ 00 g is a facet of F . By Corollary 3.6 F 0 is also a face of P , contradicting the assumption that F is a minimal face of P . Now let ; 6D F D fx W A0 x D b 0 g P for some subsystem A0 x b 0 of Ax b. Obviously F has no faces except itself. By Proposition 3.4, F is a face of P . It follows by Corollary 3.6 that F is a minimal face of P . Corollary 3.5 and Proposition 3.9 imply that LINEAR PROGRAMMING can be solved in finite time by solving the linear equation system A0 x D b 0 for each subsystem A0 x b 0 of Ax b. A more intelligent way is the SIMPLEX ALGORITHM which is described in the next section. Another consequence of Proposition 3.9 is: Corollary 3.10. Let P D fx 2 Rn W Ax bg be a polyhedron. Then all minimal faces of P have dimension nrank.A/. The minimal faces of polytopes are vertices. This is why polyhedra fx 2 Rn W Ax bg with rank.A/ D n are called pointed: their minimal faces are points. Let us close this section with some remarks on polyhedral cones. Definition 3.11. A (convex) cone is a set C Rn for which x; y 2 C and ; 0 implies x C y 2 C . A cone C is said to be generated by x1 ; : : : ; xk if x1 ; : : : ; xk 2 C and for any x 2 C there are numbers 1 ; : : : ; k 0 with P x D kiD1 i xi . A cone is called finitely generated if some finite set of vectors generates it. A polyhedral cone is a polyhedron of type fx W Ax 0g. It is immediately clear that polyhedral cones are indeed cones. We shall now show that polyhedral cones are finitely generated. I always denotes an identity matrix. Lemma 3.12. (Minkowski [1896]) Let C D fx 2 Rn W Ax 0g be a polyhedral 0 cone. Then C is generated by a subset of the set of solutions A to the 0systems My D b , where M consists of n linearly independent rows of I and b D ˙ej for some unit vector ej . Proof: Let A be an m n-matrix. Consider My D b 0 where M A the systems 0 consists of n linearly independent rows of I and b D ˙ej for some unit vector ej . Let y1 ; : : : ; y t be those solutions of these equality systems that belong to C . We claim that C is generated by y1 ; : : : ; y t . First suppose C D fx W Ax D 0g, i.e. C is a linear subspace. Write C D fx W A0 x D 0g where A0 consists of a maximal of linearly independent rows of A. Let 0set I 0 consist of some rows of I such that A is a nonsingular square matrix. Then C 0 I is generated by the solutions of

56

3 Linear Programming

0 A 0 x D ; b I0

for b D ˙ej , j D 1; : : : ; dim C .

For the general case we use induction on the dimension of C . If C is not a linear subspace, then there is a vector ´ 2 C such that ´ … C . Then there is a row a of A such that a´ < 0. 0 Let A0 consist of any maximal set of rows of A such that (i) the rows of Aa are linearly independent, and (ii) there exists a vector ´ 2 C with A0 ´ D 0 and a´ < 0. Let y be any vector with A0 y D 0 and ay D 1. We claim that y 2 C . Let ´ satisfy (ii), i.e., ´ 2 C , A0 ´ D 0 and a´ < 0. Let B be the set of rows b of A with by > 0. Each b 2 B must be linearly independent of a and A0 : otherwise b D cA0 C ıa for a vector c and a number ı, but then 0 b´ D cA0 ´ C ıa´ D ıa´, hence ı 0, contradicting 0 < by D cA0 y C ıay D ı. b´ Suppose that B is nonempty. Let WD minf by W b 2 Bg. We have 0. Then 0 0 0 0 0 ´ WD ´ y 2 C , A ´ D A ´ A y D 0, a´0 D a´ ay < 0, and there is a b 0 2 B with b 0 ´0 D 0. This contradicts the maximality of A0 . So B D ;, i.e., y 2 C. Hence by construction there is an index s 2 f1; : : : ; tg such that A0 ys D 0 and ays D 1. Now letn an arbitrary ´ 2 C be given.o Let a1 ; : : : ; am be the rows of A and WD min aaiy´s W i D 1; : : : ; m; ai ys < 0 . We have 0. Let k be an index i

where the minimum is attained. Consider ´0 WD ´ ys . By the definition of we have aj ´0 D aj ´ aaky´s aj ys for j D 1; : : : ; m, and hence ´0 2 C 0 WD fx 2 k C W ak x D 0g. C 0 is a cone whose dimension is one less than that of C (because ak ys P < 0 and ys 2 C ). By induction, C 0 is generated by a subset of y1 ; : : : ; y t , so 0 ´ D ti D1 i yi for some 1 ; : : : ; t 0. By setting 0s P WD s C (observe that 0) and 0i WD i (i 6D s), we obtain ´ D ´0 C ys D ti D1 0i yi . Thus any polyhedral cone is finitely generated. We shall show the converse at the end of Section 3.4.

3.2 The Simplex Algorithm The oldest and best-known algorithm for L INEAR PROGRAMMING is Dantzig’s [1951] simplex method. We first assume that the polyhedron has a vertex, and that some vertex is given as input. Later we shall show how general LPs can be solved with this method. For a set J of row indices we write AJ for the submatrix of A consisting of the rows in J only, and bJ for the subvector of b consisting of the components with indices in J . We abbreviate ai WD Afi g and ˇi WD bfi g .

3.2

The Simplex Algorithm

57

SIMPLEX ALGORITHM Input: Output:

A matrix A 2 Rmn and column vectors b 2 Rm ; c 2 Rn . A vertex x of P WD fx 2 Rn W Ax bg. A vertex x of P attaining maxfcx W x 2 P g or a vector w 2 Rn with Aw 0 and cw > 0 (i.e. the LP is unbounded).

1

Choose a set of n row indices J such that AJ is nonsingular and AJ x D bJ .

2

Compute c .AJ /1 and add zeros in order to obtain a vector y with c D yA such that all entries of y outside J are zero. If y 0 then stop. Return x and y. Choose the minimum index i with yi < 0. Let w be the column of .AJ /1 with index i , so AJ nfi g w D 0 and ai w D 1. If Aw 0 then stop. Return w. ˇj aj x W j 2 f1; : : : ; mg; aj w > 0 , Let WD min aj w and let j be the smallest row index attaining this minimum. Set J WD .J n fi g/ [ fj g and x WD x C w. Go to . 2

3

4 5

Step 1 relies on Proposition 3.9 and can be implemented with GAUSSIAN ELIMINATION (Section 4.3). The selection rules for i and j in 3 and 4 (often called pivot rule) are due to Bland [1977]. If one just chose an arbitrary i with yi < 0 and an arbitrary j attaining the minimum in 4 the algorithm would run into cyclic repetitions for some instances. Bland’s pivot rule is not the only one that avoids cycling; another one (the so-called lexicographic rule) was proved to avoid cycling already by Dantzig, Orden and Wolfe [1955]. Before proving the correctness of the SIMPLEX ALGORITHM, let us make the following observation (sometimes known as “weak duality”): Proposition 3.13. Let x and y be feasible solutions of the LPs maxfcx W Ax bg

and

(3.1)

minfyb W y A D c ; y 0g;

(3.2)

>

>

respectively. Then cx yb. Proof: cx D .yA/x D y.Ax/ yb.

Theorem 3.14. (Dantzig [1951], Dantzig, Orden and Wolfe [1955], Bland [1977]) The SIMPLEX ALGORITHM terminates after at most m iterations. If it returns n x and y in , 2 these vectors are optimum solutions of the LPs (3.1) and (3.2), respectively, with cx D yb. If the algorithm returns w in 3 then cw > 0 and the LP (3.1) is unbounded.

58

3 Linear Programming

Proof: We first prove that the following conditions hold at any stage of the algorithm: (a) (b) (c) (d) (e)

x 2 P; AJ x D bJ ; AJ is nonsingular; cw > 0; 0.

(a) and (b) hold initially. 2 and 3 guarantee cw D yAw D yi > 0. By , 4 x 2 P implies 0. (c) follows from the fact that AJ nfi g w D 0 and aj w > 0. It remains to show that 5 preserves (a) and (b). We show that if x 2 P , then also x C w 2 P . For a row index k we have two cases: If ak w 0 then (using 0) ak .x C w/ ak x ˇk . Otherwise ˇkaawk x and hence ak .x C w/ ak x C ak w ˇkaawk x D ˇk . (Indeed, is k k chosen in 4 to be the largest number such that x C w 2 P .) ˇ a x To show (b), note that after 4 we have AJ nfi g w D 0 and D ja wj , so j ˇ a x

AJ nfi g .x C w/ D AJ nfi g x D bJ nfi g and aj .x C w/ D aj x C aj w jaj wj D ˇj . Therefore after , 5 AJ x D bJ holds again. So we indeed have (a)–(e) at any stage. If the algorithm returns x and y in , 2 x and y are feasible solutions of (3.1) and (3.2), respectively. x is a vertex of P by (a), (b) and (c). Moreover, cx D yAx D yb since the components of y are zero outside J . This proves the optimality of x and y by Proposition 3.13. If the algorithm stops in , 3 the LP (3.1) is indeed unbounded because in this case x C w 2 P for all 0, and cw > 0 by (d). We finally show that the algorithm terminates. Let J .k/ and x .k/ be the set J and the vector x in iteration k of the SIMPLEX ALGORITHM, respectively. If the algorithm did not terminate after m n iterations, there are iterations k < l with .k/ .l/ .k/ J D J . By (b) and (c), x D x .l/ . By (d) and (e), cx never decreases, and it strictly increases if > 0. Hence is zero in all the iterations k; k C 1; : : : ; l 1, and x .k/ D x .kC1/ D D x .l/ . Let h be the highest index leaving J in one of the iterations k; : : : ; l 1, say in iteration p. Index h must also have been added to J in some iteration q 2 fk; : : : ; l 1g. Now let y 0 be the vector y at iteration p, and let w 0 be the vector w at iteration q. We have y 0 Aw 0 D cw 0 > 0. So let r be an index for which yr0 ar w 0 > 0. Since yr0 6D 0, index r belongs to J .p/ . If r > h, index r would also belong to J .q/ and J .qC1/ , implying ar w 0 D 0. So r h. But by the choice of i in iteration p we have yr0 < 0 iff r D h, and by the choice of j in iteration q we have ar w 0 > 0 iff r D h (recall that D 0 and ar x .q/ D ar x .p/ D ˇr as r 2 J .p/ ). This is a contradiction. Klee and Minty [1972] and Avis and Chvátal [1978] found examples where the SIMPLEX ALGORITHM (with Bland’s rule) needs 2n iterations on LPs with n variables and 2n constraints, proving that it is not a polynomial-time algorithm. It is not

3.2

The Simplex Algorithm

59

known whether there is a pivot rule that leads to a polynomial-time algorithm. However, Borgwardt [1982] showed that the average running time (for random instances in a certain natural probabilistic model) can be bounded by a polynomial. Spielman and Teng [2004] introduced a so-called smoothed analysis: for each input they consider the expected running time with respect to small random perturbations of the input. The maximum of all these expectations is polynomially bounded. Kelner and Spielman [2006] proposed a randomized polynomial-time algorithm for L INEAR PROGRAMMING that is similar to the SIMPLEX A LGORITHM . The SIMPLEX ALGORITHM is also quite fast in practice if implemented skilfully; see Section 3.3. We now show how to solve general linear programs with the SIMPLEX ALGORITHM. More precisely, we show how to find an initial vertex. Since there are polyhedra that do not have vertices at all, we put a given LP into a different form first. Let maxfcx W Ax bg be an LP. We substitute x by y ´ and write it equivalently in the form y y c c max W A A b; y; ´ 0 : ´ ´ So w.l.o.g. we assume that our LP has the form maxfcx W A0 x b 0 ; A00 x b 00 ; x 0g

(3.3)

with b 0 0 and b 00 < 0. We first run the SIMPLEX ALGORITHM on the instance minf.1lA00 /x C 1ly W A0 x b 0 ; A00 x C y b 00 ; x; y 0g; (3.4) where 1l denotes a vector whose entries are all 1. Since xy D 0 defines a vertex, this is possible. The LP is obviously not unbounded x since the minimum must be at least 1lb 00 . For any feasible solution x of (3.3), b 00 A is an optimum solution of 00 x (3.4) of value 1lb 00 . Hence if the minimum of (3.4) is greater than 1lb 00 , then (3.3) is infeasible. In the contrary case, let yx be an optimum vertex of (3.4) of value 1lb 00 . We claim that x is a vertex of the polyhedron defined by (3.3). To see this, first observe that A00 x C y D b 00 . Let n and m be the dimensions of x and y, respectively; then by Proposition 3.9 there is a set S of n C m inequalities of (3.4) satisfied with equality, such that the submatrix corresponding to these n C m inequalities is nonsingular. Let S 0 be the inequalities of A0 x b 0 and of x 0 that belong to S . Let S 00 consist of those inequalities of A00 x b 00 for which the corresponding inequalities of A00 x C y b 00 and y 0 both belong to S . Obviously jS 0 [ S 00 j jS j m D n, and the inequalities of S 0 [ S 00 are linearly independent and satisfied by x with equality. Hence x satisfies n linearly independent inequalities of (3.3) with equality; thus x is indeed a vertex. Therefore we can start the SIMPLEX ALGORITHM with (3.3) and x.

60

3 Linear Programming

3.3 Implementation of the Simplex Algorithm The previous description of the SIMPLEX ALGORITHM is simple but not suitable for an efficient implementation. As we will see, it is not necessary to solve a linear equation system in each iteration. To motivate the main idea, we start with a proposition (which is actually not needed later): for LPs of the form maxfcx W Ax D b; x 0g, vertices can be represented not only by subsets of rows but also by subsets of columns. For a matrix A and a set J of column indices we denote by AJ the submatrix consisting of the columns in J only. Consequently, AIJ denotes the submatrix of A with rows in I and columns in J . Sometimes the order of the rows and columns is important: if J D .j1 ; : : : ; jk / is a vector of row (column) indices, we denote by AJ (AJ ) the matrix whose i -th row (column) is the ji -th row (column) of A (i D 1; : : : ; k). Proposition 3.15. Let P WD fx W Ax D b; x 0g, where A is a matrix and b is a vector. Then x is a vertex of P if and only if x 2 P and the columns of A corresponding to positive entries of x are linearly independent. 0 0 0 Proof: Let A be an m n-matrix. Let X WD I A I and b WD b . Let N WD f1; : : : ; ng and M WD fnC1; : : : ; nCmg. For an index set J N [M with jJ j D n N \JN JN let JN WD .N [ M / n J . Then XJN is nonsingular iff XM \J is nonsingular iff XM is nonsingular. If x is a vertex of P , then – by Proposition 3.9 – there exists a set J N [ M such that jJ j D n, XJN is nonsingular, and XJN x D bJ0 . Then the components of JN x corresponding to N \ J are zero. Moreover, XM is nonsingular, and hence the N columns of AN \J are linearly independent. Conversely, let x 2 P , and let the set of columns of A corresponding to positive entries of x be linearly independent. By adding suitable unit column vectors to these B columns we obtain a nonsingular submatrix XM with xi D 0 for i 2 N n B. Then N N 0 XBN is nonsingular and XBN x D bBN . Hence, by Proposition 3.9, x is a vertex of P . ˚ Corollary 3.16. Let yx 2 P WD xy W Ax C y D b; x 0; y 0 . Then yx is a vertex of P if and only if the columns of .A I / corresponding to positive components of xy are linearly independent. Moreover, x is a vertex of fx W Ax b; x x 0g if and only if . bAx / is a vertex of P . We will now analyze the behaviour of the SIMPLEX ALGORITHM when applied to an LP of the form maxfcx W Ax b; x 0g. 0 0 Theorem 3.17. Let A 2 Rmn , b 2 Rm , and c 2 Rn . Let A0 WD I A , b WD b and cN WD .c > ; 0/. Let B 2 f1; : : : ; n C mgm such that .A I /B is nonsingular. Let J f1; : : : ; n C mg be the set of the remaining n indices. Let QB WD ..A I /B /1 . Then:

3.3

Implementation of the Simplex Algorithm

61

(a) A0J is nonsingular. (b) .b 0 A0 x/J D 0 and .b 0 A0 x/B D QB b and c > x D cNB QB b, where x WD .A0J /1 bJ0 . (c) Let y be the vector with yB D 0 and y > A0 D c > . Then y > D cNB QB .A I / c. N (d) Let i 2 J . Let w be the vector with A0i w D 1 and A0J nfi g w D 0. Then 0 AB w D QB .A I /i . (e) Define ! QB .A I / QB b : TB WD cNB QB .A I / cN c > x Given B and TB , we can compute B 0 and TB 0 in O.m.n C m// time, where B 0 arises from B by replacing j by i , and i and j are given as in – 2 4 of the SIMPLEX ALGORITHM (applied to A0 , b 0 , c, and index set J ). TB is called the simplex tableau with respect to the basis B. N nJ

Proof: (a): Let N WD f1; : : : ; ng. As .A I /B is nonsingular, also .A0 /J nN is nonsingular, and thus A0J is nonsingular. (b): The first statement follows directly from A0J x D bJ0 . Then b D Ax C I.b Ax/ D .A I /.b 0 A0 x/ D .A I /B .b 0 A0 x/B and c > x D c.b N 0 A0 x/ D B 0 0 B cN .b A x/B D cN QB b. (c): This follows from .cNB QB .A I / c/ N B D cNB QB .A I /B cNB D 0 and .cNB QB .A I / c/A N 0 D cNB QB .A I /A0 c > .I / D c > . 0 (d): This follows from 0 D .A I /A0 w D .A I /B .AB w/C.A I /J nfi g .A0J nfi g w/C i 0 B 0 i .A I / .Ai w/ D .A I / .AB w/ .A I / . (e): By (c), y as in 2 of the SIMPLEX ALGORITHM is given by the last row of TB . If y 0, we stop (x and y are optimal). Otherwise i is the first index with yi < 0, found in O.n C m/ time. If the i -th column of TB has no positive entry, we stop (the LP is unbounded, and w is given by (d)). Otherwise, by (b) and (d), we have that in 4 of the SIMPLEX ALGORITHM is given by .QB b/j i D min W j 2 f1; : : : ; mg; .QB .A I / /j > 0 ; .QB .A I /i /j and among the indices attaining this minimum, j is the one for which the j -th component of B is minimum. So we can compute j in O.m/ time by considering the i -th and the last column of TB . This yields B 0 . We can compute the updated tableau TB 0 as follows: Divide the j -th row by the entry in row j and column i . Then add a suitable multiple of the j -th row to all other rows, such that the i -th column has zeros only outside row j . Note that these row operations do not destroy the property that the tableau has the form Q.A I / Qb v.A I / cN vb

62

3 Linear Programming

for some nonsingular matrix Q and some vector v, and in addition we have 0 0 Q.A I /B D I and .v.A I / c/ N B D 0. Since there is only one choice for Q 0 and v, namely Q D QB 0 and v D cNB QB 0 , the updated tableau TB 0 is computed correctly by the above operations in O.m.n C m// time. To start the SIMPLEX ALGORITHM we consider an LP of the form maxfcx W A0 x b 0 ; A00 x b 00 ; x 0g 0

00 n

with A0 2 Rm n , A00 2 Rm ALGORITHM on the instance

, b 0 0 and b 00 < 0. We first run the SIMPLEX

minf.1lA00 /x C 1ly W A0 x b 0 ; A00 x C y b 00 ; x; y 0g; starting with the tableau

0

1 A0 0 I 0 b 0 @ A00 I 0 I b 00 A ; 1lA00 1l 0 0 0

(3.5)

corresponding to the basic solution x D 0, y D 0. Then we run the iterations of the SIMPLEX ALGORITHM as in Theorem 3.17(e). If the algorithm terminates with optimum value 1lb, we modify the final simplex tableau as follows. Multiply some rows by 1 such that none of the columns n C m00 Cm0 C1; : : : ; nCm00 Cm0 Cm00 (the fourth section in (3.5)) is a unit vector, delete the fourth section of the tableau (i.e. columns nCm00 Cm0 C1; : : : ; nCm00 Cm0 Cm00 ), and replace the last row by .c; 0; 0; 0/. Then add suitable multiples of the other rows to the last row in order to get zeros at m0 Cm00 places corresponding to columns with distinct unit vectors; these will form our basis. The result is the simplex tableau with respect to the original LP and this basis. Therefore we can continue running the iterations of the SIMPLEX ALGORITHM as in Theorem 3.17(e). In fact, one can often do even more efficiently. Suppose we want to solve an LP minfcx W Ax b; x 0g with a very large number of inequalities which are implicitly given in a way that allows us to solve the following problem efficiently: Given a vector x 0, decide if Ax b and find a violated inequality otherwise. We apply the SIMPLEX ALGORITHM to the dual LP maxfyb W yA c; y 0g D maxfby W A> y c; y 0g. Let bN WD .b > ; 0/. For a basis B we set QB WD ..A> I /B /1 and store only the right-hand part of the simplex tableau ! QB QB c : bN B QB b > x N To perform an iteration, The last row of the full simplex tableau is bN B QB .A> I / b. we must check if bN B QB 0 and bN B QB A> b 0, and find a negative component if one exists. This reduces to solving the above problem for x D .bN B QB /> . Then we generate the corresponding column of the full simplex tableau, but only for the

3.4

Duality

63

current iteration. After updating the reduced tableau we can delete it again. This technique is known under the names revised simplex and column generation. We will see applications later.

3.4 Duality Theorem 3.14 shows that the LPs (3.1) and (3.2) are related. This motivates the following definition: Definition 3.18. Given a linear program maxfcx W Ax bg, we define the dual LP to be the linear program minfyb W yA D c; y 0g. In this case, the original LP maxfcx W Ax bg is often called the primal LP. Proposition 3.19. The dual of the dual of an LP is (equivalent to) the original LP. Proof: Let the primal LP maxfcx W Ax bg be given. Its dual is minfyb W yA D c; y 0g, or equivalently 8 0 > 1 0 19 A c = < max by W @A> A y @c A : ; : 0 I (Each equality constraint has been split up into two inequality constraints.) So the dual of the dual is 8 9 0 1 ´ < = min ´c ´0 c W A A I @´0 A D b; ´; ´0 ; w 0 : ; w which is equivalent to minfcx W Ax w D b; w 0g (where we have substituted x for ´0 ´). By eliminating the slack variables w we see that this is equivalent to the primal LP. We now obtain the most important theorem in LP theory, the Duality Theorem: Theorem 3.20. (von Neumann [1947], Gale, Kuhn and Tucker [1951]) If the polyhedra P WD fx W Ax bg and D WD fy W yA D c; y 0g are both nonempty, then maxfcx W x 2 P g D minfyb W y 2 Dg. Proof: If D is nonempty, it has a vertex y. We run the SIMPLEX ALGORITHM for minfyb W y 2 Dg and y. By Proposition 3.13, the existence of some x 2 P guarantees that minfyb W y 2 Dg is not unbounded. Thus by Theorem 3.14, the

64

3 Linear Programming

SIMPLEX ALGORITHM returns optimum solutions y and ´ of the LP minfyb W y 2 Dg and its dual. However, the dual is maxfcx W x 2 P g by Proposition 3.19. We have yb D c´, as required. We can say even more about the relation between the optimum solutions of the primal and dual LP: Corollary 3.21. Let maxfcx W Ax bg and minfyb W yA D c; y 0g be a primal-dual pair of LPs. Let x and y be feasible solutions, i.e. Ax b, yA D c and y 0. Then the following statements are equivalent: (a) x and y are both optimum solutions. (b) cx D yb. (c) y.b Ax/ D 0. Proof: The Duality Theorem 3.20 immediately implies the equivalence of (a) and (b). The equivalence of (b) and (c) follows from y.b Ax/ D yb yAx D yb cx. The property (c) of optimum solutions is often called complementary slackness. It can also be formulated as follows: a point x 2 P D fx W Ax bg is an optimum solution of maxfcx W x 2 P g if and only if c is a nonnegative combination of those rows of A which correspond to inequalities of Ax b that are satisfied by x with equality. It also implies: Corollary 3.22. Let P D fx W Ax bg be a polyhedron and ; 6D Z P . Then the set of vectors c for which each ´ 2 Z is an optimum solution of maxfcx W x 2 P g is the cone generated by the rows of A0 , where A0 x b 0 is the maximal subsystem of Ax b with A0 ´ D b 0 for all ´ 2 Z. Proof: There is a ´ 2 conv.Z/ that satisfies all other inequalities of Ax b strictly. Let c be a vector for which each element of Z, and hence also ´, is an optimum solution of maxfcx W x 2 P g. Then by Corollary 3.21 there exists an y 0 with c D yA0 , i.e. c is a nonnegative linear combination of the rows of A0 . Conversely, for a row a0 x ˇ 0 of A0 x b 0 and ´ 2 Z we have a0 ´ D ˇ 0 D maxfa0 x W x 2 P g. Let us write Corollary 3.21 in another form: Corollary 3.23. Let minfcx W Ax b; x 0g and maxfyb W yA c; y 0g be a primal-dual pair of LPs. Let x and y be feasible solutions, i.e. Ax b, yA c and x; y 0. Then the following statements are equivalent: (a) x and y are both optimum solutions. (b) cx D yb. (c) .c yA/x D 0 and y.b Ax/ D 0. Proof: The˚ equivalence of (a) and (b) is obtained by applying the Duality Theorem b 3.20 to max .c/x W A . I x 0

3.4

Duality

65

To prove that (b) and (c) are equivalent, observe that we have y.b Ax/ 0 .c yA/x for any feasible solutions x and y, and that y.b Ax/ D .c yA/x iff yb D cx. The two conditions in (c) are sometimes called primal and dual complementary slackness conditions. The Duality Theorem has many applications in combinatorial optimization. One reason for its importance is that the optimality of a solution can be proved by giving a feasible solution of the dual LP with the same objective value. We shall show now how to prove that an LP is unbounded or infeasible: Theorem 3.24. There exists a vector x with Ax b if and only if yb 0 for each vector y 0 for which yA D 0. Proof: If there is a vector x with Ax b, then yb yAx D 0 for each y 0 with yA D 0. Consider the LP minf1lw W Ax w b; w 0g:

(3.6)

Writing it in standard form we have x A I x b max 0 1l W : w 0 I w 0 The dual of this LP is > y y 0 A 0 D ; y; ´ 0 ; min b 0 W I I ´ 1l ´ or, equivalently, minfyb W yA D 0; 0 y 1lg:

(3.7)

Since both (3.6) and (3.7) have a solution (x D 0, w D jbj, y D 0), we can apply Theorem 3.20. So the optimum values of (3.6) and (3.7) are the same. Since the system Ax b has a solution iff the optimum value of (3.6) is zero, the proof is complete. So the fact that a linear inequality system Ax b has no solution can be proved by giving a vector y 0 with yA D 0 and yb < 0. We mention two equivalent formulations of Theorem 3.24: Corollary 3.25. There is a vector x 0 with Ax b if and only if yb 0 for each vector y 0 with yA 0. A Proof: Apply Theorem 3.24 to the system I x b0 .

66

3 Linear Programming

Corollary 3.26. (Farkas [1894]) There is a vector x 0 with Ax D b if and only if yb 0 for each vector y with yA 0. A b Proof: Apply Corollary 3.25 to the system A x b , x 0. Corollary 3.26 is usually known as Farkas’ Lemma. The above results in turn imply the Duality Theorem 3.20 which is interesting since they have quite easy direct proofs (in fact they were known before the SIMPLEX ALGORITHM); see Exercises 11 and 12. We have seen how to prove that an LP is infeasible. How can we prove that an LP is unbounded? The next theorem answers this question. Theorem 3.27. If an LP is unbounded, then its dual LP is infeasible. If an LP has an optimum solution, then its dual also has an optimum solution. Proof: The first statement follows immediately from Proposition 3.13. To prove the second statement, suppose that the (primal) LP maxfcx W Ax bg has an optimum solution x , but the dual minfyb W yA D c; y 0g is infeasible (it cannot be unbounded due to the first statement). In other words, there is no y 0 with A> y D c, and we apply Farkas’ Lemma (Corollary 3.26) to get a vector ´ with ´A> 0 and ´c < 0. But then x ´ is feasible for the primal, because A.x ´/ D Ax A´ b. The observation c.x ´/ > cx therefore contradicts the optimality of x . So there are four cases for a primal-dual pair of LPs: either both have an optimum solution (in which case the optimum values are the same), or one is infeasible and the other one is unbounded, or both are infeasible. We also note: Corollary 3.28. A feasible LP maxfcx W Ax bg is bounded if and only if c belongs to the cone generated by the rows of A. Proof: The LP is bounded iff its dual is feasible, i.e. there is a y 0 with yA D c. Farkas’ Lemma also enables us to prove that each finitely generated cone is polyhedral: Theorem 3.29. (Minkowski [1896], Weyl [1935]) A cone is polyhedral if and only if it is finitely generated. Proof: The only-if direction is given by Lemma 3.12. So consider the cone C generated by a1 ; : : : ; a t . We have to show that C is polyhedral. Let A be the matrix whose rows are a1 ; : : : ; a t . By Lemma 3.12, the cone D WD fx W Ax 0g is generated by some vectors b1 ; : : : ; bs . Let B be the matrix whose rows are b1 ; : : : ; bs . We prove that C D fx W Bx 0g. As bj ai D ai bj 0 for all i and j , we have C fx W Bx 0g. Now suppose there is a vector w … C with Bw 0. w 62 C means that there is no v 0 such

3.5

Convex Hulls and Polytopes

67

that A> v D w. By Farkas’ Lemma (Corollary 3.26) this means that there is a vector y with yw < 0 and Ay 0. So y 2 D. Since D is generated by b1 ; : : : ; bs we have y D ´B for some ´ 0. But then 0 < yw D ´Bw 0, a contradiction.

3.5 Convex Hulls and Polytopes In this section we collect some more facts on polytopes. In particular, we show that polytopes are precisely those sets that are the convex hull of a finite number of points. We start by recalling some basic definitions: Definition 3.30. Given vectorsPx1 ; : : : ; xk 2 Rn and 1 ; : : : ; k 0 with Pk k i D1 i D 1, we call x D i D1 i xi a convex combination of x1 ; : : : ; xk . n A set X R is convex if x C .1 /y 2 X for all x; y 2 X and 2 Œ0; 1. The convex hull conv.X / of a set X is defined as the set of all convex combinations of points in X . An extreme point of a set X is an element x 2 X with x … conv.X n fxg/. So a set X is convex if and only if all convex combinations of points in X are again in X . The convex hull of a set X is the smallest convex set containing X . Moreover, the intersection of convex sets is convex. Hence polyhedra are convex. Now we prove the “finite basis theorem for polytopes”, a fundamental result which seems to be obvious but is not trivial to prove directly: Theorem 3.31. (Minkowski [1896], Steinitz [1916], Weyl [1935]) A set P is a polytope if and only if it is the convex hull of a finite set of points. Proof: (Schrijver [1986]) Let P D fx 2 Rn W Ax bg be a nonempty polytope. Obviously, x x P D xW 2 C ; where C D 2 RnC1 W 0; Ax b 0 : 1 C is a polyhedral 3.29 it is generated by finitely many nonzero xcone, so by x Theorem vectors, say by 11 ; : : : ; kk . Since P is bounded, all i are nonzero; w.l.o.g. all i are 1. So x 2 P if and only if x1 x x D 1 C C k k 1 1 1 for some 1 ; : : : ; k 0. In other words, P is the convex hull of x1 ; : : : ; xk . Now let P be the convex hull of x1 ; : : : ;xk 2 Rn . Then x 2 P if and only if x . 1 / 2 C , where C is the cone generated by x11 ; : : : ; x1k . By Theorem 3.29, C is polyhedral, so x C D W Ax C b 0 : We conclude that P D fx 2 Rn W Ax C b 0g.

68

3 Linear Programming

Corollary 3.32. A polytope is the convex hull of its vertices. Proof: Let P be a polytope. By Theorem 3.31, the convex hull of its vertices is a polytope Q. Obviously Q P . Suppose there is a point ´ 2 P n Q. Then there is a vector c with c´ > maxfcx W x 2 Qg. The supporting hyperplane fx W cx D maxfcy W y 2 P gg of P defines a face of P containing no vertex. This is impossible by Corollary 3.10. The previous two and the following result are the starting point of polyhedral combinatorics; they will be used very often in this book. For a given ground set E and a subset X E, the incidence vector of X (with respect to E) is defined as the vector x 2 f0; 1gE with xe D 1 for e 2 X and xe D 0 for e 2 E n X . Corollary 3.33. Let .E; F / be a set system, P the convex hull of the incidence vectors of the elements of F , and c W E ! R. Then maxfcx W x 2 P g D maxfc.X / W X 2 Fg. Proof: Since maxfcx W x 2 P g maxfc.X / W X 2 F g is trivial, let x be an optimum solution of maxfcx W x 2 P g (note that P is a polytope by Theorem 3.31). By definition of P , x is a convex combination of incidence vectors y1 ; : : : ; yk P P of elements of F : x D kiD1 i yi for some 1 ; : : : ; k 0 with kiD1 i D 1. Pk Since cx D i D1 i cyi , we have cyi cx for at least one i 2 f1; : : : ; kg. This yi is the incidence vector of a set Y 2 F with c.Y / D cyi cx.

Exercises 1. Let H be a hypergraph, F V .H /, Pand x; y W F ! R. The task is to find x; y W V .H / n F ! R such that e2E.H / .maxv2e x.v/ minv2e x.v/ C maxv2e y.v/ minv2e y.v// is minimum. Show that this can be formulated as an LP. Note: This is a relaxation of a placement problem in VLSI design. Here H is called the netlist, and its vertices correspond to modules that need to placed on the chip. Some (those in F ) are pre-placed in advance. The main difficulty (ignored in this relaxation) is that modules must not overlap. 2. A set of vectors x1 ; : : : ; xk is called affinely independent if there is no 2 P Rk n f0g with > 1l D 0 and kiD1 i xi D 0. Let ; 6D X Rn . Show that the maximum cardinality of an affinely independent set of elements of X equals dim X C 1. 3. Let P; Q 2 Rn be polyhedra. Prove that the closure of conv.P [ Q/ is a polyhedron. Show polyhedra P and Q for which conv.P [ Q/ is not a polyhedron. 4. Show that the problem to compute the largest ball that is a subset of a given polyhedron can be formulated as a linear program. 5. Let P be a polyhedron. Prove that the dimension of any facet of P is one less than the dimension of P .

Exercises

69

6. Let F be a minimal face of a polyhedron fx W Ax bg. Prove that then Ax D Ay for all x; y 2 F . 7. Let A 2 Rmn , b 2 Rm , c 2 Rn , and u 2 Zn . Consider the LP maxfcx W Ax b; 0 x ug. Prove: if this LP has an optimum solution, then it has an optimum solution with at most m components that are not integers. 8. Formulate the dual of the LP formulation (1.1) of the JOB ASSIGNMENT PROBLEM. Show how to solve the primal and the dual LP in the case when there are only two jobs (by a simple algorithm). 9. Let G be a digraph, c W E.G/ ! RC , E1 ; E2 E.G/, and s; t 2 V .G/. Consider the following linear program X

min

c.e/ye

e2E.G/

ye ´ t ´s ye ye

s.t.

´w ´v D1 0 0

.e D .v; w/ 2 E.G// .e 2 E1 / .e 2 E2 /:

Prove that there is an optimum solution .y; ´/ and s 2 X V .G/ n ftg with ye D 1 for e 2 ı C .X /, ye D 1 for e 2 ı .X / n E1 , and ye D 0 for all other edges e. Hint: Consider the complementary slackness conditions for the edges entering or leaving fv 2 V .G/ W ´v ´s g. 10. Let Ax b be a linear inequality system in n variables. By multiplying each row by a positive constant we may assume that the first column of A is a vector with entries 0, 1 and 1 only. So we can write Ax b equivalently as ai0 x 0 bi x1 C aj0 x 0 bj

x1 C ak0 x 0 bk

.i D 1; : : : ; m1 /; .j D m1 C 1; : : : ; m2 /; .k D m2 C 1; : : : ; m/;

0 where x 0 D .x2 ; : : : ; xn / and a10 ; : : : ; am are the rows of A without the first entry. Then one can eliminate x1 : Prove that Ax b has a solution if and only if the system

aj0 x 0

ai0 x 0 bi

bj bk ak0 x 0

.i D 1; : : : ; m1 /; .j D m1 C 1; : : : ; m2 ; k D m2 C 1; : : : ; m/

has a solution. Show that this technique, when iterated, leads to an algorithm for solving a linear inequality system Ax b (or proving infeasibility). Note: This method is known as Fourier-Motzkin elimination because it was proposed by Fourier and studied by Motzkin [1936]. One can prove that it is not a polynomial-time algorithm.

70

3 Linear Programming

11. Use Fourier-Motzkin elimination (Exercise 10) to prove Theorem 3.24 directly. (Kuhn [1956]) 12. Show that Theorem 3.24 implies the Duality Theorem 3.20. 13. Prove the decomposition theorem for polyhedra: Any polyhedron P can be written as P D fx C c W x 2 X; c 2 C g, where X is a polytope and C is a polyhedral cone. (Motzkin [1936]) 14. Let P be a rational polyhedron and F a face of P . Show that fc W c´ D max fcx W x 2 P g for all ´ 2 F g is a rational polyhedral cone. 15. Prove Carathéodory’s theorem: If X Rn and y 2 conv.X /, then there are x1 ; : : : ; xnC1 2 X such that y 2 conv.fx1 ; : : : ; xnC1 g/. (Carathéodory [1911]) 16. Prove the following extension of Carathéodory’s theorem (Exercise 15): If X Rn and y; ´ 2 conv.X /, then there are x1 ; : : : ; xn 2 X such that y 2 conv.f´; x1 ; : : : ; xn g/. 17. Prove that the extreme points of a polyhedron are precisely its vertices. 18. Let P be a nonempty polytope. Consider the graph G.P / whose vertices are the vertices of P and whose edges correspond to the 1-dimensional faces of P . Let x be any vertex of P , and c a vector with c > x < maxfc > ´ W ´ 2 P g. Prove that then there is a neighbour y of x in G.P / with c > x < c > y. 19. Use Exercise 18 to prove that G.P / is n-connected for any n-dimensional polytope P (n 1). 20. Let P Rn be a polytope (not necessarily rational) and y … P . Prove that there exists a rational vector c with maxfcx W x 2 P g < cy. Show that the statement does not hold for general polyhedra. 21. Let X Rn be a nonempty convex set, XN the closure of X , and y … X . Prove: (a) There is a unique point in XN that has minimum distance to y. (b) There exists a vector a 2 Rn n f0g with a> x a> y for all x 2 X . (c) If y … XN , then there exists a vector a 2 Rn with a> x < a> y for all x 2 X . (d) If X is bounded and y … XN , then there exists a vector a 2 Qn with a> x < a> y for all x 2 X . (e) A closed convex set is the intersection of all closed half-spaces containing it.

References General Literature: Bertsimas, D., and Tsitsiklis, J.N. [1997]: Introduction to Linear Optimization. Athena Scientific, Belmont 1997

References

71

Chvátal, V. [1983]: Linear Programming. Freeman, New York 1983 Matoušek, J., and Gärtner, B. [2007]: Understanding and Using Linear Programming. Springer, Berlin 2007 Padberg, M. [1999]: Linear Optimization and Extensions. Second Edition. Springer, Berlin 1999 Schrijver, A. [1986]: Theory of Linear and Integer Programming. Wiley, Chichester 1986

Cited References: Avis, D., and Chvátal, V. [1978]: Notes on Bland’s pivoting rule. Mathematical Programming Study 8 (1978), 24–34 Bland, R.G. [1977]: New finite pivoting rules for the simplex method. Mathematics of Operations Research 2 (1977), 103–107 Borgwardt, K.-H. [1982]: The average number of pivot steps required by the simplex method is polynomial. Zeitschrift für Operations Research 26 (1982), 157–177 Carathéodory, C. [1911]: Über den Variabilitätsbereich der Fourierschen Konstanten von positiven harmonischen Funktionen. Rendiconto del Circolo Matematico di Palermo 32 (1911), 193–217 Dantzig, G.B. [1951]: Maximization of a linear function of variables subject to linear inequalities. In: Activity Analysis of Production and Allocation (T.C. Koopmans, ed.), Wiley, New York 1951, pp. 359–373 Dantzig, G.B., Orden, A., and Wolfe, P. [1955]: The generalized simplex method for minimizing a linear form under linear inequality restraints. Pacific Journal of Mathematics 5 (1955), 183–195 Farkas, G. [1894]: A Fourier-féle mechanikai elv alkalmazásai. Mathematikai és Természettudományi Értesitö 12 (1894), 457–472 Gale, D., Kuhn, H.W., and Tucker, A.W. [1951]: Linear programming and the theory of games. In: Activity Analysis of Production and Allocation (T.C. Koopmans, ed.), Wiley, New York 1951, pp. 317–329 Hoffman, A.J., and Kruskal, J.B. [1956]: Integral boundary points of convex polyhedra. In: Linear Inequalities and Related Systems; Annals of Mathematical Study 38 (H.W. Kuhn, A.W. Tucker, eds.), Princeton University Press, Princeton 1956, pp. 223–246 Kelner, J.A., and Spielman, D.A. [2006]: A randomized polynomial-time simplex algorithm for linear programming. Proceedings of the 38th Annual ACM Symposium on Theory of Computing (2006), 51–60 Klee, V., and Minty, G.J. [1972]: How good is the simplex algorithm? In: Inequalities III (O. Shisha, ed.), Academic Press, New York 1972, pp. 159–175 Kuhn, H.W. [1956]: Solvability and consistency for linear equations and inequalities. The American Mathematical Monthly 63 (1956), 217–232 Minkowski, H. [1896]: Geometrie der Zahlen. Teubner, Leipzig 1896 Motzkin, T.S. [1936]: Beiträge zur Theorie der linearen Ungleichungen (Dissertation). Azriel, Jerusalem 1936 von Neumann, J. [1947]: Discussion of a maximum problem. Working paper. Published in: John von Neumann, Collected Works; Vol. VI (A.H. Taub, ed.), Pergamon Press, Oxford 1963, pp. 27–28 Spielman, D.A., and Teng, S.-H. [2004]: Smoothed analysis of algorithms: why the simplex algorithm usually takes polynomial time. Journal of the ACM 51 (2004), 385–463 Steinitz, E. [1916]: Bedingt konvergente Reihen und konvexe Systeme. Journal für die reine und angewandte Mathematik 146 (1916), 1–52 Weyl, H. [1935]: Elementare Theorie der konvexen Polyeder. Commentarii Mathematici Helvetici 7 (1935), 290–306

•

4 Linear Programming Algorithms

Three types of algorithms for L INEAR PROGRAMMING had the most impact: the SIMPLEX ALGORITHM (see Section 3.2), interior point algorithms, and the ELLIPSOID M ETHOD . Each of these has a disadvantage: In contrast to the other two, so far no variant of the SIMPLEX ALGORITHM has been shown to have a polynomial running time. In Sections 4.4 and 4.5 we present the E LLIPSOID METHOD and prove that it leads to a polynomial-time algorithm for LINEAR PROGRAMMING. However, the ELLIPSOID METHOD is too inefficient to be used in practice. Interior point algorithms and, despite its exponential worst-case running time, the SIMPLEX ALGORITHM are far more efficient, and they are both used in practice to solve LPs. In fact, both the ELLIPSOID METHOD and interior point algorithms can be used for more general convex optimization problems, e.g. for so-called semidefinite programs. An advantage of the SIMPLEX ALGORITHM and the ELLIPSOID METHOD is that they do not require the LP to be given explicitly. It suffices to have an oracle (a subroutine) which decides whether a given vector is feasible and, if not, returns a violated constraint. We shall discuss this in detail with respect to the E LLIPSOID METHOD in Section 4.6, because it implies that many combinatorial optimization problems can be solved in polynomial time; for some problems this is in fact the only known way to show polynomial solvability. This is the reason why we discuss the ELLIPSOID METHOD but not interior point algorithms in this book. A prerequisite for polynomial-time algorithms is that there exists an optimum solution that has a binary representation whose length is bounded by a polynomial in the input size. We prove in Section 4.1 that this condition holds for L INEAR PROGRAMMING. In Sections 4.2 and 4.3 we review some basic algorithms needed later, including the well-known Gaussian elimination method for solving systems of equations.

4.1 Size of Vertices and Faces Instances of LINEAR PROGRAMMING are vectors and matrices. Since no strongly polynomial-time algorithm for LINEAR PROGRAMMING is known we have to restrict attention to rational instances when analyzing the running time of algorithms. We assume that all numbers are coded in binary. To estimate the size (number of bits) of this representation we define size.n/ WD 1 C dlog.jnj C 1/e for B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__4, c Springer-Verlag Berlin Heidelberg 2012

73

74

4 Linear Programming Algorithms

integers n 2 Z and size.r/ WD size.p/ C size.q/ for rational numbers r D pq , where p; q are relatively prime integers (i.e. their greatest common divisor is 1). For vectors x D .x1 ; : : : ; xn / 2 Qn we store the components and have size.x/ WD n C size.x1 / C : : P : C size.xn /. For a matrix A 2 Qmn with entries aij we have size.A/ WD mn C i;j size.aij /. Of course these precise values are a somewhat random choice, but remember that we are not really interested in constant factors. For polynomial-time algorithms it is important that the sizes of numbers do not increase too much by elementary arithmetic operations. We note: Proposition 4.1. If r1 ; : : : ; rn are rational numbers, then size.r1 rn / size.r1 / C C size.rn /I size.r1 C C rn / 2.size.r1 / C C size.rn //: Proof: For integers s1 ; : : : ; sn we obviously have size.s1 sn / size.s1 /C C size.sn / and size.s1 C C sn / size.s1 / C C size.sn /. Let now ri D pqii , where pi and qi are nonzero integers (i D 1; : : : ; n). Then size.r1 rn / size.p1 pn / C size.q1 qn / size.r1 / C C size.rn /. For the second statement, observe that the denominator q1 qn has size at most size.q1 / C C size.qn /. The numerator is the sum of the numbers q1 qi 1 pi qi C1 qn (i D 1; : : : ; n), so its absolute value is at most .jp1 j C C jpn j/jq1 qn j. Therefore the size of the numerator is at most size.r1 / C C size.rn /. The first part of this proposition also implies that we can often assume w.l.o.g. that all numbers in a problem instance are integers, since otherwise we can multiply each of them with the product of all denominators. For addition and inner product of vectors we have: Proposition 4.2. If x; y 2 Qn are rational vectors, then size.x C y/ 2.size.x/ C size.y//I size.x > y/ 2.size.x/ C size.y//: P Proof: UsingP Proposition 4.1 wePhave size.x C y/ D n C niD1 size.xi C n n yi / n C 2 i D1 size.x Pni / C 2 i D1 size.y Pn i / D 2.size.x/ C Pnsize.y// 3n > and size.x 2 y/ D size x y size.x y / 2 i i i D1 i i i D1 i D1 size.xi / C P 2 niD1 size.yi / D 2.size.x/ C size.y// 4n. Even under more complicated operations the numbers involved do not grow fast. Recall that the determinant of a matrix A D .aij /1i;j n is defined by det A WD

X 2Sn

sgn./

n Y i D1

ai;.i / ;

(4.1)

4.1

Size of Vertices and Faces

75

where Sn is the set of all permutations of f1; : : : ; ng and sgn./ is the sign of the permutation (defined to be 1 if can be obtained from the identity map by an even number of transpositions, and 1 otherwise). Proposition 4.3. For any rational square matrix A we have size.det A/ 2size.A/. p

Proof: We write aij D q ij with relatively prime integers pij ; qij . Now let ij Q det AD pq where p and q are relatively prime integers. Then jdet Aj i;j .jpij j C Q 1/ and jqj i;j jqij j. We obtain size.q/ size.A/ and, using jpj D jdet Ajjqj Q i;j .jpij j C 1/jqij j, size.p/

X .size.pij / C 1 C size.qij // D size.A/: i;j

With this observation we can prove: Theorem 4.4. Suppose the rational LP maxfcx W Ax bg has an optimum solution. Then it also has an optimum solution x with size.x/ 4n.size.A/ C size.b//, with components of size at most 4.size.A/ C size.b//. If b D ei or b D ei for some unit vector ei , then there is a nonsingular submatrix A0 of A and an optimum solution x with size.x/ 4nsize.A0 /. Proof: By Corollary 3.5, the maximum is attained in a face F of fx W Ax bg. Let F 0 F be a minimal face. By Proposition 3.9, F 0 D fx W A0 x D b 0 g for some subsystem A0 x b 0 of Ax b. W.l.o.g., we may assume that the rows of A0 are linearly independent. We then take a maximal set of linear independent columns (call this matrix A00 ) and set all other components to zero. Then x D .A00 /1 b 0 , filled up with zeros, is an optimum solution to our LP. By Cramer’s rule the entries of x A000 are given by xj D det , where A000 arises from A00 by replacing the j -th column det A00 0 by b . By Proposition 4.3 we obtain size.x/ n C 2n.size.A000 / C size.A00 // 4n.size.A00 / C size.b 0 //. If b D ˙ei then j det.A000 /j is the absolute value of a subdeterminant of A00 . The encoding length of the faces of a polytope given by its vertices can be estimated as follows: Lemma 4.5. Let P Rn be a rational polytope and T 2 N such that size.x/ T for each vertex x. Then P D fx W Ax bg for some inequality system Ax b, each of whose inequalities ax ˇ satisfies size.a/ C size.ˇ/ 75n2 T . Proof: First assume that P is full-dimensional. Let F D fx 2 P W ax D ˇg be a facet of P , where P fx W ax ˇg. Let y1 ; : : : ; y t be the vertices of F (by Proposition 3.6 they are also vertices of P ). Let c be the solution of M c D e1 , where M is a t n-matrix whose i -th

76

4 Linear Programming Algorithms

row is yi y1 (i D 2; : : : ; t) and whose first row is some unit vector that is linearly independent of the other rows. Observe that rank.M / D n (because dim F D n1). So we have c > D a for some 2 R n f0g. By Theorem 4.4 size.c/ 4nsize.M 0 /, where M 0 is a nonsingular n nsubmatrix of M . By Proposition 4.2 we have size.M 0 / 4nT and size.c > y1 / 2.size.c/ C size.y1 //. So the inequality c > x ı (or c > x ı if < 0), where ı WD c > y1 D ˇ, satisfies size.c/ C size.ı/ 3size.c/ C 2T 48n2 T C 2T 50n2 T . Collecting these inequalities for all facets F yields a description of P . If P D ;, the assertion is trivial, so we now assume that P is neither fulldimensional nor empty. Let V be the set of vertices of P . For s D .s1 ; : : : ; sn / 2 f1; 1gn let Ps be the convex hull of V [ fx C si ei W x 2 V; i D 1; : : : ; ng. Each Ps is a full-dimensional polytope (Theorem 3.31), and the size of any of its vertices is at most T Cn (cf. Corollary 3.32). By the above, Ps can be described byT inequalities of size at most 50n2 .T C n/ 75n2 T (note that T 2n). Since P D s2f1;1gn Ps , this completes the proof.

4.2 Continued Fractions When we say that the numbers occurring in a certain algorithm do not grow too fast, we often assume that for each rational pq the numerator p and the denominator q are relatively prime. This assumption causes no problem if we can easily find the greatest common divisor of two natural numbers. This is accomplished by one of the oldest algorithms:

EUCLIDEAN ALGORITHM Input:

Two natural numbers p and q.

Output:

The greatest common divisor d of p and q, i.e. prime integers.

p d

and

q d

are relatively

1

While p > 0 and q > 0 do: If p < q then set q WD q b pq cp else set p WD p b pq cq.

2

Return d WD maxfp; qg.

Theorem 4.6. The EUCLIDEAN ALGORITHM works correctly. The number of iterations is at most size.p/ C size.q/. Proof: The correctness follows from the fact that the set of common divisors of p and q does not change throughout the algorithm, until one of the numbers becomes zero. One of p or q is reduced by at least a factor of two in each iteration, hence there are at most log p C log q C 1 iterations. Since no number occurring in an intermediate step is greater than p and q, we have a polynomial-time algorithm.

4.2

Continued Fractions

77

A similar algorithm is the so-called CONTINUED FRACTION EXPANSION. This can be used to approximate any number by a rational number whose denominator is 1 not too large. For any positive real number x we define x0 WD x and xi C1 WD xi bx ic for i D 1; 2; : : :, until xk 2 N for some k. Then we have x D x0 D bx0 cC

1 1 D bx0 cC x1 bx1 c C

1 x2

D bx0 cC

1 bx1 c C

1 bx2 cC x1

D

3

We claim that this sequence is finite if and only if x is rational. One direction follows immediately from the observation that xi C1 is rational if and only if xi is rational. The other direction is also easy: If x D pq , the above procedure is equivalent to the E UCLIDEAN ALGORITHM applied to p and q. This also shows that for a given rational number pq with p; q > 0 the (finite) sequence x1 ; x2 ; : : : ; xk as above can be computed in polynomial time. The following algorithm is almost identical to the EUCLIDEAN ALGORITHM except for the computation of the numbers gi and hi ; we shall prove that the sequence ghii converges to x. i 2N

CONTINUED FRACTION EXPANSION Input: Output:

Natural numbers p and q (let x WD pq ). The sequence xi D pqii with x0 D i D0;1;:::

p q

and xi C1 WD

1 xi bxi c .

Set i WD 0, p0 WD p and q0 WD q. Set g2 WD 0, g1 WD 1, h2 WD 1, and h1 WD 0. While qi 6D 0 do: Set ai WD b pqii c. Set gi WD ai gi 1 C gi 2 . Set hi WD ai hi 1 C hi 2 . Set qi C1 WD pi ai qi . Set pi C1 WD qi . Set i WD i C 1.

1 2

We claim that the sequence ghii yields good approximations of x. Before we can prove this, we need some preliminary observations: Proposition 4.7. The following statements hold for all iterations i in the above algorithm: (a) ai 1 (except possibly for i D 0) and hi hi 1 . (b) gi 1 hi gi hi 1 D .1/i . pi gi 1 C qi gi 2 (c) D x. pi hi 1 C qi hi 2 (d) ghi x if i is even and ghi x if i is odd. i

i

78

4 Linear Programming Algorithms

Proof: (a) is obvious. (b) is easily shown by induction: For i D 0 we have gi 1 hi gi hi 1 D g1 h0 D 1, and for i 1 we have gi 1 hi gi hi 1 D gi 1 .ai hi 1 C hi 2 / hi 1 .ai gi 1 C gi 2 / D gi 1 hi 2 hi 1 gi 2 : (c) is also proved by induction: For i D 0 we have pi 1 C 0 pi gi 1 C qi gi 2 D x: D pi hi 1 C qi hi 2 0 C qi 1 For i 1 we have qi 1 .ai 1 gi 2 C gi 3 / C .pi 1 ai 1 qi 1 /gi 2 pi gi 1 C qi gi 2 D pi hi 1 C qi hi 2 qi 1 .ai 1 hi 2 C hi 3 / C .pi 1 ai 1 qi 1 /hi 2 qi 1 gi 3 C pi 1 gi 2 D : qi 1 hi 3 C pi 1 hi 2 We finally prove (d). We note gh2 D 0 < x < 1 D gh1 and proceed by 2 1 induction. The induction step follows easily from the fact that the function f .˛/ WD ˛gi 1 Cgi 2 is monotone for ˛ > 0, and f . pq i / D x by (c). ˛h Ch i 1

i 2

i

Theorem 4.8. (Khintchine [1956]) Given a rational number ˛ and a natural number n, a rational number ˇ with denominator at most n such that j˛ ˇj is minimum can be found in polynomial time (polynomial in size.n/ C size.˛/). Proof: We run the CONTINUED FRACTION EXPANSION with x WD ˛. If the algorithm stops with qi D 0 and hi 1 n, we can set ˇ D ghi 1 D ˛ by i 1 Proposition 4.7(c). Otherwise let i be the last index with hi n, and let t be the maximum integer such that thi C hi 1 n (cf. Proposition 4.7(a)). Since ai C1 hi C hi 1 D hi C1 > n, we have t < ai C1 . We claim that gi tgi C gi 1 y WD or ´ WD hi thi C hi 1 is an optimum solution. Both numbers have denominators at most n. If i is even, then y x < ´ by Proposition 4.7(d). Similarly, if i is odd, we have y x > ´. We show that any rational number pq between y and ´ has denominator greater than n. Observe that jhi gi 1 hi 1 gi j 1 j´ yj D D hi .thi C hi 1 / hi .thi C hi 1 / (using Proposition 4.7(b)). On the other hand, ˇ ˇ ˇ ˇ ˇ ˇ 1 1 hi 1 C .t C 1/hi p ˇˇ ˇˇ p ˇ C D ; j´ yj D ˇ´ ˇ C ˇ y ˇˇ q q .thi C hi 1 /q hi q qhi .thi C hi 1 / so q hi 1 C .t C 1/hi > n.

The above proof is from the book of Grötschel, Lovász and Schrijver [1988], which also contains important generalizations.

4.3

Gaussian Elimination

79

4.3 Gaussian Elimination The most important algorithm in linear algebra is the so-called Gaussian elimination. It has been applied by Gauss but was known much earlier (see Schrijver [1986] for historical notes). Gaussian elimination is used to determine the rank of a matrix, to compute the determinant and to solve a system of linear equations. It occurs very often as a subroutine in linear programming algorithms; e.g. in 1 of the SIMPLEX ALGORITHM. Given a matrix A 2 Qmn , our algorithm for Gaussian Elimination works with an extended matrix Z D .B C / 2 Qm.nCm/ ; initially B D A and C D I . The algorithm transforms B to the form I0 R0 by the following elementary operations: permuting rows and columns, adding a multiple of one row to another row, and (in the final step) multiplying rows by nonzero constants. At each iteration C is modified accordingly, such that the property C AQ D B is maintained throughout where AQ results from A by permuting rows and columns. The first part of the algorithm, consisting of 2 and , 3 transforms B to an upper triangular matrix. Consider for example the matrix Z after two iterations; it has the form 0 1 ´11 6D 0 ´12 ´13 ´1n 1 0 0 0 B 0 ´22 6D 0 ´23 ´2n ´2;nC1 1 0 0C B C B 0 0 ´33 ´3n ´3;nC1 ´3;nC2 1 0 0 C B C B 0 C B C: B I C B C @ 0A 0 0 ´m3 ´mn ´m;nC1 ´m;nC2 0 0 1 i3 If ´33 6D 0, then the next step just consists of subtracting ´´33 times the third row from the i -th row, for i D 4; : : : ; m. If ´33 D 0 we first exchange the third row and/or the third column with another one. Note that if we exchange two rows, we have to exchange also the two corresponding columns of C in order to maintain the property C AQ D B. To have AQ available at each point we store the permutations of the rows and columns in variables row.i /, i D 1; : : : ; m and col.j /, j D 1; : : : ; n. Then AQ D .Arow.i /;col.j //i 2f1;:::;mg;j 2f1;:::;ng . The second part of the algorithm, consisting of 4 and , 5 is simpler since no rows or columns are exchanged anymore.

GAUSSIAN ELIMINATION Input:

A matrix A D .aij / 2 Qmn .

Output:

Its rank r, a maximal nonsingular submatrix A0 D.arow.i /;col.j //i;j 2f1;:::;rg of A, its determinant d D det A0 , and its inverse .A0 /1 D.´i;nCj /i;j 2f1;:::;rg .

80

4 Linear Programming Algorithms

1

Set r WD 0 and d WD 1. Set ´ij WD aij , row.i / WD i and col.j / WD j (i D 1; : : : ; m, j D 1; : : : ; n). Set ´i;nCj WD 0 and ´i;nCi WD 1 for 1 i; j m, i 6D j .

2

Let p 2 fr C 1; : : : ; mg and q 2 fr C 1; : : : ; ng with ´pq 6D 0. If no such p and q exist, then go to . 4 Set r WD r C 1. If p 6D r then exchange ´pj and ´rj (j D 1; : : : ; n C m), exchange ´i;nCp and ´i;nCr (i D 1; : : : ; m), and exchange row.p/ and row.r/. If q 6D r then exchange ´i q and ´i r (i D 1; : : : ; m), and exchange col.q/ and col.r/. Set d WD d ´rr . For i WD r C 1 to m do: ir Set ˛ WD ´´rr . For j WD r to n C r do: ´ij WD ´ij ˛´rj . Go to . 2 For k WD r down to 2 do: For i WD 1 to k 1 do: ik Set ˛ WD ´´kk . For j WD k to n C r do ´ij WD ´ij ˛´kj .

3

4

5

For k WD 1 to r do: Set ˛ WD ´ 1 . kk For j WD 1 to n C r do ´kj WD ˛´kj .

Theorem 4.9. GAUSSIAN ELIMINATION works correctly and terminates after O.mnr/ steps. Proof: First observe that each time before 2 we have ´i i 6D 0 for i 2 f1; : : : ; rg and ´ij D 0 for all j 2 f1; : : : ; rg and i 2 fj C 1; : : : ; mg. Hence det .´ij /i;j 2f1;2;:::;rg D ´11 ´22 ´rr D d 6D 0: Since adding a multiple of one row to another row of a square matrix does not change the value of the determinant (this well-known fact follows directly from the definition (4.1)) we have det .´ij /i;j 2f1;2;:::;rg D det .arow.i /;col.j //i;j 2f1;2;:::;rg at any stage before , 5 and hence the determinant d is computed correctly. A0 is a nonsingular r r-submatrix of A. Since .´ij /i 2f1;:::;mg;j 2f1;:::;ng has rank r at termination andPthe operations did not change the rank, A has also rank r. Moreover, jmD1 ´i;nCj arow.j /;col.k/ D ´i k for all i 2 f1; : : : ; mg and k 2 f1; : : : ; ng (i.e. C AQ D B in our above notation) holds throughout. (Note that for j D r C 1; : : : ; m we have at any stage ´j;nCj D 1 and ´i;nCj D 0 for i 6D j .) Since .´ij /i;j 2f1;2;:::;rg is the unit matrix at termination this implies that .A0 /1 is

4.3

Gaussian Elimination

81

also computed correctly. The number of steps is obviously O.rmn C r 2 .n C r// D O.mnr/. In order to prove that GAUSSIAN ELIMINATION is a polynomial-time algorithm we have to guarantee that all numbers that occur are polynomially bounded by the input size. This is not trivial but can be shown: Theorem 4.10. (Edmonds [1967]) GAUSSIAN ELIMINATION is a polynomialtime algorithm. Each number occurring in the course of the algorithm can be stored with O.m.m C n/size.A// bits. Proof: We first show that in 2 and 3 all numbers are 0, 1, or quotients of subdeterminants of A. First observe that entries ´ij with i r or j r are not modified anymore. Entries ´ij with j > n C r are 0 (if j 6D n C i ) or 1 (if j D n C i ). Furthermore, we have for all s 2 fr C 1; : : : ; mg and t 2 fr C 1; : : : ; n C mg det .´ij /i 2f1;2;:::;r;sg;j 2f1;2;:::;r;t g ´st D : det .´ij /i;j 2f1;2;:::;rg (This follows from evaluating the determinant det .´ij /i 2f1;2;:::;r;sg;j 2f1;2;:::;r;t g along the last row because ´sj D 0 for all s 2 fr C1; : : : ; mg and all j 2 f1; : : : ; rg.) We have already observed in the proof of Theorem 4.9 that det .´ij /i;j 2f1;2;:::;rg D det .arow.i /;col.j //i;j 2f1;2;:::;rg ; because adding a multiple of one row to another row of a square matrix does not change the value of the determinant. By the same argument we have det .´ij /i 2f1;2;:::;r;sg;j 2f1;2;:::;r;t g D det .arow.i /;col.j //i 2f1;2;:::;r;sg;j 2f1;2;:::;r;t g for s 2 fr C 1; : : : ; mg and t 2 fr C 1; : : : ; ng. Furthermore, det .´ij /i 2f9;2;:::;r;sg;j 2f1;2;:::;r;nCt g D det .arow.i /;col.j //i 2f1;2;:::;r;sgnft g;j 2f1;2;:::;rg for all s 2 fr C 1; : : : ; mg and t 2 f1; : : : ; rg, which is checked by evaluating the left-hand side determinant (after ) 1 along column n C t. We conclude that at any stage in 2 and 3 all numbers ´ij are 0, 1, or quotients of subdeterminants of A. Hence, by Proposition 4.3, each number occurring in 2 and 3 can be stored with O.size.A// bits. Finally observe that 4 is equivalent to applying 2 and 3 again, choosing p and q appropriately (reversing the order of the first r rows and columns). Hence each number occurring in 4 can be stored with O size .´ij /i 2f1;:::;mg;j 2f1;:::;mCng bits, which is O.m.m C n/size.A//. The easiest way to keep the representations of the numbers ´ij small enough is to guarantee that the numerator and denominator of each of these numbers are relatively prime at any stage. This can be accomplished by applying the EUCLIDEAN ALGORITHM after each computation. This gives an overall polynomial running time.

82

4 Linear Programming Algorithms

In fact, we can easily implement GAUSSIAN ELIMINATION to be a strongly polynomial-time algorithm (Exercise 4). So we can check in polynomial time whether a set of vectors is linearly independent, and we can compute the determinant and the inverse of a nonsingular matrix in polynomial time (exchanging two rows or columns changes just the sign of the determinant). Moreover we get: Corollary 4.11. Given a matrix A 2 Qmn and a vector b 2 Qm we can in polynomial time find a vector x 2 Qn with Ax D b or decide that no such vector exists. Proof: We compute a maximal nonsingular submatrix A0 D.arow.i /;col.j / /i;j 2f1;:::;rg 1 of A and its inverse .A0 /P D .´i;nCj /i;j 2f1;:::;rg by GAUSSIAN ELIMINATION. r Then we set xcol.j / WD kD1 ´j;nCk brow.k/ for j D 1; : : : ; r and xk WD 0 for k … fcol.1/; : : : ; col.r/g. We obtain for i D 1; : : : r: n X

arow.i /;j xj D

j D1

r X

arow.i /;col.j /xcol.j /

j D1

D

r X

arow.i /;col.j /

j D1

D

r X

r X

´j;nCk brow.k/

kD1

brow.k/

kD1

r X

arow.i /;col.j /´j;nCk

j D1

D brow.i / : Since the other rows of A with indices not in frow.1/; : : : ; row.r/g are linear combinations of these, either x satisfies Ax D b or no vector satisfies this system of equations.

4.4 The Ellipsoid Method In this section we describe the so-called ellipsoid method, developed by Iudin and Nemirovskii [1976] and Shor [1977] for nonlinear optimization. Khachiyan [1979] observed that it can be modified in order to solve LPs in polynomial time. Most of our presentation is based on (Grötschel, Lovász and Schrijver [1981]), (Bland, Goldfarb and Todd [1981]) and the book of Grötschel, Lovász and Schrijver [1988], which is also recommended for further study. The idea of the ellipsoid method is very roughly the following. We look for either a feasible or an optimum solution of an LP. We start with an ellipsoid which we know a priori to contain the solutions (e.g. a large ball). At each iteration k, we check if the center xk of the current ellipsoid is a feasible solution. Otherwise, we take a hyperplane containing xk such that all the solutions lie on one side of this hyperplane. Now we have a half-ellipsoid which contains all solutions. We take the smallest ellipsoid completely containing this half-ellipsoid and continue.

4.4

The Ellipsoid Method

83

Definition 4.12. An ellipsoid is a set E.A; x/ D f´ 2 Rn W .´ x/> A1 .´ x/ 1g for some symmetric positive definite n n-matrix A. Note that B.x; r/ WD E.r 2 I; x/ (with I being the n n unit matrix) is the n-dimensional Euclidean ball with center x and radius r. The volume of an ellipsoid E.A; x/ is known to be p volume .E.A; x// D det A volume .B.0; 1// (see Exercise 7). Given an ellipsoid E.A; x/ and a hyperplane f´ W a´ D axg, the smallest ellipsoid E.A0 ; x 0 / containing the half-ellipsoid E 0 D f´ 2 E.A; x/ W a´ axg is called the Löwner-John ellipsoid of E 0 (see Figure 4.1). It can be computed by the following formulas: 2 n2 0 > A bb ; A D 2 n 1 nC1 1 x0 D x C b; nC1 1 bD p Aa: a> Aa

{z : az = ax }

x

E ( A, x) E(A , x )

Fig. 4.1.

84

4 Linear Programming Algorithms

One difficulty of the ellipsoid method is caused by the square root in the computation of b. Because we have to tolerate rounding errors, it is necessary to increase the radius of the next ellipsoid a little bit. Here is an algorithmic scheme that takes care of this problem:

ELLIPSOID METHOD Input: Output: 1

2 3

4

A number n 2 N, n 2. A number N 2 N. x0 2 Qn and R 2 QC , R 2. An ellipsoid E.AN ; xN /.

Set p WD d6N C log.9n3 /e. Set A0 WD R2 I , where I is the n n unit matrix. Set k WD 0. Choose any ak 2 Qn n f0g. 1 Ak ak : Set bk WD q > ak Ak ak 1 bk . Set xkC1 W xkC1 WD xk C n C1 2 2n C 3 2 > bk bk . Ak Set AkC1 W AkC1 WD 2n2 nC1 (Here W means computing the entries up to p binary digits behind the point, taking care that AkC1 is symmetric). Set k WD k C 1. If k < N then go to 2 else stop.

So in each of the N iterations an approximation E.AkC1 ; xkC1 / of the smallest ellipsoid containing E.Ak ; xk / \ f´ W ak ´ ak xk g is computed. Two main issues, how to obtain the ak and how to choose N , will be addressed in the next section. But let us first prove some lemmas. Let jjxjj denote the Euclidean norm of vector x, while jjAjj WD maxfjjAxjj W jjxjj D 1g shall denote the norm of the matrix A. For symmetric matrices, jjAjj is the maximum absolute value of an eigenvalue and jjAjj D maxfx > Ax W jjxjj D 1g. The first lemma says that each Ek WD E.Ak ; xk / is indeed an ellipsoid. Furthermore, the absolute values of the numbers involved remain smaller than R2 2N C 2size.x0 / . Therefore each iteration of the ELLIPSOID METHOD consists of O.n2 / computational steps, each involving numbers with O.p C size.ak / C size.R/ C size.x0 // bits. Lemma 4.13. (Grötschel, Lovász and Schrijver [1981]) Let k 2 f0; 1; : : : ; N g. Then Ak is positive definite, and we have jjxk jj jjx0 jj C R2k ;

jjAk jj R2 2k ;

and

2 k jjA1 k jj R 4 :

Proof: We use induction on k. For k D 0 all the statements are obvious. Assume that they are true for some k 0. By a straightforward computation one verifies

4.4

that .AkC1 /1

The Ellipsoid Method

ak ak> 2n2 2 1 Ak C : D 2n2 C 3 n 1 ak> Ak ak

85

(4.2)

So .AkC1 /1 is the sum of a positive definite and a positive semidefinite matrix; thus it is positive definite. Hence AkC1 is also positive definite. Note that for positive semidefinite matrices A and B we have jjAjj jjA C Bjj. Therefore ˇˇ ˇˇ ˇˇ 2n2 C 3 2n2 C 3 ˇˇˇˇ 2 11 2 k > ˇˇ A jjAkC1 jj D b R 2 : b jjAk jj k k k ˇˇ ˇ ˇ 2 2 2n nC1 2n 8 Since the n n all-one matrix has norm n, the matrix AkC1 AkC1 , each of whose entries has absolute value at most 2p , has norm at most n2p . We conclude jjAkC1 jj jjAkC1 jj C jjAkC1 AkC1 jj

11 2 k R 2 C n2p R2 2kC1 8

(here we used the very rough estimate 2p n1 ). It is well-known from linear algebra that for any symmetric positive definite n n-matrix A there exists a symmetric positive definite matrix B with A D BB. Writing Ak D BB with B D B > we obtain v s u > 2 u a A ak p .Bak /> Ak .Bak / jjAk ak jj k k jjbk jj D q D t > D jjAk jj R2k1 : > .Bak / .Bak / ak Ak ak ak> Ak ak

Using this (and again the induction hypothesis) we get 1 jjbk jj C jjxkC1 xkC1 jj nC1 p 1 R2k1 C n2p jjx0 jj C R2kC1 : jjx0 jj C R2k C nC1

jjxkC1 jj jjxk jj C

Using (4.2) and jjak ak> jj D ak> ak we compute 2 ˇˇ 1 ˇˇ ˇˇ 1 ˇˇ ak> ak ˇˇA ˇˇ C 2 ˇˇ 2n ˇˇ.A / kC1 k 2n2 C 3 n 1 ak> Ak ak

(4.3)

! ˇˇ 1 ˇˇ ak> BA1 Bak 2n2 2 k ˇˇA ˇˇ C D k 2n2 C 3 n 1 ak> BBak ˇˇ 1 ˇˇ ˇˇ ˇˇ ˇˇ ˇˇ 2n2 ˇˇA ˇˇ C 2 ˇˇA1 ˇˇ < n C 1 ˇˇA1 ˇˇ k k k 2 2n C 3 n1 n1 3R2 4k :

Let be the smallest eigenvalue of AkC1 , and let v be a corresponding eigenvector with jjvjj D 1. Then – writing AkC1 D C C for a symmetric matrix C – we have

86

4 Linear Programming Algorithms

D v > AkC1 v D v > AkC1 v C v > .AkC1 AkC1 /v v> C C v C v > .AkC1 AkC1 /v 1 v > C AkC1 Cv ˇˇ1 ˇˇ 1 ˇˇ.AkC1 /1 ˇˇ jjAkC1 AkC1 jj > R2 4k n2p R2 4.kC1/ ; 3

D

where we used 2p

1 k 4 . 3n

Since > 0, AkC1 is positive definite. Furthermore,

ˇˇ ˇˇ ˇˇ.AkC1 /1 ˇˇ D 1 R2 4kC1 :

Next we show that in each iteration the ellipsoid contains the intersection of E0 and the previous half-ellipsoid: Lemma 4.14. For k D 0; : : : ; N 1 we have EkC1 fx 2 Ek \ E0 W ak x ak xk g. Proof: Let x 2 Ek \ E0 with ak x ak xk . We first compute (using (4.2)) /> .AkC1 /1 .x xkC1 / .x xkC1 > 2 ak ak> 1 2 1 2n 1 x x b b A x x C D k k k k k 2n2 C3 nC1 n1 ak> Ak ak nC1

D

D

ak ak> 2n2 2 > 1 > .x x .x x / A .x x / C / .x xk / k k k k 2n2 C 3 n1 ak> Ak ak 2 bk> ak ak> bk 1 > 1 bk Ak bk C C .n C 1/2 n 1 ak> Ak ak ! 2.x xk /> 2 ak ak> bk 1 Ak b k C nC1 n 1 ak> Ak ak ak a> 2 2n2 .x xk /> > k .x xk / C .x xk /> A1 k .x xk / C 2 2n C 3 n1 ak Ak ak ! 2 .x xk /> ak 2 2 1 : 1C 1C q .n C 1/2 n1 nC1 n1 a> A a k

k k

Since x 2 Ek , we have .x xk /> A1 k .x xk / 1. By abbreviating t WD

a> .xxk / qk > ak Ak ak

we obtain

/> .AkC1 /1 .xxkC1 / .xxkC1

2 2 2 2n2 1 1 C t t : C 2n2 C 3 n1 n2 1 n 1

> 1 Since bk> A1 k bk D 1 and bk Ak .x xk / D t, we have

4.4

The Ellipsoid Method

87

1 .x xk /> A1 k .x xk / 2 D .x xk tbk /> A1 k .x xk tbk / C t t 2;

because A1 is positive definite. So (using ak x ak xk ) we have 0 t 1 and k obtain 2n4 .x xkC1 : /> .AkC1 /1 .x xkC1 / 2n4 C n2 3 It remains to estimate the rounding error ˇ ˇ Z WD ˇ.x xkC1 /> .AkC1 /1 .x xkC1 / .x xkC1 /> .AkC1 /1 .x xkC1 /ˇ ˇ ˇ ˇ.x xkC1 /> .AkC1 /1 .xkC1 xkC1 /ˇ ˇ ˇ C ˇ.xkC1 xkC1 /> .AkC1 /1 .x xkC1 /ˇ ˇ ˇ C ˇ.x x /> .AkC1 /1 .A /1 .x x /ˇ kC1

kC1 jjx xkC1 jj jj.AkC1 / jj jjxkC1 xkC1 jj CjjxkC1 xkC1 jj jj.AkC1 /1 jj jjx xkC1 jj

kC1

1

Cjjx xkC1 jj2 jj.AkC1 /1 jj jj.AkC1 /1 jj jjAkC1 AkC1 jj:

Using Lemma 4.13 and x 2 E0 we get jjx xp kC1 jj jjx x0 jj C jjxkC1 x0 jj R C R2N and jjx xkC1 jj jjx xkC1 jj C n2p R2N C1 . We also use (4.3) and obtain p Z 2.R2N C1 /.R2 4N /. n2p / C .R2 4N C1 /.R2 4N /.3R2 4N 1 /.n2p / p D 4R1 23N n2p C 3R2 26N n2p 26N n2p 1 ; 9n2 by definition of p. Altogether we have .x xkC1 /> .AkC1 /1 .x xkC1 /

1 2n4 C 2 1: 2n4 C n2 3 9n

The volumes of the ellipsoids decrease by a constant factor in each iteration: Lemma 4.15. For k D 0; : : : ; N 1 we have

volume .EkC1 / volume .Ek /

1

< e 5n .

Proof: (Grötschel, Lovász and Schrijver [1988]) We write s s s det AkC1 det AkC1 det AkC1 volume .EkC1 / D D volume .Ek / det Ak det Ak det AkC1

88

4 Linear Programming Algorithms

and estimate the two factors independently. First observe that n 2 det AkC1 2 ak ak> Ak 2n C 3 : D det I det Ak 2n2 n C 1 ak> Ak ak The matrix

> ak ak Ak > ak Ak ak

has rank one and 1 as its only nonzero eigenvalue (eigenvector

ak ). Since the determinant is the product of the eigenvalues, we conclude that n 2 det AkC1 2 3 2 1 2n C 3 < e 2n e n D e 2n ; 1 D 2 det Ak 2n nC1 n1 n < e 2 for n 2. where we used 1 C x e x for all x and nC1 For the second estimation we use (4.3) and the well-known fact that det B jjBjjn for any matrix B: det AkC1 D det I C .AkC1 /1 .AkC1 AkC1 / det AkC1 ˇˇ ˇˇn ˇˇI C .AkC1 /1 .AkC1 AkC1 /ˇˇ n jjI jj C jj.AkC1 /1 jj jjAkC1 AkC1 jj n 1 C .R2 4kC1 /.n2p / n 1 1C 10n2 1

e 10n 2

(we used 2p 10n43 4N 10nR 3 4kC1 ). We conclude that s s det AkC1 volume .EkC1 / det AkC1 1 1 1 D e 4n e 20n D e 5n : volume .Ek / det Ak det AkC1

4.5 Khachiyan’s Theorem In this section we shall prove Khachiyan’s theorem: the E LLIPSOID METHOD can be applied to LINEAR PROGRAMMING in order to obtain a polynomial-time algorithm. Let us first prove that it suffices to have an algorithm for checking feasibility of linear inequality systems: Proposition 4.16. Suppose there is a polynomial-time algorithm for the following problem: “Given a matrix A 2 Qmn and a vector b 2 Qm , decide if fx W Ax bg is empty.” Then there is a polynomial-time algorithm for LINEAR PROGRAMMING which finds an optimum basic solution if there exists one.

4.5

Khachiyan’s Theorem

89

Proof: Let an LP maxfcx W Ax bg be given. We first check if the primal and dual LPs are both feasible. If at least one of them is infeasible, we are done by Theorem 3.27. Otherwise, by Corollary 3.21, it is sufficient to find an element of f.x; y/ W Ax b; yA D c; y 0; cx D ybg. We show (by induction on k) that a solution of a feasible system of k inequalities and l equalities can be found by k calls to the subroutine checking emptiness of polyhedra plus additional polynomial-time work. For k D 0 a solution can be found easily by GAUSSIAN ELIMINATION (Corollary 4.11). Now let k > 0. Let ax ˇ be an inequality of the system. By a call to the subroutine we check whether the system becomes infeasible by replacing ax ˇ by ax D ˇ. If so, the inequality is redundant and can be removed (cf. Proposition 3.8). If not, we replace it by the equality. In both cases we reduced the number of inequalities by one, so we are done by induction. If there exists an optimum basic solution, the above procedure generates one, because the final equality system contains a maximal feasible subsystem of Ax D b. Before we can apply the ELLIPSOID METHOD, we have to take care that the polyhedron is bounded and full-dimensional: Proposition 4.17. (Khachiyan [1979], Gács and Lovász [1981]) Let A 2 Qmn and b 2 Qm . The system Ax b has a solution if and only if the system Ax b C 1l;

R1l x R1l

has a solution, where 1l is the all-one vector, 1 D 2n24.size.A/Csize.b// and R D 1 C 24.size.A/Csize.b// . If Ax b has a solution, then volume .fx 2 Rn W Ax b C 1l; R1l x R1lg/

2 n2size.A/

n

.

Proof: The box constraints R1l x R1l do not change the solvability by Theorem 4.4. Now suppose that Ax b has no solution. By Theorem 3.24 (a version of Farkas’ Lemma), there is a vector y 0 with yA D 0 and yb D 1. By applying Theorem 4.4 to minf1ly W y 0; A> y D 0; b > y D 1g we conclude that y can be chosen such that its components are of absolute value less than 24.size.A/Csize.b// . Therefore y.b C 1l/ < 1 C .n C 1/24.size.A/Csize.b// 0. Again by Theorem 3.24, this proves that Ax b C 1l has no solution. For the second statement, if x 2 Rn with Ax b has components of absolute value at most R 1 (cf. Theorem 4.4), then fx 2 Rn W Ax b C 1l; R1l x R1lg contains all points ´ with jj´ xjj1 n2size.A/ . Note that the construction of this proposition increases the size of the system of inequalities by at most a factor of O.m C n/. Theorem 4.18. (Khachiyan [1979]) There exists a polynomial-time algorithm for LINEAR PROGRAMMING (with rational input), and this algorithm finds an optimum basic solution if there exists one.

90

4 Linear Programming Algorithms

Proof: By Proposition 4.16 it suffices to check feasibility of a system Ax b. We transform the system as in Proposition 4.17 in order to obtain a polytope P which is either empty or has volume at least

2 n2size.A/

n

.

We run the ELLIPSOID METHOD with x0 D 0, R D n 1 C 24.size.A/Csize.b// , N D d10n2 .2 log n C 5.size.A/ C size.b///e. Each time in 2 we check whether xk 2 P . If yes, we are done. Otherwise we take a violated inequality ax ˇ of the system Ax b and set ak WD a. We claim that if the algorithm does not find an xk 2 P before iteration N , then P must be empty. To see this, we first observe that P Ek for all k: for k D 0 this is clear by the construction of P and R; the induction step is Lemma 4.14. So we have P EN . By Lemma 4.15, we have, abbreviating s WD size.A/ C size.b/, N

N

volume .EN / volume .E0 /e 5n .2R/n e 5n n 4n 10ns < 2n 1 C 24s n e < n2n 25ns : On the other hand, P 6D ; implies n 1 2 n D D n2n 25ns ; volume .P / n2s n2 25s which is a contradiction.

If we estimate the running time for solving an LP maxfcx W Ax bg with the above method, we get the bound O..n C m/9 .size.A/ C size.b/ C size.c//2 / (Exercise 9), which is polynomial but completely useless for practical purposes. In practice, either the SIMPLEX ALGORITHM or interior point algorithms are used. Karmarkar [1984] was the first to describe a polynomial-time interior point algorithm for LINEAR PROGRAMMING. We shall not go into the details here. A strongly polynomial-time algorithm for LINEAR PROGRAMMING is not known. However, Tardos [1986] showed that there is an algorithm for solving maxfcx W Ax bg with a running time that polynomially depends on size.A/ only. For many combinatorial optimization problems, where A is a 0-1-matrix, this gives a strongly polynomial-time algorithm. Tardos’ result was extended by Frank and Tardos [1987].

4.6 Separation and Optimization The above method (in particular Proposition 4.16) requires that the polyhedron be given explicitly by a list of inequalities. However, a closer look shows that this is not really necessary. It is sufficient to have a subroutine which – given a vector x – decides if x 2 P or otherwise returns a separating hyperplane, i.e. a vector a such that ax > maxfay W y 2 P g. We shall prove this for full-dimensional polytopes;

4.6

Separation and Optimization

91

for the general (more complicated) case we refer to Grötschel, Lovász and Schrijver [1988] (or Padberg [1995]). The results in this section are due to Grötschel, Lovász and Schrijver [1981] and independently to Karp and Papadimitriou [1982] and Padberg and Rao [1981]. With the results of this section one can solve certain linear programs in polynomial time although the polytope has an exponential number of facets. Many examples will be discussed later in this book; see e.g. Corollary 12.22 or Theorem 20.34. By considering the dual LP one can also deal with linear programs with a huge number of variables. Let P Rn be a full-dimensional polytope, or more generally, a fulldimensional bounded convex set. We assume that we know the dimension n and two balls B.x0 ; r/ and B.x0 ; R/ such that B.x0 ; r/ P B.x0 ; R/. But we do not assume that we know a linear inequality system defining P . In fact, this would not make sense if we want to solve linear programs with an exponential number of constraints in polynomial time, or even optimize linear objective functions over nonlinearly constrained convex sets. Below we shall prove that, under some reasonable assumptions, we can optimize a linear function over a polyhedron P in polynomial time (independent of the number of constraints) if we have a so-called separation oracle: a subroutine for the following problem:

SEPARATION PROBLEM Instance:

A convex set P Rn . A vector y 2 Qn .

Task:

Either decide that y 2 P or find a vector d 2 Qn such that dx < dy for all x 2 P .

Note that such a vector d exists if P is a rational polyhedron or a compact convex set (cf. Exercise 21 of Chapter 3). Given a convex set P by such a separation oracle, we look for an oracle algorithm using this as a black box. In an oracle algorithm we may ask the oracle at any time and we get a correct answer in one step. We can regard this concept as a subroutine whose running time we do not take into account. (In Chapter 15 we shall give a formal definition.) Indeed, it often suffices to have an oracle which solves the SEPARATION PROBLEM approximately. More precisely we assume an oracle for the following problem:

WEAK SEPARATION PROBLEM Instance: Task:

A convex set P Rn , a vector c 2 Qn and a number > 0. A vector y 2 Qn . Either find a vector y 0 2 P with cy cy 0 C or find a vector d 2 Qn such that dx < dy for all x 2 P .

Using a weak separation oracle we first solve linear programs approximately:

92

4 Linear Programming Algorithms

WEAK OPTIMIZATION PROBLEM Instance:

A number n 2 N. A vector c 2 Qn . A number > 0. A convex set P Rn given by an oracle for the WEAK SEPARATION PROBLEM for P , c and 2 .

Task:

Find a vector y 2 P with cy supfcx W x 2 P g .

Note that the above two definitions differ from the ones given e.g. in Grötschel, Lovász and Schrijver [1981]. However, they are basically equivalent, and we shall need the above form again in Section 18.3. The following variant of the ELLIPSOID METHOD solves the WEAK OPTIMIZATION PROBLEM for bounded full-dimensional convex sets:

GRÖTSCHEL-L OVÁSZ-SCHRIJVER ALGORITHM Input:

Output:

A number n 2 N, n 2. A vector c 2 Qn . A number 0 < 1. A convex set P Rn given by an oracle for the WEAK SEPARATION PROBLEM for P , c and 2 . x0 2 Qn and r; R 2 QC such that B.x0 ; r/ P B.x0 ; R/. A vector y 2 P with cy supfcx W x 2 P g .

1

Set R WD maxfR; l 2g,2r mWD minfr; 1g and WD maxfjjcjj; 1g. 2 Set N WD 5n ln 6Rr . Set y WD x0 .

2

Run the ELLIPSOID METHOD, with ak in 2 being computed as follows: Run the oracle for the WEAK SEPARATION PROBLEM with y D xk . If it returns a y 0 2 P with cy cy 0 C 2 then: If cy 0 > cy then set y WD y 0 . Set ak WD c. If it returns a d 2 Qn with dx < dy for all x 2 P then: Set ak WD d .

Theorem 4.19. The GRÖTSCHEL-LOVÁSZ-SCHRIJVER ALGORITHM correctly solves the WEAK OPTIMIZATION PROBLEM for bounded full-dimensional convex sets. Its running time is bounded by O n6 ˛ 2 C n4 ˛f .size.c/; size./; nsize.x0 / C n3 ˛/ ; 2

where ˛ D log Rr and f .size.c/; size./; size.y// is an upper bound of the running time of the oracle for the WEAK SEPARATION PROBLEM for P with input c; ; y. Proof: (Grötschel, Lovász and Schrijver [1981]) The running time in each of the N D O.n2 ˛/ iterations of the E LLIPSOID METHOD is O.n2 .n2 ˛ C size.R/ C size.x0 / C q// plus one oracle call, where q is the size of the output of the oracle. As size.y/ n.size.x0 / C size.R/ C N / by Lemma 4.13, the overall running time is O.n4 ˛.n2 ˛ C size.x0 / C f .size.c/; size./; nsize.x0 / C n3 ˛///, as stated.

4.6

Separation and Optimization

93

By Lemma 4.14, we have n o EN : x 2 P W cx cy C 2 Let ´ 2 P with c´ supfcx W x 2 P g 6 . We may assume that c´ > cy C 2 ; otherwise we are done.

r x0 U

r

z

cy∗

{x : cx

2}

{x : cx

cx0 }

Fig. 4.2.

Consider the convex hull U of ´ and the .n1/-dimensional ball B.x0 ; r/\fx W cx D cx0 g (see Figure 4.2). We have U P and hence U 0 WD fx 2 U W cx cy C 2 g is contained in EN . The volume of U 0 is c´ cy 2 n c´ cx0 c´ cy 2 n n1 c´ cx0 D Vn1 r ; njjcjj c´ cx0

volume .U 0 / D volume .U /

where Vn denotes the volume of the n-dimensional unit ball. Since volume .U 0 / volume .EN /, and Lemma 4.15 yields N

N

volume .EN / e 5n volume .E0 / D e 5n Vn Rn ; we have 1 Vn .c´ cx0 /n1 njjcjj n N2 5n R : c´ cy e 2 Vn1 r n1

Since c´ cx0 jjcjj jj´ x0 jj jjcjjR we obtain 1 2 nVn Rn1 n N2 N2 R 5n < 2jjcjje c´ cy jjcjje 5n R n1 2 Vn1 r r 3

and hence cy c´ 56 supfcx W x 2 P g .

94

4 Linear Programming Algorithms

Of course we are usually interested in the exact optimum. For this we restrict ourselves to rational full-dimensional polytopes. We need some assumption on the size of the vertices of the polytope. Lemma 4.20. Let n 2 N, let P Rn be a rational polytope, and let x0 2 Qn be a point in the interior of P . Let T 2 N such that size.x0 / log T and size.x/ log T for all vertices x of P . Then B.x0 ; r/ P B.x0 ; R/, where 2 r WD n1 T 379n and R WD 2nT . Moreover, let K WD 4T 2nC1 . Let c 2 Zn , and define c 0 WD K n c C .1; K; : : : ; n1 K /. Then maxfc 0 x W x 2 P g is attained by a unique vector x , for all other vertices y of P we have c 0 .x y/ > T 2n , and x is also an optimum solution of maxfcx W x 2 P g. Proof: For any vertex x of P we have jjxjj nT and jjx0 jj nT , so jjx x0 jj 2nT and x 2 B.x0 ; R/. To show that B.x0 ; r/ P , let F D fx 2 P W ax D ˇg be a facet of P , where by Lemma 4.5 we may assume that size.a/ C size.ˇ/ < 75n2 log T . Suppose there is a point y 2 F with jjy x0 jj < r. Then jax0 ˇj D jax0 ayj jjajj jjy x0 jj < n2size.a/ r T 304n

2

But on the other hand the size of ax0 ˇ can by estimated by size.ax0 ˇ/ 4.size.a/ C size.x0 / C size.ˇ// 300n2 log T C 4 log T 304n2 log T: 2

Since ax0 6D ˇ (x0 is in the interior of P ), this implies jax0 ˇj T 304n , a contradiction. To prove the last statements, let x be a vertex of P maximizing c 0 x, and let y be another vertex of P . By the assumption on the size of the vertices of P we may write x y D ˛1 ´, where ˛ 2 f1; 2; : : : ; T 2n 1g and ´ is an integral vector whose components have absolute value at most K2 . Then ! n X 1 0 n i 1 K c´ C K ´i : 0 c .x y/ D ˛ i D1

Pn

Since K n > i D1 K i 1 j´i j, we must have c´ 0 and hence cx cy. So x indeed maximizes cx over P . Moreover, since ´ 6D 0, we obtain c 0 .x y/ as required.

1 > T 2n ; ˛

Theorem 4.21. Let n 2 N and c 2 Qn . Let P Rn be a rational polytope, and let x0 2 Qn be a point in the interior of P . Let T 2 N such that size.x0 / log T and size.x/ log T for all vertices x of P .

4.6

Separation and Optimization

95

Given n, c, x0 , T and a polynomial-time oracle for the SEPARATION PROBfor P , a vertex x of P attaining maxfc > x W x 2 P g can be found in time polynomial in n, log T and size.c/. LEM

Proof: (Grötschel, Lovász and Schrijver [1981]) We first use the GRÖTSCHELLOVÁSZ-SCHRIJVER ALGORITHM to solve the WEAK OPTIMIZATION PROBLEM; we set c 0 , r and R according to Lemma 4.20 and WD 8nT 12nC3 . (We first have to make c integral by multiplying with the product of its denominators; this increases its size by at most a factor 2n.) The GRÖTSCHEL-LOVÁSZ-SCHRIJVER ALGORITHM returns a vector y 2 P with c 0 y c 0 x , where x is an optimum of maxfc 0 x W x 2 P g. By 6 2 solution 4 Theorem time is O n ˛ C n ˛f .size.c 0 /; size./; nsize.x0 /C 4.19 the 6running 3 2 4 n ˛/ D O n ˛ C n ˛f .size.c 0 /; 6n log T; n log T C n3 ˛/ , where ˛ D 2

0

2

0

jj;1g log.16n5 T 400n 2size.c / / D O.n2 log T C size.c 0 // and f log R maxfjjc r is a polynomial upper bound of the running time of the oracle for the SEPARATION PROBLEM for P . Since size.c 0 / 6n2 log T C2size.c/, we have an overall running time that is polynomial in n, log T and size.c/. We claim that jjx yjj 2T1 2 . To see this, write y as a convex combination of the vertices x ; x1 ; : : : ; xk of P :

y D 0 x C

k X

i xi ;

i 0;

i D1

k X

i D 1:

i D0

Now – using Lemma 4.20 – c 0 .x y/ D

k X

k X i c 0 x xi > i T 2n D .1 0 /T 2n ;

i D1

i D1

so 1 0 < T 2n . We conclude that

jjy x jj

k X

i jjxi x jj .1 0 /2R < 4nT 2nC1

i D1

1 : 2T 2

So when rounding each entry of y to the next rational number with denominator at most T , we obtain x . The rounding can be done in polynomial time by Theorem 4.8. We have proved that, under certain assumptions, optimizing over a polytope can be done whenever there is a separation oracle. We close this chapter by noting that the converse is also true. We need the concept of polarity: If X Rn , we define the polar of X to be the set X ı WD fy 2 Rn W y > x 1 for all x 2 X g: When applied to full-dimensional polytopes, this operation has some nice properties:

96

4 Linear Programming Algorithms

Theorem 4.22. Let P be a polytope in Rn with 0 in the interior. Then: (a) P ı is a polytope with 0 in the interior; (b) .P ı /ı D P ; (c) x is a vertex of P if and only if x > y 1 is a facet-defining inequality of P ı . Proof: (a): Let P be the convex hull of x1 ; : : : ; xk (cf. Theorem 3.31). By definition, P ı D fy 2 Rn W y > xi 1 for all i 2 f1; : : : ; kgg, i.e. P ı is a polyhedron and the facet-defining inequalities of P ı are given by vertices of P . Moreover, 0 is in the interior of P ı because 0 satisfies all of the finitely many inequalities strictly. Suppose P ı is unbounded, i.e. there exists a w 2 Rn n f0g with ˛w 2 P ı for all ˛ > 0. Then ˛wx 1 for all ˛ > 0 and all x 2 P , so wx 0 for all x 2 P . But then 0 cannot be in the interior of P . (b): Trivially, P .P ı /ı . To show the converse, suppose that ´ 2 .P ı /ı n P . Then there is an inequality c > x ı satisfied by all x 2 P but not by ´. We have ı > 0 since 0 is in the interior of P . Then 1ı c 2 P ı but 1ı c > ´ > 1, contradicting the assumption that ´ 2 .P ı /ı . (c): We have already seen in (a) that the facet-defining inequalities of P ı are given by vertices of P . Conversely, if x1 ; : : : ; xk are the vertices of P , then PN WD conv.f 21 x1 ; x2 ; : : : ; xk g/ 6D P , and 0 is in the interior of PN . Now (b) implies PN ı 6D P ı . Hence fy 2 Rn W y > x1 2; y > xi 1.i D 2; : : : ; k/g D PN ı 6D P ı D fy 2 Rn W y > xi 1.i D 1; : : : ; k/g. We conclude that x1> y 1 is a facet-defining inequality of P ı . Now we can prove: Theorem 4.23. Let n 2 N and y 2 Qn . Let P Rn be a rational polytope, and let x0 2 Qn be a point in the interior of P . Let T 2 N such that size.x0 / log T and size.x/ log T for all vertices x of P . Given n, y, x0 , T and an oracle which for any given c 2 Qn returns a vertex x of P attaining maxfc > x W x 2 P g, we can solve the SEPARATION PROBLEM for P and y in time polynomial in n, log T and size.y/. Indeed, in the case y … P we can find a facet-defining inequality of P that is violated by y. Proof: Consider Q WD fx x0 W x 2 P g and its polar Qı . If x1 ; : : : ; xk are the vertices of P , we have Qı D f´ 2 Rn W ´> .xi x0 / 1 for all i 2 f1; : : : ; kgg: By Theorem 4.4 we have size.´/ 4n.4n log T C3n/ 28n2 log T for all vertices ´ of Qı . Observe that the SEPARATION PROBLEM for P and y is equivalent to the SEPARATION PROBLEM for Q and y x0 . Since by Theorem 4.22 Q D .Q ı /ı D fx W ´x 1 for all ´ 2 Qı g; the SEPARATION PROBLEM for Q and y x0 is equivalent to solving maxf.y x0 /> x W x 2 Qı g. Since each vertex of Q ı corresponds to a facet-defining

Exercises

97

inequality of Q (and thus of P ), it remains to show how to find a vertex attaining maxf.y x0 /> x W x 2 Q ı g. To do this, we apply Theorem 4.21 to Q ı . By Theorem 4.22, Qı is fulldimensional with 0 in the interior. We have shown above that the size of the vertices of Qı is at most 28n2 log T . So it remains to show that we can solve the SEPARATION PROBLEM for Q ı in polynomial time. However, this reduces to the optimization problem for Q which can be solved using the oracle for optimizing over P . We finally mention that a new algorithm which is faster than the E LLIPSOID METHOD and also implies the equivalence of optimization and separation has been proposed by Vaidya [1996]. However, this algorithm does not seem to be of practical use either.

Exercises

1. Let A be a nonsingular rational n n-matrix. Prove that size.A1 / 4n2 size.A/. 2. Let n 2, c 2 Rn and y1 ; : : : ; yk 2 f1; 0; 1gn such that 0 < c > yi C1 1 > 2 c yi for i D 1; : : : ; k 1. Prove that then k 3n log n. Hint: Consider the linear program maxfy1> x W yk> x D 1; .yi 2yi C1 /> x 0 .i D 1; : : : ; k 1/g and recall the proof of Theorem 4.4. (M. Goemans) 3. Consider the numbers hi in the CONTINUED FRACTION EXPANSION. Prove that hi Fi C1 for all i , where Fi is the i -th Fibonacci number (F1 D F2 D 1 and Fn D Fn1 C Fn2 for n 3). Observe that p !n p !n ! 1 1C 5 1 5 : Fn D p 2 2 5 Conclude that the number of iterations of the CONTINUED FRACTION EXPANSION is O.log q/. (Grötschel, Lovász and Schrijver [1988]) 4. Show that GAUSSIAN ELIMINATION can be made a strongly polynomial-time algorithm. Hint: First assume that A is integral. Recall the proof of Theorem 4.10 and observe that we can choose d as the common denominator of the entries. (Edmonds [1967]) 5. Let x1 ; : : : ; xk 2 Rl , d WD 1 C dimfx1 ; : : : ; xk g, 1 ; : : : ; k 2 RC with Pk Pk i D1 i D 1, and x WD i D1 i xi . Show how to compute numbers P 1 ; : : : ; k 2 RC , at most d of which are nonzero, such that kiD1 i D 1 and Pk x D i D1 i xi (cf. Exercise 15 of Chapter 3). Show that all computations can be performed in O..k C l/3 / time.

98

4 Linear Programming Algorithms

Hint: Run G ELIMINATION with the matrix A 2 R.lC1/k whose i -th AUSSIAN column is x1i . If d < k, let w 2 Rk be the vector with wcol.i / WD ´i;d C1 (i D 1; : : : ; d ), wcol.d C1/ WD 1 and wcol.i / WD 0 (i D d C 2; : : : ; k); observe that Aw D0. Add a multiple of w to , eliminate at least one vector and iterate. > 6. Let A D ˛b bC 2 Rnn be a symmetric positive semidefinite matrix with 1 ˛ 0 ˛ > 0 and b 2 Rn1 . Let A0 WD 0 C 1 bb > and U WD 1 ˛ b . Prove that 0 I

˛

A D U > A0 U and C ˛1 bb > is positive semidefinite. Iterate and conclude that for any positive semidefinite matrix A there is a matrix U with A D U > U , and such a matrix can be computed with arbitrary precision in O.n3 / steps (some of which consist of computing approximate square roots). Note: This is called Cholesky factorization. It cannot be computed exactly as U can be irrational. 7. Let A be a symmetric positive definite n n-matrix. Let v1 ; : : : ; vn be n orthogonal eigenvectors of A, with corresponding eigenvalues 1 ; : : : ; n . W.l.o.g. jjvi jj D 1 for i D 1; : : : ; n. Prove that then n p o p E.A; 0/ D 1 1 v1 C C n n vn W 2 Rn ; jjjj 1 :

8. 9. 10. 11.

12.

(The eigenvectors correspond to thep axes of symmetry of the ellipsoid.) Conclude that volume .E.A; 0// D det A volume .B.0; 1//. Let E.A; x/ Rn be an ellipsoid and a 2 Rn , and let E.A0 ; x 0 // be as defined on page 83. Prove that f´ 2 E.A; x/ W a´ axg E.A0 ; x 0 /. Prove that the algorithm of Theorem 4.18 solves a linear program maxfcx W Ax bg in O..n C m/9 .size.A/ C size.b/ C size.c//2 / time. Show that the assumption that P is bounded can be omitted in Theorem 4.21. One can detect if the LP is unbounded and otherwise find an optimum solution. Let P R3 be a 3-dimensional polytope with 0 in its interior. Consider again the graph G.P / whose vertices are the vertices of P and whose edges correspond to the 1-dimensional faces of P (cf. Exercises 18 and 19 of Chapter 3). Show that G.P ı / is the planar dual of G.P /. Note: Steinitz [1922] proved that for every simple 3-connected planar graph G there is a 3-dimensional polytope P with G D G.P /. Let G be a simple connected undirected graph. Show that the LP X min xvw eDfv;wg2E.G/

s.t.

X

w2S

xvw

˙1 4

jS j2 C 12 jS j

.v 2 V .G/; S V .G/ n fvg/

xuw xuv C xvw

.u; v; w 2 V .G//

xvw 0

.v; w 2 V .G//

xvv D 0

.v 2 V .G//

References

99

can be solved in time polynomial in jV .G/j. Note: This can be regarded as a relaxation of the OPTIMAL LINEAR ARRANGEMENT PROBLEM ; cf. Exercise 8 of Chapter 19. 13. Prove that the polar of a polyhedron is always a polyhedron. For which polyhedra P is .P ı /ı D P ?

References General Literature: Grötschel, M., Lovász, L., and Schrijver, A. [1988]: Geometric Algorithms and Combinatorial Optimization. Springer, Berlin 1988 Padberg, M. [1999]: Linear Optimization and Extensions. Second edition. Springer, Berlin 1999 Schrijver, A. [1986]: Theory of Linear and Integer Programming. Wiley, Chichester 1986

Cited References: Bland, R.G., Goldfarb, D., and Todd, M.J. [1981]: The ellipsoid method: a survey. Operations Research 29 (1981), 1039–1091 Edmonds, J. [1967]: Systems of distinct representatives and linear algebra. Journal of Research of the National Bureau of Standards B 71 (1967), 241–245 Frank, A., and Tardos, É. [1987]: An application of simultaneous Diophantine approximation in combinatorial optimization. Combinatorica 7 (1987), 49–65 Gács, P., and Lovász, L. [1981]: Khachiyan’s algorithm for linear programming. Mathematical Programming Study 14 (1981), 61–68 Grötschel, M., Lovász, L., and Schrijver, A. [1981]: The ellipsoid method and its consequences in combinatorial optimization. Combinatorica 1 (1981), 169–197 Iudin, D.B., and Nemirovskii, A.S. [1976]: Informational complexity and effective methods of solution for convex extremal problems. Ekonomika i Matematicheskie Metody 12 (1976), 357–369 [in Russian] Karmarkar, N. [1984]: A new polynomial-time algorithm for linear programming. Combinatorica 4 (1984), 373–395 Karp, R.M., and Papadimitriou, C.H. [1982]: On linear characterizations of combinatorial optimization problems. SIAM Journal on Computing 11 (1982), 620–632 Khachiyan, L.G. [1979]: A polynomial algorithm in linear programming [in Russian]. Doklady Akademii Nauk SSSR 244 (1979) 1093–1096. English translation: Soviet Mathematics Doklady 20 (1979), 191–194 Khintchine, A. [1956]: Kettenbrüche. Teubner, Leipzig 1956 Padberg, M.W., and Rao, M.R. [1981]: The Russian method for linear programming III: Bounded integer programming. Research Report 81-39, New York University 1981 Shor, N.Z. [1977]: Cut-off method with space extension in convex programming problems. Cybernetics 13 (1977), 94–96 Steinitz, E. [1922]: Polyeder und Raumeinteilungen. Enzyklopädie der Mathematischen Wissenschaften, Band 3 (1922), 1–139 Tardos, É. [1986]: A strongly polynomial algorithm to solve combinatorial linear programs. Operations Research 34 (1986), 250–256 Vaidya, P.M. [1996]: A new algorithm for minimizing convex functions over convex sets. Mathematical Programming 73 (1996), 291–341

•

5 Integer Programming

In this chapter, we consider linear programs with integrality constraints:

INTEGER PROGRAMMING Instance:

A matrix A 2 Zmn and vectors b 2 Zm ; c 2 Zn .

Task:

Find a vector x 2 Zn such that Ax b and cx is maximum, decide that fx 2 Zn W Ax bg D ;, or decide that supfcx W x 2 Zn ; Ax bg D 1.

We do not consider mixed integer programs, i.e. linear programs with integrality constraints for only a subset of the variables. Most of the theory of linear and integer programming can be extended to mixed integer programming in a natural way.

PI P

Fig. 5.1.

Virtually all combinatorial optimization problems can be formulated as integer programs. The set of feasible solutions can be written as fx W Ax b; x 2 Zn g for some matrix A and some vector b. The set P WD fx 2 Rn W Ax bg is a polyhedron, so let us define by PI D fx W Ax bgI the convex hull of the integral vectors in P . We call PI the integer hull of P . Obviously PI P . B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__5, c Springer-Verlag Berlin Heidelberg 2012

101

102

5 Integer Programming

If P is bounded, then PI is also a polytope by Theorem 3.31 (see Figure 5.1). Meyer [1974] proved: Theorem 5.1. For any rational polyhedron P , its integer hull PI is a rational polyhedron. Proof: Let P D fx W Ax bg. By Lemma 3.12 the rational polyhedral cone C WD f.x; / W x 2 Rn ; 0; Ax b 0g is generated by a finite set of rational vectors. We may assume that .x1 ; 1/; : : : ; .xk ; 1/; .y1 ; 0/; : : : ; .yl ; 0/ generate C , where x1 ; : : : ; xk are rational and y1 ; : : : ; yl are integral (by multiplying the elements of a finite set of generators by suitable positive scalars). Consider the polytope ( k l k X X X Q WD i xi C i yi W i 0 .i D 1; : : : ; k/; i D 1; i D1

i D1

i D1

)

0 i 1 .i D 1; : : : ; l/ : Note that Q P . Let ´1 ; : : : ; ´m be the integral points in Q. By Theorem 3.29 the cone C 0 generated by .y1 ; 0/; : : : ; .yl ; 0/; .´1 ; 1/; : : : ; .´m ; 1/ is polyhedral, i.e. can be written as f.x; / W M x C d 0g for a rational matrix M and a rational vector d . We claim that PI D fx W M x d g. P To show “”, let x 2 P \ Zn . We have .x; 1/ 2 C , i.e. x D kiD1 i xi C Pl Pk i D1 i yi for some 1 ; : : : ; k 0 with i D1 i D 1 and 1 ; : : : ; l 0. Then Pl c WD b cy is integral, and hence x c is integral. Moreover, x c D i i i D1 Pk Pl i D1 i xi C i D1 .i bi c/yi 2 Q, and hence x c D ´i for some i . Thus .x; 1/ D .c; 0/ C .x c; 1/ 2 C 0 and hence M x C d 0. To show “”, let x be a vector satisfying M x d , i.e. .x; 1/ 2 C 0 . Then x D Pl Pm Pm i D1 i yi C i D1 i ´i for some 1 ; : : : ; l ; 1 ; : : : ; m 0 with i D1 i D i 1. W.l.o.g. assume l 1 and 1 > 0. Let 0i WD l for i D 1; : : : ; l. Then 1 .´1 C yi ; 1/ 2 C for all i D 1; : : : ; l and > 0 and hence xD

l X 1 0 bi c C 1 0i ´1 C b0i cyi l i D1

C

l m X X 1 0 i b0i c ´1 C .b0i c C 1/yi C i ´i l i D1

is a convex combination of integral points in P .

i D2

This does in general not hold for irrational polyhedra; see Exercise 1. Due to Theorem 5.1 we can write an instance of I NTEGER PROGRAMMING as maxfc > x W x 2 PI g where P D fx W Ax bg.

5.1

The Integer Hull of a Polyhedron

103

We prove a generalization of Meyer’s Theorem 5.1 in Section 5.1 (Theorem 5.8). After some preparation in Section 5.2 we study conditions under which polyhedra are integral (i.e. P D PI ) in Sections 5.3 and 5.4. Note that in this case the integer linear program is equivalent to its LP relaxation (arising by omitting the integrality constraints), and can hence be solved in polynomial time. We shall encounter this situation for several combinatorial optimization problems in later chapters. In general, however, INTEGER PROGRAMMING is much harder than L INEAR PROGRAMMING, and polynomial-time algorithms are not known. This is indeed not surprising since we can formulate many apparently hard problems as integer programs. Nevertheless we discuss a general method for finding the integer hull by successively cutting off parts of P n PI in Section 5.5. Although it does not yield a polynomial-time algorithm it is a useful technique in some cases. Finally Section 5.6 contains an efficient way of approximating the optimal value of an integer linear program.

5.1 The Integer Hull of a Polyhedron As linear programs, integer programs can be infeasible or unbounded. It is not easy to decide whether PI D ; for a polyhedron P . But if an integer program is feasible we can decide whether it is bounded by simply considering the LP relaxation. Proposition 5.2. Let P D fx W Ax bg be some rational polyhedron whose integer hull is nonempty, and let c be some vector (not necessarily rational). Then max fcx W x 2 P g is bounded if and only if max fcx W x 2 PI g is bounded. Proof: Suppose max fcx W x 2 P g is unbounded. Then Corollary 3.28 says that the system yA D c; y 0 has no solution. By Corollary 3.26 there is a vector ´ with c´ < 0 and A´ 0. Then the LP minfc´ W A´ 0; 1l ´ 1lg is feasible. Let ´ be an optimum basic solution of this LP. ´ is rational as it is a vertex of a rational polytope. Multiply ´ by a suitable natural number to obtain an integral vector w with Aw 0 and cw < 0. Let v 2 PI be some integral vector. Then v kw 2 PI for all k 2 N, and thus max fcx W x 2 PI g is unbounded. The other direction is trivial. Definition 5.3. Let A be an integral matrix. A subdeterminant of A is det B for some square submatrix B of A (defined by arbitrary row and column indices). We write „.A/ for the maximum absolute value of the subdeterminants of A. Lemma 5.4. Let C D fx W Ax 0g be a polyhedral cone, where A is an integral matrix. Then C is generated by a finite set of integral vectors, each having components with absolute value at most „.A/. Proof: By Lemma 3.12, C is generated by some of the vectors y1 ; : : : ; y t , such that for each i , yi is the solution to a system My D b 0 where M consists of n

104

5 Integer Programming

0 linearly independent rows of A I and b D ˙ej for some unit vector ej . Set ´i WD j det M jyi . By Cramer’s rule, ´i is integral with jj´i jj1 „.A/. Since this holds for each i , the set f´1 ; : : : ; ´ t g has the required properties. A similar lemma will be used in the next section: Lemma 5.5. Each rational polyhedral cone C is generated by a finite set of integral vectors fa1 ; : : : ; a t g such that each integral vector in C is a nonnegative integral combination of a1 ; : : : ; a t . (Such a set is called a Hilbert basis for C .) Proof: Let C be generated by the integral vectors b1 ; : : : ; bk . Let a1 ; : : : ; a t be all integral vectors in the polytope f1 b1 C : : : C k bk W 0 i 1 .i D 1; : : : ; k/g We show that fa1 ; : : : ; a t g is a Hilbert basis for C . They indeed generate C , because b1 ; : : : ; bk occur among the a1 ; : : : ; a t . For any integral vector x 2 C there are 1 ; : : : ; k 0 with x D 1 b1 C : : : C k bk D b1 cb1 C : : : C bk cbk C .1 b1 c/b1 C : : : C .k bk c/bk ; so x is a nonnegative integral combination of a1 ; : : : ; a t .

An important basic fact in integer programming is that optimum integral and fractional solutions are not too far away from each other: Theorem 5.6. (Cook et al. [1986]) Let A be an integral mn-matrix and b 2 Rm , c 2 Rn arbitrary vectors. Let P WD fx W Ax bg and suppose that PI 6D ;. (a) Suppose y is an optimum solution of max fcx W x 2 P g. Then there exists an optimum integral solution ´ of max fcx W x 2 PI g with jj´ yjj1 n „.A/. (b) Suppose y is a feasible integral solution of max fcx W x 2 PI g, but not an optimal one. Then there exists a feasible integral solution ´ 2 PI with c´ > cy and jj´ yjj1 n „.A/. Proof: The proof is almost the same for both parts. Let first y 2 P arbitrary. Let ´ 2 P \ Zn be (a) an optimum solution of max fcx W x 2 PI g (note that PI D fx W Ax bbcgI is a polyhedron by Theorem 5.1, and thus the maximum is attained) or (b) a vector with c´ > cy. We split Ax b into two subsystems A1 x b1 , A2 x b2 such that A1 ´ A1 y and A2 ´ < A2 y. Then ´ y belongs to the polyhedral cone C WD fx W A1 x 0; A2 x 0g. C is generated by some vectors xi (i D 1; : : : ; s). By Lemma 5.4, we may assume that xi is integral and jjxi jj1 „.A/ for all i . Ps Since ´ y 2 C , there are nonnegative numbers 1 ; : : : ; s with ´ y D i D1 i xi . We may assume that at most n of the i are nonzero.

5.1

The Integer Hull of a Polyhedron

105

For D .1 ; : : : ; s / with 0 i i (i D 1; : : : ; s) we define ´ WD ´

s X

i xi D y C

i D1

s X .i i /xi i D1

and observe that ´ 2 P : the first representation of ´ implies A1 ´ A1 ´ b1 ; the second one implies A2 ´ A2 y b2 . Case 1: There is some i 2 f1; : : : ; sg with i 1 and cxi > 0. Let ´ WD y C xi . We have c´ > cy, showing that this case cannot occur in case (a). In case (b), when y is integral, ´ is an integral solution of Ax b such that c´ > cy and jj´ yjj1 D jjxi jj1 „.A/. Case 2: For all i 2 f1; : : : ; sg, i 1 implies cxi 0. Let ´ WD ´bc D ´

s X

bi c xi :

i D1

´ is an integral vector of P with c´ c´ and jj´ yjj1

s X

.i bi c/ jjxi jj1 n „.A/:

i D1

Hence in both (a) and (b) this vector ´ does the job.

As a corollary we can bound the size of optimum solutions of integer programming problems: Corollary 5.7. If P D fx 2 Qn W Ax bg is a rational polyhedron and maxfcx W x 2 PI g has an optimum solution, then it also has an optimum integral solution x with size.x/ 13n.size.A/ C size.b//. Proof: By Proposition 5.2 and Theorem 4.4, maxfcx W x 2 P g has an optimum solution y with size.y/ 4n.size.A/ C size.b//. By Theorem 5.6(a) there is an optimum solution x of maxfcx W x 2 PI g with jjx yjj1 n „.A/. By Propositions 4.1 and 4.3 we have size.x/ 2size.y/ C 2nsize.n „.A// 8n.size.A/ C size.b// C 2n log n C 4nsize.A/ 13n.size.A/ C size.b//: Theorem 5.6(b) implies the following: given any feasible solution of an integer program, optimality of a vector x can be checked simply by testing x C y for a finite set of vectors y that depend on the matrix A only. Such a finite test set (whose existence has been proved first by Graver [1975]) enables us to prove a fundamental theorem on integer programming:

106

5 Integer Programming

Theorem 5.8. (Wolsey [1981], Cook et al. [1986]) For each integral mn-matrix A there exists an integral matrix M whose entries have absolute value at most n2n „.A/n , such that for each vector b 2 Qm there exists a rational vector d with fx W Ax bgI D fx W M x d g: Proof: We may assume A ¤ 0. Let C be the cone generated by the rows of A. Let L WD f´ 2 Zn W jj´jj1 n„.A/g: For each K L, consider the cone CK WD C \ fy W ´y 0 for all ´ 2 Kg: By the proof of Theorem 3.29 and Lemma 5.4, CK D fy W Uy 0g for some integral matrix U (whose rows are generators of fx W Ax 0g and elements of K) whose entries have absolute value at most n„.A/. Hence, again by Lemma 5.4, there is a finite set G.K/ of integral vectors generating CK , each having components with absolute value at most „.U / SnŠ.n„.A//n n2n „.A/n . Let M be the matrix with rows KL G.K/. Since C; D C , we may assume that the rows of A are also rows of M . Now let b be some fixed vector. If Ax b has no solution, we can complete b to a vector d arbitrarily and have fx W M x d g fx W Ax bg D ;. If Ax b contains a solution, but no integral solution, we set b 0 WD b A0 1l, where A0 arises from A by taking the absolute value of each entry. Then Ax b 0 has no solution, since any such solution yields an integral solution of Ax b by rounding. Again, we complete b 0 to d arbitrarily. Now we may assume that Ax b has an integral solution. For y 2 C we define ıy WD max fyx W Ax b; x integralg (by Corollary 3.28 this maximum is bounded for y 2 C ). It suffices to show that 8 9 < = [ G.K/ : (5.1) fx W Ax bgI D x W yx ıy for each y 2 : ; KL

Here “” is trivial. To show the converse, let c be any vector for which max fcx W Ax b; x integralg is bounded, and let x be a vector attaining this maximum. We show that cx cx for all x satisfying the inequalities on the right-hand side of (5.1). By Proposition 5.2 the LP max fcx W Ax bg is bounded, so by Corollary 3.28 we have c 2 C . N so Let KN WD f´ 2 L W A.x C ´/ bg. By definition c´ 0 for all ´ 2 K, N c 2 CKN . Thus there are nonnegative numbers y (y 2 G.K// such that

5.2

c D

X

Unimodular Transformations

107

y y:

N y2G.K/

Next we claim that x is an optimum solution for max fyx W Ax b; x integralg N the contrary assumption would, by Theorem 5.6(b), yield a for each y 2 G.K/: N vector ´ 2 K with y´ > 0, which is impossible since y 2 CKN . We conclude that 0 1 X X X y ıy D y yx D @ y y A x D cx : N y2G.K/

N y2G.K/

N y2G.K/

Thus the inequality cx cx is a nonnegative linear combination of the inequalities N Hence (5.1) is proved. yx ıy for y 2 G.K/. See Lasserre [2004] for a similar result.

5.2 Unimodular Transformations In this section we shall prove two lemmas for later use. A square matrix is called unimodular if it is integral and has determinant 1 or 1. Three types of unimodular matrices will be of particular interest: For n 2 N, p 2 f1; : : : ; ng and q 2 f1; : : : ; ng n fpg consider the matrices .aij /i;j 2f1;:::;ng defined in one of the following ways: 8 8 ˆ ˆ if i D j 6D p ˇ. Then clearly (f) is violated, since max fax W x 2 P g (which is finite by Proposition 5.2) is not attained by any integral vector. (b))(d) is also trivial since the intersection of a supporting hyperplane with P is a face of P . (d))(e) and (c))(b) are trivial. (e))(c): Let P D fx W Ax bg. We may assume that A and b are integral. Let F D fx W A0 x D b 0 g be a minimal face of P , where A0 x b 0 is a subsystem of Ax b (we use Proposition 3.9). If A0 x D b 0 has no integral solution, then – by Lemma 5.11 – there exists a rational vector y such that c WD yA0 is integral but ı WD yb 0 is not an integer. Adding integers to components of y does not destroy this property (A0 and b 0 are integral), so we may assume that all components of y are positive. Observe that H WD fx W cx D ıg is a rational hyperplane which contains no integral vectors. We finally show that H is a supporting hyperplane by proving that H \ P D F . Since F H is trivial, it remains to show that H \ P F . But for x 2 H \ P we have yA0 x D cx D ı D yb 0 , so y.A0 x b 0 / D 0. Since y > 0 and A0 x b 0 , this implies A0 x D b 0 , so x 2 F . (f))(g) is trivial, so we finally show (g))(e). Let H D fx W cx D ıg be a rational supporting hyperplane of P , so maxfcx W x 2 P g D ı. Suppose H

110

5 Integer Programming

contains no integral vectors. Then – by Lemma 5.11 – there exists a number such that c is integral but ı … Z. Then maxf.j jc/x W x 2 P g D j j maxfcx W x 2 P g D j jı … Z;

contradicting our assumption.

See also Gomory [1963], Fulkerson [1971] and Chvátal [1973] for earlier partial results. By (a),(b) and Corollary 3.6 every face of an integral polyhedron is integral. The equivalence of (f) and (g) of Theorem 5.13 motivated Edmonds and Giles to define TDI-systems: Definition 5.14. (Edmonds and Giles [1977]) A system Ax b of linear inequalities is called totally dual integral (TDI) if the minimum in the LP duality equation max fcx W Ax bg D min fyb W yA D c; y 0g has an integral optimum solution y for each integral vector c for which the minimum is finite. With this definition we get an easy corollary of (g))(a) of Theorem 5.13: Corollary 5.15. Let Ax b be a TDI-system where A is rational and b is integral. Then the polyhedron fx W Ax bg is integral. But total dual integrality is not a property of polyhedra (cf. Exercise 8). In general, a TDI-system contains more inequalities than necessary for describing the polyhedron. Adding valid inequalities does not destroy total dual integrality: Proposition 5.16. If Ax b is TDI and ax ˇ is a valid inequality for fx W Ax bg, then the system Ax b; ax ˇ is also TDI. Proof: Let c be an integral vector such that min fyb C ˇ W yA C a D c; y 0; 0g is finite. Since ax ˇ is valid for fx W Ax bg, min fyb W yA D c; y 0g D max fcx W Ax bg D max fcx W Ax b; ax ˇg D min fyb C ˇ W yA C a D c; y 0; 0g: The first minimum is attained by some integral vector y , so y D y ; D 0 is an integral optimum solution for the second minimum. Theorem 5.17. (Giles and Pulleyblank [1979]) For each rational polyhedron P there exists a rational TDI-system Ax b with A integral and P D fx W Ax bg. Here b can be chosen to be integral if and only if P is integral.

5.3

Total Dual Integrality

111

Proof: Let P D fx W C x d g with C and d integral. W.l.o.g., P 6D ;. For each minimal face F of P let KF WD fc W c´ D max fcx W x 2 P g for all ´ 2 F g: By Corollary 3.22 and Theorem 3.29, KF is a rational polyhedral cone. By Lemma 5.5 there exists an integral Hilbert basis a1 ; : : : ; a t generating KF . Let S F be the system of inequalities a1 x max fa1 x W x 2 P g ; : : : ; a t x max fa t x W x 2 P g: Let Ax b be the collection of all these systems SF (for all minimal faces F ). Note that if P is integral then b is integral. Moreover, P fx W Ax bg. Let c be an integral vector for which max fcx W x 2 P g is finite. The set of vectors attaining this maximum is a face of P , so let F be a minimal face such that c´ D max fcx W x 2 P g for all ´ 2 F . Let SF be the system a1 x ˇ1 ; : : : ; a t x ˇ t . Then c D 1 a1 C C t a t for some nonnegative integers 1 ; : : : ; t . We add N Dc zero components to 1 ; : : : ; t in order to get an integral vector N 0 with A N N N D .A´/ N N and thus cx D .A/x D .Ax/ b D .A/´ D c´ for all x with Ax b and all ´ 2 F . Applying this for each row c of C yields C x d for all x with Ax b; and thus P D fx W Ax bg. Moreover, for general c we conclude that N is an optimum solution of the dual LP min fyb W y 0; yA D cg. Hence Ax b is TDI. If P is integral, we have chosen b to be integral. Conversely, if b can be chosen integral, by Corollary 5.15 P must be integral. Indeed, for full-dimensional rational polyhedra there is a unique minimal TDIsystem describing it (Schrijver [1981]). For later use, we prove that each “face” of a TDI-system is again TDI: Theorem 5.18. (Cook [1983]) Let Ax b; ax ˇ be a TDI-system, where a is integral. Then the system Ax b; ax D ˇ is also TDI. Proof: (Schrijver [1986]) Let c be an integral vector such that max fcx W Ax b; ax D ˇg D min fyb C . /ˇ W y; ; 0; yA C . /a D cg

(5.2)

is finite. Let x ; y ; ; attain these optima. We set c 0 WD c Cd ea and observe that max fc 0 x W Ax b; ax ˇg D min fyb Cˇ W y; 0; yACa D c 0 g (5.3) is finite, because x WD x is feasible for the maximum and y WD y ; WD C d e is feasible for the minimum. Since Ax b; ax ˇ is TDI, the minimum in (5.3) has an integral optimum Q We finally set y WD y; solution y; Q . Q WD Q and WD d e and claim that .y; ; / is an integral optimum solution for the minimum in (5.2).

112

5 Integer Programming

Obviously .y; ; / is feasible for the minimum in (5.2). Furthermore, Q d eˇ yb C . /ˇ D yb Q C ˇ y b C . C d e /ˇ d eˇ Q is an since .y ; C d e / is feasible for the minimum in (5.3), and .y; Q / optimum solution. We conclude that yb C . /ˇ y b C . /ˇ; proving that .y; ; / is an integral optimum solution for the minimum in (5.2). The following statements are straightforward consequences of the definition of TDI-systems: A system Ax D b; x 0 is TDI if min fyb W yA cg has an integral optimum solution y for each integral vector c for which the minimum is finite. A system Ax b; x 0 is TDI if min fyb W yA c; y 0g has an integral optimum solution y for each integral vector c for which the minimum is finite. One may ask whether there are matrices A such that Ax b; x 0 is TDI for each integral vector b. It will turn out that these matrices are exactly the totally unimodular matrices.

5.4 Totally Unimodular Matrices Definition 5.19. A matrix A is totally unimodular if each subdeterminant of A is 0, C1, or 1. In particular, each entry of a totally unimodular matrix must be 0, C1, or 1. The main result of this section is: Theorem 5.20. (Hoffman and Kruskal [1956]) An integral matrix A is totally unimodular if and only if the polyhedron fx W Ax b; x 0g is integral for each integral vector b. Proof: Let A be an m n-matrix and P WD fx W Ax b; x 0g. Observe that the minimal faces of P are vertices. To prove necessity, suppose that A is totally unimodular. Let b be some integral vector and xa vertex of solution of A0 x D b 0 for some subsystem P . x is the 0 0 0 A b A x b of I x 0 , with A being a nonsingular n n-matrix. Since A is totally unimodular, j det A0 j D 1, so by Cramer’s rule x D .A0 /1 b 0 is integral. We now prove sufficiency. Suppose that the vertices of P are integral for each integral vector b. Let A0 be some nonsingular kk-submatrix of A. We have to show j det A0 j D 1. W.l.o.g., A0 contains the elements of the first k rows and columns of A. Consider the integral m m-matrix B consisting of the first k and the last m k columns of .A I / (see Figure 5.2). Obviously, j det Bj D j det A0 j.

5.4 n− k

k

k

A

Totally Unimodular Matrices

k

m − k

I

0

113

(A I) m − k

0

0

I

0

z

z

Fig. 5.2.

To prove j det Bj D 1, we shall prove that B 1 is integral. Since det B det B 1 D 1, this implies that j det Bj D 1, and we are done. Let i 2 f1; : : : ; mg; we prove that B 1 ei is integral. Choose an integral vector y such that ´ WD y C B 1 ei 0. Then b WD B´ D By C ei is integral. We add zero components to ´ in order to obtain ´0 with A I ´0 D B´ D b: Now ´00 , consisting of the first n components of ´0 , belongs to P . Furthermore, n linearly independent constraints are satisfied with equality, namely the first k and the last n k inequalities of A b ´00 : I 0 Hence ´00 is a vertex of P . By our assumption ´00 is integral. But then ´0 must also be integral: its first n components are the components of ´00 , and the last m components are the slack variables b A´00 (and A and b are integral). So ´ is also integral, and hence B 1 ei D ´ y is integral. The above proof is due to Veinott and Dantzig [1968]. Corollary 5.21. An integral matrix A is totally unimodular if and only if for all integral vectors b and c both optima in the LP duality equation max fcx W Ax b; x 0g D min fyb W y 0; yA cg are attained by integral vectors (if they are finite).

114

5 Integer Programming

Proof: This follows from the Hoffman-Kruskal Theorem 5.20 by using the fact that the transpose of a totally unimodular matrix is also totally unimodular. Let us reformulate these statements in terms of total dual integrality: Corollary 5.22. An integral matrix A is totally unimodular if and only if the system Ax b; x 0 is TDI for each vector b. Proof: If A (and thus A> ) is totally unimodular, then by the Hoffman-Kruskal Theorem min fyb W yA c; y 0g is attained by an integral vector for each vector b and each integral vector c for which the minimum is finite. In other words, the system Ax b; x 0 is TDI for each vector b. To show the converse, suppose Ax b; x 0 is TDI for each integral vector b. Then by Corollary 5.15, the polyhedron fx W Ax b; x 0g is integral for each integral vector b. By Theorem 5.20 this means that A is totally unimodular. This is not the only way how total unimodularity can be used to prove that a certain system is TDI. The following lemma contains another proof technique; this will be used several times later (Theorems 6.14, 19.17 and 14.12). Lemma 5.23. Let Ax b; x 0 be an inequality system, where A 2 Rmn and b 2 Rm . Suppose that for each c 2 Zn for which minfyb W yA c; y 0g has an optimum solution, it has one y such that the rows of A corresponding to nonzero components of y form a totally unimodular matrix. Then Ax b; x 0 is TDI. Proof: Let c 2 Zn , and let y be an optimum solution of minfyb W yA c; y 0g such that the rows of A corresponding to nonzero components of y form a totally unimodular matrix A0 . We claim that minfyb W yA c; y 0g D minfyb 0 W yA0 c; y 0g;

(5.4)

where b 0 consists of the components of b corresponding to the rows of A0 . To see the inequality “” of (5.4), observe that the LP on the right-hand side arises from the LP on the left-hand side by setting some variables to zero. The inequality “” follows from the fact that y without zero components is a feasible solution for the LP on the right-hand side. Since A0 is totally unimodular, the second minimum in (5.4) has an integral optimum solution (by the Hoffman-Kruskal Theorem 5.20). By filling this solution with zeros we obtain an integral optimum solution to the first minimum in (5.4), completing the proof. A very useful criterion for total unimodularity is the following: Theorem 5.24. (Ghouila-Houri [1962]) A matrix A D .aij / 2 Zmn is totally : unimodular if and only if for every R f1; : : : ; mg there is a partition R D R1 [ R2 such that

5.4

X i 2R1

aij

X

Totally Unimodular Matrices

115

aij 2 f1; 0; 1g

i 2R2

for all j D 1; : : : ; n. Proof: Let A be totally unimodular, and let R f1; : : :; mg. Let dr WD 1 for A> r 2 R and dr WD 0 for r 2 f1; : : : ; mg n R. The matrix A> is also totally I

unimodular, so by Theorem 5.20 the polytope

1 1 x W xA dA ; xA dA ; x d; x 0 2 2 is integral. Moreover it is nonempty because it contains 12 d . So it has an integral vertex, say ´. Setting R1 WD fr 2 R W ´r D 0g and R2 WD fr 2 R W ´r D 1g we obtain 0 1 X X @ aij aij A D .d 2´/A 2 f1; 0; 1gn; i 2R1

i 2R2

1j n

as required. We now prove the converse. By induction on k we prove that every k ksubmatrix has determinant 0, 1 or 1. For k D 1 this is directly implied by the criterion for jRj D 1. Now let k > 1, and let B D .bij /i;j 2f1;:::;kg be a nonsingular k k-submatrix B0 0 of A. By Cramer’s rule, each entry of B 1 is det det B , where B arises from B by replacing a column by a unit vector. By the induction hypothesis, det B 0 2 f1; 0; 1g. So B WD .det B/B 1 is a matrix with entries 1; 0; 1 only. Let b1 be the first row of B . We have b1 B D .det B/e1 , where e1 is the first unit vector. Let R WD fi W b1i 6D 0g. Then for j D 2; : : : ; k we have 0 D .b1 B/j D P i 2R b1i bij , so jfi 2 R W bij 6D 0gj is even. : P By the hypothesis there is a partition R D R [ R2 with Pi 2R1 bij 1 P for all j . SoP for j D 2; : : : ; k we have i 2R1 bij Pi 2R2 bij 2 f1; 0; 1g P b D 0. If also b i 2R2 ij i 2R1 i1 i 2R2 bi1 D 0, then the sum of the rows in R1 equals the sum of the rows in R2 , contradicting the assumption that B is nonsingular R 6D ;). P (becauseP So i 2R1 bi1 i 2R2 bi1 2 f1; 1g and we have yB 2 fe1 ; e1 g, where 8 ˆ if i 2 R1 jE.B 0 /j we have

6.2

Minimum Weight Arborescences

139

c 0 .E.B// > c 0 .E.B 0 // (and branchings with n 1 edges are exactly the spanning arborescences). Given an instance .G; c/ of the MAXIMUM WEIGHT BRANCHING PROBLEM, : let G 0 WD .V .G/ [ frg; E.G/ [ f.r; v/ W v 2 V .G/g/. Let c 0 .e/ WD c.e/ for e 2 E.G/ and c.e/ WD 0 for e 2 E.G 0 / n E.G/. Then the instance .G 0 ; r; c 0 / of the MINIMUM WEIGHT ROOTED ARBORESCENCE PROBLEM is equivalent. Finally, given an instance .G; r; c/ of the MINIMUM WEIGHT ROOTED : ARBORESCENCE PROBLEM, let G 0 WD .V .G/ [ fsg; E.G/ [ f.s; r/g/ and c..s; r// WD 0. Then the instance .G 0 ; c/ of the MINIMUM WEIGHT ARBORESCENCE PROBLEM is equivalent. In the rest of this section we shall deal with the M AXIMUM WEIGHT BRANCHPROBLEM only. This problem is not as easy as its undirected version, the M AXIMUM WEIGHT FOREST PROBLEM . For example any maximal forest is maximum, but the bold edges in Figure 6.1 form a maximal branching which is not maximum. ING

Fig. 6.1.

Recall that a branching is a graph B with jıB .x/j 1 for all x 2 V .B/, such that the underlying undirected graph is a forest. Equivalently, a branching is an acyclic digraph B with jıB .x/j 1 for all x 2 V .B/; see Theorem 2.5(g): Proposition 6.10. Let B be a digraph with jıB .x/j 1 for all x 2 V .B/. Then B contains a circuit if and only if the underlying undirected graph contains a circuit. Now let G be a digraph and c W E.G/ ! RC . We can ignore negative weights since such edges will never appear in an optimum branching. A first idea towards an algorithm could be to take the best entering edge for each vertex. Of course the resulting graph may contain circuits. Since a branching cannot contain circuits, we must delete at least one edge of each circuit. The following lemma says that one is enough. Lemma 6.11. (Karp [1972]) Let B0 be a maximum weight subgraph of G with jıB0 .v/j 1 for all v 2 V .B0 /. Then there exists an optimum branching B of G such that for each circuit C in B0 , jE.C / n E.B/j D 1. Proof: Let B be an optimum branching of G containing as many edges of B0 as possible. Let C be some circuit in B0 . Let E.C /nE.B/ D f.a1 ; b1 /; : : : ; .ak ; bk /g;

140

6 Spanning Trees and Arborescences a1

b1

C a2

b3

a3

b2

Fig. 6.2.

suppose that k 2 and a1 ; b1 ; a2 ; b2 ; a3 ; : : : ; bk lie in this order on C (see Figure 6.2). We claim that B contains a bi -bi 1 -path for each i D 1; : : : ; k (b0 WD bk ). This, however, is a contradiction because these paths form a closed edge progression in B, and a branching cannot have a closed edge progression. Let i 2 f1; : : : ; kg. It remains to show that B contains a bi -bi 1 -path. Consider B 0 with V .B 0 / D V .G/ and E.B 0 / WD f.x; y/ 2 E.B/ W y 6D bi g [ f.ai ; bi /g. B 0 cannot be a branching since it would be optimum and contain more edges of B0 than B. So (by Proposition 6.10) B 0 contains a circuit, i.e. B contains a bi -ai path P . Since k 2, P is not completely on C , so let e be the last edge of P not belonging to C . Obviously e D .x; bi 1 / for some x, so P (and thus B) contains a bi -bi 1 -path. The main idea of Edmonds’ [1967] algorithm is to find first B0 as above, and then contract every circuit of B0 in G. If we choose the weights of the resulting graph G1 correctly, any optimum branching in G1 will correspond to an optimum branching in G.

EDMONDS’ BRANCHING ALGORITHM Input:

A digraph G, weights c W E.G/ ! RC .

Output:

A maximum weight branching B of G.

1

Set i WD 0, G0 WD G, and c0 WD c.

2

Let Bi be a maximum weight subgraph of Gi with jıBi .v/j 1 for all v 2 V .Bi /. If Bi contains no circuit then set B WD Bi and go to . 5

3

6.2

4

5

Minimum Weight Arborescences

141

. Contract these circuits: Let C be the set of circuits in BiS Let V .Gi C1 / WD C [ .V .Gi / n C 2C V .C //. 0 For e D .v; w/ 2 E.Gi / let e 0 D .v 0 ; w 0 / and ˆi C1 .e S/ WD e, where v 0 D C if v 2 V .C / for C 2 C, and v 0 D v if v … CS2C V .C /, and w 0 D C if w 2 V .C / for C 2 C, and w 0 D w if w … C 2C V .C /. Let E.Gi C1 / WD fe 0 D .v 0 ; w 0 / W e 2 E.Gi /; v 0 6D w 0 g (parallel edges may arise). For e D .v; w/ 2 E.Gi / with e 0 D .v 0 ; w 0 / 2 E.Gi C1 / set ci C1 .e 0 / WD ci .e/ if w 0 … C, and ci C1 .e 0 / WD ci .e/ ci .˛.e; C // C ci .eC / if w 0 D C 2 C, where ˛.e; C / 2 ıC .w/ and eC is some cheapest edge of C . Set i WD i C 1 and go to . 2 While i > 0 do: Set B 0 WD .V .Gi 1 /; fˆi .e/ W e 2 E.B/g/. For each circuit C of Bi 1 do: If there is an edge e 2 ıB0 .V .C // then set E.B 0 / WD E.B 0 / [ .E.C / n f˛.e; C /g/ else set E.B 0 / WD E.B 0 / [ .E.C / n feC g/. Set B WD B 0 and i WD i 1.

This algorithm was also discovered independently by Chu and Liu [1965] and Bock [1971]. Theorem 6.12. (Edmonds [1967]) EDMONDS’ BRANCHING ALGORITHM works correctly. Proof: We show that in , 5 B is always an optimum branching of Gi . This is trivial for the first time we reach . 5 So we have to show that one iteration of 5 transforms an optimum branching B of Gi into an optimum branching B 0 of Gi 1 . Let Bi1 be any branching of Gi 1 such that jE.C / n E.Bi1 /j D 1 for each circuit C of Bi 1 . Let Bi result from Bi1 by contracting the circuits of Bi 1 . Bi is a branching of Gi . Furthermore we have X .ci 1 .E.C // ci 1 .eC //: ci 1 .Bi1 / ci .Bi / C C W circuit of Bi 1

By the induction hypothesis, B is an optimum branching of Gi , so we have ci .B/ ci .Bi /. We conclude that X

ci 1 .Bi1 / ci .B/ C

.ci 1 .E.C // ci 1 .eC //

C W circuit of Bi 1

D ci 1 .B 0 /: This, together with Lemma 6.11, implies that B 0 is an optimum branching of Gi 1 .

142

6 Spanning Trees and Arborescences

This proof is due to Karp [1972]. Edmonds’ original proof was based on a linear programming formulation (see Corollary 6.15). The running time of EDMONDS’ BRANCHING ALGORITHM is easily seen to be O.mn/, where m D jE.G/j and n D jV .G/j: there are at most n iterations (i.e. i n at any stage of the algorithm), and each iteration can be implemented in O.m/ time. The best known bound has been obtained by Gabow et al. [1986] using a Fibonacci heap: their branching algorithm runs in O.m C n log n/ time.

6.3 Polyhedral Descriptions A polyhedral description of the M INIMUM SPANNING TREE PROBLEM is as follows: Theorem 6.13. (Edmonds [1970]) Given a connected undirected graph G, n WD jV .G/j, the polytope P WD 9 8 = < X X xe D n 1; xe jX j 1 for ; 6D X V .G/ x 2 Œ0; 1E.G/ W ; : e2E.G/

e2E.GŒX/

is integral. Its vertices are exactly the incidence vectors of spanning trees of G. (P is called the spanning tree polytope of G.) Proof: Let T be a spanning tree of G, and let x be the incidence vector of E.T /. Obviously (by Theorem 2.4), x 2 P . Furthermore, since x 2 f0; 1gE.G/ , it must be a vertex of P . On the other hand let x be an integral vertex of P . Then x is the incidence vector of the edge set of some subgraph H with n 1 edges and no circuit. Again by Theorem 2.4 this implies that H is a spanning tree. So it suffices to show that P is integral (recall Theorem 5.13). Let c W E.G/ ! R, and let T be the tree produced by KRUSKAL’S ALGORITHM when applied to .G; c/ (ties are broken arbitrarily when sorting the edges). Denote E.T / D ff1 ; : : : ; fn1 g, where the fi were taken in this order by the algorithm. In particular, c.f1 / c.fn1 /. Let Xk V .G/ be the connected component of .V .G/; ff1 ; : : : ; fk g/ containing fk (k D 1; : : : ; n 1). Let x be the incidence vector of E.T /. We show that x is an optimum solution to the LP X min c.e/xe e2E.G/

s.t.

X

e2E.G/ X

xe D n 1 xe jX j 1

.; 6D X V .G//

xe 0

.e 2 E.G//:

e2E.GŒX/

6.3

Polyhedral Descriptions

143

We introduce a dual variable ´X for each ; 6D X V .G/ and one additional dual variable ´V .G/ for the equality constraint. Then the dual LP is X max .jX j 1/´X ;6DXV .G/

s.t.

X

´X c.e/

.e 2 E.G//

´X 0

.; 6D X V .G//:

eXV .G/

Note that the dual variable ´V .G/ is not forced to be nonnegative. For k D 1; : : : ; n 2 let ´X WD c.fl / c.fk /, where l is the first index greater than k k for which fl \ Xk 6D ;. Let ´V .G/ WD c.fn1 /, and let ´X WD 0 for all X 62 fX1 ; : : : ; Xn1 g. For each e D fv; wg we have that X ´X D c.fi /; eXV .G/

where i is the smallest index such that v; w 2 Xi . Moreover c.fi / c.e/ since v and w are in different connected components of .V .G/; ff1 ; : : : ; fi 1 g/. Hence ´ is a feasible dual solution. Moreover xe > 0, i.e. e 2 E.T /, implies X ´X D c.e/; eXV .G/ > 0 i.e. the corresponding dual constraint is satisfied with equality. Finally, ´X implies that T ŒX is connected, so the corresponding primal constraint is satisfied with equality. In other words, the primal and dual complementary slackness conditions are satisfied, thus (by Corollary 3.23) x and ´ are optimum solutions for the primal and dual LP, respectively.

Indeed, we have proved that the inequality system in Theorem 6.13 is TDI. We remark that the above is also an alternative proof of the correctness of KRUSKAL’S ALGORITHM (Theorem 6.4). Another description of the spanning tree polytope is the subject of Exercise 19. There is also a polynomial-size LP formulation; see Exercise 20. P P If we replace the constraint e2E.G/ xe D n 1 by e2E.G/ xe n 1, we obtain the convex hull of the incidence vectors of all forests in G (Exercise 21). A generalization of these results is Edmonds’ characterization of the matroid polytope (Theorem 13.21). We now turn to a polyhedral description of the MINIMUM WEIGHT ROOTED ARBORESCENCE PROBLEM. First we prove a classical result of Fulkerson. Recall that an r-cut is a set of edges ı C .S / for some S V .G/ with r 2 S . Theorem 6.14. (Fulkerson [1974]) Let G be a digraph with weights c W E.G/ ! ZC , and r 2 V .G/ such that G contains a spanning arborescence rooted at r. Then

144

6 Spanning Trees and Arborescences

the minimum weight of a spanning arborescence rooted at r equals the maximum number t of r-cuts C1 ; : : : ; C t (repetitions allowed) such that no edge e is contained in more than c.e/ of these cuts. Proof: Let A be the matrix whose columns are indexed by the edges and whose rows are all incidence vectors of r-cuts. Consider the LP minfcx W Ax 1l; x 0g; and its dual maxf1ly W yA c; y 0g: Then (by part (e) of Theorem 2.5) we have to show that for any nonnegative integral c, both the primal and dual LP have integral optimum solutions. By Corollary 5.15 it suffices to show that the system Ax 1l; x 0 is TDI. We use Lemma 5.23. Since the dual LP is feasible if and only if c is nonnegative, let c W E.G/ ! ZC . Let y be an optimum solution of maxf1ly W yA c; y 0g for which X yı .X/ jX j2 (6.1) ;6DXV .G/nfrg

is as large as possible. We claim that F WD fX W yı .X/ > 0g is laminar. To see this, suppose X; Y 2 F with X \ Y 6D ;, X n Y 6D ; and Y n X 6D ; (Figure 6.3). Let WD minfyı .X/ ; yı .Y / g. Set yı0 .X/ WD yı .X/ , yı0 .Y / WD yı .Y / , yı0 .X\Y / WD yı .X\Y / C , yı0 .X[Y / WD yı .X[Y / C , and y 0 .S / WD y.S / for all other r-cuts S . Observe that y 0 A yA, so y 0 is a feasible dual solution. Since 1ly D 1ly 0 , it is also optimum and contradicts the choice of y, because (6.1) is larger for y 0 . (For any numbers a > b c > d > 0 with a C d D b C c we have a2 C d 2 > b 2 C c 2 .) X

Y

r

Fig. 6.3.

Now let A0 be the submatrix of A consisting of the rows corresponding to the elements of F . A0 is the one-way cut-incidence matrix of a laminar family (to be precise, we must consider the graph resulting from G by reversing each edge). So by Theorem 5.28 A0 is totally unimodular, as required. The above proof also yields the promised polyhedral description:

6.4

Packing Spanning Trees and Arborescences

145

Corollary 6.15. (Edmonds [1967]) Let G be a digraph with weights c W E.G/ ! RC , and r 2 V .G/ such that G contains a spanning arborescence rooted at r. Then the LP 8 9 < = X min cx W x 0; xe 1 for all X V .G/ with r 2 X : ; C e2ı .X/

has an integral optimum solution (which is the incidence vector of a minimum weight spanning arborescence rooted at r, plus possibly some edges of zero weight). For a description of the convex hull of the incidence vectors of all branchings or spanning arborescences rooted at r, see Exercises 22 and 23.

6.4 Packing Spanning Trees and Arborescences If we are looking for more than one spanning tree or arborescence, classical theorems of Tutte, Nash-Williams and Edmonds are of help. We first give a proof of Tutte’s Theorem on packing spanning trees which is essentially due to Mader (see Diestel [1997]) and which uses the following lemma: Lemma 6.16. Let G be an undirected graph, and let F D .F1 ; : : : ; Fk / be a ktuple of edge-disjoint forests in G such that jE.F /j is maximum, where E.F / WD Sk i D1 E.Fi /. Let e 2 E.G/ n E.F /. Then there exists a set X V .G/ with e X such that Fi ŒX is connected for each i 2 f1; : : : ; kg. Proof: For two k-tuples F 0 D .F10 ; : : : ; Fk0 / and F 00 D .F100 ; : : : ; Fk00 / of edgedisjoint forests we say that F 00 arises from F 0 by exchanging e 0 for e 00 if Fj00 D :

.Fj0 n e 0 / [ e 00 for some j and Fi00 D Fi0 for all i 6D j . Let F be the set of all k-tuples of edge-disjoint forests arising from F by a sequence of such exchanges. T 0 Let E WD E.G/ n E.F / and G WD .V .G/; E/. We have F 2 F and thus 0 F 2F e 2 E. Let X be the vertex set of the connected component of G containing e. We shall prove that Fi ŒX is connected for each i . Claim: For any F 0 D .F10 ; : : : ; Fk0 / 2 F and any eN D fv; wg 2 E.GŒX /nE.F 0 / there exists a v-w-path in Fi0 ŒX for all i 2 f1; : : : ; kg. To prove this, let i 2 f1; : : : ; kg be fixed. Since F 0 2 F and jE.F 0 /j D jE.F /j is maximum, Fi0 C eN contains a circuit C . Now for all e 0 2 E.C / n feg N we have Fe00 2 F , where Fe00 arises from F 0 by exchanging e 0 for e. N This shows that E.C / E, and so C eN is a v-w-path in Fi0 ŒX . This proves the claim. Since GŒX is connected, it suffices to prove that for each eN D fv; wg 2 E.GŒX / and each i there is a v-w-path in Fi ŒX . So let eN D fv; wg 2 E.GŒX /. Since eN 2 E, there is some F 0 D .F10 ; : : : ; Fk0 / 2 F with eN 62 E.F 0 /. By the claim there is a v-w-path in Fi0 ŒX for each i . Now there is a sequence F D F .0/ ; F .1/ : : : ; F .s/ D F 0 of elements of F such that F .rC1/ arises from F .r/ by exchanging one edge (r D 0; : : : ; s 1). It suffices

146

6 Spanning Trees and Arborescences

to show that the existence of a v-w-path in Fi.rC1/ ŒX implies the existence of a v-w-path in Fi.r/ ŒX (r D 0; : : : ; s 1). .rC1/ .r/ To see this, suppose that Fi arises from Fi by exchanging er for erC1 , .rC1/ and let P be the v-w-path in Fi ŒX . If P does not contain erC1 D fx; yg, it is .r/ also a path in Fi ŒX . Otherwise erC1 2 E.GŒX /, and we consider the x-y-path .r/ Q in Fi ŒX which exists by the claim. Since .E.P / n ferC1 g/ [ E.Q/ contains a .r/ v-w-path in Fi ŒX , the proof is complete. Now we can prove Tutte’s theorem on disjoint spanning trees. A multicut in an undirected graph G is a set of edges ı.X1 ; : : : ; Xp / WD ı.X1 /[ [ı.Xp / for some : : : partition V .G/ D X1 [ X2 [ [ Xp of the vertex set into nonempty subsets. For p D 3 we also speak of 3-cuts. Observe that cuts are multicuts with p D 2. Theorem 6.17. (Tutte [1961], Nash-Williams [1961]) An undirected graph G contains k edge-disjoint spanning trees if and only if jı.X1 ; : : : ; Xp /j k.p 1/ for every multicut ı.X1 ; : : : ; Xp /. Proof: To prove necessity, let T1 ; : : : ; Tk be edge-disjoint spanning trees in G, and let ı.X1 ; : : : ; Xp / be a multicut. Contracting each of the vertex subsets X1 ; : : : ; Xp yields a graph G 0 whose vertices are X1 ; : : : ; Xp and whose edges correspond to the edges of the multicut. T1 ; : : : ; Tk correspond to edge-disjoint connected subgraphs T10 ; : : : ; Tk0 in G 0 . Each of the T10 ; : : : ; Tk0 has at least p 1 edges, so G 0 (and thus the multicut) has at least k.p 1/ edges. To prove sufficiency we use induction on jV .G/j. For n WD jV .G/j 2 the statement is true. Now assume n > 2, and suppose that jı.X1; : : : ; Xp /j k.p 1/ for every multicut ı.X1 ; : : : ; Xp /. In particular (consider the partition into singletons) G has at least k.n1/ edges. Moreover, the condition is preserved when contracting vertex sets, so by the induction hypothesis G=X contains k edge-disjoint spanning trees for each X V .G/ with jX j 2. Let F D .F1 ; : : : ; Fk / be a k-tuple of edge-disjoint forests in G such that S jE.F /j is maximum, where again E.F / WD kiD1 E.Fi /. We claim that each Fi is a spanning tree. Otherwise jE.F /j < k.n 1/, so there is an edge e 2 E.G/ n E.F /. By Lemma 6.16 there is an X V .G/ with e X such that Fi ŒX is connected for each i . Since jX j 2, G=X contains k edge-disjoint spanning trees F10 ; : : : ; Fk0 . Now Fi0 together with Fi ŒX forms a spanning tree in G for each i , and all these k spanning trees are edge-disjoint. We now turn to the corresponding problem in digraphs, packing spanning arborescences: Theorem 6.18. (Edmonds [1973]) Let G be a digraph and r 2 V .G/. Then the maximum number of edge-disjoint spanning arborescences rooted at r equals the minimum cardinality of an r-cut.

6.4

Packing Spanning Trees and Arborescences

147

Proof: Let k be the minimum cardinality of an r-cut. Obviously there are at most k edge-disjoint spanning arborescences rooted at r. We prove the existence of k edge-disjoint spanning arborescences rooted at r by induction on k. The case k D 0 is trivial. If we can find one spanning arborescence A rooted at r such that ˇ C ˇ min ˇıG .S / n E.A/ˇ k 1; (6.2) r2SV .G/

then we are done by induction. Suppose we have already found some arborescence A rooted at r (but not necessarily spanning) such that (6.2) holds. Let R V .G/ be the set of vertices covered by A. Initially, R D frg; if R D V .G/, we are done. If R 6D V .G/, we call a set X V .G/ critical if (a) r 2 X ; (b) X [ R 6D V .G/; C (c) jıG .X / n E.A/j D k 1.

R x

r e X

y

Fig. 6.4.

If there is no critical vertex set, we can augment A by any edge leaving R. Otherwise let X be a maximal critical set, and let e D .x; y/ be an edge such that x 2 R n X and y 2 V .G/ n .R [ X / (see Figure 6.4). Such an edge must exist because C C C jıGE.A/ .R [ X /j D jıG .R [ X /j k > k 1 D jıGE.A/ .X /j:

We now add e to A. Obviously A C e is an arborescence rooted at r. We have to show that (6.2) continues to hold. C Suppose there is some Y such that r 2 Y V .G/ and jıG .Y / n E.A C e/j < C k 1. Then x 2 Y , y … Y , and jıG .Y / n E.A/j D k 1. Now Lemma 2.1(a) implies C C k 1 C k 1 D jıGE.A/ .X /j C jıGE.A/ .Y /j C C .X [ Y /j C jıGE.A/ .X \ Y /j jıGE.A/

k1Ck1 ;

148

6 Spanning Trees and Arborescences

because r 2 X \ Y and y 2 V .G/ n .X [ Y /. So equality must hold throughout, in C particular jıGE.A/ .X [ Y /j D k 1. Since y 2 V .G/ n .X [ Y [ R/ we conclude that X [ Y is critical. But since x 2 Y n X , this contradicts the maximality of X . This proof is due to Lovász [1976]. Fujishige [2010] generalized this result to packing arborescences with given (but not necessarily identical) roots, spanning given subsets of vertices. A common generalization of Theorems 6.17 and 6.18 was found by Frank [1981]. A good characterization (see Chapter 15 for an explanation of this term) of the problem of packing spanning arborescences with arbitrary roots is given by the following theorem, which we cite without proof: Theorem 6.19. (Frank [1979]) A digraph G contains k edge-disjoint spanning arborescences if and only if p X

jı .Xi /j k.p 1/

i D1

for every collection of pairwise disjoint nonempty subsets X1 ; : : : ; Xp V .G/. Another question is how many forests are needed to cover a graph. This is answered by the following theorem: Theorem 6.20. (Nash-Williams [1964]) The edge set of an undirected graph G is the union of k forests if and only if jE.GŒX /j k.jX j 1/ for all ; 6D X V .G/. Proof: The necessity is clear since no forest can contain more than jX j 1 edges within a vertex set X . To prove the sufficiency, assume that jE.GŒX /j k.jX j1/ for all ; 6D X V .G/, and letˇ F D .F1 ; : ˇ: : ; Fk / be a k-tuple of edge-disjoint ˇS ˇ forests in G such that jE.F /j D ˇ kiD1 E.Fi /ˇ is maximum. We claim that E.F / D E.G/. To see this, suppose there is an edge e 2 E.G/ n E.F /. By Lemma 6.16 there exists a set X V .G/ with e X such that Fi ŒX is connected for each i . In particular, ˇ ˇ k ˇ ˇ : [ ˇ ˇ jE.GŒX /j ˇfeg [ E.Fi ŒX /ˇ 1 C k.jX j 1/; ˇ ˇ i D1

contradicting the assumption.

Exercise 29 gives a directed version. A generalization of Theorems 6.17 and 6.20 to matroids can be found in Exercise 19 of Chapter 13.

Exercises 1. Prove Cayley’s Theorem 6.2 by showing that the following defines a oneto-one correspondence between the spanning trees in Kn and the vectors in

Exercises

2. 3.

4.

5.

6.

7.

8.

9.

10.

149

f1; : : : ; ngn2 : For a tree T with V .T / D f1; : : : ; ng, n 3, let v be the leaf with the smallest index and let a1 be the neighbour of v. We recursively define a.T / WD .a1 ; : : : ; an2 /, where .a2 ; : : : ; an2 / D a.T v/. (Prüfer [1918]) Prove that there are exactly .n C 1/n1 branchings B with V .B/ D f1; : : : ; ng. Let pn be the probability that vertex 1 is a leaf in T if T is chosen randomly among all trees with vertex set f1; : : : ; ng (with uniform distribution). What is limn!1 pn ? Let .V; T1 / and .V; T2 / be two trees on the same vertex set V . Prove that for any edge e 2 T1 there is an edge f 2 T2 such that both .V; .T1 n feg/ [ ff g/ and .V; .T2 n ff g/ [ feg/ are trees. Let .G; c/ be an instance of the MINIMUM SPANNING TREE PROBLEM where G is connected and c.e/ 6D c.e 0 / for any two distinct edges e and e 0 . Prove that then there is exactly one optimum solution. Given an undirected graph G with weights c W E.G/ ! R and a vertex v 2 V .G/, we ask for a minimum weight spanning tree in G where v is not a leaf. Can you solve this problem in polynomial time? We want to determine the set of edges e in an undirected graph G with weights c W E.G/ ! R for which there exists a minimum weight spanning tree in G containing e (in other words, we are looking for the union of all minimum weight spanning trees in G). Show how this problem can be solved in O.mn/ time. Given an undirected graph G with arbitrary weights c W E.G/ ! R, we ask for a minimum weight connected spanning subgraph. Can you solve this problem efficiently? Consider the following algorithm (sometimes called WORST-OUT-GREEDY ALGORITHM, see Section 13.4). Examine the edges in order of non-increasing weights. Delete an edge unless it is a bridge. Does this algorithm solve the M INIMUM SPANNING T REE PROBLEM ? Consider the following “colouring” algorithm. Initially all edges are uncoloured. Then apply the following rules in arbitrary order until all edges are coloured: Blue rule: Select a cut containing no blue edge. Among the uncoloured edges in the cut, select one of minimum cost and colour it blue. Red rule: Select a circuit containing no red edge. Among the uncoloured edges in the circuit, select one of maximum cost and colour it red. Show that one of the rules is always applicable as long as there are uncoloured edges left. Moreover, show that the algorithm maintains the “colour invariant”: there always exists an optimum spanning tree containing all blue edges but no red edge. (So the algorithm solves the MINIMUM SPANNING TREE PROBLEM optimally.) Observe that KRUSKAL’S ALGORITHM and PRIM’S ALGORITHM are special cases. (Tarjan [1983])

150

6 Spanning Trees and Arborescences

11. Suppose we wish to find a spanning tree T in an undirected graph such that the maximum weight of an edge in T is as small as possible. How can this be done? 12. Is it true that the maximum length of a path in a branching implementing a Fibonacci heap is O.log n/, where n is the number of elements? 13. Show that two Fibonacci heaps with n1 and n2 elements can be merged in O.log.n1 C n2 // time. The resulting Fibonacci heap shall contain all n1 C n2 elements. 14. For a finite set V R2 , the Vorono˘ı diagram consists of the regions Pv WD x 2 R2 W jjx vjj2 D min jjx wjj2 w2V

for v 2 V . The Delaunay triangulation of V is the graph .V; ffv; wg V; v 6D w; jPv \ Pw j > 1g/ :

15.

16.

17.

18.

A minimum spanning tree for V is a tree T with V .T / D V whose length P fv;wg2E.T / jjv wjj2 is minimum. Prove that every minimum spanning tree is a subgraph of the Delaunay triangulation. Note: Using the fact that the Delaunay triangulation can be computed in O.n log n/ time (where n D jV j; see e.g. Fortune [1987], Knuth [1992]), this implies an O.n log n/ algorithm for the M INIMUM SPANNING TREE PROBLEM for point sets in the plane. (Shamos and Hoey [1975]; see also Zhou, Shenoy and Nicholls [2002]) Can you decide in linear time whether a digraph contains a spanning arborescence? Hint: To find a possible root, start at an arbitrary vertex and traverse edges backwards as long as possible. When encountering a circuit, contract it. Can you find a maximum cardinality branching in a given digraph in linear time? Hint: First find the strongly connected components. The MINIMUM WEIGHT ROOTED ARBORESCENCE PROBLEM can be reduced to the MAXIMUM WEIGHT BRANCHING PROBLEM by Proposition 6.9. However, it can also be solved directly by a modified version of EDMONDS’ BRANCHING ALGORITHM. Show how. Prove that the spanning tree polytope of an undirected graph G (see Theorem 6.13) with n WD jV .G/j is in general a proper subset of the polytope 8 9 < = X X x 2 Œ0; 1E.G/ W xe D n 1; xe 1 for ; X V .G/ : : ; e2E.G/

e2ı.X/

Hint: To prove that this polytope is not integral, consider the graph shown in Figure 6.5 (the numbers are edge weights). (Magnanti and Wolsey [1995])

Exercises 1

151

0 0

1

0

1

Fig. 6.5.

19. In Exercise 18 we saw that cut constraints do not suffice to describe the spanning tree polytope. However, if we consider multicuts instead, we obtain a complete description: Prove that the spanning tree polytope of an undirected graph G with n WD jV .G/j consists of all vectors x 2 Œ0; 1E.G/ with X X xe D n 1 and xe k 1 for all multicuts C D ı.X1 ; : : : ; Xk /: e2E.G/

e2C

(Magnanti and Wolsey [1995])

20. Let G be an undirected graph and n WD jV .G/j. Prove that the following linear inequality system with O.n3 / variables and constraints describes a polytope whose orthogonal projection onto the x-variables yields the spanning tree polytope of G: xe 0 (e 2 E.G/), ´u;v;w 0 (fu; vg 2 E.G/; w 2 V .G/nfu; vg), P u;v;w C ´v;u;w (e D fu; vg 2 E.G/, e2E.G/ xe D n 1, xe D ´P w 2 V .G/ n fu; vg), and xe C fu;vg2ı.v/nfeg ´u;v;w D 1 (v 2 V .G/, e D fv; wg 2 ı.v/). Note: See Conforti, Cornuéjols and Zambelli [2010] for a survey of such extended formulations of combinatorial LPs. 21. Prove that the convex hull of the incidence vectors of all forests in an undirected graph G is the polytope 8 9 < = X P WD x 2 Œ0; 1E.G/ W xe jX j 1 for ; 6D X V .G/ : : ; e2E.GŒX/

P Note: This statement implies Theorem 6.13 since e2E.GŒX/ xe D jV .G/j 1 is a supporting hyperplane. Moreover, it is a special case of Theorem 13.21.

22. Prove that the convex hull of the incidence vectors of all branchings in a digraph G is the set of all vectors x 2 Œ0; 1E.G/ with X X xe jX j 1 for ; 6D X V .G/ and xe 1 for v 2 V .G/: e2E.GŒX/

e2ı .v/

Note: This is a special case of Theorem 14.13.

23. Let G be a digraph and r 2 V .G/. Prove that the polytopes

152

6 Spanning Trees and Arborescences

( x 2 Œ0; 1E.G/ W xe D 0 .e 2 ı .r//;

X

xe D 1 .v 2 V .G/ n frg/;

e2ı .v/

X

)

xe jX j 1 for ; 6D X V .G/

e2E.GŒX/

and ( x 2 Œ0; 1E.G/ W xe D 0 .e 2 ı .r//;

X

xe D 1 .v 2 V .G/ n frg/;

e2ı .v/

X

)

xe 1 for r 2 X V .G/

e2ı C .X/

24. 25.

26.

27.

28.

29.

are both equal to the convex hull of the incidence vectors of all spanning arborescences rooted at r. Prove that every 2k-edge-connected graph contains k pairwise edge-disjoint spanning trees. Let G be a digraph and r 2 V .G/. Prove that G is the disjoint union of k spanning arborescences rooted at r if and only if the underlying undirected graph is the disjoint union of k spanning trees and jı .x/j D k for all x 2 V .G/ n frg. (Edmonds) Let G be a digraph and r 2 V .G/. Suppose that G contains k edge-disjoint paths from r to every other vertex, but removing any edge destroys this property. Prove that every vertex of G except r has exactly k entering edges. Hint: Use Theorem 6.18. Prove the statement of Exercise 26 without using Theorem 6.18. Formulate and prove a vertex-disjoint version. Hint: If a vertex v has more than k entering edges, take k edge-disjoint rv-paths. Show that an edge entering v that is not used by these paths can be deleted. Give a polynomial-time algorithm for finding a maximum set of edge-disjoint spanning arborescences (rooted at r) in a digraph G. Note: The most efficient algorithm is due to Gabow [1995]; see also (Gabow and Manu [1998]). Prove that the edges of a digraph G can be covered by k branchings if and only if the following two conditions hold: (a) jı .v/j k for all v 2 V .G/; (b) jE.GŒX /j k.jX j 1/ for all X V .G/. Hint: Use Theorem 6.18. (Frank [1979])

References

153

References General Literature: Ahuja, R.K., Magnanti, T.L., and Orlin, J.B. [1993]: Network Flows. Prentice-Hall, Englewood Cliffs 1993, Chapter 13 Balakrishnan, V.K. [1995]: Network Optimization. Chapman and Hall, London 1995, Chapter 1 Cormen, T.H., Leiserson, C.E., Rivest, R.L., and Stein, C. [2001]: Introduction to Algorithms. Second Edition. MIT Press, Cambridge 2001, Chapter 23 Gondran, M., and Minoux, M. [1984]: Graphs and Algorithms. Wiley, Chichester 1984, Chapter 4 Magnanti, T.L., and Wolsey, L.A. [1995]: Optimal trees. In: Handbooks in Operations Research and Management Science; Volume 7: Network Models (M.O. Ball, T.L. Magnanti, C.L. Monma, G.L. Nemhauser, eds.), Elsevier, Amsterdam 1995, pp. 503–616 Schrijver, A. [2003]: Combinatorial Optimization: Polyhedra and Efficiency. Springer, Berlin 2003, Chapters 50–53 Tarjan, R.E. [1983]: Data Structures and Network Algorithms. SIAM, Philadelphia 1983, Chapter 6 Wu, B.Y., and Chao, K.-M. [2004]: Spanning Trees and Optimization Problems. Chapman & Hall/CRC, Boca Raton 2004

Cited References: Bock, F.C. [1971]: An algorithm to construct a minimum directed spanning tree in a directed network. In: Avi-Itzhak, B. (Ed.): Developments in Operations Research, Volume I. Gordon and Breach, New York 1971, pp. 29–44 Boruvka, O. [1926a]: O jistém problému minimálním. Práca Moravské P˘rírodov˘edecké Spolne˘cnosti 3 (1926), 37–58 [in Czech] Boruvka, O. [1926b]: P˘ríspev˘ek k ˘re˘sení otázky ekonomické stavby. Elektrovodních sítí. Elektrotechnicky Obzor 15 (1926), 153–154 [in Czech] Cayley, A. [1889]: A theorem on trees. Quarterly Journal on Mathematics 23 (1889), 376–378 Chazelle, B. [2000]: A minimum spanning tree algorithm with inverse-Ackermann type complexity. Journal of the ACM 47 (2000), 1028–1047 Cheriton, D., and Tarjan, R.E. [1976]: Finding minimum spanning trees. SIAM Journal on Computing 5 (1976), 724–742 Chu, Y., and Liu, T. [1965]: On the shortest arborescence of a directed graph. Scientia Sinica 4 (1965), 1396–1400; Mathematical Review 33, # 1245 Conforti, M., Cornuéjols, G., and Zambelli, G. [2010]: Extended formulations in combinatorial optimization. 4OR 8 (2010), 1–48 Diestel, R. [1997]: Graph Theory. Springer, New York 1997 Dijkstra, E.W. [1959]: A note on two problems in connexion with graphs. Numerische Mathematik 1 (1959), 269–271 Dixon, B., Rauch, M., and Tarjan, R.E. [1992]: Verification and sensitivity analysis of minimum spanning trees in linear time. SIAM Journal on Computing 21 (1992), 1184–1192 Edmonds, J. [1967]: Optimum branchings. Journal of Research of the National Bureau of Standards B 71 (1967), 233–240

154

6 Spanning Trees and Arborescences

Edmonds, J. [1970]: Submodular functions, matroids and certain polyhedra. In: Combinatorial Structures and Their Applications; Proceedings of the Calgary International Conference on Combinatorial Structures and Their Applications 1969 (R. Guy, H. Hanani, N. Sauer, J. Schönheim, eds.), Gordon and Breach, New York 1970, pp. 69–87 Edmonds, J. [1973]: Edge-disjoint branchings. In: Combinatorial Algorithms (R. Rustin, ed.), Algorithmic Press, New York 1973, pp. 91–96 Fortune, S. [1987]: A sweepline algorithm for Voronoi diagrams. Algorithmica 2 (1987), 153–174 Frank, A. [1981]: On disjoint trees and arborescences. In: Algebraic Methods in Graph Theory; Colloquia Mathematica Societatis János Bolyai 25 (L. Lovász, V.T. Sós, eds.), North-Holland, Amsterdam 1981, pp. 159–169 Frank, A. [1979]: Covering branchings. Acta Scientiarum Mathematicarum (Szeged) 41 (1979), 77–82 Fredman, M.L., and Tarjan, R.E. [1987]: Fibonacci heaps and their uses in improved network optimization problems. Journal of the ACM 34 (1987), 596–615 Fredman, M.L., and Willard, D.E. [1994]: Trans-dichotomous algorithms for minimum spanning trees and shortest paths. Journal of Computer and System Sciences 48 (1994), 533–551 Fujishige, S. [2010]: A note on disjoint arborescences. Combinatorica 30 (2010), 247–252 Fulkerson, D.R. [1974]: Packing rooted directed cuts in a weighted directed graph. Mathematical Programming 6 (1974), 1–13 Gabow, H.N. [1995]: A matroid approach to finding edge connectivity and packing arborescences. Journal of Computer and System Sciences 50 (1995), 259–273 Gabow, H.N., Galil, Z., and Spencer, T. [1989]: Efficient implementation of graph algorithms using contraction. Journal of the ACM 36 (1989), 540–572 Gabow, H.N., Galil, Z., Spencer, T., and Tarjan, R.E. [1986]: Efficient algorithms for finding minimum spanning trees in undirected and directed graphs. Combinatorica 6 (1986), 109–122 Gabow, H.N., and Manu, K.S. [1998]: Packing algorithms for arborescences (and spanning trees) in capacitated graphs. Mathematical Programming B 82 (1998), 83–109 Jarník, V. [1930]: O jistém problému minimálním. Práca Moravské P˘rírodov˘edecké Spole˘cnosti 6 (1930), 57–63 Karger, D., Klein, P.N., and Tarjan, R.E. [1995]: A randomized linear-time algorithm to find minimum spanning trees. Journal of the ACM 42 (1995), 321–328 Karp, R.M. [1972]: A simple derivation of Edmonds’ algorithm for optimum branchings. Networks 1 (1972), 265–272 King, V. [1997]: A simpler minimum spanning tree verification algorithm. Algorithmica 18 (1997), 263–270 Knuth, D.E. [1992]: Axioms and hulls; LNCS 606. Springer, Berlin 1992 Korte, B., and Nešetˇril, J. [2001]: Vojt˘ech Jarník’s work in combinatorial optimization. Discrete Mathematics 235 (2001), 1–17 Kruskal, J.B. [1956]: On the shortest spanning subtree of a graph and the travelling salesman problem. Proceedings of the AMS 7 (1956), 48–50 Lovász, L. [1976]: On two minimax theorems in graph. Journal of Combinatorial Theory B 21 (1976), 96–103 Nash-Williams, C.S.J.A. [1961]: Edge-disjoint spanning trees of finite graphs. Journal of the London Mathematical Society 36 (1961), 445–450 Nash-Williams, C.S.J.A. [1964]: Decompositions of finite graphs into forests. Journal of the London Mathematical Society 39 (1964), 12

References

155

Nešetˇril, J., Milková, E., and Nešetˇrilová, H. [2001]: Otakar Boruvka on minimum spanning tree problem. Translation of both the 1926 papers, comments, history. Discrete Mathematics 233 (2001), 3–36 Pettie, S., and Ramachandran, V. [2002]: An optimal minimum spanning tree algorithm. Journal of the ACM 49 (2002), 16–34 Prim, R.C. [1957]: Shortest connection networks and some generalizations. Bell System Technical Journal 36 (1957), 1389–1401 Prüfer, H. [1918]: Neuer Beweis eines Satzes über Permutationen. Arch. Math. Phys. 27 (1918), 742–744 Shamos, M.I., and Hoey, D. [1975]: Closest-point problems. Proceedings of the 16th Annual IEEE Symposium on Foundations of Computer Science (1975), 151–162 Sylvester, J.J. [1857]: On the change of systems of independent variables. Quarterly Journal of Mathematics 1 (1857), 42–56 Tarjan, R.E. [1975]: Efficiency of a good but not linear set union algorithm. Journal of the ACM 22 (1975), 215–225 Tutte, W.T. [1961]: On the problem of decomposing a graph into n connected factor. Journal of the London Mathematical Society 36 (1961), 221–230 Zhou, H., Shenoy, N., and Nicholls, W. [2002]: Efficient minimum spanning tree construction without Delaunay triangulation. Information Processing Letters 81 (2002), 271–276

•

7 Shortest Paths

One of the best-known combinatorial optimization problems is to find a shortest path between two specified vertices of a directed or undirected graph:

SHORTEST PATH PROBLEM Instance: Task:

A graph G (directed or undirected), weights c W E.G/ ! R and two vertices s; t 2 V .G/. Find a shortest s-t-path P , i.e. one of minimum weight c.E.P //, or decide that t is not reachable from s.

Obviously this problem has many practical applications. Like the MINIMUM SPANNING TREE PROBLEM it also often appears as a subproblem when one deals with more difficult combinatorial optimization problems. In fact, the problem is not easy to solve if we allow arbitrary weights. For example, if all weights are 1 then the s-t-paths of weight 1 jV .G/j are precisely the Hamiltonian s-t-paths. Deciding whether such a path exists is a difficult problem (see Exercise 17(b) of Chapter 15). The problem becomes much easier if we restrict ourselves to nonnegative weights or at least exclude negative circuits: Definition 7.1. Let G be a (directed or undirected) graph with weights cWE.G/ ! R. c is called conservative if there is no circuit of negative total weight. We shall present algorithms for the SHORTEST PATH PROBLEM in digraphs in Section 7.1. The first one allows nonnegative weights only while the second algorithm can deal with arbitrary conservative weights. The algorithms of Section 7.1 in fact compute a shortest s-v-path for all v 2 V .G/ without using significantly more running time. Sometimes one is interested in the distance for every pair of vertices; Section 7.2 shows how to deal with this problem. Since negative circuits cause problems we also show how to detect them. If none exists, a circuit of minimum total weight can be computed quite easily. Another interesting problem asks for a circuit whose mean weight is minimum. As we shall see in Section 7.3, the directed version of this problem can also be solved efficiently by similar techniques. Finding shortest paths in undirected graphs is more difficult unless the edge weights are nonnegative. Undirected edges of nonnegative weights can be replaced B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__7, c Springer-Verlag Berlin Heidelberg 2012

157

158

7 Shortest Paths

equivalently by a pair of oppositely directed edges of the same weight; this reduces the undirected problem to a directed one. However, this construction does not work for edges of negative weight since it would introduce negative circuits. We shall return to the problem of finding shortest paths in undirected graphs with conservative weights in Section 12.2 (Corollary 12.13). Henceforth we work with a digraph G. Without loss of generality we may assume that G is connected and simple; among parallel edges we have to consider only the one with least weight.

7.1 Shortest Paths From One Source All shortest path algorithms we present are based on the following observation, sometimes called Bellman’s principle of optimality, which is indeed the core of dynamic programming: Proposition 7.2. Let G be a digraph with conservative weights c W E.G/ ! R, let k 2 N, and let s and w be two vertices. Let P be a shortest one among all s-w-paths with at most k edges, and let e D .v; w/ be its final edge. Then PŒs;v (i.e. P without the edge e) is a shortest one among all s-v-paths with at most k 1 edges. Proof: Suppose Q is a shorter s-v-path than PŒs;v , and jE.Q/j k 1. Then c.E.Q// C c.e/ < c.E.P //. If Q does not contain w, then Q C e is a shorter s-w-path than P , otherwise QŒs;w has length c.E.QŒs;w// D c.E.Q// C c.e/ c.E.QŒw;v C e// < c.E.P // c.E.QŒw;v C e// c.E.P //, because QŒw;v C e is a circuit and c is conservative. In both cases we have a contradiction to the assumption that P is a shortest s-w-path with at most k edges. The same result holds for undirected graphs with nonnegative weights and also for acyclic digraphs with arbitrary weights. It yields the recursion formulas dist.s; s/ D 0 and dist.s; w/ D minfdist.s; v/ C c..v; w// W .v; w/ 2 E.G/g for w 2 V .G/nfsg which immediately solve the SHORTEST PATH PROBLEM for acyclic digraphs (Exercise 7). Proposition 7.2 is also the reason why most algorithms compute the shortest paths from s to all other vertices. If one computes a shortest s-t-path P , one has already computed a shortest s-v-path for each vertex v on P . Since we cannot know in advance which vertices belong to P , it is only natural to compute shortest s-vpaths for all v. We can store these s-v-paths very efficiently by just storing the final edge of each path. We first consider nonnegative edge weights, i.e. c W E.G/ ! RC . The SHORTEST PATH PROBLEM can be solved by BFS if all weights are 1 (Proposition 2.18). For weights c W E.G/ ! N one could replace an edge e by a path of length c.e/ and again use BFS. However, this might introduce an exponential number P of edges; recall that the input size is ‚ n log m C m log n C e2E.G/ log c.e/ , where n D jV .G/j and m D jE.G/j.

7.1

Shortest Paths From One Source

159

A much better idea is to use the following algorithm, due to Dijkstra [1959]. It is quite similar to PRIM’S ALGORITHM for the MINIMUM SPANNING TREE PROBLEM (Section 6.1).

DIJKSTRA’S ALGORITHM Input:

A digraph G, weights c W E.G/ ! RC and a vertex s 2 V .G/.

Output:

Shortest paths from s to all v 2 V .G/ and their lengths. More precisely, we get the outputs l.v/ and p.v/ for all v 2 V .G/nfsg. l.v/ is the length of a shortest s-v-path, which consists of a shortest sp.v/-path together with the edge .p.v/; v/. If v is not reachable from s, then l.v/ D 1 and p.v/ is undefined.

2

Set l.s/ WD 0. Set l.v/ WD 1 for all v 2 V .G/ n fsg. Set R WD ;. Find a vertex v 2 V .G/ n R such that l.v/ D min

3

Set R WD R [ fvg.

4

For all w 2 V .G/ n R such that .v; w/ 2 E.G/ do: If l.w/ > l.v/ C c..v; w// then set l.w/ WD l.v/ C c..v; w// and p.w/ WD v. If R 6D V .G/ then go to . 2

1

5

w2V .G/nR

l.w/.

Theorem 7.3. (Dijkstra [1959]) DIJKSTRA’S ALGORITHM works correctly. Proof: We prove that the following statements hold at any stage of the algorithm: (a) For each v 2 V .G/ n fsg with l.v/ < 1 we have p.v/ 2 R, l.p.v// C c..p.v/; v// D l.v/, and the sequence v; p.v/; p.p.v//; : : : contains s. (b) For all v 2 R: l.v/ D dist.G;c/ .s; v/. The statements trivially hold after . 1 l.w/ is decreased to l.v/ C c..v; w// and p.w/ is set to v in 4 only if v 2 R and w … R. As the sequence v; p.v/; p.p.v//; : : : contains s but no vertex outside R, in particular not w, (a) is preserved by . 4 (b) is trivial for v D s. Suppose that v 2 V .G/ n fsg is added to R in , 3 and there is an s-v-path P in G that is shorter than l.v/. Let y be the first vertex on P that belongs to .V .G/ n R/ [ fvg, and let x be the predecessor of y on P . Since x 2 R, we have by 4 and the induction hypothesis: l.y/ l.x/ C c..x; y// D dist.G;c/ .s; x/ C c..x; y// c.E.PŒs;y // c.E.P // < l.v/; contradicting the choice of v in . 2

The running time is obviously O.n2 /. Using a Fibonacci heap we can do better:

160

7 Shortest Paths

Theorem 7.4. (Fredman and Tarjan [1987]) DIJKSTRA’S ALGORITHM implemented with a Fibonacci heap runs in O.m C n log n/ time, where n D jV .G/j and m D jE.G/j. Proof: We apply Theorem 6.7 to maintain the set f.v; l.v// W v 2 V .G/ n R; l.v/ < 1g. Then 2 and 3 are one DELETEMIN-operation, while the update of l.w/ in 4 is an INSERT -operation if l.w/ was infinite and a DECREASEKEYoperation otherwise. This is the best known strongly polynomial running time for the SHORTEST PATH PROBLEM with nonnegative weights. (On different computational models, Fredman and Willard [1994], Thorup [2000] and Raman [1997] achieved slightly better running times.) If the weights are integers within a fixed range there is a simple linear-time algorithm (Exercise running times of O.m log log cmax / (Johnson [1982]) p3). In general, and O m C n log cmax (Ahuja et al. [1990]) are possible for weights c W E.G/ ! f0; : : : ; cmax g. This has been improved by Thorup [2004] to O.m C n log log cmax / and O.m C n log log n/, but even the latter bound applies to integral edge weights only, and the algorithm is not strongly polynomial. For general nonnegative weights, Orlin et al. [2010] described an O.m log.2 C nk=m//-time algorithm, where k is the number of distinct edge weights. For planar digraphs there is a linear-time algorithm due to Henzinger et al. [1997]. Finally we mention that Thorup [1999] found a linear-time algorithm for finding a shortest path in an undirected graph with nonnegative integral weights. See also Pettie and Ramachandran [2005]; this paper also contains more references. We now turn to an algorithm for general conservative weights:

MOORE-BELLMAN-FORD ALGORITHM Input:

A digraph G, weights c W E.G/ ! R, and a vertex s 2 V .G/.

Output:

A negative circuit C in G, or shortest paths from s to all v 2 V .G/ and their lengths. More precisely, in the second case we get the outputs l.v/ and p.v/ for all v 2 V .G/ n fsg. l.v/ is the length of a shortest s-v-path, which consists of a shortest s-p.v/-path together with the edge .p.v/; v/. If v is not reachable from s, then l.v/ D 1 and p.v/ is undefined.

1

Set l.s/ WD 0 and l.v/ WD 1 for all v 2 V .G/ n fsg. Let n WD jV .G/j.

2

For i WD 1 to n 1 do: For each edge .v; w/ 2 E.G/ do: If l.w/ > l.v/ C c..v; w// then set l.w/ WD l.v/ C c..v; w// and p.w/ WD v. If there is an edge .v; w/ 2 E.G/ with l.w/ > l.v/ C c..v; w// then set xn WD w, xn1 WD v, and xni 1 WD p.xni / for i D 1; : : : ; n 1, and output any circuit C in .V .G/; f.xi 1 ; xi / W i D 1; : : : ; ng/.

3

7.1

Shortest Paths From One Source

161

Theorem 7.5. (Moore [1959], Bellman [1958], Ford [1956]) The MOORE-BELLMAN -FORD A LGORITHM works correctly. Its running time is O.nm/. Proof: The O.nm/ running time is obvious. At any stage of the algorithm, for v 2 V .G/, let k.v/ be the iteration in which l.v/ was decreased to its present value, and k.v/ WD 0 if l.v/ has not been changed after . 1 Let F WD f.p.y/; y/ W y 2 V .G/; k.y/ > 0g, and F 0 WD f.v; w/ 2 E.G/ W l.w/ > l.v/Cc..v; w//g. We claim that the following statements always hold: (a) l.y/ l.x/ C c..x; y// and k.x/ k.y/ 1 for all .x; y/ 2 F ; (b) If F [ F 0 contains a circuit C , then C has negative total weight. To prove (a), observe that l.y/ D l.x/ C c..x; y// and k.x/ k.y/ 1 when p.y/ is set to x, and l.x/ is never increased, and k.x/ is never decreased. 0 P a circuit C in .V .G/; F [ F /. By (a) we have P To prove (b), consider .v;w/2E.C / c..v; w// D .v;w/2E.C / .c..v; w// C l.v/ l.w// 0. This proves (b) except in the case that E.C / F . If at some stage a circuit C in .V .G/; F / is created by setting p.y/ WD x, then we had just before the insertion .x; y/ 2 F 0 , and hence C is a negative circuit. If the algorithm finds an edge .v; w/ 2 F 0 in , 3 then k.v/ D n 1, and thus k.xi / i for i D n 2; : : : ; 1. Hence the sequence x0 ; : : : ; xn is well-defined, and it must contain a repetition. Hence 3 indeed finds a circuit C , which has negative total weight due to (b). If theP algorithm ends with l.w/ P l.v/ C c..v; w// for all .v; w/ 2 E.G/, then we have .v;w/2E.C / c..v; w// D .v;w/2E.C / .c..v; w// C l.v/ l.w// 0 for every circuit C in GŒR, where R WD fv 2 V .G/ W l.v/ < 1g. Hence GŒR contains no negative circuit. Then (b) implies that .R; F / is acyclic. Moreover, x 2 R n fsg implies p.x/ 2 R, so .R; F / is an arborescence rooted at s. By (a), l.x/ is at least the length of the s-x-path in .R; F / for any x 2 R (at any stage of the algorithm). We claim that after k iterations of the algorithm, l.x/ is at most the length of a shortest s-x-path with at most k edges. This statement is easily proved by induction: Let P be a shortest s-x-path with at most k edges and let .w; x/ be the last edge of P . Then, by applying Proposition 7.2 to GŒR, PŒs;w must be a shortest s-wpath with at most k 1 edges, and by the induction hypothesis we have l.w/ c.E.PŒs;w // after k 1 iterations. But in the k-th iteration edge .w; x/ is also examined, after which l.x/ l.w/ C c..w; x// c.E.P //. Since no path has more than n1 edges, the above claim implies the correctness of the algorithm. Note that if c is conservative, .R; F / is an arborescence containing a shortest path from s to each vertex that is reachable from s. This is sometimes called a shortest paths tree. This algorithm is still the fastest known strongly polynomial-time algorithm for the SHORTEST PATH PROBLEM in digraphs with conservative p weights. A scaling algorithm due to Goldberg [1995] has a running time of O nm log.jcmin j C 2/

162

7 Shortest Paths

if the edge weights are integral and at least cmin . For planar digraphs, Mozes and Wulff-Nilsen [2010] described an O.n log2 n= log log n/-time algorithm. If G contains negative circuits, no polynomial-time algorithm for the SHORTEST PATH PROBLEM is known (the problem becomes NP-hard; see Exercise 17(b) of Chapter 15). The main difficulty is that Proposition 7.2 does not hold for general weights. It is not clear how to construct a path instead of an arbitrary edge progression. If there are no negative circuits, any shortest edge progression is a path, plus possibly some circuits of zero weight that can be deleted. In view of this it is also an important question how to prove that there are no negative circuits. The following concept due to Edmonds and Karp [1972] is useful: Definition 7.6. Let G be a digraph with weights c W E.G/ ! R, and let W V .G/ ! R. Then for any .x; y/ 2 E.G/ we define the reduced cost of .x; y/ with respect to by c ..x; y// WD c..x; y// C .x/ .y/. If c .e/ 0 for all e 2 E.G/, is called a feasible potential. Theorem 7.7. Let G be a digraph with weights c W E.G/ ! R. There exists a feasible potential of .G; c/ if and only if c is conservative. Given a digraph G with weights c W E.G/ ! R, we can find in O.nm/ time either a feasible potential or a negative circuit. Proof: If is a feasible potential, we have for each circuit C : X X 0 c .e/ D .c.e/ C .x/ .y// D e2E.C /

eD.x;y/2E.C /

X

c.e/

e2E.C /

(the potentials cancel). So c is conservative. To find either a negative circuit or a feasible potential, we add a new vertex s and edges .s; v/ of zero cost for all v 2 V .G/. Then we run the MOORE-BELLMANFORD ALGORITHM. The output is either a negative circuit (which of course cannot contain s) or numbers l.v/ < 1 for all v 2 V .G/ constituting a feasible potential. This can be regarded as a special form of LP duality; see Exercise 9. In practice there are more efficient methods to detect negative circuits; see Cherkassky and Goldberg [1999].

7.2 Shortest Paths Between All Pairs of Vertices Suppose we now want to find a shortest s-t-path for all ordered pairs of vertices .s; t/ in a digraph:

ALL PAIRS SHORTEST PATHS PROBLEM Instance:

A digraph G and conservative weights c W E.G/ ! R.

Task:

Find numbers lst and vertices pst for all s; t 2 V .G/ with s 6D t, such that lst is the length of a shortest s-t-path, and .pst ; t/ is the final edge of such a path (if it exists).

7.2

Shortest Paths Between All Pairs of Vertices

163

Of course we could run the MOORE-BELLMAN-FORD ALGORITHM n times, once for each choice of s. This immediately gives us an O.n2 m/-algorithm. However, one can do better, as was observed by Bazaraa and Langley [1974] and Johnson [1977]: Theorem 7.8. The ALL PAIRS SHORTEST PATHS PROBLEM can be solved in O.mn C n2 log n/ time, where n D jV .G/j and m D jE.G/j. Proof: Let .G; c/ be an instance. First we compute a feasible potential , which is possible in O.nm/ time by Corollary 7.7. Then for each s 2 V .G/ we do a single-source shortest path computation from s using the reduced costs c instead of c. For any vertex t the resulting s-t-path is also a shortest path with respect to c, because the length of any s-t-path changes by .s/ .t/, a constant. Since the reduced costs are nonnegative, we can use DIJKSTRA’S ALGORITHM each time. So, by Theorem 7.4, the total running time is O.mn C n.m C n log n//. The same idea will be used again in Chapter 9 (in the proof of Theorem 9.13). Pettie [2004] showed how to improve the running time to O.mn C n2 log log n/; this is the best known time bound. For dense graphs with nonnegative weights, Chan’s [2010] bound of O.n3 log3 log n= log2 n/ is slightly better. If all edge weights are small positive integers, this can be improved using fast matrix multiplication; see e.g. Zwick [2002]. The solution of the ALL PAIRS SHORTEST PATHS PROBLEM also enables us to compute the metric closure: Definition 7.9. Given a graph G (directed or undirected) with conservative N c/, weights c W E.G/ ! R. The metric closure of .G; c/ is the pair .G; N where N G is the simple graph on V .G/ that, for x; y 2 V .G/ with x 6D y, contains an edge e D fx; yg (or e D .x; y/ if G is directed) with weight c.e/ N D dist.G;c/ .x; y/ if and only if y is reachable from x in G. Corollary 7.10. Let G be a digraph with conservative weights c W E.G/ ! R, or an undirected graph with nonnegative weights c W E.G/ ! RC . Then the metric closure of .G; c/ can be computed in O.mn C n2 log n/ time. Proof: If G is undirected, we replace each edge by a pair of oppositely directed edges. Then we solve the resulting instance of the ALL PAIRS SHORTEST PATHS PROBLEM. The rest of the section is devoted to the FLOYD-WARSHALL ALGORITHM, another O.n3 /-algorithm for the ALL PAIRS SHORTEST PATHS PROBLEM. The main advantage of the FLOYD-WARSHALL ALGORITHM is its simplicity. We assume w.l.o.g. that the vertices are numbered 1; : : : ; n.

164

7 Shortest Paths

FLOYD-WARSHALL ALGORITHM Input: Output:

A digraph G with V .G/ D f1; : : : ; ng and conservative weights c W E.G/ ! R. Matrices .lij /1i;j n and .pij /1i;j n where lij is the length of a shortest path from i to j , and .pij ; j / is the final edge of such a path (if it exists).

1

Set lij WD c..i; j // for all .i; j / 2 E.G/. Set lij WD 1 for all .i; j / 2 .V .G/ V .G// n E.G/ with i 6D j . Set li i WD 0 for all i . Set pij WD i for all i; j 2 V .G/.

2

For j WD 1 to n do: For i WD 1 to n do: If i 6D j then: For k WD 1 to n do: If k 6D j then: If li k > lij C ljk then set li k WD lij C ljk and pi k WD pjk .

Theorem 7.11. (Floyd [1962], Warshall [1962]) The FLOYD-WARSHALL ALGORITHM works correctly. Its running time is O.n3 /. Proof: The running time is obvious. Claim: After the algorithm has run through the outer loop for j D 1; 2; : : : ; j0 , the variable li k contains the length of a shortest i -k-path with intermediate vertices v 2 f1; : : : ; j0 g only (for all i and k), and .pi k ; k/ is the final edge of such a path. This statement will be shown by induction for j0 D 0; : : : ; n. For j0 D 0 it is true by , 1 and for j0 D n it implies the correctness of the algorithm. Suppose the claim holds for some j0 2 f0; : : : ; n 1g. We have to show that it still holds for j0 C 1. For any i and k, during processing the outer loop for j D j0 C 1, li k (containing by the induction hypothesis the length of a shortest i -k-path with intermediate vertices v 2 f1; : : : ; j0 g only) is replaced by li;j0 C1 C lj0 C1;k if this value is smaller. It remains to show that the corresponding i -.j0 C 1/-path P and the .j0 C 1/-k-path Q have no inner vertex in common. Suppose that there is an inner vertex belonging to both P and Q. By shortcutting a maximal closed walk in P C Q (which by our assumption has nonnegative weight because it is the union of circuits) we get an i -k-path R with intermediate vertices v 2 f1; : : : ; j0 g only. R is no longer than li;j0 C1 C lj0 C1;k (and in particular shorter than the li k before processing the outer loop for j D j0 C 1/. This contradicts the induction hypothesis since R has intermediate vertices v 2 f1; : : : ; j0 g only. Like the MOORE-BELLMAN-FORD ALGORITHM, the FLOYD-WARSHALL ALGORITHM can also be used to detect the existence of negative circuits (see Exercise 13 and Hougardy [2010]). The ALL PAIRS SHORTEST PATHS PROBLEM in undirected graphs with arbitrary conservative weights is more difficult; see Theorem 12.14.

7.3

Minimum Mean Cycles

165

7.3 Minimum Mean Cycles We can easily find a circuit of minimum total weight in a digraph with conservative weights, using the above shortest path algorithms (see Exercise 14). Another problem asks for a circuit whose mean weight is minimum:

DIRECTED MINIMUM MEAN CYCLE PROBLEM Instance:

A digraph G, weights c W E.G/ ! R.

Task:

Find a circuit C whose mean weight that G is acyclic.

c.E.C // jE.C /j

is minimum, or decide

In this section we show how to solve this problem with dynamic programming, quite similar to the shortest path algorithms. We could assume that G is strongly connected, since otherwise we can identify the strongly connected components in linear time (Theorem 2.19) and solve the problem for each strongly connected component separately. But for the following min-max theorem it suffices to assume that there is a vertex s from which all vertices are reachable. We consider not only paths, but arbitrary edge progressions (where vertices and edges may be repeated). Theorem 7.12. (Karp [1978]) Let G be a digraph with weights c W E.G/ ! R. Let s 2 V .G/ such that each vertex is reachable from s. For x 2 V .G/ and k 2 ZC let ( k ) X c..vi 1 ; vi // W v0 D s; vk D x; .vi 1 ; vi / 2 E.G/ for all i Fk .x/ WD min i D1

be the minimum weight of an edge progression of length k from s to x (and 1 if there is none). Let .G; c/ be the minimum mean weight of a circuit in G (and .G; c/ D 1 if G is acyclic). Then .G; c/ D

min

max

x2V .G/ 0kn1 Fk .x/ 1 do: For e D .p; vi / 2 ıG .vi / with p 2 fv1 ; : : : ; vi 1 g do: f 0 Set ˇ WD minfˇ.vi /; uf .e/g. Augment f along e by ˇ 0 . Set ˇ.vi / WD ˇ.vi / ˇ 0 and ˇ.p/ WD ˇ.p/ C ˇ 0 . Set i WD i 1. Go to . 2

6

7

Theorem 8.22. FUJISHIGE’S ALGORITHM correctly solves the MAXIMUM FLOW PROBLEM for simple digraphs G and integral capacities u W E.G/ ! ZC in O.mn log umax / time, where n WD jV .G/j, m WD jE.G/j and umax WD maxfu.e/ W e 2 E.G/g. Proof: Let us call an iteration a sequence of steps ending with 4 or . 7 In – 2 , 5 v1 ; : : : ; vi is always an order of a subset of vertices such that b.vj /

186

8 Network Flows

D uf .E C .fv1 ; : : : ; vj 1 g; fvjP g// ˛ for j D 2; : : : ; i . In 6 the flow f is augmented with the invariant v2V .G/ ˇ.v/ D ˛, and by the above the result is an s-t-flow whose value is ˛ units larger. Thus after at most n 1 iterations, ˛ will be decreased for the first time. When C we decrease ˛ to ˛ 0 D b ˛2 c ˛3 in , .fv1 ; : : : ; vi g/ in Gf 4 we have an s-t-cut ıG f C of capacity less than ˛.jV .G/ji / because b.v/ D uf .E .fv1 ; : : : ; vi g; fvg// < ˛ for all v 2 V .G/ n fv1 ; : : : ; vi g. By Lemma 8.3(b), a maximum s-t-flow in Gf has value less than ˛.n i / < 3˛ 0 n. Hence after less than 3n iterations, ˛ will be decreased again. If ˛ is decreased from 1 to 0, we have an s-t-cut of capacity 0 in Gf , so f is maximum. As ˛ is decreased at most 1 C log umax times before it reaches 0, and each iteration takes O.m/ time, the overall running time is O.mn log umax /. Such a scaling technique is useful in many contexts and will reappear in Chapter 9. Fujishige [2003] also described a variant of his algorithm without scaling, where vi in 5 is chosen as a vertex attaining maxfb.v/ W v 2 V .G/ n fv1 ; : : : ; vi 1 gg. The resulting order is called MA order and will reappear in Section 8.7. The running time of this variant is slightly higher than the above and not strongly polynomial either (Shioura [2004]). See Exercise 24.

8.5 The Goldberg-Tarjan Algorithm In this section we shall describe the PUSH-Rp ELABEL A LGORITHM due to Goldberg and Tarjan [1988]. We shall derive an O.n2 m/ bound for the running time. Sophisticated implementations using dynamic trees (seeSleator and Tarjan 2 [1983]) result in network flow algorithms with running time O nm log nm (Gold np berg and Tarjan [1988]) and O nm log m log umax C 2 , where umax is the maximum (integral) edge capacity (Ahuja, Orlin and Tarjan [1989]). The best known bounds today are O nm log2Cm=.n log n/ n (King, Rao and Tarjan [1994]) and 2 n O minfm1=2 ; n2=3 gm log log umax m (Goldberg and Rao [1998]). By definition and Theorem 8.5, a flow f is a maximum s-t-flow if and only if the following conditions hold: exf .v/ D 0 for all v 2 V .G/ n fs; tg; There is no f -augmenting path. In the algorithms discussed so far, the first condition is always satisfied, and the algorithms stop when the second condition is satisfied. The PUSH-RELABEL ALGORITHM starts with an f satisfying the second condition and maintains it throughout. Naturally it stops when the first condition is satisfied as well. So f will not be an

8.5

The Goldberg-Tarjan Algorithm

187

s-t-flow during the algorithm (except at termination), but an s-t-preflow (cf. Definition 8.19). Definition 8.23. Let .G; u; s; t/ be a network and f an s-t-preflow. A distance labeling is a function W V .G/ ! ZC such that .t/ D 0, .s/ D n WD jV .G/j $

and .v/ .w/ C 1 for all .v; w/ 2 E.Gf /. An edge e D .v; w/ 2 E.G/ is called admissible if e 2 E.Gf / and .v/ D .w/ C 1. If is a distance labeling, .v/ (for v ¤ s) must be a lower bound on the distance to t (number of edges in a shortest v-t-path) in Gf . The PUSH-RELABEL ALGORITHM to be described below always works with an s-t-preflow f and a distance labeling . It starts with the preflow that is equal to the capacity on each edge leaving s and zero on all other edges. The initial distance labeling is .s/ D n and .v/ D 0 for all v 2 V .G/ n fsg. Then the algorithm performs the update operations P USH (updating f ) and RELABEL (updating ) in any order.

PUSH-RELABEL ALGORITHM Input:

A network .G; u; s; t/.

Output:

A maximum s-t-flow f .

1 2 3

Set f .e/ WD u.e/ for each e 2 ı C .s/. Set f .e/ WD 0 for each e 2 E.G/ n ı C .s/. Set .s/ WD n WD jV .G/j and .v/ WD 0 for all v 2 V .G/ n fsg. While there exists an active vertex do: Let v be an active vertex. C If no e 2 ıG .v/ is admissible f then RELABEL(v), C else let e 2 ıG .v/ be an admissible edge and PUSH(e). f

PUSH(e) 1

Set WD minfexf .v/; uf .e/g, where v is the tail of e.

2

Augment f along e by .

RELABEL(v) 1

Set

C .v/g. .v/ WD minf .w/ C 1 W .v; w/ 2 ıG f

Proposition 8.24. During the execution of the PUSH-RELABEL ALGORITHM f is always an s-t-preflow and is always a distance labeling with respect to f . For each v 2 V .G/, .v/ is strictly increased by every RELABEL.v/.

188

8 Network Flows

Proof: We have to show that the procedures PUSH and RELABEL preserve these properties. It is clear that after a PUSH operation, f is still an s-t-preflow. A RELABEL operation does not even change f . If RELABEL.v/ is called and was a distance labeling before, then .v/ is C strictly increased (as no e 2 ıG .v/ was admissible), and remains a distance f labeling. We finally show that after a PUSH operation, is still a distance labeling with respect to the new preflow. We have to check .a/ .b/ C 1 for all new edges .a; b/ in Gf . But if we apply PUSH(e) for some e D .v; w/, the only possible new edge in Gf is the reverse edge of e, and here we have .w/ D .v/ 1, since e is admissible. Lemma 8.25. If f is an s-t-preflow and f , then:

is a distance labeling with respect to

(a) s is reachable from any active vertex v in Gf . (b) If w is reachable from v in Gf for some v; w 2 V .G/, then .v/ (c) t is not reachable from s in Gf .

.w/Cn1.

Proof: (a): Let v be an active vertex, and let R be the set of vertices reachable from v in Gf . Then f .e/ D 0 for all e 2 ıG .R/. So X w2R

exf .w/ D

X

f .e/

e2ıG .R/

X

f .e/ 0:

C e2ıG .R/

But v is active, meaning exf .v/ > 0, and therefore there must exist a vertex w 2 R with exf .w/ < 0. Since f is an s-t-preflow, this vertex must be s. (b): Suppose there is a v-w-path in Gf , say with vertices v D v0 ; v1 ; : : : ; vk D w. Since is a distance labeling with respect to f , .vi / .vi C1 / C 1 for i D 0; : : : ; k 1. So .v/ .w/ C k. Note that k n 1. (c): follows from (b) as .s/ D n and .t/ D 0. Part (c) helps us to prove the following: Theorem 8.26. When the algorithm terminates, f is a maximum s-t-flow. Proof: f is an s-t-flow because there are no active vertices. Lemma 8.25(c) implies that there is no augmenting path. Then by Theorem 8.5 we know that f is maximum. The question now is how many PUSH and RELABEL operations are performed. Lemma 8.27. (a) For each v 2 V .G/, .v/ never decreases, and .v/ 2n 1 at any stage of the algorithm. (b) No The total increase of P vertex is relabelled more than 2n 1 times. 2 .v/ during the algorithm is at most 2n n. v2V .G/

8.5

The Goldberg-Tarjan Algorithm

189

Proof: Recall from Proposition 8.24 that .v/ is strictly increased by every RELABEL.v/. Moreover, we only change .v/ by RELABEL.v/ if v is active. By Lemma 8.25(a) and (b), .v/ .s/ C n 1 D 2n 1. This implies (a) and (b). We shall now analyse the number of PUSH operations. We distinguish between saturating pushes (where uf .e/ D 0 after the push) and nonsaturating pushes. As usual we denote m WD jE.G/j (and n WD jV .G/j). Lemma 8.28. The number of saturating pushes is at most 2mn. Proof: After each saturating push from v to w, another such push cannot occur until .w/ increases by at least 2, a push from w to v occurs, and .v/ increases by at least 2. Together with Lemma 8.27(a), this proves that there are at most n $

saturating pushes on each edge .v; w/ 2 E.G/.

The number of nonsaturating pushes can be in the order of n2 m in general (Exercise 25). By choosing an active vertex v with .v/ maximum in 3 we can prove a better bound. We may assume n m n2 . Lemma 8.29. If we always choose v to be an active vertex with .v/ maximum in PUSH-RELABEL ALGORITHM, the number of nonsaturating pushes is at 3 of thep most 8n2 m. Proof: Call a phase the time between two consecutive changes of WD maxf .v/ W v activeg. As can increase only by relabeling, its total increase is less than 2n2 . As D 0 initially, it decreases less than 2n2 times, and the number of phases is less than 4n2 . p Call a phase cheap if it contains at most m nonsaturating pushes and expensive p otherwise. Clearly there are at most 4n2 m nonsaturating pushes in cheap phases. Let X ˆ WD jfw 2 V .G/ W .w/ .v/gj: v2V .G/Wv active Initially ˆ n2 . A relabeling step may increase ˆ by at most n. A saturating push may increase ˆ by at most n. A nonsaturating push does not increase ˆ. Since ˆ D 0 at termination, the total decrease of ˆ is at most n2 Cn.2n2 n/Cn.2mn/ 4mn2 . Now consider the nonsaturating pushes in an expensive phase. Each of them pushes flow along an edge .v; w/ with .v/ D D .w/ C 1, deactivating v and possibly activating w. As the phase ends by deactivating the last active vertex v with .v/ D or by relabeling, the set of verticesp w with .w/ D remains constant during the phase, and it contains more than m vertices as the phase is expensive. Hence each p nonsaturating push in an expensive phase decreases ˆ by at least m. Thus the total p 2 p number of nonsaturating pushes in expensive phases is at most 4mn D 4n2 m. m

190

8 Network Flows

This proof is due to Cheriyan and Mehlhorn [1999]. We finally get: Theorem 8.30. (Goldberg and Tarjan [1988], Cheriyan and Maheshwari [1989], Tunçel [1994]) The PUSH-RELABEL ALGORITHM solves p the MAXIMUM FLOW PROBLEM correctly and can be implemented to run in O.n2 m/ time. Proof: The correctness follows from Theorem 8.26. As in Lemma 8.29 we always choose v in 3 to be an active vertex with .v/ maximum. To make this easy we keep track of doubly-linked lists L0 ; : : : ; L2n1 , where Li contains the active vertices v with .v/ D i . These lists can be updated during each PUSH and RELABEL operation in constant time. We can then start by scanning Li for i D 0. When a vertex is relabelled, we increase i accordingly. When we find a list Li for the current i empty (after deactivating the last active vertex at that level), we decrease i until Li is nonempty. As we increase i at most 2n2 times by Lemma 8.27(b), we also decrease i at most 2n2 times. As a second data structure, we store a doubly-linked list Av containing the admissible edges leaving v for each vertex v. They can also be updated in each PUSH operation in constant time, and in each RELABEL operation in time proportional to the total number of edges incident to the relabelled vertex. So RELABEL.v/ takes a total of O.jıG .v/j/ time, and by Lemma 8.27(b) the overall time for relabelling is O.mn/. Each PUSH takes constant p time, and by Lemma 8.28 and Lemma 8.29 the total number of pushes is O.n2 m/.

8.6 Gomory-Hu Trees Any algorithm for the MAXIMUM FLOW PROBLEM also implies a solution to the following problem:

MINIMUM CAPACITY CUT PROBLEM Instance:

A network .G; u; s; t/.

Task:

An s-t-cut in G with minimum capacity.

Proposition 8.31. The MINIMUM CAPACITY CUT PROBLEM can be solved in pthe same running time as the MAXIMUM FLOW PROBLEM, in particular in O.n2 m/ time. Proof: For a network .G; u; s; t/ we compute a maximum s-t-flow f and define X to be the set of all vertices reachable from s in Gf . X can be computed with the GRAPH SCANNING ALGORITHM in linear time (Proposition 2.17). By Lemma p8.3 C and Theorem 8.5, ıG .X / constitutes a minimum capacity s-t-cut. The O.n2 m/ running time follows from Theorem 8.30 (and is not best possible). In this section we consider the problem of finding a minimum capacity s-tcut for each pair of vertices s; t in an undirected graph G with capacities u W E.G/!RC .

8.6

Gomory-Hu Trees

191

This problem can be reduced to the above one: For all pairs s; t 2 V .G/ we solve the MINIMUM CAPACITY CUT PROBLEM for .G 0 ; u0 ; s; t/, where .G 0 ; u0 / arises from .G; u/ by replacing each undirected edge fv; wg by two oppositely directed 0 edges .v; w/ and .w; v/ with u0 ..v; w// D u ..w; v// D u.fv; wg/. In this way we obtain minimum s-t-cuts for all s; t after n2 flow computations. This section is devoted to the elegant method of Gomory and Hu [1961], which requires only n 1 flow computations. We shall see some applications in Sections 12.3 and 20.3. Definition 8.32. Let G be an undirected graph and u W E.G/ ! RC a capacity function. For two vertices s; t 2 V .G/ we denote by st their local edgeconnectivity, i.e. the minimum capacity of a cut separating s and t. The edge-connectivity of a graph is obviously the minimum local edgeconnectivity with respect to unit capacities. Lemma 8.33. For all vertices i; j; k 2 V .G/ we have i k minfij ; jk g. Proof: Let ı.A/ be a cut with i 2 A, k 2 V .G/ n A and u.ı.A// D i k . If j 2 A then ı.A/ separates j and k, so u.ı.A// jk . If j 2 V .G/nA then ı.A/ separates i and j , so u.ı.A// ij . We conclude that i k D u.ı.A// minfij ; jk g. Indeed, this condition is not only necessary but also sufficient for numbers .ij /1i;j n with ij D j i to be local edge-connectivities of some graph (Exercise 31). Definition 8.34. Let G be an undirected graph and u W E.G/ ! RC a capacity function. A tree T is called a Gomory-Hu tree for .G; u/ if V .T / D V .G/ and st D

min

e2E.Pst /

u.ıG .Ce // for all s; t 2 V .G/;

where Pst is the (unique) s-t-path in T and, for e 2 E.T /, Ce and V .G/ n Ce are the connected components of T e (i.e. ıG .Ce / is the fundamental cut of e with respect to T ). We shall see that every undirected graph possesses a Gomory-Hu tree. This implies that for any undirected graph G there is a list of n 1 cuts such that for each pair s; t 2 V .G/ a minimum s-t-cut belongs to the list. This is not true for digraphs: for each n 2 N, Jelinek and Mayeda [1963] constructed a digraph G with n vertices and capacities u W E.G/ ! RC such that the set fminfu.ı C .X // W s 2 X V .G/nftgg W s; t 2 V .G/; s 6D tg contains .nC2/.n1/=2 different numbers. In general, a Gomory-Hu tree cannot be chosen as a subgraph of G. For example, consider G D K3;3 and u 1. Here st D 3 for all s; t 2 V .G/. It is easy to see that the Gomory-Hu trees for .G; u/ are exactly the stars with five edges. The main idea of the algorithm for constructing a Gomory-Hu tree is as follows. First we choose any s; t 2 V .G/ and find some minimum s-t-cut, say ı.A/. Let B WD V .G/ n A. Then we contract A (or B) to a single vertex, choose any

192

8 Network Flows

s 0 ; t 0 2 B (or s 0 ; t 0 2 A, respectively) and look for a minimum s 0 -t 0 -cut in the contracted graph G 0 . We continue this process, always choosing a pair s 0 ; t 0 of vertices not separated by any cut obtained so far. At each step, we contract – for each cut E.A0 ; B 0 / obtained so far – A0 or B 0 , depending on which part does not contain s 0 and t 0 . Eventually each pair of vertices is separated. We have obtained a total of n 1 cuts. The crucial observation is that a minimum s 0 -t 0 -cut in the contracted graph G 0 is also a minimum s 0 -t 0 -cut in G. This is the subject of the following lemma. Note that when contracting a set A of vertices in .G; u/, the capacity of each edge in G 0 is the capacity of the corresponding edge in G. Lemma 8.35. Let G be an undirected graph and u W E.G/ ! RC a capacity function. Let s; t 2 V .G/, and let ı.A/ be a minimum s-t-cut in .G; u/. Let now s 0 ; t 0 2 V .G/ n A, and let .G 0 ; u0 / arise from .G; u/ by contracting A to a single vertex. Then for any minimum s 0 -t 0 -cut ı.K [ fAg/ in .G 0 ; u0 /, ı.K [ A/ is a minimum s 0 -t 0 -cut in .G; u/. Proof: Let s; t; A; s 0 ; t 0 ; G 0 ; u0 be as above. W.l.o.g. s 2 A. It suffices to prove that there is a minimum s 0 -t 0 -cut ı.A0 / in .G; u/ such that A A0 . So let ı.C / be any minimum s 0 -t 0 -cut in .G; u/. W.l.o.g. s 2 C . A

V (G) \ A

t V (G) \ C C s

s

Fig. 8.3.

Since u.ı.// is submodular (cf. Lemma 2.1(c)), we have u.ı.A// C u.ı.C // u.ı.A \ C // C u.ı.A [ C //. But ı.A \ C / is an s-t-cut, so u.ı.A \ C // st D u.ı.A//. Therefore u.ı.A [ C // u.ı.C // D s 0 t 0 proving that ı.A [ C / is a minimum s 0 -t 0 -cut. (See Figure 8.3.) Now we describe the algorithm which constructs a Gomory-Hu tree. Note that the vertices of the intermediate trees T will be vertex sets of the original graph;

8.6

Gomory-Hu Trees

193

indeed they form a partition of V .G/. At the beginning, the only vertex of T is V .G/. In each iteration, a vertex of T containing at least two vertices of G is chosen and split into two.

GOMORY-HU ALGORITHM Input:

An undirected graph G and a capacity function u W E.G/ ! RC .

Output:

A Gomory-Hu tree T for .G; u/.

1

Set V .T / WD fV .G/g and E.T / WD ;.

2

Choose some X 2 V .T / with jX j 2. If no such X exists then go to . 6

3

Choose s; t 2 X with s 6D t. S For each connected component C of T X do: Let SC WD Y 2V .C / Y . Let .G 0 ; u0 / arise from .G; u/ by contracting SC to a single vertex vC for each connected component C of T X . (So V .G 0 / D X [ fvC W C is a connected component of T X g.) 0 0 WD V .G 0 / n A Find a minimum s-t-cut1ı.A0 / in .G 0 ; u0 /. Let B0 0 1. [ [ SC A [ .A0 \ X / and B WD @ SC A [ .B 0 \ X /. Set A WD @

4

vC 2A0 nX

5

6

vC 2B 0 nX

Set V .T / WD .V .T / n fX g/ [ fA \ X; B \ X g. For each edge e D fX; Y g 2 E.T / incident to the vertex X do: If Y A then set e 0 WD fA \ X; Y g else set e 0 WD fB \ X; Y g. Set E.T / WD .E.T / n feg/ [ fe 0 g and w.e 0 / WD w.e/. Set E.T / WD E.T / [ ffA \ X; B \ X gg. Set w.fA \ X; B \ X g/ WD u0 .ıG 0 .A0 //. Go to . 2 Replace all fxg 2 V .T / by x and all ffxg; fygg 2 E.T / by fx; yg. Stop.

Figure 8.4 illustrates the modification of T in . 5 To prove the correctness of this algorithm, we first show the following lemma: Lemma 8.36. Each time at the end of 4 we have :

(a) A [ B D V .G/ (b) E.A; B/ is a minimum s-t-cut in .G; u/. Proof: The elements of V .T / are always nonempty subsets of V .G/, indeed V .T / constitutes a partition of V .G/. From this, (a) follows easily. We now prove (b). The claim is trivial for the first iteration (since here G 0 D G). We show that the property is preserved in each iteration. Let C1 ; : : : ; Ck be the connected components of T X . Let us contract them one by one; for i D 0; : : : ; k let .Gi ; ui / arise from .G; u/ by contracting each of SC1 ; : : : ; SCi to a single vertex. So .Gk ; uk / is the graph which is denoted by .G 0 ; u0 / in 3 of the algorithm.

194

8 Network Flows

a

X

b

A∩X

B∩X

Fig. 8.4.

Claim: For any minimum s-t-cut ı.Ai / in .Gi ; ui /, ı.Ai 1 / is a minimum s-t-cut in .Gi 1 ; ui 1 /, where ( .Ai n fvCi g/ [ SCi if vCi 2 Ai Ai 1 WD : Ai if vCi … Ai Applying this claim successively for k; k 1; : : : ; 1 implies (b). To prove the claim, let ı.Ai / be a minimum s-t-cut in .Gi ; ui /. By our assumption that (b) is true for the previous iterations, ı.SCi / is a minimum si -ti -cut in .G; u/ for some appropriate si ; ti 2 V .G/. Furthermore, s; t 2 V .G/ n SCi . So applying Lemma 8.35 completes the proof. Lemma 8.37. At any stage of the algorithm (until 6 is reached) for all e 2 E.T / 0 0 11 [ w.e/ D u @ıG @ Z AA ; Z2Ce

8.6

Gomory-Hu Trees

195

where Ce and V .T / n Ce are the connected components of T e. Moreover for all e D fP; Qg 2 E.T / there are vertices p 2 P and q 2 Q with pq D w.e/. Proof: Both statements are trivial at the beginning of the algorithm when T contains no edges; we show that they are never violated. So let X be the vertex of T chosen in 2 in some iteration of the algorithm. Let s; t; A0 ; B 0 ; A; B be as determined in 3 and 4 next. W.l.o.g. assume s 2 A0 . Edges of T not incident to X are not affected by . 5 For the new edge fA \ X; B \ X g, w.e/ is clearly set correctly, and we have st D w.e/, s 2 A \ X , t 2 B \ X. So let us consider an edge e D fX; Y g that is replaced by e 0 in . 5 We assume w.l.o.g. Y A, so e 0 D fA \ X; Y g. Assuming that the assertions were true for e 0 we claim that they remain true for e . This is trivial for the first assertion, because S 0 w.e/ D w.e / and u ıG Z does not change. Z2Ce To show the second statement, we assume that there are p 2 X; q 2 Y with pq D w.e/. If p 2 A \ X then we are done. So henceforth assume that p 2 B \ X (see Figure 8.5).

q

Y

s

t

p

B∩X

A∩X

Fig. 8.5.

We claim that sq D pq . Since pq D w.e/ D w.e 0 / and s 2 A \ X , this will conclude the proof. By Lemma 8.33, sq minfst ; tp ; pq g: Since by Lemma 8.36(b) E.A; B/ is a minimum s-t-cut, and since s; q 2 A, we may conclude from Lemma 8.35 that sq does not change if we contract B. Since t; p 2 B, this means that adding an edge ft; pg with arbitrary high capacity does not change sq . Hence sq minfst ; pq g: Now observe that st pq because the minimum s-t-cut E.A; B/ also separates p and q. So we have

196

8 Network Flows

sq pq : To prove equality, observe that w.e/ is the capacity of a cut separating X and Y , and thus s and q. Hence sq w.e/ D pq :

This completes the proof.

Theorem 8.38. (Gomory and Hu [1961]) The GOMORY-HU ALGORITHM works correctly. Every pundirected graph possesses a Gomory-Hu tree, and such a tree is found in O.n3 m/ time. Proof: The complexity of the algorithm is clearly determined by n 1 times the complexity of finding a minimum s-t-cut, since everything p else can be implemented in O.n3 / time. By Proposition 8.31 we obtain the O.n3 m/ bound. We prove that the output T of the algorithm is a Gomory-Hu tree for .G; u/. It should be clear that T is a tree with V .T / D V .G/. Now let s; t 2 V .G/. Let Pst be the (unique) s-t-path in T and, for e 2 E.T /, let Ce and V .G/ n Ce be the connected components of T e. Since ı.Ce / is an s-t-cut for each e 2 E.Pst /, st

min

e2E.Pst /

u.ı.Ce //:

On the other hand, a repeated application of Lemma 8.33 yields st

min

fv;wg2E.Pst /

vw :

Hence applying Lemma 8.37 to the situation before execution of 6 (where each vertex X of T is a singleton) yields st

min

e2E.Pst /

u.ı.Ce //;

so equality holds.

A similar algorithm for the same task (which might be easier to implement) was suggested by Gusfield [1990]. For digraphs, Cheung, Lau and Leung [2011] showed how to compute the minimum cardinality of an s-t-cut for all pairs s; t 2 V .G/ in O.m2:38 / time.

8.7 The Minimum Capacity of a Cut in an Undirected Graph If we are only interested in a minimum capacity cut in an undirected graph G with capacities u W E.G/ ! RC , there is a simpler method using n 1 flow computations: just compute a minimum s-t-cut for some fixed vertex s and each t 2 V .G/ n fsg. However, there are more efficient algorithms.

8.7

The Minimum Capacity of a Cut in an Undirected Graph

197

2

Hao and Orlin [1994] found an O.nm log nm /-algorithm for determining a minimum capacity cut. They use a modified version of the PUSH-RELABEL ALGORITHM . If we just want to compute the edge-connectivity of the graph (i.e. unit capacities), the currently fastest algorithm is due to Gabow [1995] with running time n O.mC2 n log .G/ /, where .G/ is the edge-connectivity (observe that 2m n). Gabow’s algorithm uses matroid intersection techniques. We remark that the M AXIMUM FLOW PROBLEM in undirected graphs with unit capacities can also be solved faster than in general (Karger and Levine [1998]). Nagamochi and Ibaraki [1992] found a completely different algorithm to determine a minimum capacity cut in an undirected graph. Their algorithm does not use max-flow computations at all. In this section we present this algorithm in a simplified form due to Stoer and Wagner [1997] and independently to Frank [1994]. We start with an easy definition. Definition 8.39. Given an undirected graph G with capacities u W E.G/ ! RC , we call an order v1 ; : : : ; vn of the vertices an MA (maximum adjacency) order if for all i 2 f2; : : : ; ng: X X u.e/ D max u.e/: e2E.fv1 ;:::;vi 1 g;fvi g/

j 2fi;:::;ng

e2E.fv1 ;:::;vi 1 g;fvj g/

Proposition 8.40. Given an undirected graph G with capacities u W E.G/ ! RC , an MA order can be found in O.m C n log n/ time. Proof: Consider the following algorithm. First set ˛.v/ WD 0 for all v 2 V .G/. Then for i WD 1 to n do the following: choose vi from among V .G/ n fv1 ; : : : ; vi 1 g such P that it has maximum ˛-value (breaking ties arbitrarily), and set ˛.v/ WD ˛.v/C e2E.fvi g;fvg/ u.e/ for all v 2 V .G/ n fv1 ; : : : ; vi g. The correctness of this algorithm is obvious. By implementing it with a Fibonacci heap, storing each vertex v with key ˛.v/ until it is selected, we get a running time of O.m C n log n/ by Theorem 6.7 as there are n INSERT-, n DELETEMIN - and (at most) m DECREASEKEY -operations. Lemma 8.41. (Stoer and Wagner [1997], Frank [1994]) Let G be an undirected graph with n WD jV .G/j 2, capacities u W E.G/ ! RC and an MA order v1 ; : : : ; vn . Then X u.e/: vn1 vn D e2ı.vn /

Proof: Of course we only have to show “”. We shall use induction on jV .G/j C jE.G/j. For jV .G/j < 3 the statement is trivial. We may assume that there is no edge e D fvn1 ; vn g 2 E.G/, because otherwise we would delete it (both left-hand side and right-hand side decrease by u.e/) and apply the induction hypothesis. Denote the right-hand side by R. Of course v1 ; : : : ; vn1 is an MA order in G vn . So by induction,

198

8 Network Flows

n Gv vn2 vn1 D

X

X

u.e/

e2E.fvn1 g;fv1 ;:::;vn2 g/

u.e/ D R:

e2E.fvn g;fv1 ;:::;vn2 g/

Here the inequality holds because v1 ; : : : ; vn was an MA order for G. The last equalGvn ity is true because fvn1 ; vn g … E.G/. So G vn2 vn1 vn2 vn1 R. On the other hand v1 ; : : : ; vn2 ; vn is an MA order in G vn1 . So by induction, X n1 u.e/ D R; Gv vn2 vn D e2E.fvn g;fv1 ;:::;vn2 g/ Gvn1 again because fvn1 ; vn g … E.G/. So G vn2 vn vn2 vn D R. Now by Lemma 8.33 vn1 vn minfvn1 vn2 ; vn2 vn g R. P Note that the existence of two vertices x; y with xy D e2ı.x/ u.e/ was already shown by Mader [1972], and follows easily from the existence of a GomoryHu tree (Exercise 33).

Theorem 8.42. (Nagamochi and Ibaraki [1992], Stoer and Wagner [1997]) A minimum capacity cut in an undirected graph with nonnegative capacities can be found in O.mn C n2 log n/ time. Proof: We may assume that the given graph G is simple since we can unite parallel edges. Denote by .G/ the minimum capacity of a cut in G. The algorithm proceeds as follows: Let G0 WD G. In the i -th step (i D 1; : : : ; n1) choose vertices x; y 2 V .Gi 1 / with X i 1 D G u.e/: xy e2ıGi 1 .x/

By Proposition 8.40 and Lemma 8.41 this can be done in O.m C n log n/ time. Set G i WD xyi 1 , ´i WD x, and let Gi result from Gi 1 by contracting fx; yg. Observe that .Gi 1 / D minf.Gi /; i g; (8.1) because a minimum cut in Gi 1 either separates x and y (in this case its capacity is i ) or does not (in this case contracting fx; yg does not change anything). After arriving at Gn1 which has only one vertex, we choose a k 2 f1; : : : ; n1g for which k is minimum. We claim that ı.X / is a minimum capacity cut in G, where X is the vertex set in G whose contraction resulted in the vertex ´k of Gk1 . But this is easy to see, since by (8.1) .G/ D minf1 ; : : : ; n1 g D k and k is the capacity of the cut ı.X /. A randomized contraction algorithm for finding a minimum cut (with high probability) is discussed in Exercise 37. Moreover, we mention that the vertexconnectivity of a graph can be computed by O.n2 / flow computations in a graph with unit capacities (Exercise 38).

Exercises

199

In this section we have shown how to minimize f .X / WD u.ı.X // over ; 6D X V .G/. Note that this f W 2V .G/ ! RC is submodular and symmetric (i.e. f .A/ D f .V .G/ n A/ for all A). The algorithm presented here has been generalized by Queyranne [1998] to minimize general symmetric submodular functions; see Section 14.5. The problem of finding a maximum cut is much harder and will be discussed in Section 16.2.

Exercises 1. Let .G; u; s; t/ be a network, and let ı C .X / and ı C .Y / be minimum s-t-cuts in .G; u/. Show that ı C .X \ Y / and ı C .X [ Y / are also minimum s-t-cuts in .G; u/. 2. Show that in case of irrational capacities, the FORD-FULKERSON ALGORITHM may not terminate at all. Hint: Consider the following network (Figure 8.6): x1

y1

x2

y2

s

t x3

y3

x4

y4

Fig. 8.6.

All lines represent edges in both directions. All edges have capacity S D except

1 1

u..x1 ; y1 // D 1; u..x2 ; y2 // D ; u..x3 ; y3 // D u..x4 ; y4 // D 2 p

n nC1 where D 51 C nC2 . 2 . Note that D (Ford and Fulkerson [1962]) 3. Let G be a digraph and M the incidence matrix of G. Prove that for all c; l; u 2 ZE.G/ with l u: o n max cx W x 2 ZE.G/ ; l x u; M x D 0 D

o n E.G/ min y 0 u y 00 l W y 0 ; y 00 2 ZC ; ´M C y 0 y 00 D c for some ´ 2 ZV .G/ : Show how this implies Theorem 8.6 and Corollary 8.7.

200

8 Network Flows

4. Prove Hoffman’s circulation theorem: Given a digraph G and lower and upper capacities l; u W E.G/ ! RC with l.e/ u.e/ for all e 2 E.G/, there is circulation f with l.e/ f .e/ u.e/ for all e 2 E.G/ if and only if X X l.e/ u.e/ for all X V .G/: e2ı .X/

e2ı C .X/

Note: Hoffman’s circulation theorem in turn quite easily implies the Max-FlowMin-Cut Theorem. (Hoffman [1960]) 5. Consider a network .G; u; s; t/, a maximum s-t-flow f and the residual graph Gf . Form a digraph H from Gf by contracting the set S of vertices reachable from s to a vertex vS , contracting the set T of vertices from which t is reachable to a vertex vT , and contracting each strongly connected component X of Gf .S [ T / to a vertex vX . Observe that H is acyclic. Prove that there is C a one-to-one correspondence between the sets X V .G/ for which ıG .X / is C a minimum s-t-cut in .G; u/ and the sets Y V .H / for which ıH .Y / is a directed vT -vS -cut in H (i.e. a directed cut in H separating vT and vS ). Note: This statement also holds for Gf without any contraction instead of H . However, we shall use the statement in the above form in Section 20.4. (Picard and Queyranne [1980]) 0 6. Let G be a digraph and c; cP W E.G/ ! R. We Plook for a set X V .G/ with s 2 X and t … X such that e2ı C .X/ c.e/ e2ı .X/ c 0 .e/ is minimum. (a) Show how to reduce this problem to the MINIMUM CAPACITY CUT PROBLEM. (b) Now consider the special case where c D c 0 . Can you solve this problem in linear time? 7. Let G be an acyclic digraph with mappings ; ; c W E.G/ ! RC , and a number C 2 RC . We look for a mapping x W E.G/ ! RC such that .e/ x.e/ P .e/ for all e 2 E.G/ and e2E.G/ ..e/x.e//c.e/ C . Among the feasible solutions we want to minimize the length (with respect to x) of the longest path in G. The meaning behind the above is the following. The edges correspond to jobs, .e/ and .e/ stand for the minimum and maximum completion time of job e, and c.e/ is the cost of reducing the completion time of job e by one unit. If there are two jobs e D .i; j / and e 0 D .j; k/, job e has to be finished before job e 0 can be processed. We have a fixed budget C and want to minimize the total completion time. Show how to solve this problem using network flow techniques. (This application is known as PERT, program evaluation and review technique, or CPM, critical path method. The problem is also known as the budget version of the time-cost tradeoff problem.) Hint: Introduce one source s and one sink t. Start with x D and successively reduce the length of the longest s-t-path (with respect to x) at the minimum possible cost. Use Exercise 8 of Chapter 7, Exercise 9 of Chapter 3, and Exercise 6. (Phillips and Dessouky [1977])

Exercises

201

8. Let .G; c; s; t/ be a network such that G is planar even when an edge e D .s; t/ is added. Consider the following algorithm. Start with the flow f 0 and let G 0 WD Gf . At each step consider the boundary B of a face of G 0 C e containing e (with respect to some fixed planar embedding). Augment f along B e. Let G 0 consist of the forward edges of Gf only and iterate as long as t is reachable from s in G 0 . Prove that this algorithm computes a maximum s-t-flow. Use Theorem 2.40 to show that it can be implemented to run in O.n2 / time. (Ford and Fulkerson [1956], Hu [1969]) Note: This problem can be solved in O.n/ time. For general planar networks an O.n log n/-algorithm exists; see Weihe [1997] and Borradaile and Klein [2009]. 9. Show that the directed edge-disjoint version of Menger’s Theorem 8.9 also follows directly from Theorem 6.18. 10. Let G be an undirected graph. Prove that one can compute an orientation G 0 of G in linear time such that for each v; w 2 V .G/ the following holds: if G has two edge-disjoint v-w-paths, then G 0 has a (directed) v-w-path. Hint: Use DFS. (Tarjan [1972]) 11. Let G be a digraph with conservative weights c W E.G/ ! R and two vertices s; t 2 V .G/ such that t is reachable from s. Suppose that for every edge e 2 E.G/ we have dist.Ge;c/ .s; t/ D dist.G;c/ .s; t/. Prove that then there are two edge-disjoint shortest s-t-paths in .G; c/. 12. Consider an undirected graph G with edge-connectivity k 2 N and (not necessarily distinct) vertices v0 ; v1 ; : : : ; vk 2 V .G/. Prove that there are pairwise edge-disjoint paths P1 ; : : : ; Pk such that Pi is a v0 -vi -path (i D 1; : : : ; k). 13. Let G be a graph (directed or undirected), x; y; ´ three vertices, and ˛; ˇ 2 N with ˛ xy , ˇ x´ and ˛ C ˇ maxfxy ; x´ g. Prove that there are ˛ xy-paths and ˇ x-´-paths such that these ˛ C ˇ paths are pairwise edge-disjoint. 14. Let G be a digraph that contains k edge-disjoint s-t-paths for any two vertices s and t (such a graph is called strongly k-edge-connected). Let H be any digraph with V .H / D V .G/ and jE.H /j D k. Prove that the instance .G; H / of the DIRECTED EDGE-DISJOINT PATHS PROBLEM has a solution. (Mader [1981] and Shiloach [1979]) 15. Let G be a digraph with at least k edges. Prove: G contains k edge-disjoint s-t-paths for any two vertices s and t if and only if for any k distinct edges e1 D .x1 ; y1 /; : : : ; ek D .xk ; yk /, G fe1 ; : : : ; ek g contains k edge-disjoint spanning arborescences T1 ; : : : ; Tk such that Ti is rooted at yi (i D 1; : : : ; k). Note: This generalizes Exercise 14. Hint: Use Theorem 6.18. (Su [1997])

202

8 Network Flows

16. Let G be a digraph with capacities c W E.G/ ! RC and r 2 V .G/. Can one determine an r-cut with minimum capacity in polynomial time? Can one determine a directed cut with minimum capacity in polynomial time (or decide that G is strongly connected)? Note: The answer to the first question solves the SEPARATION PROBLEM for the MINIMUM WEIGHT ROOTED ARBORESCENCE PROBLEM; see Corollary 6.15. 17. An airline wants to conduct a given set of scheduled flights with as few airplanes as possible. All available airplanes are of the same type. For each flight we know the departure time and the flight time. We also know, for any pair of flights i and j , how much time an airplane needs after finishing flight i until it can begin flight j (this time will depend in particular on where i ends and where j begins). Show how to compute efficiently a feasible schedule with as few airplanes as possible. 18. Prove that the value of a blocking s-t-flow in a network .G; u; s; t/ with an 1 acyclic digraph G is at least jV .G/j times the value of a maximum s-t-flow. Show that this bound is sharp up to a constant factor. 19. Show how to find a blocking flow in an acyclic network in O.nm/ time by successively augmenting along a path of non-saturated edges and using DEPTHFIRST SEARCH to find such a path. Show how to obtain a running time of O.m/ if all edges that are not incident to s or t have capacity 1. 20. Let .G; u; s; t/ be a network with u.e/ D 1 for all edges e 2 E.G/ that are not incident to s or t. (a) Show that then a maximum s-t-flow can be computed in O.mn2=3 / time. (b) Let in addition G have the property that for each v 2 V .G/ n fs; tg we have C jı .v/j D 1 or jıp .v/j D 1. Show that then a maximum s-t-flow can be computed in O.m n/ time. Hint: Consider DINIC’S ALGORITHM and the p situation when no augmenting path has length less than dn2=3 e in (a) and d ne in (b). Bound the number of remaining iterations and use the second part of Exercise 19. (Karzanov [1973], Even and Tarjan [1975]) 21. An s-t-preflow f is called maximum if exf .t/ is maximum. (a) Show that for any maximum preflow f there exists a maximum flow f 0 with f 0 .e/ f .e/ for all e 2 E.G/. (b) Show how a maximum preflow can be converted into a maximum flow in O.nm/ time. 22. Let .G; u; s; t/ be a network such that G t is an arborescence. Show how to find a maximum s-t-flow in linear time. Hint: Use DFS. 23. Let .G; u; s; t/ be a network such that the underlying undirected graph of G fs; tg is a forest. Show how to find a maximum s-t-flow in linear time. (Vygen [2002]) 24. Consider a modified version of FUJISHIGE’S ALGORITHM where in 5 we choose vi 2 V .G/ n fv1 ; : : : ; vi 1 g such that b.vi / is maximum, step 4 is

Exercises

25. 26.

27.

28.

29.

30.

31.

32.

203

replaced by stopping if b.v/ D 0 for all v 2 V .G/ n fv1 ; : : : ; vi g, and in the beginning of 6 we set ˇ.t/ WD minji D2 b.j /. Then X and ˛ are not needed anymore. (a) Show that this variant of the algorithm works correctly. (b) Let ˛k be the number minji D2 b.j / in iteration k (or zero if the algorithm stops before iteration k). Show that minkC2n ˛ 12 ˛k for all k. Conclude lDkC1 l that the number of iterations is O.n log umax /. (c) Show how to implement one iteration in O.m C n log n/ time. Prove that the PUSH-RELABEL ALGORITHM performs O.n2 m/ nonsaturating pushes, independent of the choice of v in . 3 Let .G; u; s; t/ be a network, f an s-t-preflow, and a distance labeling with respect to f with .v/ 2n for v 2 V .G/. Define 0 .v/ WD minfdistGf .v; t/; n C distGf .v; s/; 2ng for v 2 V .G/. Show that 0 is a distance labeling with respect to f , and 0 . Note: Replacing by 0 from time to time, e.g. after every n RELABEL operations, improves the performance of the PUSH-RELABEL ALGORITHM in practice. Given an acyclic digraph G with weights c W E.G/ ! RC , find a maximum weight directed cut in G. Show how this problem can be reduced to the MINIMUM CAPACITY CUT PROBLEM . Hint: Use Exercise 6. Let G be an acyclic digraph with weights c W E.G/ ! RC . We look for the maximum weight edge set F E.G/ such that no path in G contains more than one edge of F . Show that this problem is equivalent to looking for the maximum weight directed cut in G (and thus can be solved in O.n3 / time by Exercise 27). Let G be a digraph and p W V .G/ ! R. Show how to find a set X V .G/ with ı C .X / D ; such that p.X / is maximum. Note: This was used to model open-pit mining, where p.v/ is the (possibly negative) profit of mining v, and an edge .v; w/ models the constraint that we cannot mine v unless we mine w. Given an undirected graph G with capacities u W E.G/ ! RC and a set T V .G/ with jT j 2. PWe look for a set X V .G/ with T \ X 6D ; and T nX 6D ; such that e2ı.X/ u.e/ is minimum. Show how to solve this problem in O.n4 / time, where n D jV .G/j. Let ij , 1 i; j n, be nonnegative numbers with ij D j i and i k minfij ; jk g for any three distinct indices i; j; k 2 f1; : : : ; ng. Show that there exists a graph G with V .G/ D f1; : : : ; ng and capacities u W E.G/ ! RC such that the local edge-connectivities are precisely the ij . Hint: Consider a maximum weight spanning tree in .Kn ; c/, where c.fi; j g/ WD ij . (Gomory and Hu [1961]) Let G be an undirected graph with capacities u W E.G/ ! RC , and let T V .G/ with jT j even. A T -cut in G is a cut ı.X / with jX \ T j odd. Construct a

204

33.

34.

35.

36.

37.

8 Network Flows

polynomial time algorithm for finding a T -cut of minimum capacity in .G; u/. Hint: Use a Gomory-Hu tree. (A solution of this exercise can be found in Section 12.3.) Let G be a simple undirected graph with at least two vertices. Suppose the degree of each vertex of G is at least k. Prove that there are two vertices s and t such that at least k edge-disjoint s-t-paths exist. What if there is exactly one vertex with degree less than k? Hint: Consider a Gomory-Hu tree for G. Consider the problem of determining the edge-connectivity .G/ of an undirected graph (with unit capacities). Section 8.7 shows how to solve this problem in O.mn/ time, provided that we can find an MA order of an undirected graph with unit capacities in O.m C n/ time. How can this be done? G Let G be an undirected graph with an MA order v1 ; : : : ; vn . Let uv denote the maximum number of internally disjoint u-v-paths in G. Prove vGn1 vn D jE.fvn g; fv1 ; : : : ; vn1 g/j (the vertex-disjoint counterpart of Lemma 8.41). G Hint: Prove by induction that vjijvi D jE.fvj g; fv1 ; : : : ; vi g/j, where Gij D GŒfv1 ; : : : ; vi g [ fvj g. To do this, assume w.l.o.g. that fvj ; vi g … E.G/, choose a minimal set Z fv1 ; : : : ; vi 1 g separating vj and vi (Menger’s Theorem 8.10), and let h i be the maximum number such that vh … Z and vh is adjacent to vi or vj . (Frank [unpublished]) An undirected graph is called chordal if it has no circuit of length at least four as an induced subgraph. An order v1 ; : : : ; vn of an undirected graph G is called simplicial if fvi ; vj g; fvi ; vk g 2 E.G/ implies fvj ; vk g 2 E.G/ for i < j < k. (a) Prove that a graph with a simplicial order must be chordal. (b) Let G be a chordal graph, and let v1 ; : : : ; vn be an MA order. Prove that vn ; vn1 ; : : : ; v1 is a simplicial order. Hint: Use Exercise 35 and Menger’s Theorem 8.10. Note: The fact that a graph is chordal if and only if it has a simplicial order is due to Rose [1970]. Let G be an undirected graph with capacities u W E.G/ ! RC . Let ; 6D A

V .G/ such that ı.A/ is a minimum capacity cut in G. (a) Show that u.ı.A// n2 u.E.G//. (Hint: Consider the trivial cuts ı.x/, x 2 V .G/.) (b) Assume w.l.o.g. that u.ı.A// > 0 and consider the following procedure. We randomly choose an edge and contract it; each edge e is chosen with u.e/ probability u.E.G// . We repeat this operation until there are only two vertices. Prove that the probability that we never contract an edge of ı.A/ is at 2 least .n1/n . (c) Conclude that running the randomized algorithm in (b) k n2 times yields ı.A/ with probability at least 1 e 2k . (Such an algorithm with a positive probability of a correct answer is called a Monte Carlo algorithm.) (Karger and Stein [1996]; see also Karger [2000])

References

205

38. Show how the vertex-connectivity of an undirected graph can be determined in O.n2:5 m/ time. Hint: Recall the proof of Menger’s Theorem and use Exercise 20. Note: Faster algorithms were proposed by Henzinger, Rao and Gabow [2000], and by Gabow [2006]. 39. Let G be a connected undirected graph with capacities u W E.G/ ! RC . We are looking for a minimum capacity 3-cut, i.e. an edge set whose deletion splits G into at least three connected components. Let n WD jV .G/j 4. Let ı.X1 /; ı.X2 /; : : : be a list of the cuts ordered by nondecreasing capacities: u.ı.X1 // u.ı.X2 // . Assume that we know the first 2n 2 elements of this list (note: they can be computed in polynomial time by a method of Vazirani and Yannakakis [1992]). (a) Show that for some indices i; j 2 f1; : : : ; 2n 2g all sets Xi n Xj , Xj n Xi , Xi \ Xj and V .G/ n .Xi [ Xj / are nonempty. (b) Show that there is a 3-cut of capacity at most 32 u.ı.X2n2 /. (c) For each i D 1; : : : ; 2n 2 consider ı.Xi / plus a minimum capacity cut of G Xi , and also ı.Xi / plus a minimum capacity cut of GŒXi . This yields a list of at most 4n 4 3-cuts. Prove that one of them is optimum. (Nagamochi and Ibaraki [2000]) Note: This was generalized to k-cuts (for any fixed k) by Kamidoi, Yoshida and Nagamochi [2007]; see also Thorup [2008]. The problem of finding the optimum 3-cut separating three given vertices is much harder; see Dahlhaus et al. [1994] and Cheung, Cunningham and Tang [2006]. 40. Let G be an undirected graph with capacities u W E.G/ ! ZC . (a) Show that if ı.X / and ı.Y / are two minimum capacity cuts with X \Y 6D ; and X [ Y 6D V .G/, then ı.X n Y / \ ı.Y n X / D ;. (b) Suppose that the minimum capacity of a cut is odd. Show that then the family of vertex sets X for which ı.X / is a minimum capacity cut is crossfree, and hence there are at most n 1 minimum capacity cuts. Note: Dinitz, Karzanov and Lomonosov [1976] showed that there are at most n2 minimum capacity cuts in general. They can be described by a socalled cactus representation, generalizing tree-representations. See also Frank [2011].

References General Literature: Ahuja, R.K., Magnanti, T.L., and Orlin, J.B. [1993]: Network Flows. Prentice-Hall, Englewood Cliffs 1993 Cook, W.J., Cunningham, W.H., Pulleyblank, W.R., and Schrijver, A. [1998]: Combinatorial Optimization. Wiley, New York 1998, Chapter 3 Cormen, T.H., Leiserson, C.E., Rivest, R.L., and Stein, C. [2001]: Introduction to Algorithms. Second Edition. MIT Press, Cambridge 2001, Chapter 26

206

8 Network Flows

Ford, L.R., and Fulkerson, D.R. [1962]: Flows in Networks. Princeton University Press, Princeton 1962 Frank, A. [1995]: Connectivity and network flows. In: Handbook of Combinatorics; Vol. 1 (R.L. Graham, M. Grötschel, L. Lovász, eds.), Elsevier, Amsterdam, 1995 Frank, A. [2011]: Connections in Combinatorial Optimization. Oxford University Press, Oxford 2011 Goldberg, A.V., Tardos, É., and Tarjan, R.E. [1990]: Network flow algorithms. In: Paths, Flows, and VLSI-Layout (B. Korte, L. Lovász, H.J. Prömel, A. Schrijver, eds.), Springer, Berlin 1990, pp. 101–164 Gondran, M., and Minoux, M. [1984]: Graphs and Algorithms. Wiley, Chichester 1984, Chapter 5 Jungnickel, D. [2007]: Graphs, Networks and Algorithms. Third Edition. Springer, Berlin 2007 Phillips, D.T., and Garcia-Diaz, A. [1981]: Fundamentals of Network Analysis. Prentice-Hall, Englewood Cliffs 1981 Ruhe, G. [1991]: Algorithmic Aspects of Flows in Networks. Kluwer Academic Publishers, Dordrecht 1991 Schrijver, A. [2003]: Combinatorial Optimization: Polyhedra and Efficiency. Springer, Berlin 2003, Chapters 9,10,13–15 Tarjan, R.E. [1983]: Data Structures and Network Algorithms. SIAM, Philadelphia 1983, Chapter 8 Thulasiraman, K., and Swamy, M.N.S. [1992]: Graphs: Theory and Algorithms. Wiley, New York 1992, Chapter 12

Cited References: Ahuja, R.K., Orlin, J.B., and Tarjan, R.E. [1989]: Improved time bounds for the maximum flow problem. SIAM Journal on Computing 18 (1989), 939–954 Borradaile, G. and Klein, P. [2009]: An O.n log n/ algorithm for maximum st-flow in a directed planar graph. Journal of the ACM 56 (2009), Article 9 Cheriyan, J., and Maheshwari, S.N. [1989]: Analysis of preflow push algorithms for maximum network flow. SIAM Journal on Computing 18 (1989), 1057–1086 Cheriyan, J., and Mehlhorn, K. [1999]: An analysis of the highest-level selection rule in the preflow-push max-flow algorithm. Information Processing Letters 69 (1999), 239–242 Cherkassky, B.V. [1977]: Algorithm of construction of maximal flow in networks with comp plexity of O.V 2 E/ operations. Mathematical Methods of Solution of Economical Problems 7 (1977), 112–125 [in Russian] Cheung, K.K.H., Cunningham, W.H., and Tang, L. [2006]: Optimal 3-terminal cuts and linear programming. Mathematical Programming 106 (2006), 1–23 Cheung, H.Y., Lau, L.C., and Leung, K.M. [2011]: Graph connectivities, network coding, and expander graphs. Proceedings of the 52nd Annual IEEE Symposium on Foundations of Computer Science (2011), 190–199 Dahlhaus, E., Johnson, D.S., Papadimitriou, C.H., Seymour, P.D., and Yannakakis, M. [1994]: The complexity of multiterminal cuts. SIAM Journal on Computing 23 (1994), 864–894 Dantzig, G.B., and Fulkerson, D.R. [1956]: On the max-flow min-cut theorem of networks. In: Linear Inequalities and Related Systems (H.W. Kuhn, A.W. Tucker, eds.), Princeton University Press, Princeton 1956, pp. 215–221

References

207

Dinic, E.A. [1970]: Algorithm for solution of a problem of maximum flow in a network with power estimation. Soviet Mathematics Doklady 11 (1970), 1277–1280 Dinitz, E.A., Karzanov, A.V., and Lomonosov, M.V. [1976]: On the structure of the system of minimum edge cuts of a graph. Issledovaniya po Diskretno˘ı Optimizatsii (A.A. Fridman, ed.), Nauka, Moscow, 1976, pp. 290–306 [in Russian] Edmonds, J., and Karp, R.M. [1972]: Theoretical improvements in algorithmic efficiency for network flow problems. Journal of the ACM 19 (1972), 248–264 Elias, P., Feinstein, A., and Shannon, C.E. [1956]: Note on maximum flow through a network. IRE Transactions on Information Theory, IT-2 (1956), 117–119 Even, S., and Tarjan, R.E. [1975]: Network flow and testing graph connectivity. SIAM Journal on Computing 4 (1975), 507–518 Ford, L.R., and Fulkerson, D.R. [1956]: Maximal Flow Through a Network. Canadian Journal of Mathematics 8 (1956), 399–404 Ford, L.R., and Fulkerson, D.R. [1957]: A simple algorithm for finding maximal network flows and an application to the Hitchcock problem. Canadian Journal of Mathematics 9 (1957), 210–218 Frank, A. [1994]: On the edge-connectivity algorithm of Nagamochi and Ibaraki. Laboratoire Artemis, IMAG, Université J. Fourier, Grenoble, 1994 Fujishige, S. [2003]: A maximum flow algorithm using MA ordering. Operations Research Letters 31 (2003), 176–178 Gabow, H.N. [1995]: A matroid approach to finding edge connectivity and packing arborescences. Journal of Computer and System Sciences 50 (1995), 259–273 Gabow, H.N. [2006]: Using expander graphs to find vertex-connectivity. Journal of the ACM 53 (2006), 800–844 5 2 Galil, Z. [1980]: An O.V 3 E 3 / algorithm for the maximal flow problem. Acta Informatica 14 (1980), 221–242 Galil, Z., and Namaad, A. [1980]: An O.EV log2 V / algorithm for the maximal flow problem. Journal of Computer and System Sciences 21 (1980), 203–217 Gallai, T. [1958]: Maximum-minimum Sätze über Graphen. Acta Mathematica Academiae Scientiarum Hungaricae 9 (1958), 395–434 Goldberg, A.V., and Rao, S. [1998]: Beyond the flow decomposition barrier. Journal of the ACM 45 (1998), 783–797 Goldberg, A.V., and Tarjan, R.E. [1988]: A new approach to the maximum flow problem. Journal of the ACM 35 (1988), 921–940 Gomory, R.E., and Hu, T.C. [1961]: Multi-terminal network flows. Journal of SIAM 9 (1961), 551–570 Gusfield, D. [1990]: Very simple methods for all pairs network flow analysis. SIAM Journal on Computing 19 (1990), 143–155 Hao, J., and Orlin, J.B. [1994]: A faster algorithm for finding the minimum cut in a directed graph. Journal of Algorithms 17 (1994), 409–423 Henzinger, M.R., Rao, S., and Gabow, H.N. [2000]: Computing vertex connectivity: new bounds from old techniques. Journal of Algorithms 34 (2000), 222–250 Hoffman, A.J. [1960]: Some recent applications of the theory of linear inequalities to extremal combinatorial analysis. In: Combinatorial Analysis (R.E. Bellman, M. Hall, eds.), AMS, Providence 1960, pp. 113–128 Hu, T.C. [1969]: Integer Programming and Network Flows. Addison-Wesley, Reading 1969 Jelinek, F., and Mayeda, W. [1963]: On the maximum number of different entries in the terminal capacity matrix of oriented communication nets. IEEE Transactions on Circuit Theory 10 (1963), 307–308

208

8 Network Flows

Kamidoi, Y., Yoshida, N., and Nagamochi, H. [2007]: A deterministic algorithm for finding all minimum k-way cuts. SIAM Journal on Computing 36 (2007), 1329–1341 Karger, D.R. [2000]: Minimum cuts in near-linear time. Journal of the ACM 47 (2000), 46–76 Karger, D.R., and Levine, M.S. [1998]: Finding maximum flows in undirected graphs seems easier than bipartite matching. Proceedings of the 30th Annual ACM Symposium on Theory of Computing (1998), 69–78 Karger, D.R., and Stein, C. [1996]: A new approach to the minimum cut problem. Journal of the ACM 43 (1996), 601–640 Karzanov, A.V. [1973]: On finding a maximum flow in a network with special structure and some applications. In: Matematicheskie Voprosy Upravleniya Proizvodstvom 5 (L.A. Lyusternik, ed.), Moscow State University Press, Moscow, 1973, pp. 81–94 [in Russian] Karzanov, A.V. [1974]: Determining a maximal flow in a network by the method of preflows. Soviet Mathematics Doklady 15 (1974), 434–437 King, V., Rao, S., and Tarjan, R.E. [1994]: A faster deterministic maximum flow algorithm. Journal of Algorithms 17 (1994), 447–474 Mader, W. [1972]: Über minimal n-fach zusammenhängende, unendliche Graphen und ein Extremalproblem. Arch. Math. 23 (1972), 553–560 Mader, W. [1981]: On a property of n edge-connected digraphs. Combinatorica 1 (1981), 385–386 Malhotra, V.M., Kumar, M.P., and Maheshwari, S.N. [1978]: An O.jV j3 / algorithm for finding maximum flows in networks. Information Processing Letters 7 (1978), 277–278 Menger, K. [1927]: Zur allgemeinen Kurventheorie. Fundamenta Mathematicae 10 (1927), 96–115 Nagamochi, H., and Ibaraki, T. [1992]: Computing edge-connectivity in multigraphs and capacitated graphs. SIAM Journal on Discrete Mathematics 5 (1992), 54–66 Nagamochi, H., and Ibaraki, T. [2000]: A fast algorithm for computing minimum 3-way and 4-way cuts. Mathematical Programming 88 (2000), 507–520 Phillips, S., and Dessouky, M.I. [1977]: Solving the project time/cost tradeoff problem using the minimal cut concept. Management Science 24 (1977), 393–400 Picard, J., and Queyranne, M. [1980]: On the structure of all minimum cuts in a network and applications. Mathematical Programming Study 13 (1980), 8–16 Queyranne, M. [1998]: Minimizing symmetric submodular functions. Mathematical Programming B 82 (1998), 3–12 Rose, D.J. [1970]: Triangulated graphs and the elimination process. Journal of Mathematical Analysis and Applications 32 (1970), 597–609 Shiloach, Y. [1978]: An O.nI log2 I / maximum-flow algorithm. Technical Report STANCS-78-802, Computer Science Department, Stanford University, 1978 Shiloach, Y. [1979]: Edge-disjoint branching in directed multigraphs. Information Processing Letters 8 (1979), 24–27 Shioura, A. [2004]: The MA ordering max-flow algorithm is not strongly polynomial for directed networks. Operations Research Letters 32 (2004), 31–35 Sleator, D.D. [1980]: An O.nm log n/ algorithm for maximum network flow. Technical Report STAN-CS-80-831, Computer Science Department, Stanford University, 1978 Sleator, D.D., and Tarjan, R.E. [1983]: A data structure for dynamic trees. Journal of Computer and System Sciences 26 (1983), 362–391 Su, X.Y. [1997]: Some generalizations of Menger’s theorem concerning arc-connected digraphs. Discrete Mathematics 175 (1997), 293–296 Stoer, M., and Wagner, F. [1997]: A simple min cut algorithm. Journal of the ACM 44 (1997), 585–591

References

209

Tarjan, R.E. [1972]: Depth first search and linear graph algorithms. SIAM Journal on Computing 1 (1972), 146–160 Thorup, M. [2008]: Minimum k-way cuts via deterministic greedy tree packing. Proceedings of the 40th Annual ACM Symposium on Theory of Computing (2008), 159–165 Tunçel, L. [1994]: On the complexity preflow-push algorithms for maximum flow problems. Algorithmica 11 (1994), 353–359 Vazirani, V.V., and Yannakakis, M. [1992]: Suboptimal cuts: their enumeration, weight, and number. In: Automata, Languages and Programming; Proceedings of the 19th ICALP conference; LNCS 623 (W. Kuich, ed.), Springer, Berlin 1992, pp. 366–377 Vygen, J. [2002]: On dual minimum cost flow algorithms. Mathematical Methods of Operations Research 56 (2002), 101–126 Weihe, K. [1997]: Maximum .s; t/-flows in planar networks in O.jV j log jV j/ time. Journal of Computer and System Sciences 55 (1997), 454–475 Whitney, H. [1932]: Congruent graphs and the connectivity of graphs. American Journal of Mathematics 54 (1932), 150–168

•

9 Minimum Cost Flows

In this chapter we show how we can take edge costs into account. For example, in our application of the MAXIMUM FLOW PROBLEM to the JOB ASSIGNMENT PROBLEM mentioned in the introduction of Chapter 8 one could introduce edge costs to model that the employees have different salaries; our goal is to meet a deadline when all jobs must be finished at a minimum cost. Of course, there are many more applications. A second generalization, allowing several sources and sinks, is more due to technical reasons. We introduce the general problem and an important special case in Section 9.1. In Section 9.2 we prove optimality criteria that are the basis of the minimum cost flow algorithms presented in Sections 9.3, 9.4, 9.5 and 9.6. Most of these use algorithms of Chapter 7 for finding a minimum mean cycle or a shortest path as a subroutine. Section 9.7 concludes this chapter with an application to time-dependent flows.

9.1 Problem Formulation We are again given a digraph G with capacities u W E.G/ ! RC , but in addition numbers c W E.G/ ! R indicating the cost of each edge. Furthermore, we allow several sources and sinks: Definition 9.1. Given P a digraph G, capacities u W E.G/ ! RC , and numbers b W V .G/ ! R with v2V .G/ b.v/ D 0, a b-flow P in .G; u/ is a function P f W E.G/ ! RC with f .e/ u.e/ for all e 2 E.G/ and e2ı C .v/ f .e/ e2ı .v/ f .e/ D b.v/ for all v 2 V .G/. Thus a b-flow with b 0 is a circulation. b.v/ is called the balance of vertex v. jb.v/j is sometimes called the supply (if b.v/ > 0) or the demand (if b.v/ < 0) of v. Vertices v with b.v/ > 0 are called sources, those with b.v/ < 0 sinks. Theorem 9.2. (Gale [1957]) LetPG be a digraph with capacities u W E.G/ ! RC , and let b W V .G/ ! R with v2V .G/ b.v/ D 0. There exists a b-flow if and only if X X u.e/ b.v/ for all X V .G/: e2ı C .X/

v2X

B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__9, c Springer-Verlag Berlin Heidelberg 2012

211

212

9 Minimum Cost Flows

p We can find one or decide that none exists in O.n2 m/ time, where n WD jV .G/j and m WD jE.G/j. Proof: Let G 0 result from G by adding two vertices s and t and edges .s; v/, .v; t/ with capacities u..s; v// P WD maxf0; b.v/g and P u..v; t// WD maxf0; b.v/g for all v 2 V .G/. Let B WD v2V .G/ u..s; v// D v2V .G/ u..v; t//. Then the b-flows in .G; u/ are precisely the restrictions of the s-t-flows with value B in .G 0 ; u/ to E.G/. By the Max-Flow-Min-Cut Theorem 8.6, an s-t-flow of value P B exists in .G 0 ; u/ if and only if e2ı C .fsg[X/ u.e/ B for every X V .G/. P G0 P P Note that e2ı C .fsg[X/ u.e/ D e2ı C .X/ u.e/ C B C v2X .maxf0; b.v/g G P G 0P maxf0; b.v/g/ D e2ı C .X/ u.e/ C B v2X b.v/, implying the first claim. G We can find a b-flow or decide that none exists by solving the MAXIMUM FLOW PROBLEM in .G 0 ; u; s; t/. The running time follows from Theorem 8.30. The problem that we study in this chapter is to find a minimum cost b-flow:

MINIMUM COST FLOW PROBLEM Instance: Task:

A digraph P G, capacities u W E.G/ ! RC , numbers b W V .G/ ! R with v2V .G/ b.v/ D 0, and weights c W E.G/ ! R. P Find a b-flow f whose cost c.f / WD e2E.G/ f .e/c.e/ is minimum (or decide that none exists).

Sometimes one also allows infinite capacities. In this case an instance can be unbounded, but this can be checked in advance easily; see Exercise 5. Note that (in contrast to many other problems, e.g. the MAXIMUM FLOW PROBLEM) we cannot assume without loss of generality that the input graph is simple when considering the MINIMUM COST FLOW PROBLEM. The MINIMUM COST FLOW PROBLEM is quite general and has a couple of interesting special cases. The uncapacitated case (u 1) is sometimes called the transshipment problem. An even more restricted problem, also known as the transportation problem, has been formulated quite early by Hitchcock [1941] and others:

HITCHCOCK PROBLEM

:

Instance:

A digraph G with V .G/ D A [ B and E.G/ A B. Supplies b.v/ P 0 for v 2 A and demands b.v/ 0 for v 2 B with v2V .G/ b.v/ D 0. Weights c W E.G/ ! R.

Task:

Find a b-flow f in .G; 1/ of minimum cost (or decide that none exists).

In the HITCHCOCK PROBLEM it causes no loss of generality to assume that c is nonnegative: Adding a constant ˛ P to each weight increases the cost of each b-flow by the same amount, namely by ˛ v2A b.v/. Often only the special case where c is nonnegative and E.G/ D A B is considered.

9.1

Problem Formulation

213

Obviously, any instance of the HITCHCOCK PROBLEM can be written as an instance of the MINIMUM COST FLOW PROBLEM on a bipartite graph with infinite capacities. It is less obvious that any instance of the M INIMUM COST FLOW PROBLEM can be transformed to an equivalent (but larger) instance of the H ITCHCOCK PROBLEM: Lemma 9.3. (Orden [1956], Wagner [1959]) An instance of the MINIMUM COST FLOW PROBLEM with n vertices and m edges can be transformed to an equivalent instance of the HITCHCOCK PROBLEM with n C m vertices and 2m edges.

b( x ) = 4

b (e 1 ) = 5

e1

b (e 2 ) = 4 e2

b( y ) = − 1

e3

b( z ) = − 3

b (e 3 ) = 7

0 c(e1 ) 0 c(e 2 ) c(e 3 )

u (e 1 ) = 5, u (e 2 ) = 4, u (e 3 ) = 7

0

b (x) = − 1

b ( y) = − 5

b ( z ) = − 10

u ≡∞

Fig. 9.1.

Proof: Let .G; u; b; c/ be an instance of the MINIMUM COST FLOW PROBLEM. We define an equivalent instance .G 0 ; A0 ; B 0 ; b 0 ; c 0 / of the HITCHCOCK PROBLEM as follows: Let A0 WD E.G/, B 0 WD V .G/ and G 0 WD .A0 [ B 0 ; E1 [ E2 /, where E1 WD f..x; y/; x/ W .x; y/ 2 E.G/g and E2 WD f..x; y/; y/ W .x; y/ 2 E.G/g. Let c 0 ..e; x// WD 0 for .e; x/ 2 E1 and c 0 ..e; y// WD c.e/ for .e; y/ 2 E2 . Finally let b 0 .e/ WD u.e/ for e 2 E.G/ and X u.e/ for x 2 V .G/: b 0 .x/ WD b.x/ C e2ıG .x/

For an example, see Figure 9.1. We prove that both instances are equivalent. Let f be a b-flow in .G; u/. Define f 0 ..e; y// WD f .e/ and f 0 ..e; x// WD u.e/ f .e/ for e D .x; y/ 2 E.G/. Obviously f 0 is a b 0 -flow in G 0 with c 0 .f 0 / D c.f /. Conversely, if f 0 is a b 0 -flow in G 0 , then f ..x; y// WD f 0 ...x; y/; y// defines a b-flow in G with c.f / D c 0 .f 0 /. The above proof is due to Ford and Fulkerson [1962].

214

9 Minimum Cost Flows

9.2 An Optimality Criterion In this section we prove some simple results, in particular an optimality criterion, which will be the basis for the algorithms in the subsequent sections. We again use the concepts of residual graphs and augmenting paths. We extend the weights $

c to G by defining c. e / WD c.e/ for each edge e 2 E.G/. Our definition of a residual graph has the advantage that the weight of an edge in a residual graph Gf is independent of the flow f . Definition 9.4. Given a digraph G with capacities and a b-flow f , an f-augmenting cycle is a circuit in Gf . The following simple observation will prove useful: Proposition 9.5. Let G be a digraph with capacities u W E.G/ ! RC . Let f and $

f 0 be b-flows in .G; u/. Then g W E.G/ ! RC defined by g.e/ WD maxf0; f 0 .e/ $

f .e/g and g. e / WD maxf0; f .e/ f 0 .e/g for e 2 E.G/ is a circulation in G. Furthermore, g.e/ D 0 for all e … E.Gf / and c.g/ D c.f 0 / c.f /. $

Proof: At each vertex v 2 V .G/ we have X X X X g.e/ g.e/ D .f 0 .e/ f .e// .f 0 .e/ f .e// .v/ e2ı$

C e2ı$ .v/

G

G

.v/ e2ıG

C e2ıG .v/

D b.v/ b.v/ D 0; $

so g is a circulation in G. $

For e 2 E.G/ n E.Gf / we consider two cases: If e 2 E.G/ then f .e/ D u.e/ and thus f 0 .e/ f .e/, implying g.e/ D 0. If e D e0 for some e0 2 E.G/ then f .e0 / D 0 and thus g.e0 / D 0. The last statement is easily verified: X X X c.g/ D c.e/g.e/ D c.e/f 0 .e/ c.e/f .e/ D c.f 0 /c.f /: $

e2E. G /

e2E.G/

e2E.G/

Just as Eulerian graphs can be partitioned into circuits, circulations can be decomposed into flows on single circuits: Proposition 9.6. (Ford and Fulkerson [1962]) For any circulation f in a digraph G there is a family C of atP most jE.G/j circuits in G and positive numbers h.C / (C 2 C) such that f .e/ D C 2C; e2E.C / h.C / for all e 2 E.G/. Proof: This is a special case of Theorem 8.8.

9.2

An Optimality Criterion

215

Now we can prove an optimality criterion: Theorem 9.7. (Klein [1967]) Let .G; u; b; c/ be an instance of the MINIMUM COST FLOW PROBLEM. A b-flow f is of minimum cost if and only if there is no f -augmenting cycle with negative total weight. Proof: If there is an f -augmenting cycle C with weight < 0, we can augment f along C by some " > 0 and get a b-flow f 0 with cost decreased by ". So f is not a minimum cost flow. If f is not a minimum cost b-flow, there is another b-flow f 0 with smaller cost. Consider g as defined in Proposition 9.5. Then g is a circulation with c.g/ < 0. By Proposition 9.6, g can be decomposed into flows on single circuits. Since g.e/ D 0 for all e … E.Gf /, all these circuits are f -augmenting. At least one of them must have negative total weight, proving the theorem. This result goes back essentially to Tolsto˘ı [1930] and has been rediscovered several times in different forms. One equivalent formulation is the following: Corollary 9.8. (Ford and Fulkerson [1962]) Let .G; u; b; c/ be an instance of the MINIMUM COST FLOW PROBLEM. A b-flow f is of minimum cost if and only if there exists a feasible potential for .Gf ; c/. Proof: By Theorem 9.7 f is a minimum cost b-flow if and only if Gf contains no negative circuit. By Theorem 7.7 there is no negative circuit in .Gf ; c/ if and only if there exists a feasible potential. Feasible potentials can also be regarded as solutions of the linear programming dual of the MINIMUM COST FLOW PROBLEM. This is shown by the following different proof of the above optimality criterion: Second Proof of Corollary 9.8: We write the MINIMUM COST FLOW PROBLEM as a maximization problem and consider the LP X max c.e/xe e2E.G/

s.t.

X

xe

e2ı C .v/

and its dual min

X v2V .G/

s.t.

X

xe D b.v/

.v 2 V .G//

xe u.e/ xe 0

.e 2 E.G// .e 2 E.G//

(9.1)

e2ı .v/

b.v/yv C

X

u.e/´e

e2E.G/

yv yw C ´e c.e/ ´e 0

.e D .v; w/ 2 E.G// .e 2 E.G//

(9.2)

Let x be any b-flow, i.e. any feasible solution of (9.1). By Corollary 3.23 x is optimum if and only if there exists a feasible dual solution .y; ´/ of (9.2) such that x and .y; ´/ satisfy the complementary slackness conditions

216

9 Minimum Cost Flows

´e .u.e/xe / D 0 and xe .c.e/C´e Cyv yw / D 0 for all e D .v; w/ 2 E.G/: So x is optimum if and only if there exists a pair of vectors .y; ´/ with 0 D ´e c.e/ C yv yw

for e D .v; w/ 2 E.G/ with xe < u.e/

c.e/ C yv yw D ´e 0

for e D .v; w/ 2 E.G/ with xe > 0:

and

This is equivalent to the existence of a vector y such that c.e/ C yv yw 0 for all residual edges e D .v; w/ 2 E.Gx /, i.e. to the existence of a feasible potential y for .Gx ; c/.

9.3 Minimum Mean Cycle-Cancelling Algorithm Note that Klein’s Theorem 9.7 already suggests an algorithm: first find any b-flow (using a max-flow algorithm as described above), and then successively augment along negative weight augmenting cycles until no more exist. We must however be careful in choosing the cycle if we want to have polynomial running time (see Exercise 7). A good strategy is to choose an augmenting cycle with minimum mean weight each time:

MINIMUM MEAN CYCLE-CANCELLING ALGORITHM Input:

A digraph P G, capacities u W E.G/ ! RC , numbers b W V .G/ ! R with v2V .G/ b.v/ D 0, and weights c W E.G/ ! R.

Output:

A minimum cost b-flow f .

1

Find a b-flow f .

2

Find a circuit C in Gf whose mean weight is minimum. If C has nonnegative total weight (or Gf is acyclic) then stop.

3

Compute WD min uf .e/. Augment f along C by . e2E.C /

Go to . 2 As described in Section 9.1, 1 can be implemented with any algorithm for the MAXIMUM FLOW PROBLEM. 2 can be implemented with the algorithm presented in Section 7.3. We shall now prove that this algorithm terminates after a polynomial number of iterations. The proof will be similar to the one in Section 8.3. Let .f / denote the minimum mean weight of a circuit in Gf . Then Theorem 9.7 says that a b-flow f is optimum if and only if .f / 0. We first show that .f / is non-decreasing throughout the algorithm. Moreover, we can show that it is strictly increasing with every jE.G/j iterations. As usual we denote by n and m the number of vertices and edges of G, respectively. Lemma 9.9. Let f1 ; f2 ; : : : ; f t be a sequence of b-flows such that for i D 1; : : : ; t 1 we have .fi / < 0 and fi C1 results from fi by augmenting along Ci , where Ci is a circuit of minimum mean weight in Gfi . Then

9.3

Minimum Mean Cycle-Cancelling Algorithm

217

(a) .fk / .fkC1 / for all k. n (b) .fk / n2 .fl / for all k < l such that Ck [ Cl contains a pair of reverse edges. Proof: (a): Let fk ; fkC1 be two consecutive flows in this sequence. Consider the : Eulerian graph H resulting from .V .G/; E.Ck / [ E.CkC1 // by deleting pairs of reverse edges. (Edges appearing both in Ck and CkC1 are counted twice.) Every simple subgraph of H is a subgraph of Gfk , because each edge in E.GfkC1 / n E.Gfk / must be the reverse of an edge in E.Ck /. Since H is Eulerian, it can be decomposed into circuits, and each of these circuits has mean weight at least .fk /. So c.E.H // .fk /jE.H /j. Since the total weight of each pair of reverse edges is zero, c.E.H // D c.E.Ck // C c.E.CkC1 // D .fk /jE.Ck /j C .fkC1 /jE.CkC1 /j: Since jE.H /j jE.Ck /j C jE.CkC1 /j, we conclude .fk /.jE.Ck /j C jE.CkC1 /j/ .fk /jE.H /j c.E.H // D .fk /jE.Ck /j C .fkC1 /jE.CkC1 /j; implying .fkC1 / .fk /. (b): By (a) it is enough to prove the statement for those k; l such that for k < i < l, Ci [ Cl contains no pair of reverse edges. As in the proof of (a), consider the Eulerian graph H resulting from .V .G/, : E.Ck / [ E.Cl // by deleting pairs of reverse edges. Every simple subgraph of H is a subgraph of Gfk because any edge in E.Cl / n E.Gfk / must be the reverse of an edge in one of Ck ; CkC1 ; : : : ; Cl1 . But – due to the choice of k and l – only Ck among these contains the reverse of an edge of Cl . So as in (a) we have c.E.H // .fk /jE.H /j and c.E.H // D .fk /jE.Ck /j C .fl /jE.Cl /j: Since jE.H /j jE.Ck /j C

n2 n jE.Cl /j

(we deleted at least two edges) we get

n2 jE.Cl /j .fk /jE.H /j .fk / jE.Ck /j C n c.E.H // D .fk /jE.Ck /j C .fl /jE.Cl /j; implying .fk /

n n2

.fl /.

Corollary 9.10. During the execution of the MINIMUM MEAN CYCLE-CANCE1 LLING A LGORITHM , j.f /j decreases by at least a factor of 2 with every mn iterations.

218

9 Minimum Cost Flows

Proof: Let Ck ; CkC1 ; : : : ; CkCm be the augmenting cycles in consecutive iterations of the algorithm. Since each of these circuits contains one edge as a bottleneck edge (an edge removed afterwards from the residual graph), there must be two of these circuits, say Ci and Cj (k i < j k C m) whose union contains a pair of reverse edges. By Lemma 9.9 we then have .fk / .fi /

n n .fj / .fkCm /: n2 n2

So j.f /j decreases by at least a factor of n2 n with every m iterations. The n2 n corollary follows from this because of n < e 2 < 12 . This already proves that the algorithm runs in polynomial time provided that all edge costs are integral: j.f /j is at most jcmin j at the beginning, where cmin is the minimum cost of any edge, and decreases by at least a factor of 12 with every mn iterations. So after O.mn log.njcmin j// iterations, .f / is greater than n1 . If the edge costs are integral, this implies .f / 0 and the algorithm stops. So by Corollary 7.13, the running time is O m2 n2 log.njcmin j/ . Even better, we can also derive a strongly polynomial running time for the M INIMUM COST FLOW PROBLEM (first obtained by Tardos [1985]): Theorem 9.11. (Goldberg and Tarjan [1989]) The MINIMUM MEAN CYCLECANCELLING ALGORITHM runs in O m3 n2 log n time. Proof: We show that every mn.dlog ne C 1/ iterations at least one edge is fixed, i.e. the flow on this edge will not change anymore. Therefore there are at most O m2 n log n iterations. Using Theorem 9.2 for 1 and Corollary 7.13 for 2 then proves the theorem. Let f be the flow at some iteration, and let f 0 be the flow mn.dlog ne C 1/ iterations later. Define weights c 0 by c 0 .e/ WD c.e/ .f 0 / (e 2 E.Gf 0 /). Let be a feasible potential of .Gf 0 ; c 0 / (which exists by Theorem 7.7). We have 0 c0 .e/ D c .e/ .f 0 /, so c .e/ .f 0 /

for all e 2 E.Gf 0 /:

(9.3)

Now let C be the circuit of minimum mean weight in Gf that is chosen in the algorithm to augment f . Since by Corollary 9.10 .f / 2dlog neC1 .f 0 / 2n.f 0 / (see Figure 9.2), we have X X c .e/ D c.e/ D .f /jE.C /j 2n.f 0 /jE.C /j: e2E.C /

e2E.C /

So let e0 2 E.C / with c .e0 / 2n.f 0 /. By (9.3) we have e0 … E.Gf 0 /. Claim: For any b-flow f 00 with e0 2 E.Gf 00 / we have .f 00 / < .f 0 /.

9.4 µ( f )

Successive Shortest Path Algorithm

2n µ( f )

µ( f )

219

0

Fig. 9.2.

By Lemma 9.9(a) the claim implies that e0 will never be in the residual graph anymore, i.e. e0 and e0 are fixed mn.dlog ne C 1/ iterations after e0 is used in C . This completes the proof. To prove the claim, let f 00 be a b-flow with e0 2 E.Gf 00 /. We apply Proposition 9.5 to f 0 and f 00 and obtain a circulation g with g.e/ D 0 for all e … E.Gf 0 / and g.e0 / > 0 (because e0 2 E.Gf 00 / n E.Gf 0 /). By Proposition 9.6, g can be written as the sum of flows on f 0 -augmenting cycles. One of these circuits, say W , must contain e0 . By using c .e0 / D c .e0 / 2n.f 0 / and applying (9.3) to all e 2 E.W / n fe0 g we obtain a lower bound for the total weight of W : X c.E.W // D c .e/ 2n.f 0 / C .n 1/.f 0 / > n.f 0 /: e2E.W /

But the reverse of W is an f 00 -augmenting cycle (this can be seen by exchanging the roles of f 0 and f 00 ), and its total weight is less than n.f 0 /. This means that Gf 00 contains a circuit whose mean weight is less than .f 0 /, and so the claim is proved. The MINIMUM MEAN CYCLE-CANCELLING ALGORITHM was generalized in various ways by Karzanov and McCormick [1997].

9.4 Successive Shortest Path Algorithm The following theorem gives rise to another algorithm: Theorem 9.12. (Jewell [1958], Iri [1960], Busacker and Gowen [1961]) Let .G; u; b; c/ be an instance of the MINIMUM COST FLOW PROBLEM, and let f be a minimum cost b-flow. Let P be a shortest (with respect to c) s-t-path in Gf (for some s and t). Let f 0 be a flow obtained when augmenting f along P by at most the minimum residual capacity on P . Then f 0 is a minimum cost b 0 -flow (for some b 0 ). Proof: f 0 is a b 0 -flow for some b 0 . Suppose f 0 is not a minimum cost b 0 -flow. Then by Theorem 9.7 there is a circuit C in Gf 0 with negative total weight. Consider : the graph H resulting from .V .G/; E.C / [ E.P // by deleting pairs of reverse edges. (Again, edges appearing both in C and P are taken twice.) For any edge e 2 E.Gf 0 / n E.Gf /, the reverse of e must be in E.P /. Therefore every simple subgraph of H is a subgraph of Gf . As f is a minimum cost b-flow, no circuit in Gf , and hence in H , has negative total weight.

220

9 Minimum Cost Flows

We have c.E.H // D c.E.C // C c.E.P // < c.E.P //. Furthermore, H is the union of an s-t-path and some circuits. None of these circuits has negative weight. Therefore H , and thus Gf , contains an s-t-path of less weight than P , contradicting the choice of P . If the weights are conservative, we can start with f 0 as an optimum circulation (b-flow with b 0). Otherwise we can initially saturate all edges of negative cost, i.e., set f .e/ WD u.e/ for e 2 F WD fe 0 2 E.G/ W c.e 0 / < 0g and f .e/ WD 0 for e 2 E.G/ n F , and find a minimum cost b 0 -flow in .Gf ; uf /, where b 0 .v/ D b.v/ C exf .v/ for v 2 V .G/. For instances with infinite capacities more work is needed; see Exercise 5.

SUCCESSIVE SHORTEST PATH ALGORITHM Input:

A digraph P G, capacities u W E.G/ ! RC , numbers b W V .G/ ! R with v2V .G/ b.v/ D 0, and conservative weights c W E.G/ ! R.

Output:

A minimum cost b-flow f .

1

Set b 0 WD b and f .e/ WD 0 for all e 2 E.G/.

2

If b 0 D 0 then stop, else: Choose a vertex s with b 0 .s/ > 0. Choose a vertex t with b 0 .t/ < 0 such that t is reachable from s in Gf . If there is no such t then stop. (There exists no b-flow.) Find an s-t-path P in Gf of minimum weight. 0 0 Compute WD min min uf .e/; b .s/; b .t/ .

3 4

e2E.P /

Set b 0 .s/ WD b 0 .s/ and b 0 .t/ WD b 0 .t/ C . Augment f along P by . Go to . 2 If we allow arbitrary capacities, we have the same problems as with the FORDFULKERSON ALGORITHM (see Exercise 2 of Chapter 8; set all costs to zero). So henceforth we assume u and Pb to be integral. Then it is clear that the algorithm stops after at most B WD 12 v2V .G/ jb.v/j augmentations. By Theorem 9.12, the resulting flow is optimum if the initial zero flow is optimum. This is true if and only if c is conservative. We remark that if the algorithm decides that there is no b-flow, this decision is indeed correct. This is an easy observation, left as Exercise 13. Each augmentation requires a shortest path computation. Since negative weights occur, we have to use the MOORE-BELLMAN-FORD ALGORITHM whose running time is O.nm/ (Theorem 7.5), so the overall running time will be O.Bnm/. However, as in the proof of Theorem 7.8, it can be arranged that (except at the beginning) the shortest paths are computed in a graph with nonnegative weights:

9.4

Successive Shortest Path Algorithm

221

Theorem 9.13. (Tomizawa [1971], Edmonds and Karp [1972]) If u and b are integral, the SUCCESSIVE SHORTEST PATH ALGORITHM can Pbe implemented with a running time of O .nm C B.m C n log n//, where B D 12 v2V .G/ jb.v/j. Proof: We introduce a potential i W V .G/ ! R for each iteration i of the SUCCESSIVE SHORTEST PATH A LGORITHM . We start with any feasible potential 0 of .G; c/. By Corollary 7.7, this exists and can be computed in O.mn/ time. Now let fi 1 be the flow before iteration i . Then the shortest path computation in iteration i is done with the reduced costs ci 1 instead of c. Moreover, we extend Gfi 1 to Gf0 by adding edges .t; v/ of zero weight for all v 2 V .G/ (this is i 1 to ensure that all vertices are reachable from s). Let li .v/ denote the length of a shortest s-v-path in Gf0 with respect to the weights ci 1 . Then we set i .v/ WD i 1 i 1 .v/ C li .v/. We prove by induction on i that i is a feasible potential for .Gfi ; c/. This is clear for i D 0. For i > 0 and any edge e D .x; y/ 2 E.Gfi 1 / we have (by definition of li and the induction hypothesis) li .y/ li .x/ C ci 1 .e/ D li .x/ C c.e/ C i 1 .x/ i 1 .y/; so ci .e/ D c.e/Ci .x/i .y/ D c.e/Ci 1 .x/Cli .x/i 1 .y/li .y/ 0: For any edge e D .x; y/ 2 Pi (where Pi is the augmenting path in iteration i ) we have li .y/ D li .x/ C ci 1 .e/ D li .x/ C c.e/ C i 1 .x/ i 1 .y/; so ci .e/ D 0, and the reverse edge of e also has zero weight. Since each edge in E.Gfi / n E.Gfi 1 / is the reverse of an edge in Pi , ci is indeed a nonnegative weight function on E.Gfi /. We observe that in iteration i the shortest s-t-paths in Gfi 1 with respect to c are precisely the shortest s-t-paths in Gf0 with respect to ci 1 , because the added i 1 edges leaving t cannot occur and ci 1 .P / c.P / D i 1 .s/ i 1 .t/ for any s-t-path P . Hence we can use DIJKSTRA’S ALGORITHM – which runs in O .m C n log n/ time when implemented with a Fibonacci heap by Theorem 7.4 – for all shortest path computations except the initial one. Since we have at most B iterations, we obtain an overall running time of O .nm C B.m C n log n//. The running time of Theorem 9.13 is still exponential unless B is known to be small. If B D O.n/, this is the fastest algorithm known. For an application, see Section 11.1. In the rest of this section we show how to modify the algorithm in order to reduce the number of shortest path computations. We only consider the case when all capacities are infinite. By Lemma 9.3 each instance of the MINIMUM COST FLOW

222

9 Minimum Cost Flows

PROBLEM can be transformed to an equivalent instance with infinite capacities. The basic idea – due to Edmonds and Karp [1972] – is the following. In early iterations we consider only augmenting paths where – the amount of flow that can be pushed – is large. We start with D 2blog bmax c and reduce by a factor of two if no more augmentations by can be done. After blog bmax c C 1 iterations we have D 1 and stop (we again assume b to be integral). Such a scaling technique has proved useful for many algorithms (see also Exercise 14). A detailed description of the first scaling algorithm reads as follows:

CAPACITY SCALING ALGORITHM Input:

Output: 1 2

3 4 5

A digraph G with infinite P capacities u.e/ D 1 (e 2 E.G/), numbers b W V .G/ ! Z with v2V .G/ b.v/ D 0, and conservative weights c W E.G/ ! R. A minimum cost b-flow f .

Set b 0 WD b and f .e/ WD 0 for all e 2 E.G/. Set D 2blog bmax c , where bmax D maxfb.v/ W v 2 V .G/g. If b 0 D 0 then stop, else: Choose a vertex s with b 0 .s/ . Choose a vertex t with b 0 .t/ such that t is reachable from s in Gf . If there is no such s or t then go to . 5 Find an s-t-path P in Gf of minimum weight. Set b 0 .s/ WD b 0 .s/ and b 0 .t/ WD b 0 .t/ C . Augment f along P by . Go to . 2 If D 1 then stop. (There exists no b-flow.) Else set WD 2 and go to . 2

Theorem 9.14. (Edmonds and Karp [1972]) The CAPACITY SCALING ALGORITHM correctly solves the M INIMUM COST FLOW PROBLEM for integral b, infinite capacities and conservative weights. It can be implemented to run in O.n.m C n log n/ log.2 C bmax // time, where bmax D maxfb.v/ W v 2 V .G/g. Proof: As above, the correctness follows directly from Theorem 9.12. Note that at any time, the residual capacity of any edge is either infinite or an integral multiple of . To establish the running time, we call the period in which remains constant a phase. We prove that there are at most n augmentations within each phase. Let , f , and b 0 be the values at the beginning of some phase. Let S WD fv 2 V .G/ W b 0 .v/ g, S C WD fv 2 V .G/ W b 0 .v/ 2 g, T WD fv 2 V .G/ W b 0 .v/ g, and T C WD fv 2 V .G/ W b 0 .v/ 2 g. Let R be the set of vertices that are reachable from some element of S C in Gf . Note that S C R. We also have R \ T C D ;, because otherwise the previous phase would not have ended.

9.5

Orlin’s Algorithm

223

Let .si ; ti /, i D 1; : : : ; k, be the pairs .s; t/ in the considered phase; repetitions C are of course possible. As ıG .R/ D ;, we have jfi W si 2 R; ti … Rgj jfi W f si … R; ti 2 Rgj. Thus we can bound the number k of iterations in this phase by k jfi W si ; ti 2 Rgj C 2jfi W si … R; ti 2 Rgj C jfi W si ; ti … Rgj D jfi W ti 2 Rgj C jfi W si … Rgj jT \ Rj C jS n Rj n, where the second to last inequality holds because T C \ R D ; and S C n R D ;. This means that the total number of shortest path computations is O.n log.2 C bmax //. Combining this with the technique of Theorem 9.13 we obtain the O.mn C n log.2 C bmax /.m C n log n// bound. This was the first polynomial-time algorithm for the M INIMUM COST FLOW PROBLEM. By some further modifications we can even obtain a strongly polynomial running time. This is the subject of the next section.

9.5 Orlin’s Algorithm The CAPACITY SCALING ALGORITHM of the previous section can be improved further. A basic idea is that if an edge carries more than 2n units of flow at any stage of the CAPACITY SCALING ALGORITHM, it may be contracted. Namely, observe that such an edge will always keep a positive flow (and thus zero reduced cost with respect to any feasible potential in the residual graph): there are at most n more augmentations by , another n by 2 and so on; hence the total amount of flow moved in the rest of the algorithm is less than 2n . We shall describe ORLIN’S ALGORITHM without explicitly using contraction. This simplifies the description, especially from the point of view of implementing the algorithm. A set F keeps track of the edges (and their reverse edges) that can be contracted. .V .G/; F / will always arise from a forest by orienting each edge in both directions. A representative is chosen out of each connected component of .V .G/; F /. The algorithm maintains the property that the representative of a connected component is its only non-balanced vertex. This will lead to more augmentations in each phase, but still by less than 4n . For any vertex x, r.x/ denotes the representative of the connected component of .V .G/; F / containing x. G 0 denotes the subgraph of G containing the edges in F and all edges .x; y/ with r.x/ 6D r.y/. Edges outside G 0 will not be used anymore. ORLIN’S ALGORITHM does not require that b is integral. However, it can deal with uncapacitated problems only (but recall Lemma 9.3).

ORLIN’S ALGORITHM Input:

Output:

A digraph G with infinite P capacities u.e/ D 1 (e 2 E.G/), numbers b W V .G/ ! R with v2V .G/ b.v/ D 0, and conservative weights c W E.G/ ! R. A minimum cost b-flow f .

224

1

9 Minimum Cost Flows

Set b 0 WD b and f .e/ WD 0 for all e 2 E.G/. Set r.v/ WD v for all v 2 V .G/. Set F WD ; and G 0 WD G. Set D max jb 0 .v/j. v2V .G/

0

2

If b D 0 then stop.

3

. Choose a vertex s with b 0 .s/ > n1 n If there is no such s then go to . 4 Choose a vertex t with b 0 .t/ < n1 such that t is reachable from s in Gf . If there is no such t then stop. (There exists no b-flow.) Go to . 5

4

Choose a vertex t with b 0 .t/ < n1 n . If there is no such t then go to . 6 Choose a vertex s with b 0 .s/ > n1 such that t is reachable from s in Gf . If there is no such s then stop. (There exists no b-flow.) Find an s-t-path P in Gf0 of minimum weight. Set b 0 .s/ WD b 0 .s/ and b 0 .t/ WD b 0 .t/ C . Augment f along P by . Go to . 2 0 0 ; max / n F then set WD min jb .v/j , If f .e/ D 0 for all e 2 E.G 2 v2V .G/ else set WD 2 .

5

6

7

8

While there is an e D .x; y/ 2 E.G 0 / n F with f .e/ > 6n do: Set F WD F [ fe; e g. Let x 0 WD r.x/ and y 0 WD r.y/. Let Q be the x 0 -y 0 -path in F . If b 0 .x 0 / > 0 then augment f along Q by b 0 .x 0 /, else augment f along the reverse of Q by b 0 .x 0 /. 0 0 Set b .y / WD b 0 .y 0 / C b 0 .x 0 / and b 0 .x 0 / WD 0. For all e 0 D .v; w/ 2 E.G 0 / n F with fr.v/; r.w/g D fx 0 ; y 0 g do: Set E.G 0 / WD E.G 0 / n fe 0 g. Set r.´/ WD y 0 for all vertices ´ reachable from y 0 in F . Go to . 2

This algorithm is due to Orlin [1993]. See also (Plotkin and Tardos [1990]). We first prove its correctness. Let us call the time between two changes of a phase. We call a vertex v important if jb 0 .v/j > n1 . A phase ends when there is no n important vertex. Lemma 9.15. The number of augmentations in 5 during one phase is at most the number of important vertices at the beginning of this phase plus the number of augmentations in 7 at the beginning of this phase. l 0 m P jb .v/j n1 by Proof: Each augmentation in 5 decreases ˆ WD v2V .G/ n at least one, while an augmentation in 7 cannot increase ˆ by more than one.

9.5

Orlin’s Algorithm

225

Moreover, ˆ is the number of important vertices at the beginning of each phase. Lemma 9.16. ORLIN’S ALGORITHM solves the uncapacitated MINIMUM COST FLOW PROBLEM with conservative weights correctly. At any stage f is a minimumcost .b b 0 /-flow. Proof: We first prove that f is always a .b b 0 /-flow. In particular, we have to show that f is always nonnegative. To this end, we first observe that at any time the flow on each edge in E.G 0 / n F , and hence also the residual capacity of the reverse edge, is an integral multiple of . Moreover we claim that every edge e 2 F always has positive residual capacity. To see this, first observe that after e has become a member of F in the -phase there are at most n 1 augmentations in , 7 each by less than 2 . Moreover, any phase has at most 2n 1 augmentations by in 5 (cf. Lemma 9.15); hence the total amount of flow moved after e has become a member of F in the -phase is less than 2n in , 7 less than 2n in 5 during this phase, less than 2n 2 in 5 during the next phase, and so on, thus less than 6n overall. Hence we always have positive flow on every edge in F \ E.G/. Hence f is always nonnegative and thus it is always a .b b 0 /-flow. We now prove that f is always a minimum cost .b b 0 /-flow. This is true initially because c is conservative. While f is an optimum .b b 0 /-flow, each v-w-path in .V .G/; F / is a shortest v-w-path in Gf (a shorter path would result in a negative circuit in Gf ). Now the claim follows from Theorem 9.12: P in 5 and Q in 7 are shortest paths in Gf0 and .V .G/; F /, respectively, and hence in Gf (note that for any .v; w/ 2 E.Gf / n E.Gf0 / there is a v-w-path in .V .G/; F /). We finally show that if the algorithm stops in 3 or 4 with b 0 6D 0, then there is indeed no b-flow. Suppose the algorithm stops in , 3 implying that there is a vertex s with b 0 .s/ > n1 , but that no vertex t with b 0 .t/ < n1 is reachable from n s in Gf . ThenP let R be the set of vertices reachable from s in Gf . Since f is a .b b 0 /-flow, x2R .b.x/ b 0 .x// D 0. Therefore we have X X X b.x/ D b 0 .x/ D b 0 .s/ C b 0 .x/ > 0 x2R

x2R

x2Rnfsg

C but ıG .R/ D ;. This proves that no b-flow exists. An analogous proof applies in the case that the algorithm stops in . 4

We now analyse the running time. Lemma 9.17. (Plotkin and Tardos [1990]) If a vertex ´ is important at some stage of the algorithm, then the connected component of .V .G/; F / containing ´ increases during the next d2 log n C log me C 3 phases. Proof: Let jb 0 .´/j > n1 1 for a vertex ´ at the beginning of some phase of n the algorithm where D 1 . Let 0 be the -value in the preceding phase (and

226

9 Minimum Cost Flows

0 D 21 if there is none), and 2 the -value d2 log n C log me C 2 phases later. We have 12 0 1 4n2 m2 . Let b10 and f1 be the b 0 and f at the beginning of the 1 -phase, respectively, and let b20 and f2 be the b 0 and f at the end of the 2 -phase, respectively. Let Z be the connected component of .V .G/; F / containing ´ in the 1 -phase, and suppose that this remains unchanged for the d2 log n C log me C 3 phases considered. Note that 7 guarantees b 0 .v/ D 0 for all vertices v with r.v/ 6D v. Hence b 0 .v/ D 0 for all v 2 Z n f´g and X X X X b.x/ b10 .´/ D .b.x/ b10 .x// D f1 .e/ f1 .e/: (9.4) x2Z

x2Z

e2ı C .Z/

e2ı .Z/

The right-hand side is an integral multiple of 0 , and 1 n1 n1 1 1 1 < jb10 .´/j 0 < 0 1 : n n n n

(9.5)

ˇ ˇ ˇX ˇ 1 ˇ ˇ b.x/ˇ > 1 : (9.6) ˇ ˇ ˇ n x2Z P P P As in (9.4), we have e2ı C .Z/ f2 .e/ e2ı .Z/ f2 .e/ D x2Z b.x/b20 .´/. Using (9.6) and jb20 .´/j n1 2 we obtain n ˇ ˇ ˇX ˇ X 1 n1 ˇ ˇ 2 jf2 .e/j ˇ b.x/ˇ jb20 .´/j > 1 ˇ ˇ n n C x2Z e2ı .Z/[ı .Z/ 2 : > .4nm 1/2 > m 6n 2

Hence

Thus there exists at least one edge e with exactly one end in Z and f2 .e/ > 6n 22 . By 7 of the algorithm, this means that Z is increased at the beginning of the 22 phase. Theorem 9.18. (Orlin [1993]) ORLIN’S ALGORITHM solves the uncapacitated MINIMUM COST FLOW PROBLEM with conservative weights correctly in O.n log n.m C n log n// time. Proof: The correctness has been proved above (Lemma 9.16). In each phase, 7 takes O.m.i C 1// time, where i is the number of iterations in the while-loop. Note that the total number of iterations in this while-loop is at most n 1 as the number of connected components of .V .G/; F / decreases each time. By 6 and , 7 there can be at most dlog ne C 3 subsequent phases without an important vertex. Therefore, Lemma 9.17 implies that the total number of phases is O.n log m/. By Lemma 9.15, the total number of augmentations in 5 is at most n 1 plus the number of pairs .; ´/, where ´ is important at the beginning of the -phase. By

9.6

The Network Simplex Algorithm

227

Lemma 9.17, and since all vertices v with r.v/ 6D v have b 0 .v/ D 0 at any time, the number of these pairs is O.log m/ times the number of sets that are at some stage of the algorithm a connected component of .V .G/; F /. Since the family of these sets is laminar, there are at most 2n 1 such sets (Corollary 2.15), and thus O.n log m/ augmentations in 5 altogether. Using the technique of Theorem 9.13, we obtain an overall running time of O .mn log m C .n log m/.m C n log n//. We may assume m D O.n2 /, and thus log m D O.log n/, because among a set of uncapacitated parallel edges we need only a cheapest one. This is the best known running time for the uncapacitated M INIMUM COST FLOW PROBLEM. Theorem 9.19. (Orlin [1993]) The general MINIMUM COST FLOW PROBLEM can be solved in O .m log m.m C n log n// time, where n D jV .G/j and m D jE.G/j. Proof: We apply the construction given in Lemma 9.3. Thus we have to solve an uncapacitated MINIMUM COST FLOW PROBLEM on a bipartite graph H with : V .H / D A0 [ B 0 , where A0 D E.G/ and B 0 D V .G/. Since H is acyclic, an initial feasible potential can be computed in O.jE.H /j/ D O.m/ time. As shown above (Theorem 9.18), the overall running time is bounded by O.m log m/ shortest $

path computations in a subgraph of H with nonnegative weights. Before we call DIJKSTRA’S ALGORITHM we apply the following operation to each vertex a 2 A0 that is not an endpoint of the path we are looking for: add an edge .b; b 0 / for each pair of edges .b; a/; .a; b 0 / and set its weight to the sum of the weights of .b; a/ and .a; b 0 /; finally delete a. Clearly the resulting instance of the SHORTEST PATH PROBLEM is equivalent. Since each vertex in A0 has four incident $

edges in H , the resulting graph has O.m/ edges and at most n C 2 vertices. The preprocessing takes constant time per vertex, i.e. O.m/. The same holds for the final $

computation of the path in H and of the distance labels of the deleted vertices. We get an overall running time of O ..m log m/.m C n log n//. This is the fastest known strongly polynomial algorithm for the general M INICOST FLOW PROBLEM. An algorithm which achieves the same running time but works directly on capacitated instances has been described by Vygen [2002]. MUM

9.6 The Network Simplex Algorithm The MINIMUM COST FLOW PROBLEM is a special case of LINEAR PROGRAMMING. By applying the SIMPLEX A LGORITHM and exploiting the special structure we arrive at what is called the NETWORK SIMPLEX ALGORITHM. To make the connection clear, we first characterize the set of basic solutions (although we will not need this to prove correctness).

228

9 Minimum Cost Flows

Definition 9.20. Let .G; u; b; c/ be an instance of the MINIMUM COST FLOW PROBLEM. A b-flow f in .G; u/ is a spanning tree solution if .V .G/; fe 2 E.G/ W 0 < f .e/ < u.e/g/ contains no undirected circuit. Proposition 9.21. An instance of the MINIMUM COST FLOW PROBLEM either has an optimum solution which is a spanning tree solution or has no optimum solution at all. Proof: Given an optimum solution f and an undirected circuit C in .V .G/; fe 2 E.G/ W 0 < f .e/ < u.e/g/, we have two directed circuits C 0 and C 00 in Gf with the same underlying undirected graph as C . Let be the minimum residual capacity in E.C 0 / [ E.C 00 /. We can obtain two other feasible solutions f 0 and f 00 by augmenting f by along C 0 and C 00 , respectively. As 2c.f / D c.f 0 / C c.f 00 /, both f 0 and f 00 are also optimum solutions. At least one of them has fewer edges e with 0 < f .e/ < u.e/ than f , so after less than jE.G/j steps we arrive at an optimum spanning tree solution. Corollary 9.22. Let .G; u; b; c/ be an instance of the MINIMUM COST FLOW PROBLEM. Then the basic solutions of ( x 2 RE.G/ W 0 xe u.e/ .e 2 E.G//; X e2ı C .v/

xe

X

) xe D b.v/ .v 2 V .G//

e2ı .v/

are precisely the spanning tree solutions of .G; u; b; c/. Proof: Proposition 9.21 shows that each basic solution is a spanning tree solution. For a spanning tree solution f we consider the inequalities xe 0 for eP2 E.G/ withPf .e/ D 0, xe u.e/ for e 2 E.G/ with f .e/ D u.e/, and e2ı C .v/ xe e2ı .v/ xe D b.v/ for all v except one vertex of each connected component of .V .G/; fe 2 E.G/ W 0 < f .e/ < u.e/g/. These jE.G/j inequalities are all satisfied by f with equality, and the submatrix corresponding to these inequalities is nonsingular. Thus f is a basic solution. In a spanning tree solution there are three types of edges: those with zero flow, those with saturated capacity, and those whose flow is positive but less than the capacity. Assuming that G is connected, we can extend the last set of edges to a connected spanning subgraph without undirected circuits (i.e., an oriented spanning tree; hence the name “spanning tree solution”). Definition 9.23. Let .G; u; b; c/ be an instance of the MINIMUM COST FLOW PROBLEM where G is connected. A spanning tree structure is a quadruple : : .r; T; L; U / where r 2 V .G/, E.G/ D T [ L [ U , jT j D jV .G/j 1, and .V .G/; T / contains no undirected circuit. The b-flow associated with the spanning tree structure .r; T; L; U / is defined by

9.6

The Network Simplex Algorithm

229

f .e/ WD 0 for e 2 L, f .e/ WD u.e/ P for e 2 U , P P f .e/ WD v2Ce b.v/ C e2U \ı .Ce / u.e/ e2U \ı C .Ce / u.e/ for e 2 T , where for e D .v; w/ we denote by Ce the connected component of .V .G/; T n feg/ containing v. .r; T; L; U / is called feasible if 0 f .e/ u.e/ for all e 2 T . Call an edge .v; w/ in T downward if v belongs to the undirected r-w-path in T , otherwise upward. .r; T; L; U / is called strongly feasible if 0 < f .e/ u.e/ for each downward edge e 2 T and 0 f .e/ < u.e/ for each upward edge e 2 T . The unique function W V .G/ ! R with .r/ D 0 and c .e/ D 0 for all e 2 T is called the potential associated with the spanning tree structure .r; T; L; U /. b-flow f associated with a spanning tree structure satisfies P Evidently the P f .e/ C e2ı .v/ e2ı .v/ f .e/ D b.v/ for all v 2 V .G/ (though it is not always a feasible b-flow). Moreover we note: Proposition 9.24. Given an instance .G; u; b; c/ of the MINIMUM COST FLOW PROBLEM and a spanning tree structure .r; T; L; U /, the b-flow f and the potential associated with it can be computed in O.m/ and O.n/ time, respectively. Moreover, f is integral whenever b and u are integral, and is integral whenever c is integral. Proof: The potential associated with .r; T; L; U / can be computed simply by applying the GRAPH SCANNING ALGORITHM to the edges of T and their reverse edges. The b-flow associated with .r; T; L; U / can be computed in linear time by scanning the vertices in an order of nonincreasing distance from r. The integrality properties follow immediately from the definition. The NETWORK SIMPLEX ALGORITHM maintains a strongly feasible spanning tree structure and works towards optimality. Note that the optimality criterion in Corollary 9.8 immediately implies: Proposition 9.25. Let .r; T; L; U / be a feasible spanning tree structure and let be the potential associated with it. Suppose that c .e/ 0 for all e 2 L, and c .e/ 0 for all e 2 U . Then .r; T; L; U / is associated with an optimum b-flow.

$

Note that .v/ is the length of the r-v-path in G that contains only edges of T $

or their reverse edges. For an edge e D .v; w/ 2 E.G/ we define the fundamental circuit C of e to consist of e and the w-v-path that contains only edges of T and their reverse edges. The vertex of C that is closest to r in T is called its peak. Hence for e D .v; w/ … T , c .e/ D c.e/ C .v/ .w/ is the cost of sending one unit of flow along the fundamental circuit of e.

230

9 Minimum Cost Flows

There are several ways to obtain an initial feasible spanning tree structure. For example, one could compute any b-flow (by solving a MAXIMUM FLOW PROBLEM), apply the procedure in the proof of Proposition 9.21, choose r arbitrarily, and define T; L; U according to the flow (adding suitable edges to T if necessary). Alternatively, one could apply “phase one” of the SIMPLEX METHOD. However, this may not lead to a strongly feasible spanning tree structure. The simplest possibility is to introduce very expensive auxiliary edges with sufficient capacity between r and each other vertex: For each sink v 2 V .G/nfrg we introduce an edge .r; v/ with capacity b.v/, and for each other vertex v 2 V .G/ n frg we introduce an edge .v; r/ with capacity b.v/ C 1. The cost of each auxiliary edge should be high enough so that they never occur in an optimum solution, for example 1 C .jV .G/j 1/ maxe2E.G/ jc.e/j (Exercise 20). Then we can choose T as the set of all auxiliary edges, L as the set of all original edges, and U WD ; to obtain an initial strongly feasible spanning tree structure.

NETWORK SIMPLEX ALGORITHM Input: Output:

An instance .G; u; b; c/ of the MINIMUM COST FLOW PROBLEM and a strongly feasible spanning tree structure .r; T; L; U /. An optimum solution f .

1

Compute the b-flow f and the potential associated with .r; T; L; U /.

2

Let e 2 L with c .e/ < 0 or e 2 U with c .e/ > 0. If such an edge e does not exist then stop.

3

Let C be the fundamental circuit of e (if e 2 L) or of e (if e 2 U ). Let WD c .e/. Let ı WD mine0 2E.C / uf .e 0 /, and let e 0 be the last edge where the minimum is attained when traversing C in its orientation, starting at its peak. Let e0 2 E.G/ such that e 0 is e0 or e0 . Remove e from L or U . Set T WD .T [ feg/ n fe0 g. If e 0 D e0 then insert e0 into U else insert e0 into L. Augment f by ı along C . Let X be the connected component of .V .G/; T n feg/ containing r. If e 2 ı C .X / then set .v/ WD .v/ C for v 2 V .G/ n X . If e 2 ı .X / then set .v/ WD .v/ for v 2 V .G/ n X . Go to . 2

4

5

6

We remark that 6 could be replaced simply by going back to , 1 as f and computed in 6 are associated with the new spanning tree structure. Also note that e D e0 is possible; in this case X D V .G/, and T and do not change, but e moves from L to U or vice versa, and ı D u.e/.

9.7

Flows Over Time

231

Theorem 9.26. (Dantzig [1951], Cunningham [1976]) The NETWORK SIMPLEX ALGORITHM stops after finitely many iterations and returns an optimum solution. Proof: First observe that 6 maintains the property that f and are the b-flow and potential associated with .r; T; L; U /. Next we prove that the spanning tree structure is always strongly feasible. By the choice of ı we maintain the condition 0 f .e/ u.e/ for all e, and hence the spanning tree structure remains feasible. As the edges of the subpath of C from the head of e 0 to the peak did not attain the minimum in , 4 they will continue to have positive residual capacity after the augmentation. For the edges of the subpath of C from the peak to the tail of e 0 we have to make sure that their reverse edges have positive residual capacity after the augmentation. This is clear if ı > 0. Otherwise (if ı D 0), the fact that the spanning tree structure was strongly feasible before implies that neither e nor e can belong to this subpath (i.e. e D e0 or ı .X / \ E.C / \ fe; e g 6D ;), and that the reverse edges of the subpath of C from the peak to tail of e or e had positive residual capacity. By Proposition 9.25 the computed flow f is optimum when the algorithm terminates. We show that there are no two iterations with the same pair .f; /, and hence each spanning tree structure occurs at most once. In each iteration the cost of the flow is reduced by j jı. As 6D 0, we only need to consider iterations with ı D 0. Here the cost of the flow P remains constant. If e 6D e0 , then e 2 L \ ı .X / or e 2 U \ ı C .X /, and hence v2V .G/ .v/ strictly increases (by at least j j). Finally, if ı D 0 and e D e0 , then u.e/ D 0, X D V .G/, remains constant, and jfe 2 L W c .e/ < 0gj C jfe 2 U W c .e/ > 0gj strictly decreases. This shows that no two iterations feature the same spanning tree structure. Although the NETWORK SIMPLEX ALGORITHM is not a polynomial-time algorithm, it is quite efficient in practice. Orlin [1997] proposed a variant that runs in polynomial time. Polynomial-time dual network simplex algorithms were found by Orlin, Plotkin and Tardos [1993], and Armstrong and Jin [1997].

9.7 Flows Over Time We now consider flows over time (also sometimes called dynamic flows); i.e. the flow value on each edge may change over time, and flow entering an edge arrives at the endvertex after a specified delay: Definition 9.27. Let .G; u; s; t/ be a network with transit times l W E.G/ ! RC and a time horizon T 2 RC . Then an s-t-flow over time f consists of a Lebesguemeasurable function fe W Œ0; T ! RC for each e 2 E.G/ with fe ./ u.e/ for all 2 Œ0; T and e 2 E.G/ and

232

9 Minimum Cost Flows

exf .v; a/ WD

X Z e2ı .v/

X Z

maxf0;al.e/g

fe ./d

0

e2ı C .v/

a 0

fe ./d 0 (9.7)

for all v 2 V .G/ n fsg and a 2 Œ0; T . fe ./ is called the rate of flow entering e at time (and leaving this edge l.e/ time units later). (9.7) allows intermediate storage at vertices, like in s-t-preflows. It is natural to maximize the flow arriving at sink t:

MAXIMUM FLOW OVER TIME PROBLEM Instance: Task:

A network .G; u; s; t/. Transit times l W E.G/ ! RC and a time horizon T 2 RC . Find an s-t-flow over time f such that value .f / WD exf .t; T / is maximum.

Following Ford and Fulkerson [1958], we show that this problem can be reduced to the MINIMUM COST FLOW PROBLEM. Theorem 9.28. The MAXIMUM FLOW OVER TIME PROBLEM can be solved in the same time as the MINIMUM COST FLOW PROBLEM. Proof: Given an instance .G; u; s; t; l; T / as above, define a new edge e 0 D .t; s/ and G 0 WD G C e 0 . Set u.e 0 / WD u.E.G// C 1, c.e 0 / WD T and c.e/ WD l.e/ for e 2 E.G/. Consider the instance .G 0 ; u; 0; c/ of the MINIMUM COST FLOW PROBLEM. Let f 0 be an optimum solution, i.e. a minimum cost (with respect to c) circulation in .G 0 ; u/. By Proposition 9.6, f 0 can be decomposed into flows on 0 circuits, i.e. there P is a set C of circuits in G and positive numbers h W C ! RC such 0 that f .e/ D fh.C / W C 2 C; e 2 E.C /g. We have c.E.C // 0 for all C 2 C as f 0 is a minimum cost circulation. Let C 2 C with c.E.C // < 0. C must contain e 0 . For e D .v; w/ 2 E.C /nfe 0 g, let deC be the distance from s to v in .C; c/. Set o Xn fe ./ WD h.C / W C 2 C ; c.E.C // < 0; e 2 E.C /; deC deC c.E.C // for e 2 E.G/ and 2 Œ0; T . This defines an s-t-flow over time without intermediate storage (i.e. exf .v; a/ D 0 for all v 2 V .G/ n fs; tg and all a 2 Œ0; T ). Moreover,

value .f / D

X Z e2ı .t /

T l.e/ 0

fe ./d D

X

c.e/f 0 .e/:

e2E.G 0 /

We claim that f is optimum. To see this, let f be any s-t-flow over time, and set fe ./ WD 0 for e 2 E.G/ and … Œ0; T . Let .v/ WD T Cminf0; dist.G 0 0 ;c/ .t; v/g f for v 2 V .G/. As Gf0 0 contains no negative circuit (cf. Theorem 9.7), is a feasible potential in .Gf0 0 ; c/. We have

Exercises

value .f / D exf .t; T /

X

233

exf .v; .v//

v2V .G/

because of (9.7), .t/ D T , .s/ D 0 and 0 .v/ T for all v 2 V .G/. Hence ! Z .w/l.e/ Z .v/ X fe ./d fe ./d value .f / eD.v;w/2E.G/

X

0

0

..w/ l.e/ .v//u.e/

eD.v;w/2E.G/W.w/l.e/>.v/

X

D

..w/ l.e/ .v//f 0 .e/

eD.v;w/2E.G/

X

D

..w/ c.e/ .v//f 0 .e/

eD.v;w/2E.G 0 /

X

D

c.e/f 0 .e/

eD.v;w/2E.G 0 /

D value .f /:

Other flow over time problems are significantly more difficult. Hoppe and Tardos [2000] solved the so-called quickest transshipment problem (with several sources and sinks) with integral transit times using submodular function minimization (see Chapter 14). Finding minimum cost flows over time is NP-hard (Klinz and Woeginger [2004]). See Fleischer and Skutella [2007] for approximation algorithms and more information.

Exercises 1. Show that the M AXIMUM FLOW PROBLEM can be regarded as a special case of the MINIMUM COST FLOW PROBLEM. 2. Let G be a digraph with lower and upper capacities l; u W E.G/ ! RC , where l.e/ u.e/ for all e 2 E.G/, and let b1 ; b2 W V .G/ ! R with b1 .v/ b2 .v/ for all v 2 V .G/. Prove that there exists a flow f with l.e/ f .e/ u.e/ for all e 2 E.G/ and X X b1 .v/ f .e/ f .e/ b2 .v/ for all v 2 V .G/ e2ı .v/

e2ı C .v/

if and only if X e2ı C .X/

u.e/ max

8 <X :

v2X

b1 .v/;

X

v2V .G/nX

9 = b2 .v/

;

C

X e2ı .X/

l.e/

234

9 Minimum Cost Flows

for all X V .G/. Note: This generalizes Exercise 4 of Chapter 8 and Theorem 9.2. (Hoffman [1960]) 3. Prove the following theorem of Ore [1956]. Given a digraph G and nonnegative integers a.x/; b.x/ for each x 2 V .G/, then G has a spanning subgraph H with C jıH .x/j D a.x/ and jıH .x/j D b.x/ for all x 2 V .G/ if and only if X X a.x/ D b.x/ and x2V .G/

X x2X

a.x/

X

x2V .G/

C minfb.y/; jıG .X n fyg/ \ ıG .y/jg

for all X V .G/:

y2V .G/

(Ford and Fulkerson [1962]) 4. Let .G; u; c; b/ be an instance of the MINIMUM COST FLOW PROBLEM with c.e/ 0 for all e 2 E.G/. Let F be the set of edges e 2 E.G/ for which an optimum solution f with f .e/ > 0 exists. Prove that every circuit in .V .G/; F / consists only of edges e with c.e/ D 0. 5. Consider the MINIMUM COST FLOW PROBLEM where infinite capacities (u.e/ D 1 for some edges e) are allowed. (a) Show that an instance is unbounded if and only if it is feasible and there is a negative circuit all whose edges have infinite capacity. (b) Show how to decide in O.n3 C m/ time whether an instance is unbounded. (c) Show that for an instance that is not unbounded each infinite capacity can be equivalently replaced by a finite capacity. 6. Let .G; u; c; b/ be an instance of the MINIMUM COST FLOW PROBLEM. We call a function W V .G/ ! R an optimal potential if there exists a minimum cost b-flow f such that is a feasible potential with respect to .Gf ; c/. (a) Prove that a function W V .G/ ! R is an optimal potential if and only if for all X V .G/: X X b.X / C u.e/ u.e/: e2ı .X/Wc .e/ c.X / or assert that no such Y exists. Suppose this algorithm has a running time which is polynomial in size.c/. Prove that then there is an algorithm for finding a maximum weight set X 2 F for a given .E; F / 2 ‰ and c W E ! ZC , whose running time is polynomial in size.c/. (Grötschel and Lovász [1995]; see also Schulz, Weismantel and Ziegler [1995], and Schulz and Weismantel [2002]) Prove that ORLIN’S ALGORITHM always computes a spanning tree solution.

236

9 Minimum Cost Flows

16. Prove that in 7 of ORLIN’ S ALGORITHM one can replace the 6n-bound by 5n . 17. Consider the shortest path computations with nonnegative weights (using DIJKSTRA’S ALGORITHM) in the algorithms of Section 9.4 and 9.5. Show that even for graphs with parallel edges each of these computations can be performed in O.n2 / time, provided that we have the incidence list of G sorted by edge costs. Conclude that ORLIN’S ALGORITHM runs in O.mn2 log m/ time.

18. The PUSH-RELABEL ALGORITHM (Section 8.5) can be generalized to the M INIMUM COST FLOW PROBLEM . For an instance .G; u; b; c/ with integral costs c, we look for a b-flow f and a feasible potential in .Gf ; c/. We start by setting WD 0 and saturating all edges e with negative cost. Then we apply 3 of the PUSH-RELABEL ALGORITHM with the following modifications. An edge e is admissible if e 2 E.Gf / and c .e/ < 0. A vertex v is active if b.v/ C exf .v/ > 0. RELABEL.v/ consists of setting .v/ WD maxf.w/ c.e/ 1 W e D .v; w/ 2 E.Gf /g. In PUSH.e/ for e 2 ı C .v/ we set WD minfb.v/ C exf .v/; uf .e/g. (a) Prove that the number of RELABEL operations is O.n2 jcmax j/, where cmax D maxe2E.G/ c.e/. Hint: Some vertex w with b.w/ C exf .w/ < 0 must be reachable in Gf from any active vertex v. Note that b.w/ has never changed and recall the proofs of Lemmata 8.25 and 8.27. (b) Show that the overall running time is O.n2 mcmax /. (c) Prove that the algorithm computes an optimum solution. (d) Apply scaling to obtain an O.n2 m log cmax /-algorithm for the MINIMUM COST FLOW PROBLEM with integral costs c. (Goldberg and Tarjan [1990]) 19. Let .G; u; b; c/ be an instance of the MINIMUM COST FLOW PROBLEM, where u and b are integral. Prove the following statement using (a) the MINIMUM MEAN CYCLE-CANCELLING ALGORITHM or (b) the SUCCESSIVE SHORTEST PATH ALGORITHM, or (c) total unimodularity. If there exists a b-flow in .G; u/, then there exists a minimum cost b-flow which is integral. 20. Let .G; u; c; b/ be an instance of the MINIMUM COST FLOW PROBLEM. Let eN 2 E.G/ with c.e/ N > .jV .G/j 1/ maxe2E.G/nfeg N jc.e/j. Prove: If there exists a b-flow f in .G; u/ with f .e/ N D 0, then f .e/ N D 0 holds for every optimum solution f . 21. Given a network .G; u; s; t/ with integral transit times l W E.G/ ! ZC , a time horizon T 2 N, a value V 2 RC , and costs c W E.G/ ! RC . We look for an s-t-flow over time f with value .f / D V and minimum cost RT P e2E.G/ c.e/ 0 fe ./d . Show how to solve this in polynomial time if T is a constant. Hint: Consider a time-expanded network with a copy of G for each discrete time step.

References

237

References General Literature: Ahuja, R.K., Magnanti, T.L., and Orlin, J.B. [1993]: Network Flows. Prentice-Hall, Englewood Cliffs 1993 Cook, W.J., Cunningham, W.H., Pulleyblank, W.R., and Schrijver, A. [1998]: Combinatorial Optimization. Wiley, New York 1998, Chapter 4 Goldberg, A.V., Tardos, É., and Tarjan, R.E. [1990]: Network flow algorithms. In: Paths, Flows, and VLSI-Layout (B. Korte, L. Lovász, H.J. Prömel, A. Schrijver, eds.), Springer, Berlin 1990, pp. 101–164 Gondran, M., and Minoux, M. [1984]: Graphs and Algorithms. Wiley, Chichester 1984, Chapter 5 Jungnickel, D. [2007]: Graphs, Networks and Algorithms. Third Edition. Springer, Berlin 2007, Chapters 10 and 11 Lawler, E.L. [1976]: Combinatorial Optimization: Networks and Matroids. Holt, Rinehart and Winston, New York 1976, Chapter 4 Ruhe, G. [1991]: Algorithmic Aspects of Flows in Networks. Kluwer Academic Publishers, Dordrecht 1991 Skutella, M. [2009]: An introduction to network flows over time. In: Research Trends in Combinatorial Optimization (W.J. Cook, L. Lovász, J. Vygen, eds.), Springer, Berlin 2009, pp. 451–482

Cited References: Arkin, E.M., and Silverberg, E.B. [1987]: Scheduling jobs with fixed start and end times. Discrete Applied Mathematics 18 (1987), 1–8 Armstrong, R.D., and Jin, Z. [1997]: A new strongly polynomial dual network simplex algorithm. Mathematical Programming 78 (1997), 131–148 Busacker, R.G., and Gowen, P.J. [1961]: A procedure for determining a family of minimumcost network flow patterns. ORO Technical Paper 15, Operational Research Office, Johns Hopkins University, Baltimore 1961 Cunningham, W.H. [1976]: A network simplex method. Mathematical Programming 11 (1976), 105–116 Dantzig, G.B. [1951]: Application of the simplex method to a transportation problem. In: Activity Analysis and Production and Allocation (T.C. Koopmans, Ed.), Wiley, New York 1951, pp. 359–373 Edmonds, J., and Karp, R.M. [1972]: Theoretical improvements in algorithmic efficiency for network flow problems. Journal of the ACM 19 (1972), 248–264 Fleischer, L., and Skutella, M. [2007]: Quickest flows over time. SIAM Journal on Computing 36 (2007), 1600–1630 Ford, L.R., and Fulkerson, D.R. [1958]: Constructing maximal dynamic flows from static flows. Operations Research 6 (1958), 419–433 Ford, L.R., and Fulkerson, D.R. [1962]: Flows in Networks. Princeton University Press, Princeton 1962 Gale, D. [1957]: A theorem on flows in networks. Pacific Journal of Mathematics 7 (1957), 1073–1082 Goldberg, A.V., and Tarjan, R.E. [1989]: Finding minimum-cost circulations by cancelling negative cycles. Journal of the ACM 36 (1989), 873–886

238

9 Minimum Cost Flows

Goldberg, A.V., and Tarjan, R.E. [1990]: Finding minimum-cost circulations by successive approximation. Mathematics of Operations Research 15 (1990), 430–466 Grötschel, M., and Lovász, L. [1995]: Combinatorial optimization. In: Handbook of Combinatorics; Vol. 2 (R.L. Graham, M. Grötschel, L. Lovász, eds.), Elsevier, Amsterdam 1995 Hassin, R. [1983]: The minimum cost flow problem: a unifying approach to dual algorithms and a new tree-search algorithm. Mathematical Programming 25 (1983), 228–239 Hitchcock, F.L. [1941]: The distribution of a product from several sources to numerous localities. Journal of Mathematical Physics 20 (1941), 224–230 Hoffman, A.J. [1960]: Some recent applications of the theory of linear inequalities to extremal combinatorial analysis. In: Combinatorial Analysis (R.E. Bellman, M. Hall, eds.), AMS, Providence 1960, pp. 113–128 Hoppe, B., and Tardos, É. [2000]: The quickest transshipment problem. Mathematics of Operations Research 25 (2000), 36–62 Iri, M. [1960]: A new method for solving transportation-network problems. Journal of the Operations Research Society of Japan 3 (1960), 27–87 Jewell, W.S. [1958]: Optimal flow through networks. Interim Technical Report 8, MIT 1958 Karzanov, A.V., and McCormick, S.T. [1997]: Polynomial methods for separable convex optimization in unimodular linear spaces with applications. SIAM Journal on Computing 26 (1997), 1245–1275 Klein, M. [1967]: A primal method for minimum cost flows, with applications to the assignment and transportation problems. Management Science 14 (1967), 205–220 Klinz, B., and Woeginger, G.J. [2004]: Minimum cost dynamic flows: the series-parallel case. Networks 43 (2004), 153–162 Orden, A. [1956]: The transshipment problem. Management Science 2 (1956), 276–285 Ore, O. [1956]: Studies on directed graphs I. Annals of Mathematics 63 (1956), 383–406 Orlin, J.B. [1993]: A faster strongly polynomial minimum cost flow algorithm. Operations Research 41 (1993), 338–350 Orlin, J.B. [1997]: A polynomial time primal network simplex algorithm for minimum cost flows. Mathematical Programming 78 (1997), 109–129 Orlin, J.B., Plotkin, S.A., and Tardos, É. [1993]: Polynomial dual network simplex algorithms. Mathematical Programming 60 (1993), 255–276 Plotkin, S.A., and Tardos, É. [1990]: Improved dual network simplex. Proceedings of the 1st Annual ACM-SIAM Symposium on Discrete Algorithms (1990), 367–376 Schulz, A.S., Weismantel, R., and Ziegler, G.M. [1995]: 0/1-Integer Programming: optimization and augmentation are equivalent. In: Algorithms – ESA ’95; LNCS 979 (P. Spirakis, ed.), Springer, Berlin 1995, pp. 473–483 Schulz, A.S., and Weismantel, R. [2002]: The complexity of generic primal algorithms for solving general integer problems. Mathematics of Operations Research 27 (2002), 681–692 Tardos, É. [1985]: A strongly polynomial minimum cost circulation algorithm. Combinatorica 5 (1985), 247–255 Tolsto˘ı, A.N. [1930]: Metody nakhozhdeniya naimen’shego summovogo kilometrazha pri planirovanii perevozok v prostanstve. In: Planirovanie Perevozok, Sbornik pervy˘ı, Transpechat’ NKPS, Moskow 1930, pp. 23–55. (See A. Schrijver, On the history of the transportation and maximum flow problems, Mathematical Programming 91 (2002), 437–445) Tomizawa, N. [1971]: On some techniques useful for solution of transportation network problems. Networks 1 (1971), 173–194

References

239

Vygen, J. [2002]: On dual minimum cost flow algorithms. Mathematical Methods of Operations Research 56 (2002), 101–126 Wagner, H.M. [1959]: On a class of capacitated transportation problems. Management Science 5 (1959), 304–318

•

10 Maximum Matchings

Matching theory is one of the classical and most important topics in combinatorial theory and optimization. All the graphs in this chapter are undirected. Recall that a matching is a set of pairwise disjoint edges. Our main problem is:

CARDINALITY MATCHING PROBLEM Instance:

An undirected graph G.

Task:

Find a maximum cardinality matching in G.

Since the weighted version of this problem is significantly more difficult we postpone it to Chapter 11. But already the above cardinality version has applications: Suppose in the JOB ASSIGNMENT PROBLEM each job has the same processing time, say one hour, and we ask whether we can finish all the jobs within one hour. : In other words: given a bipartite graph G P with bipartition V .G/ D A [ B, we lookP for numbers x W E.G/ ! RC with e2ı.a/ x.e/ D 1 for each job a 2 A and e2ı.b/ x.e/ 1 for each employee b 2 B. We can write this as a linear inequality system x 0, M x 1l, M 0 x 1l, where the rows of M and M 0 are rows of the node-edge incidence matrix of G. These matrices are totally unimodular by Theorem 5.25. From Theorem 5.20 we conclude that if there is any solution x, then there is also an integral solution. Now observe that the integral solutions to the above linear inequality system are precisely the incidence vectors of the matchings in G covering A. Definition 10.1. Let G be a graph and M a matching in G. We say that a vertex v is covered by M if v 2 e for some e 2 M ; otherwise v is exposed (by M ). M is called a perfect matching if all vertices are covered by M . In Section 10.1 we consider matchings in bipartite graphs. Algorithmically this problem can be reduced to the M AXIMUM FLOW PROBLEM. The Max-Flow-MinCut Theorem as well as the concept of augmenting paths have nice interpretations in our context. Matching in general, non-bipartite graphs does not reduce directly to network flows. We introduce two necessary and sufficient conditions for a general graph to have a perfect matching in Sections 10.2 and 10.3. In Section 10.4 we consider factor-critical graphs which have a matching covering all vertices but v, for each v 2 V .G/. These play an important role in Edmonds’ algorithm for the CARDINALITY B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__10, c Springer-Verlag Berlin Heidelberg 2012

241

242

10 Maximum Matchings

MATCHING PROBLEM, described in Section 10.5, and its weighted version which we postpone to Sections 11.2 and 11.3.

10.1 Bipartite Matching Since the CARDINALITY MATCHING PROBLEM is easier if G is bipartite, we shall deal with this case first. In this section, a bipartite graph G is always assumed to : have the bipartition V .G/ D A [ B. Since we may assume that G is connected, we can regard this bipartition as unique (Exercise 25 of Chapter 2). For a graph G, let .G/ denote the maximum cardinality of a matching in G, while .G/ is the minimum cardinality of a vertex cover in G. Theorem 10.2. (König [1931]) If G is bipartite, then .G/ D .G/. :

Proof: Consider the graph G 0 D .V .G/ [ fs; tg; E.G/ [ ffs; ag W a 2 Ag [ ffb; tg W b 2 Bg/. Then .G/ is the maximum number of internally disjoint st-paths, while .G/ is the minimum number of vertices whose deletion makes t unreachable from s. The theorem now immediately follows from Menger’s Theorem 8.10. .G/ .G/ evidently holds for any graph (bipartite or not), but we do not have equality in general (as the triangle K3 shows). Several statements are equivalent to König’s Theorem. Hall’s Theorem is probably the best-known version. Theorem 10.3. (Hall [1935]) Let G be a bipartite graph with bipartition V .G/ D : A [ B. Then G has a matching covering A if and only if j.X /j jX j

for all X A:

(10.1)

Proof: The necessity of the condition is obvious. To prove the sufficiency, assume that G has no matching covering A, i.e. .G/ < jAj. By Theorem 10.2 this implies .G/ < jAj. Let A0 A; B 0 B such that A0 [ B 0 covers all the edges and jA0 [ B 0 j < jAj. Obviously .A n A0 / B 0 . Therefore j.A n A0 /j jB 0 j < jAj jA0 j D jA n A0 j, and the Hall condition (10.1) is violated. It is worthwhile to mention that it is not too difficult to prove Hall’s Theorem directly. The following proof is due to Halmos and Vaughan [1950]: Second Proof of Theorem 10.3: We show that any G satisfying the Hall condition (10.1) has a matching covering A. We use induction on jAj, the cases jAj D 0 and jAj D 1 being trivial. If jAj 2, we consider two cases: If j.X /j > jX j for every nonempty proper subset X of A, then we take any edge fa; bg (a 2 A, b 2 B), delete its two vertices and apply induction. The smaller graph satisfies the Hall condition because j.X /j jX j can have decreased by at most one for any X A n fag.

10.1

Bipartite Matching

243

Now assume that there is a nonempty proper subset X of A with j.X /j D jX j. By induction there is a matching covering X in GŒX [ .X /. We claim that we can extend this to a matching in G covering A. Again by the induction hypothesis, we have to show that GŒ.A n X / [ .B n .X // satisfies the Hall condition. To check this, observe that for any Y A n X we have (in the original graph G): j.Y / n .X /j D j.X [ Y /j j.X /j jX [ Y j jX j D jY j: A special case of Hall’s Theorem is the so-called “Marriage Theorem”: Theorem 10.4. (Frobenius [1917]) Let G be a bipartite graph with bipartition : V .G/ D A [ B. Then G has a perfect matching if and only if jAj D jBj and j.X /j jX j for all X A. The variety of applications of Hall’s Theorem is indicated by Exercises 4–7. The proof of König’s Theorem 10.2 shows how to solve the bipartite matching problem algorithmically: Theorem 10.5. The CARDINALITY MATCHING PROBLEM for bipartite graphs G can be solved in O.nm/ time, where n D jV .G/j and m D jE.G/j. :

Proof: Let G be a bipartite graph with bipartition V .G/ D A [ B. Add a vertex s and connect it to all vertices of A, and add another vertex t connected to all vertices of B. Orient the edges from s to A, from A to B, and from B to t. Let the capacities be 1 everywhere. Then a maximum integral s-t-flow corresponds to a maximum cardinality matching (and vice versa). So we apply the FORD-FULKERSON ALGORITHM and find a maximum s-tflow (and thus a maximum matching) after at most n augmentations. Since each augmentation takes O.m/ time, we are done. This result is essentially due to Kuhn [1955]. In fact, one can use the concept of shortest augmenting paths p again (cf. the EDMONDS-KARP ALGORITHM). In this way one obtains the O n.m C n/ -algorithm of Hopcroft and Karp [1973] and Karzanov [1973]. This algorithm will be discussed in Exercises 10 and 11. Slightimprovements of the HOPCROFT-KARP pALGORITHM yield running times q log.n2 =m/ mn of O n log (Alt et al. [1991]) and O m (Feder and Motwani n n log n [1995]). The latter bound is the best known for dense graphs. Let us reformulate the augmenting path concept in our context. Definition 10.6. Let G be a graph (bipartite or not), and let M be some matching in G. A path P is an M-alternating path if E.P / n M is a matching. An M alternating path is M-augmenting if it has positive length and its endpoints are exposed by M . One immediately checks that M -augmenting paths must have odd length.

244

10 Maximum Matchings

Theorem 10.7. (Petersen [1891], Berge [1957]) Let G be a graph (bipartite or not) with some matching M . Then M is maximum if and only if there is no M augmenting path. Proof: If there is an M -augmenting path P , the symmetric difference M 4E.P / is a matching and has greater cardinality than M , so M is not maximum. On the other hand, if there is a matching M 0 such that jM 0 j > jM j, the symmetric difference M 4M 0 is the vertex-disjoint union of alternating circuits and paths, where at least one path must be M -augmenting. This was already observed by Petersen and rediscovered by Berge; it is commonly known as Berge’s Theorem. In the bipartite case it of course also follows from Theorem 8.5.

10.2 The Tutte Matrix We now consider maximum matchings from an algebraic point of view. Let G be a simple undirected graph, and let G 0 be the directed graph resulting from G by arbitrarily orienting the edges. For any vector x D .xe /e2E.G/ of variables, we define the Tutte matrix x TG .x/ D .tvw /v;w2V .G/

by x tvw

8 ˆ <xfv;wg WD xfv;wg ˆ : 0

if .v; w/ 2 E.G 0 / if .w; v/ 2 E.G 0 / : otherwise

Such a matrix M , where M D M > , is called skew-symmetric. The matrix TG .x/, but not its rank, depends on the orientation G 0 of G. Note that det TG .x/ is a polynomial in the variables xe (e 2 E.G/). Theorem 10.8. (Tutte [1947]) G has a perfect matching if and only if det TG .x/ is not identically zero. Proof: Let V .G/ D fv1 ; : : : ; vn g, and let Sn be the set of all permutations on f1; : : : ; ng. By definition of the determinant, det TG .x/ D n

X 2Sn

sgn./

n Y i D1

tvxi ;v.i / :

o Q Let Sn0 WD 2 Sn W niD1 tvxi ;v.i / 6D 0 . Each permutation 2 Sn corresponds to a directed graph H WD .V .G/; f.vi ; v.i / / W i D 1; : : : ; ng/ where each C vertex x has jıH .x/j D jıH .x/j D 1. For permutations 2 Sn0 , H is a subgraph $

of G 0 .

10.2

The Tutte Matrix

245

If there exists a permutation 2 Sn0 such that H consists of even circuits only, then by taking every second edge of each circuit (and ignoring the orientations) we obtain a perfect matching in G. Otherwise, for each 2 Sn0 there is a permutation r./ 2 Sn0 such that Hr./ is obtained by reversing the first odd circuit in H , i.e. the odd circuit containing the vertex with minimum index. Of course r.r.// D . Observe that sgn./ D sgn.r.//, i.e. the two permutations have the same sign: if the first odd circuit consists of the vertices vi1 ; : : : ; vi2kC1 with .ij / D ij C1 (j D 1; : : : ; 2k) and .i2kC1 / D i1 , then we obtain r./ by 2k transpositions: for j D 1; : : : ; k exchange .i2j 1 / with Q Q .i2k / and then .i2j / with .i2kC1 /. Moreover, niD1 tvxi ;v.i / D niD1 tvxi ;vr./.i / . So the two corresponding terms in the sum n X Y det TG .x/ D sgn./ tvxi ;v.i / 2Sn0

i D1

cancel each other. Since this holds for all pairs ; r./ 2 Sn0 , we conclude that det TG .x/ is identically zero. So if G has no perfect matching, det TG .x/ is identically zero. On the other hand, if G has a perfect matching M , consider the permutation defined Q by .i / WD j and .j / WD i for all fvi ; vj g 2 M . The corresponding term niD1 tvxi ;v.i / D Q 2 cannot cancel out with any other term, so det TG .x/ is not identically e2M xe zero. Originally, Tutte used Theorem 10.8 to prove his main theorem on matchings, Theorem 10.13. Theorem 10.8 does not provide a good characterization of the property that a graph has a perfect matching. The problem is that the determinant is easy to compute if the entries are numbers (Theorem 4.10) but difficult to compute if the entries are variables. However, the theorem suggests a randomized algorithm for the CARDINALITY MATCHING PROBLEM: Corollary 10.9. (Lovász [1979]) Let x D .xe /e2E.G/ be a random vector where each coordinate is uniformly distributed in Œ0; 1. Then with probability 1 the rank of TG .x/ is exactly twice the size of a maximum matching. Proof: Suppose the rank of TG .x/ is k, say the first k rows are linearly indepenA B dent. We write TG .x/ D B > C , where A is a skew-symmetric .k k/-matrix and A B has rank k. Then there is a matrix D with D A B D B > C . We have AD > D .DA/> D B, and hence A has rank k. So the principal submatrix A of TG .x/ is nonsingular, and by Theorem 10.8 the subgraph induced by the corresponding vertices has a perfect matching. In particular, k is even and G has a matching of cardinality k2 . On the other hand, if G has a matching of cardinality k, the determinant of the principal submatrix T 0 whose rows and columns correspond to the 2k vertices covered by M is not identically zero by Theorem 10.8. The set of vectors x for

246

10 Maximum Matchings

which det T 0 .x/ D 0 must then have measure zero. So with probability one, the rank of TG .x/ is at least 2k. Of course it is not possible to choose random numbers from Œ0; 1 with a digital computer. However, it can be shown that it suffices to choose random integers from the finite set f1; 2; : : : ; N g. For sufficiently large N , the probability of error will become arbitrarily small (see Lovász [1979]). Lovász’ algorithm can be used to determine a maximum matching (not only its cardinality). See Rabin and Vazirani [1989], Mulmuley, Vazirani and Vazirani [1987], and Mucha and Sankowski [2004] for further randomized algorithms for finding a maximum matching in a graph. Moreover we note that Geelen [2000] has shown how to derandomize Lovász’ algorithm. Although its running time is worse than that of Edmonds’ matching algorithm (see Section 10.5), it is important for some generalizations of the CARDINALITY MATCHING PROBLEM (e.g., see Geelen and Iwata [2005]).

10.3 Tutte’s Theorem We now consider the CARDINALITY MATCHING PROBLEM in general graphs. A necessary condition for a graph to have a perfect matching is that every connected component is even (i.e. has an even number of vertices). This condition is not sufficient, as the graph K1;3 (Figure 10.1(a)) shows.

a

b

Fig. 10.1.

The reason that K1;3 has no perfect matching is that there is one vertex (the black one) whose deletion produces three odd connected components. The graph shown in Figure 10.1(b) is more complicated. Does this graph have a perfect matching? If we delete the three black vertices, we get five odd connected components (and one even connected component). If there were a perfect matching, at least one vertex of each odd connected component would have to be connected to one of the black vertices.

10.3

Tutte’s Theorem

247

This is impossible because the number of odd connected components exceeds the number of black vertices. More generally, for X V .G/ let qG .X / denote the number of odd connected components in G X . Then a graph for which qG .X / > jX j holds for some X V .G/ cannot have a perfect matching: otherwise there must be, for each odd connected component in G X , at least one matching edge connecting this connected component with X , which is impossible if there are more odd connected components than elements of X . Tutte’s Theorem says that the above necessary condition is also sufficient: Definition 10.10. A graph G satisfies the Tutte condition if qG .X / jX j for all X V .G/. A nonempty vertex set X V .G/ is a barrier if qG .X / D jX j. To prove the sufficiency of the Tutte condition we shall need an easy observation and an important definition: Proposition 10.11. For any graph G and any X V .G/ we have qG .X / jX j jV .G/j .mod 2/: Definition 10.12. A graph G is called factor-critical if G v has a perfect matching for each v 2 V .G/. A matching is called near-perfect if it covers all vertices but one. Now we can prove Tutte’s Theorem: Theorem 10.13. (Tutte [1947]) A graph G has a perfect matching if and only if it satisfies the Tutte condition: qG .X / jX j

for all X V .G/:

Proof: We have already seen the necessity of the Tutte condition. We now prove the sufficiency by induction on jV .G/j (the case jV .G/j 2 being trivial). Let G be a graph satisfying the Tutte condition. jV .G/j cannot be odd since otherwise the Tutte condition is violated because qG .;/ 1. So by Proposition 10.11, jX j qG .X / must be even for every X V .G/. Since jV .G/j is even and the Tutte condition holds, every singleton is a barrier. We choose a maximal barrier X . G X has jX j odd connected components. G X cannot have any even connected components because otherwise X [ fvg, where v is a vertex of some even connected component, is a barrier (G .X [ fvg/ has jX j C 1 odd connected components), contradicting the maximality of X . We now claim that each odd connected component of G X is factor-critical. To prove this, let C be some odd connected component of GX and v 2 V .C /. If C v has no perfect matching, by the induction hypothesis there is some Y V .C / n fvg

248

10 Maximum Matchings

such that qC v .Y / > jY j. By Proposition 10.11, qC v .Y / jY j must be even, so qC v .Y / jY j C 2: Since X; Y and fvg are pairwise disjoint, we have qG .X [ Y [ fvg/ D qG .X / 1 C qC .Y [ fvg/ D jX j 1 C qC v .Y / jX j 1 C jY j C 2 D jX [ Y [ fvgj: So X [ Y [ fvg is a barrier, contradicting the maximality of X . : We now consider the bipartite graph G 0 with bipartition V .G 0 / D X [ Z which arises when we delete edges with both ends in X and contract the odd connected components of G X to single vertices (forming the set Z). It remains to show that G 0 has a perfect matching. If not, then by Frobenius’ Theorem 10.4 there is some A Z such that jG 0 .A/j < jAj. This implies qG .G 0 .A// jAj > jG 0 .A/j, a contradiction. This proof is due to Anderson [1971]. The Tutte condition provides a good characterization of the perfect matching problem: either a graph has a perfect matching or it has a so-called Tutte set X proving that it has no perfect matching. An important consequence of Tutte’s Theorem is the so-called Berge-Tutte formula: Theorem 10.14. (Berge [1958]) 2.G/ C max .qG .X / jX j/ D jV .G/j: XV .G/

Proof: For any X V .G/, any matching must leave at least qG .X /jX j vertices uncovered. Therefore 2.G/ C qG .X / jX j jV .G/j. To prove the reverse inequality, let k WD

max .qG .X / jX j/:

XV .G/

We construct a new graph H by adding k new vertices to G, each of which is connected to all the old vertices. If we can prove that H has a perfect matching, then 2.G/ C k 2.H / k D jV .H /j k D jV .G/j; and the theorem is proved. Suppose H has no perfect matching, then by Tutte’s Theorem there is a set Y V .H / such that qH .Y / > jY j. By Proposition 10.11, k has the same parity as jV .G/j, implying that jV .H /j is even. Therefore Y 6D ; and thus qH .Y / > 1. But then Y contains all the new vertices, so

10.4

Ear-Decompositions of Factor-Critical Graphs

249

qG .Y \ V .G// D qH .Y / > jY j D jY \ V .G/j C k; contradicting the definition of k.

Let us close this section with a proposition for later use. Proposition 10.15. Let G be a graph and X V .G/ with jV .G/j 2.G/ D qG .X / jX j. Then any maximum matching of G contains a perfect matching in each even connected component of G X , a near-perfect matching in each odd connected component of G X , and matches all the vertices in X to vertices of distinct odd connected components of G X . Later we shall see (Theorem 10.32) that X can be chosen such that each odd connected component of G X is factor-critical.

10.4 Ear-Decompositions of Factor-Critical Graphs This section contains some results on factor-critical graphs which we shall need later. In Exercise 21 of Chapter 2 we have seen that the graphs having an eardecomposition are exactly the 2-edge-connected graphs. Here we are interested in odd ear-decompositions only. Definition 10.16. An ear-decomposition is called odd if every ear has odd length. Theorem 10.17. (Lovász [1972]) A graph is factor-critical if and only if it has an odd ear-decomposition. Furthermore, the initial vertex of the ear-decomposition can be chosen arbitrarily. Proof: Let G be a graph with a fixed odd ear-decomposition. We prove that G is factor-critical by induction on the number of ears. Let P be the last ear in the odd ear-decomposition, say P goes from x to y, and let G 0 be the graph before adding P . We have to show for any vertex v 2 V .G/ that G v contains a perfect matching. If v is not an inner vertex of P this is clear by induction (add every second edge of P to the perfect matching in G 0 v). If v is an inner vertex of P , then exactly one of PŒv;x and PŒv;y must be even, say PŒv;x . By induction there is a perfect matching in G 0 x. By adding every second edge of PŒy;v and of PŒv;x we obtain a perfect matching in G v. We now prove the reverse direction. Choose the initial vertex ´ of the eardecomposition arbitrarily, and let M be a near-perfect matching in G covering V .G/ n f´g. Suppose we already have an odd ear-decomposition of a subgraph G 0 of G such that ´ 2 V .G 0 / and M \E.G 0 / is a near-perfect matching in G 0 . If G D G 0 , we are done. If not, then – since G is connected – there must be an edge e D fx; yg 2 E.G/ n E.G 0 / with x 2 V .G 0 /. If y 2 V .G 0 /, e is the next ear. Otherwise let N be a near-perfect matching in G covering V .G/ n fyg. M 4N obviously contains the edges of a y-´-path P . Let w be the first vertex of P (when traversed from y)

250

10 Maximum Matchings

that belongs to V .G 0 /. The last edge of P 0 WD PŒy;w cannot belong to M (because no edge of M leaves V .G 0 /), and the first edge cannot belong to N . Since P 0 is M -N -alternating, jE.P 0 /j must be even, so together with e it forms the next ear. In fact, we have constructed a special type of odd ear-decomposition: Definition 10.18. Given a factor-critical graph G and a near-perfect matching M , an M-alternating ear-decomposition of G is an odd ear-decomposition such that each ear is an M -alternating path or a circuit C with jE.C / \ M j C 1 D jE.C / n M j. It is clear that the initial vertex of an M -alternating ear-decomposition must be the vertex exposed by M . The proof of Theorem 10.17 immediately yields: Corollary 10.19. For any factor-critical graph G and any near-perfect matching M in G there exists an M -alternating ear-decomposition. From now on, we shall only be interested in M -alternating ear-decompositions. An interesting way to store an M -alternating ear-decomposition efficiently is due to Lovász and Plummer [1986]: Definition 10.20. Let G be a factor-critical graph and M a near-perfect matching in G. Let r; P1 ; : : : ; Pk be an M -alternating ear-decomposition of G and ; ' W V .G/ ! V .G/ two functions. We say that and ' are associated with the eardecomposition r; P1 ; : : : ; Pk if .x/ D y if fx; yg 2 M , '.x/ D y if fx; yg 2 E.Pi / n M and x … frg [ V .P1 / [ [ V .Pi 1 /, .r/ D '.r/ D r. If M is fixed, we also say that ' is associated with r; P1 ; : : : ; Pk . If M is some fixed near-perfect matching and ; ' are associated with two M -alternating ear-decompositions, they are the same up to the order of the ears. Moreover, an explicit list of the ears can be obtained in linear time:

EAR-DECOMPOSITION ALGORITHM Input: Output: 1 2

A factor-critical graph G, functions ; ' associated with an M alternating ear-decomposition. An M -alternating ear-decomposition r; P1 ; : : : ; Pk .

Let initially be X WD frg, where r is the vertex with .r/ D r. Let k WD 0, and let the stack be empty. If X D V .G/ then go to . 5 If the stack is nonempty then let v 2 V .G/ n X be an endpoint of the topmost element of the stack, else choose v 2 V .G/ n X arbitrarily.

10.4

3

4

5

Ear-Decompositions of Factor-Critical Graphs

251

Set x WD v, y WD .v/ and P WD .fx; yg; ffx; ygg/. While '.'.x// D x do: Set P WD P C fx; '.x/g C f'.x/; .'.x//g and x WD .'.x//. While '.'.y// D y do: Set P WD P C fy; '.y/g C f'.y/; .'.y//g and y WD .'.y//. Set P WD P C fx; '.x/g C fy; '.y/g. P is the ear containing y as an inner vertex. Put P on top of the stack. While both endpoints of the topmost element P of the stack are in X do: Delete P from the stack, set k WD kC1, Pk WD P and X WD X [V .P /. Go to . 2 For all fy; ´g 2 E.G/ n .E.P1 / [ [ E.Pk // do: Set k WD k C 1 and Pk WD .fy; ´g; ffy; ´gg/.

Proposition 10.21. Let G be a factor-critical graph and ; ' functions associated with an M -alternating ear-decomposition. Then this ear-decomposition is unique up to the order of the ears. The EAR-DECOMPOSITION ALGORITHM correctly determines an explicit list of these ears; it runs in linear time. Proof: Let D be an M -alternating ear-decomposition associated with and '. The uniqueness of D as well as the correctness of the algorithm follows from the obvious fact that P as computed in 3 is indeed an ear of D. The running time of 1 – 4 is evidently O.jV .G/j/, while 5 takes O.jE.G/j/ time. The most important property of the functions associated with an alternating eardecomposition is the following: Lemma 10.22. Let G be a factor-critical graph and ; ' two functions associated with an M -alternating ear-decomposition. Let r be the vertex exposed by M . Then the maximal path given by an initial subsequence of x; .x/; '..x//; .'..x///; '..'..x////; : : : defines an M -alternating x-r-path of even length for all x 2 V .G/. Proof: Let x 2 V .G/ n frg, and let Pi be the first ear containing x. Clearly some initial subsequence of x; .x/; '..x//; .'..x///; '..'..x////; : : : must be a subpath Q of Pi from x to y, where y 2 frg [ V .P1 / [ [ V .Pi 1 /. Because we have an M -alternating ear-decomposition, the last edge of Q does not belong to M ; hence Q has even length. If y D r, we are done, otherwise we apply induction on i . The converse of Lemma 10.22 is not true: In the counterexample in Figure 10.2 (bold edges are matching edges, edges directed from u to v indicate '.u/ D v),

252

10 Maximum Matchings

Fig. 10.2.

and ' also define alternating paths to the vertex exposed by the matching. However, and ' are not associated with any alternating ear-decomposition. For the WEIGHTED MATCHING ALGORITHM (Section 11.3) we shall need a fast routine for updating an alternating ear-decomposition when the matching changes. Although the proof of Theorem 10.17 is algorithmic (provided that we can find a maximum matching in a graph), this is far too inefficient. We make use of the old ear-decomposition: Lemma 10.23. Given a factor-critical graph G, two near-perfect matchings M and M 0 , and functions ; ' associated with an M -alternating ear-decomposition. Then functions 0 ; ' 0 associated with an M 0 -alternating ear-decomposition can be found in O.jV .G/j/ time. Proof: Let v be the vertex exposed by M , and let v 0 be the vertex exposed by M 0 . Let P be the v 0 -v-path in M 4M 0, say P D x0 ; x1 ; : : : ; xk with x0 D v 0 and xk D v. An explicit list of the ears of the old ear-decomposition can be obtained from and ' by the EAR-DECOMPOSITION ALGORITHM in linear time (Proposition 10.21). Indeed, since we do not have to consider ears of length one, we can omit : 5 then the total number of edges considered is at most 32 .jV .G/j1/ (cf. Exercise 20). Suppose we have already constructed an M 0 -alternating ear-decomposition of a spanning subgraph of GŒX for some X V .G/ with v 0 2 X (initially X WD fv 0 g). Of course no M 0 -edge leaves X . Let p WD maxfi 2 f0; : : : ; kg W xi 2 X g (illustrated in Figure 10.3). At each stage we keep track of p and of the edge set ı.X / \ M . Their update when extending X is clearly possible in linear total time. Now we show how to extend the ear-decomposition. We shall add one or more ears in each step. The time needed for each step will be proportional to the total number of edges in new ears. Case 1: jı.X / \ M j 2. Let f 2 ı.X / \ M with xp … f . Evidently, f belongs to an M -M 0-alternating path which can be added as the next ear. The time needed to find this ear is proportional to its length. Case 2: jı.X / \ M j D 1. Then v … X , and e D fxp ; xpC1 g is the only edge in ı.X / \ M . Let R0 be the xpC1 -v-path determined by and ' (cf. Lemma 10.22). The first edge of R0 is e. Let q be the minimum index i 2 fp C 2; p C 4; : : : ; kg

10.4

Ear-Decompositions of Factor-Critical Graphs

253

xp + 1 xp

e

X M M

P

Fig. 10.3. 0 with xi 2 V .R0 / and V .RŒx / \ fxi C1 ; : : : ; xk g D ; (cf. Figure 10.4). Let pC1;x i

0 . So R has vertices xp , '.xp /, .'.xp //, '..'.xp ///, : : : ; xq , and R WD RŒx p ;xq can be traversed in time proportional to its length.

X x0 =

xq xp

xk =

xp + 1

Fig. 10.4.

Let S WD E.R/ n E.GŒX /, D WD .M 4M 0/ n .E.GŒX / [ E.PŒxq ;v //, and Z WD S 4D. S and D consist of M -alternating paths and circuits. Observe that every vertex outside X has degree 0 or 2 with respect to Z. Moreover, for every vertex outside X with two incident edges of Z, one of them belongs to M 0 . (Here the choice of q is essential.)

254

10 Maximum Matchings

Hence all connected components C of .V .G/; Z/ with E.C / \ ı.X / 6D ; can be added as next ears, and after these ears have been added, S n Z D S \ .M 4M 0 / is the vertex-disjoint union of paths each of which can then be added as an ear. Since e 2 D n S Z, we have Z \ ı.X / 6D ;, so at least one ear is added. It remains to show that the time needed for the above construction is proportional to the total number of edges in new ears. Obviously, it suffices to find S in O.jS j/ time. This is difficult because of the subpaths of R inside X . However, we do not really care what they look like. So we would like to shortcut these paths whenever possible. To achieve this, we modify the '-variables. Namely, in each application of Case 2, let RŒa;b be a maximal subpath of R inside X with a 6D b. Let y WD .b/; y is the predecessor of b on R. We set '.x/ WD y for all vertices x on RŒa;y where RŒx;y has odd length. It does not matter whether x and y are joined by an edge. See Figure 10.5 for an illustration.

y

X

R

xp

xp + 1

x0 =

Fig. 10.5.

The time required for updating the '-variables is proportional to the number of edges examined. Note that these changes of ' do not destroy the property of Lemma 10.22, and the '-variables are not used anymore except for finding M -alternating paths to v in Case 2. Now it is guaranteed that the time required for finding the subpaths of R inside X is proportional to the number of subpaths plus the number of edges examined for the first time inside X . Since the number of subpaths inside X is less than or equal to the number of new ears in this step, we obtain an overall linear running time.

10.5

Edmonds’ Matching Algorithm

255

Case 3: ı.X / \ M D ;. Then v 2 X . We consider the ears of the (old) M -alternating ear-decomposition in their order. Let R be the first ear with V .R/ n X 6D ;. Similar to Case 2, let S WD E.R/ n E.GŒX /, D WD .M 4M 0 / n E.GŒX /, and Z WD S 4D. Again, all connected components C of .V .G/; Z/ with E.C / \ ı.X / 6D ; can be added as next ears, and after these ears have been added, S n Z is the vertex-disjoint union of paths each of which can then be added as an ear. The total time needed for Case 3 is obviously linear.

10.5 Edmonds’ Matching Algorithm Recall Berge’s Theorem 10.7: A matching in a graph is maximum if and only if there is no augmenting path. Since this holds for non-bipartite graphs as well, our matching algorithm will again be based on augmenting paths. However, it is not at all clear how to find an augmenting path (or decide that there is none). In the bipartite case (Theorem 10.5) it was sufficient to mark the vertices that are reachable from an exposed vertex via an alternating edge progression. Since there were no odd circuits, vertices reachable by an alternating edge progression were also reachable by an alternating path. This is no longer the case when dealing with general graphs.

Fig. 10.6.

Consider the example in Figure 10.6 (the bold edges constitute a matching M ). When starting at v1 , we have an alternating edge progression v1 ; v2 ; v3 ; v4 ; v5 ; v6 , v7 ; v5 ; v4 ; v8 , but this is not a path. We have run through an odd circuit, namely v5 ; v6 ; v7 . Note that in our example there exists an augmenting path (v1 ; v2 ; v3 ; v7 , v6 ; v5 ; v4 ; v8 ) but it is not clear how to find it. The question arises what to do if we encounter an odd circuit. Surprisingly, it suffices to get rid of it by shrinking it to a single vertex. It turns out that the smaller graph has a perfect matching if and only if the original graph has one. This is the general idea of EDMONDS’ CARDINALITY MATCHING ALGORITHM. We formulate this idea in Lemma 10.25 after giving the following definition:

256

10 Maximum Matchings

Definition 10.24. Let G be a graph and M a matching in G. A blossom in G with respect to M is a factor-critical subgraph C of G with jM \ E.C /j D jV .C2/j1 . The vertex of C exposed by M \ E.C / is called the base of C . The blossom we have encountered in the above example (Figure 10.6) is induced by fv5 ; v6 ; v7 g. Note that this example contains other blossoms. Any single vertex is also a blossom in terms of our definition. Now we can formulate the Blossom Shrinking Lemma: Lemma 10.25. Let G be a graph, M a matching in G, and C a blossom in G (with respect to M ). Suppose there is an M -alternating v-r-path Q of even length from a vertex v exposed by M to the base r of C , where E.Q/ \ E.C / D ;. Let G 0 and M 0 result from G and M by shrinking V .C / to a single vertex. Then M is a maximum matching in G if and only if M 0 is a maximum matching in G 0 . Proof: Suppose that M is not a maximum matching in G. N WD M 4E.Q/ is a matching of the same cardinality, so it is not maximum either. By Berge’s Theorem 10.7 there then exists an N -augmenting path P in G. Note that N does not cover r. At least one of the endpoints of P , say x, does not belong to C . If P and C are disjoint, let y be the other endpoint of P . Otherwise let y be the first vertex on P – when traversed from x – belonging to C . Let P 0 result from PŒx;y when shrinking V .C / in G. The endpoints of P 0 are exposed by N 0 (the matching in G 0 corresponding to N ). Hence P 0 is an N 0 -augmenting path in G 0 . So N 0 is not a maximum matching in G 0 , and nor is M 0 (which has the same cardinality). To prove the converse, suppose that M 0 is not a maximum matching in G 0 . Let 0 N be a larger matching in G 0 . N 0 corresponds to a matching N0 in G which covers at most one vertex of C in G. Since C is factor-critical, N0 can be extended by k WD jV .C2/j1 edges to a matching N in G, where jN j D jN0 j C k D jN 0 j C k > jM 0 j C k D jM j; proving that M is not a maximum matching in G.

It is necessary to require that the base of the blossom is reachable from a vertex exposed by M by an M -alternating path of even length which is disjoint from the blossom. For example, the blossom induced by fv4 ; v6 ; v7 ; v2 ; v3 g in Figure 10.6 cannot be shrunk without destroying the only augmenting path. When looking for an augmenting path, we shall build up an alternating forest: Definition 10.26. Given a graph G and a matching M in G. An alternating forest with respect to M in G is a forest F in G with the following properties: (a) V .F / contains all the vertices exposed by M . Each connected component of F contains exactly one exposed vertex, its root.

10.5

Edmonds’ Matching Algorithm

257

Fig. 10.7.

(b) We call a vertex v 2 V .F / an outer (inner) vertex if it has even (odd) distance to the root of the connected component containing v. (In particular, the roots are outer vertices.) All inner vertices have degree 2 in F . (c) For any v 2 V .F /, the unique path from v to the root of the connected component containing v is M -alternating. Figure 10.7 shows an alternating forest. The bold edges belong to the matching. The black vertices are inner, the white vertices outer. Proposition 10.27. In any alternating forest the number of outer vertices that are not a root equals the number of inner vertices. Proof: Each outer vertex that is not a root has exactly one neighbour which is an inner vertex and whose distance to the root is smaller. This is obviously a bijection between the outer vertices that are not a root and the inner vertices. Informally, EDMONDS’ CARDINALITY MATCHING ALGORITHM works as follows. Given some matching M , we build up an M -alternating forest F . We start with the set S of exposed vertices and no edges. At any stage of the algorithm we consider a neighbour y of an outer vertex x. Let P .x/ denote the unique path in F from x to a root. There are three interesting cases, corresponding to three operations (“grow”, “augment”, and “shrink”): Case 1: y … V .F /. Then the forest will grow when we add fx; yg and the matching edge covering y.

258

10 Maximum Matchings

Case 2: y is an outer vertex in a different connected component of F . Then we augment M along P .x/ [ fx; yg [ P .y/. Case 3: y is an outer vertex in the same connected component of F (with root q). Let r be the first vertex of P .x/ (starting at x) also belonging to P .y/. (r can be one of x; y.) If r is not a root, it must have degree at least 3. So r is an outer vertex. Therefore C WD P .x/Œx;r [ fx; yg [ P .y/Œy;r is a blossom with at least three vertices. We shrink C . If none of the cases applies, all the neighbours of outer vertices are inner. We claim that M is maximum. Let X be the set of inner vertices, s WD jX j, and let t be the number of outer vertices. G X has t odd components (each outer vertex is isolated in G X ), so qG .X / jX j D t s. Hence by the trivial part of the Berge-Tutte formula, any matching must leave at least t s vertices uncovered. But on the other hand, the number of vertices exposed by M , i.e. the number of roots of F , is exactly t s by Proposition 10.27. Hence M is indeed maximum. Since this is not at all a trivial task, we shall spend some time on implementation details. The difficult question is how to perform the shrinking efficiently so that the original graph can be recovered afterwards. Of course, several shrinking operations may involve the same vertex. Our presentation is based on the one given by Lovász and Plummer [1986]. Rather than actually performing the shrinking operation, we allow our forest to contain blossoms. Definition 10.28. Given a graph G and a matching M in G. A subgraph F of G is a general blossom forest (with respect to M ) if there exists a partition V .F / D : : : V1 [ V2 [ [ Vk such that Fi WD F ŒVi is a maximal factor-critical subgraph of F with jM \ E.Fi /j D jVi2j1 (i D 1; : : : ; k) and after contracting each of V1 ; : : : ; Vk we obtain an alternating forest F 0 . Fi is called an outer blossom (inner blossom) if Vi is an outer (inner) vertex in F 0 . All the vertices of an outer (inner) blossom are called outer (inner). A general blossom forest where each inner blossom is a single vertex is a special blossom forest. Figure 10.8 shows a connected component of a special blossom forest with five nontrivial outer blossoms. This corresponds to one of the connected components of the alternating forest in Figure 10.7. The orientations of the edges will be explained later. All vertices of G not belonging to the special blossom forest are called out-of-forest. Note that the Blossom Shrinking Lemma 10.25 applies to outer blossoms only. However, in this section we shall deal only with special blossom forests. General blossom forests will appear only in the WEIGHTED MATCHING ALGORITHM in Chapter 11. To store a special blossom forest F , we introduce the following data structures. For each vertex x 2 V .G/ we have three variables .x/, '.x/, and .x/ with the following properties:

10.5

Edmonds’ Matching Algorithm

259

y

x

Fig. 10.8.

(

x y 8 ˆ x ˆ ˆ ˆ ˆ ˆ 1gI "2 WD min fslack.x; y/ W x outer; y out-of-forestg I 1 "3 WD min fslack.x; y/ W x; y outer, belonging to different blossomsg I 2 " WD minf"1 ; "2 ; "3 g: This " is the maximum number such that the dual change by " preserves dual feasibility. If " D 1, (11.2) is unbounded and so (11.1) is infeasible. In this case G has no perfect matching. Obviously, " can be computed in finite time. However, in order to obtain an O.n3 / overall running time we must be able to compute " in O.n/ time. This is easy as far as "1 is concerned, but requires additional data structures for "2 and "3 . For A 2 B let X A WD ´B : B2BWAB

We shall update these values whenever changing the dual solution; this can easily be done in linear time (using the tree-representation of B). Then ˚ "2 D min c.fx; yg/ fxg fyg W x outer; y out-of-forest ; ˚ 1 "3 D min c.fx; yg/ fxg fyg W x; y outer, fx; yg 6 B for B 2 B : 2 We introduce variables tvA and vA for each outer vertex v and each A 2 B, unless there is a B 2 B with A [ fvg B. vA is a vertex in A minimizing slack.v; vA /, and tvA WD slack.v; vA / C C A , where denotes the sum of the "-values in

11.3

Implementation of the Weighted Matching Algorithm

283

all dual changes. Observe that tvA does not change as long as v remains outer and A 2 B. Finally, we write t A WD minftvA W v … A; v outerg. We have n o "2 D min slack.v; vA / W v outer, A 2 B maximal out-of-forest n o D min t A A W A 2 B maximal out-of-forest ; and, similarly, "3 D

n o 1 min t A A W A 2 B maximal outer : 2

Although when computing "2 and "3 we are interested only in the values tvA for maximal out-of-forest and maximal outer blossoms of B, we update these variables also for inner blossoms and those that are not maximal, because they may become relevant later. Blossoms that are outer but not maximal will not become maximal outer before an augmentation takes place. After each augmentation, however, all these variables are recomputed. In the beginning, after each augmentation, and when a vertex v becomes outer which was not outer before, we have to compute vA and tvA , and possibly update t A , for all A 2 B (except those that are outer but not maximal). This can be done as follows:

UPDATE Input:

An outer vertex v.

Output:

Updated values of vA ; tvA and t A for all A 2 B and w for all out-offorest vertices w.

1

For each x 2 V .G/ do: Set vfxg WD x and tvfxg WD c.fv; xg/ fvg C .

2

For A 2 B with jAj > 1 (in an order of nondecreasing cardinality) do: 0 0 Set vA WD vA and tvA WD tvA A0 C A , where A0 is a maximal 0 proper subset of A in B for which tvA A0 is minimum.

3

For A 2 B with v … A, except those that are outer but not maximal, do: Set t A WD minft A ; tvA g.

Obviously this computation coincides with the above definition of vA and tvA . It is important that this procedure runs in linear time: Lemma 11.7. If B is laminar, the procedure UPDATE can be implemented with O.n/ time. Proof: By Proposition 2.15, a laminar family of subsets of V .G/ has cardinality at most 2jV .G/j D O.n/. If B is stored by its tree-representation, then a linear-time implementation is easy.

284

11 Weighted Matching

We can now go ahead with the formal description of the algorithm. Instead of identifying inner and outer vertices by the -, - and -values, we directly mark each vertex with its status (inner, outer or out-of-forest).

WEIGHTED MATCHING ALGORITHM Input:

A graph G, weights c W E.G/ ! R.

Output:

A minimum weight perfect matching in G, given by the edges fx; .x/g, or the answer that G has no perfect matching.

1

2 3

4

5

Set B WD ffvg W v 2 V .G/g and K WD 0. Set WD 0. Set ´fvg WD 12 minfc.e/ W e 2 ı.v/g and fvg WD ´fvg for all v 2 V .G/. Set kv WD 0, .v/ WD v, 0 .v/ WD v, and ' 0 .v/ WD v for all v 2 V .G/. Mark all vertices as outer. Set t A WD 1 for all A 2 B. For all outer vertices v do: UPDATE.v/. (“dual change”) Set "1 WD minf´A W A maximal inner element of B; jAj > 1g. Set "2 WD minft A A W A maximal out-of-forest element of Bg. Set "3 WD minf 21 .t A A / W A maximal outer element of Bg. Set " WD minf"1 ; "2 ; "3 g. If " D 1, then stop (G has no perfect matching). For each maximal outer element A of B do: Set ´A WD ´A C " and A0 WD A0 C " for all A0 2 B with A0 A. For each maximal inner element A of B do: Set ´A WD ´A " and A0 WD A0 " for all A0 2 B with A0 A. Set WD C ". If " D "1 then go to . 8 If " D "2 and txA A D slack.x; y/ D 0, x outer, y 2 A out-of-forest then go to . 5 If " D "3 and txA A D slack.x; y/ D 0, x; y outer, A maximal outer element of B, x … A, y 2 A then: Let P .x/ WD TREEPATH.x/ be given by .x D x0 ; x1 ; x2 ; : : : ; x2h /. Let P .y/ WD TREEPATH.y/ be given by .y D y0 ; y1 ; y2 ; : : : ; y2j /. If P .x/ and P .y/ are vertex-disjoint then go to , 6 else go to . 7 (“grow”) Set .ky .y// WD y and .y/ WD x. Mark all vertices v with kv .v/ D ky .y/ as inner. Mark all vertices v with .kv .v// D ky .y/ as outer. For each new outer vertex v do: UPDATE.v/. Go to . 3

11.3

6

7

8

Implementation of the Weighted Matching Algorithm

285

(“augment”) For i WD 0 to h 1 do: Set .x2i C1 / WD x2i C2 and .x2i C2 / WD x2i C1 . For i WD 0 to j 1 do: Set .y2i C1 / WD y2i C2 and .y2i C2 / WD y2i C1 . Set .x/ WD y and .y/ WD x. Mark all vertices v for which the endpoint of TREEPATH.v/ is either x2h or y2j as out-of-forest. Update all values ' i .v/ and i .v/ (using Lemma 10.23). If .v/ 6D v for all v then stop, else go to . 2 (“shrink”) Let r D x2h0 D y2j 0 be the first outer vertex of V .P .x// \ V .P .y// with kr .r/ D r. Let A WD fv 2 V .G/ W kv .v/ 2 V .P .x/Œx;r / [ V .P .y/Œy;r /g. Set K WD K C 1, B WD B [ fAg, ´A WD 0 and A WD 0. For all v 2 A do: Set kv WD kv C 1, b kv .v/ WD K, kv .v/ WD r, ' kv .v/ WD ' kv 1 .v/. For i WD 1 to h0 do: If kx2i 1 .x2i / 6D r then set ' kx2i .x2i / WD x2i 1 . If kx2i 1 1 .x2i 1 / 6D r then set ' kx2i 1 .x2i 1 / WD x2i . For i WD 1 to j 0 do: If ky2i 1 .y2i / 6D r then set ' ky2i .y2i / WD y2i 1 . If ky2i 1 1 .y2i 1 / 6D r then set ' ky2i 1 .y2i 1 / WD y2i . If kx 1 .x/ 6D r then set ' kx .x/ WD y. If ky 1 .y/ 6D r then set ' ky .y/ WD x. For each outer vertex v … A do: 0 0 Set tvA WD tvA A0 and vA WD vA , where A0 is a maximal proper 0 subset of A in B for which tvA A0 is minimum. A N Set t WD minftvA W v outer, there is no AN 2 B with A [ fvg Ag. Mark all v 2 A outer. For each new outer vertex v do: UPDATE.v/. Go to . 3 (“unpack”) Let A 2 B be a maximal inner blossom with ´A D 0 and jAj > 1. Set B WD B n fAg. Let y WD .kv .v// for some v 2 A. Let Q.y/ WD BLOSSOMPATH .y/ be given by .y D r0 ; r1 ; r2 ; : : : ; r2l1 ; r2l D ky .y//. Mark all v 2 A with kv 1 .v/ … V .Q.y// as out-of-forest. Mark all v 2 A with kv 1 .v/ D r2i 1 for some i as outer. For all v 2 A with kv 1 .v/ D r2i for some i (v remains inner) do: Set .kv .v// WD rj and .rj / WD rj 1 , where k 1 j WD minfj 0 2 f0; : : : ; 2lg W rj 0 .rj 0 / D kv 1 .v/g. For all v 2 A do: Set kv WD kv 1. For each new outer vertex v do: UPDATE.v/. Go to . 3

286

11 Weighted Matching

b

a r 10 r9

r8 r7

r6

r5 r3

r2

y = r0

r1

r4

Fig. 11.3.

Note that in contrast to our previous discussion, " D 0 is possible. The variables vA are not needed explicitly. The “unpack”-step 8 is illustrated in Figure 11.3, where a blossom with 19 vertices is unpacked. Two of the five sub-blossoms become out-of-forest, two become inner blossoms and one becomes an outer blossom. Before analysing the algorithm, let us demonstrate its major steps by an example. Consider the graph in Figure 11.4(a). Initially, the algorithm sets ´fag D ´fd g D ´fhg D 2, ´fbg D ´fcg D ´ff g D 4 and ´feg D ´fgg D6. In Figure 11.4(b) the slacks can be seen. So in the beginning the edges fa; d g; fa; hg; fb; cg; fb; f g; fc; f g are tight. Therefore we will have D 0 in the first iterations. We assume that the algorithm scans the vertices in alphabetical order. So the first steps are augment.a; d /;

a

b

8

a

augment.b; c/;

b

8

c

10

h

14 13

8

8

g

12

f

12

e

0

2 d

4 5

0

0

2

5

4

3 g

Fig. 11.4.

c

5

h

13

10

9

d

0 4

0

4

11

b

2

a 8

4

grow.f; b/:

f

2

e

11.3

a

Implementation of the Weighted Matching Algorithm

b

c

e

d c

b

b

g

f

h

a

d

287

e

a

g

f

h

Fig. 11.5.

a

b

b

0

2 a

c

4 0

0

3

b

0

d

c

d

h

2 3

0

0

g

3

2

1 0

0

f e

e

g

a

h

f

Fig. 11.6.

Figure 11.5(a) shows the current general blossom forest. The next steps are shrink.f; c/;

grow.h; a/;

resulting in the general blossom forest shown in Figure 11.5(b). Now all the tight edges are used up, so the dual variables have to change. In 3 we obtain " D "3 D 1, say A D fb; c; f g and dA D c. The new dual variables are ´fb;c;f g D 1, ´fag D 1, ´fd g D ´fhg D 3, ´fbg D ´fcg D ´ff g D 4, ´feg D ´fgg D 7. The current slacks are shown in Figure 11.6(a). The next step is augment.d; c/: The blossom fb; c; f g becomes out-of-forest (Figure 11.6(b)). Now again " D "3 D 0 in 3 as fe; f g is tight. The next steps are grow.e; f /;

grow.d; a/:

We arrive at Figure 11.7(a). No more edges incident to outer vertices are tight, and we get " D "1 D 1 in 3 and obtain the new dual solution ´fb;c;f g D 0, ´fag D 0, ´fd g D ´fhg D ´fbg D ´fcg D ´ff g D 4, ´feg D ´fgg D 8. The new slacks are shown in Figure 11.7(b). Since the dual variable for the inner blossom fB; C; F g becomes zero, we have to unpack.fb; c; f g/:

288

11 Weighted Matching

a

b

h

b

0

4 a

a 0

d

h

2

b

1

0

0

1

2

1 g

f

0

0

3

d

c

c

6

e

0

0 f

e

g

Fig. 11.7.

a

b

h

a

b

0

4 a d

0

0 c

0

2

d

h

2 0

0

1

g

0

2

1

b

0

0

e

f

f

e

c

7

g

Fig. 11.8.

The general blossom forest we get is shown in Figure 11.8(a). After another dual variable change with " D "3 D 12 we obtain ´fag D 0:5, ´fcg D ´ff g D 3:5, ´fbg D ´fd g D ´fhg D 4:5, ´feg D ´fgg D 8:5 (the slacks are shown in Figure 11.8(b)). The final steps are shrink.d; e/;

augment.g; h/;

11.3

Implementation of the Weighted Matching Algorithm

289

and the algorithm terminates. The final matching is M D ffe; f g; fb; cg; fa; d g, fg; hgg. We check that M has total weight 37, equal to the sum of the dual variables. Let us now check that the algorithm works correctly. Proposition 11.8. The following statements hold at any stage of the WEIGHTED MATCHING ALGORITHM: ˚ 1 kv (a) For each j ˚2 f1; : : : ; Kg let X.j / WD v 2 V .G/ W j 2 fb .v/; : : : ; b .v/g . Then B D X.j / W j D 1; : : : ; K [ ffvg W v 2 V .G/g is a laminar family. The sets Vr WD fv W kv .v/ D rg for r 2 V .G/ with kr .r/ D r are exactly the maximal elements of B. The vertices in each Vr are marked either all outer or all inner or all out-of-forest. Each .Vr ; ffv; ' kv .v/g W v 2 Vr n frgg [ ffv; .v/g W v 2 Vr n frgg/ is a blossom with base r. (b) The edges fx; .x/g form a matching M . M contains a near-perfect matching within each element of B. (c) For b D 1; : : : ; K the variables .v/ and ' i .v/, for those v and i with b i .v/ D b, are associated with an M -alternating ear-decomposition in GŒX.b/. (d) The edges fx; .x/g and fx; ' i .x/g for all x and i , and the edges f.x/, ..x//g for all bases x of maximal inner blossoms, are all tight. (e) The edges fx; .x/g, fx; ' kx .x/g for all inner or outer x, together with the edges f.x/; ..x//g for all bases x of maximal inner blossoms, form a general blossom forest F with respect to M . The vertex marks (inner, outer, out-offorest) are consistent with F . (f) Contracting the maximal sub-blossoms of any blossom in B 2 B with jBj > 1 results in a circuit. (g) For each outer vertex v, the procedure TREEPATH gives an M -alternating v-rpath, where r is the root of the tree in F containing v. Proof: The properties clearly hold at the beginning (after 2 is executed the first time). We show that they are maintained throughout the algorithm. This is easily seen for (a) by considering 7 and . 8 For (b), this follows from Proposition 11.6 and the assumption that (f) and (g) hold before augmenting. The proof that (c) continues to hold after shrinking is the same as in the nonweighted case (see Lemma 10.30 (c)). The '-values are recomputed after augmenting and not changed elsewhere. (d) is guaranteed by . 3 It is easy to see that (e) is maintained by : 5 The blossom containing y was outof-forest, and setting .y/ WD x and .v/ WD y for the base v of the blossom makes it inner. The blossom containing .ky .y// was also out-of-forest, and becomes outer. In , 6 two connected components of the general blossom forest become out-offorest, so (e) is maintained. In , 7 the vertices in the new blossom become outer because r was outer before. In , 8 for the vertices v 2 A with kv 1 .v/ … V .Q.y// we also have .kv .v// … V .Q.y//, so they become out-of-forest. For each other v 2 A we have kv 1 .v/ D rk for some k. Since fri ; ri C1 g 2 M iff i is even, v becomes outer iff k is odd.

290

11 Weighted Matching

(f) holds as any new blossom arises from an odd circuit in . 7 To see that (g) is maintained, it suffices to observe that .x/ and ..x// are set correctly for all bases x of maximal inner blossoms. This is easily checked for both 5 and . 8 Proposition 11.8(a) justifies calling the maximal elements of B inner, outer or out-of-forest in 3 and 8 of the algorithm. Next we show that the algorithm maintains a feasible dual solution. Lemma 11.9. At any stage of the algorithm, ´ is a feasible dual solution. If " D 1 then G has no perfect matching. Proof: We always have ´A D 0 for all A 2 A n B. ´A is decreased only for those A 2 B that are maximal in B and inner. So the choice of "1 guarantees that ´A continues to be nonnegativeP for all A with jAj > 1. P How can the constraints A2AWe2ı.A/ ´A c.e/ be violated? If A2AWe2ı.A/ ´A increases in , 3 e must either connect an outer and an out-of-forest vertex or two different outer blossoms. So the maximal " such that the new ´ still satisfies P 1 A2AWe2ı.A/ ´A c.e/ is slack.e/ in the first case and 2 slack.e/ in the second case. We thus have to prove that "2 and "3 are computed correctly: "2 D minfslack.v; w/ W v outer; w out-of-forestg and

n o 1 min slack.v; w/ W v; w outer; kv .v/ 6D kw .w/ : 2 We claim that at any stage of the algorithm the following holds for any outer N vertex v and any A 2 B such that there is no AN 2 B with A [ fvg A: "3 D

(a) (b) (c) (d) (e)

vA 2 A. A slack.v; P v / D minfslack.v; u/ W u 2 Ag. A D B2BWAB ´B . is the sum of the "-values in all dual changes so far. slack.v; vA / D tvA A . N t A D minftvA W v outer and there is no AN 2 B with A [ fvg Ag.

(a), (c), and (e) are easily seen to be true. (b) and (d) hold when vA is defined (in 7 or in UPDATE .v/), and afterwards slack.v; u/ decreases exactly by the amount that CA increases (due to (c)). Now (a), (b), (d), and (e) imply that "3 is computed correctly. Now suppose " D 1, i.e. " can be chosen arbitrarily large without destroying dual feasibility. Since the dual objective 1l´ increases by at least " in , 3 we conclude that the dual LP (11.2) is unbounded. Hence by Theorem 3.27 the primal LP (11.1) is infeasible. Now the correctness of the algorithm follows: Theorem 11.10. If the algorithm terminates in , 6 the edges fx; .x/g form a minimum weight perfect matching in G.

11.3

Implementation of the Weighted Matching Algorithm

291

Proof: Let x be the incidence vector of M (the matching consisting of the edges fx; .x/g). The complementary slackness conditions X xe > 0 ) ´A D c.e/ A2AWe2ı.A/

´A > 0 )

X

xe D 1

e2ı.A/

are satisfied: the first one holds since all the matching edges are tight (Proposition 11.8(d)), and the second one follows from Proposition 11.8(b). Since we have feasible primal and dual solutions (Lemma 11.9), both must be optimal (Corollary 3.23). So x is optimal for the LP (11.1) and integral, proving that M is a minimum weight perfect matching. Until now we have not proved that the algorithm terminates. Theorem 11.11. The running time of the WEIGHTED MATCHING ALGORITHM between two augmentations is O.n2 /. The overall running time is O.n3 /. Proof: By Lemma 11.7 and Proposition 11.8(a), the UPDATE procedure runs in linear time. Both 2 and 6 take O.n2 / time, once per augmentation. 3 and 4 take O.n/ time. Moreover, each of , 5 , 7 and 8 can be done in O.nk/ time, where k is the number of new outer vertices. (In , 7 the number of maximal proper subsets A0 of A to be considered is at most 2k C 1: every second sub-blossom of a new blossom must have been inner.) Since an outer vertex continues to be outer until the next augmentation, the total time spent by , 5 , 7 and 8 between two augmentations is O.n2 /. Moreover, each call of , 5 , 7 and 8 creates at least one new outer vertex. Since at least one of , 5 , 6 , 7 8 is called in each iteration, the number of iterations between two augmentations is O.n/. This proves the O.n2 / running time between two augmentations. Since there are only n2 augmentations, the total running time is O.n3 /. Corollary 11.12. The MINIMUM WEIGHT PERFECT MATCHING PROBLEM can be solved in O.n3 / time. Proof: This follows from Theorems 11.10 and 11.11.

The first O.n3 /-implementation of Edmonds’ algorithm for the MINIMUM WEIGHT PERFECT MATCHING PROBLEM was due to Gabow [1973] (see also Gabow [1976] and Lawler [1976]). The theoretically best running time, namely O.mn C n2 log n/, has also been obtained by Gabow [1990]. 3 For planar graphs a minimum weight perfect matching can be found in O n 2 log n time, as Lipton and Tarjan [1979,1980] showed by a divide and conquer approach, using the

292

11 Weighted Matching

fact that planar graphs have small “separators”. For Euclidean instances (a set of points in the plane defining a complete graph whose edge weights are given by the 3 5 Euclidean distances) Varadarajan [1998] found an O n 2 log n algorithm. Efficient implementations are described by Mehlhorn and Schäfer [2000], Cook and Rohe [1999], and Kolmogorov [2009]. They solve matching problems with millions of vertices optimally. A “primal” weighted matching algorithm – always maintaining a perfect matching and obtaining a feasible dual solution only at termination – was described by Cunningham and Marsh [1978].

11.4 Postoptimality In this section we prove a postoptimality result which we shall need in Section 12.2. We add two vertices to an instance that has already been solved: Lemma 11.13. Let .G; c/ be an instance of the MINIMUM WEIGHT PERFECT MATCHING PROBLEM, and let s; t 2 V .G/ be two vertices. Suppose we have run the WEIGHTED MATCHING ALGORITHM for the instance .G fs; tg; c/. Then a minimum weight perfect matching with respect to .G; c/ can be determined in O.n2 / time. Proof: The addition of two vertices requires the initialization of the data structures. In particular, for each v 2 fs; tg we mark v as outer, set .v/ WD v, add ˚fvg to B, set k˚v WD 0, 0 .v/ WD v, ' 0 .v/ WD v, and fvg WD ´v WD min 12 c.fs; tg/; min fc.fv; wg/ fwg W w 2 V .G/ n fs; tg , where we used the notation c.e/ WD 1 for e … E.G/. Then we start the WEIGHTED MATCHING A LGORITHM with . 2 By Theorem 11.11 the algorithm terminates after O.n2 / steps with an augmentation, yielding a minimum weight perfect matching in .G; c/. We also get a second postoptimality result: Lemma 11.14. (Weber [1981], Ball and Derigs [1983]) Suppose we have run the WEIGHTED MATCHING ALGORITHM for an instance .G; c/. Let s 2 V .G/, and let c 0 W E.G/ ! R with c 0 .e/ D c.e/ for all e 62 ı.s/. Then a minimum weight perfect matching with respect to .G; c 0 / can be determined in O.n2 / time. Proof: Let G 0 result from G by adding two vertices x; y, an edge fs; xg, and an edge fv; yg for each edge fv; sg 2 E.G/. We set c.fv; yg/ WD c 0 .fv; sg/ for these new edges. The weight of fs; xg can be chosen arbitrarily. We then find a minimum weight perfect matching in .G 0 ; c/, using Lemma 11.13. Removing the edge fs; xg and replacing the matching edge fv; yg by fv; sg yields a minimum weight perfect matching with respect to .G; c 0 /. The same result for a “primal” weighted matching algorithm was found by Cunningham and Marsh [1978].

11.5

The Matching Polytope

293

11.5 The Matching Polytope The correctness of the WEIGHTED MATCHING ALGORITHM also yields Edmonds’ characterization of the perfect matching polytope as a by-product. We again use the notation A WD fA V .G/ W jAj oddg. Theorem 11.15. (Edmonds [1965]) Let G be an undirected graph. The perfect matching polytope of G, i.e. the convex hull of the incidence vectors of all perfect matchings in G, is the set of vectors x satisfying X

xe 0

.e 2 E.G//

xe D 1

.v 2 V .G//

xe 1

.A 2 A/

e2ı.v/

X

e2ı.A/

Proof: By Corollary 3.32 it suffices to show that all vertices of the polytope described above are integral. By Theorem 5.13 this is true if the minimization problem has an integral optimum solution for any weight function. But our WEIGHTED MATCHING ALGORITHM finds such a solution for any weight function (cf. the proof of Theorem 11.10). An alternative proof will be given in Section 12.3 (see the remark after Theorem 12.18). We can also describe the matching polytope, i.e. the convex hull of the incidence vectors of all matchings in an undirected graph G: Theorem 11.16. (Edmonds [1965]) Let G be a graph. The matching polytope of G is the set of vectors x 2 RE.G/ satisfying C X e2ı.v/

xe 1 for all v 2 V .G/

and

X e2E.GŒA/

xe

jAj 1 for all A 2 A: 2

Proof: Since the incidence vector of any matching obviously satisfies these E.G/ inequalities, we only have to prove one direction. Let x 2 RC be a vector P P with e2ı.v/ xe 1 for v 2 V .G/ and e2E.GŒA/ xe jAj1 for A 2 A. We 2 prove that x is a convex combination of incidence vectors of matchings. We use the same construction as in the proof of Proposition 11.1: let H be the graph with V .H / WD f.v; i / W v 2 V .G/; i 2 f1; 2gg, and E.H / WD ff.v; i /; .w; i /g W fv; wg 2 E.G/; i 2 f1; 2gg [ ff.v; 1/; .v; 2/g W v 2 V .G/g. So H consists of two copies of G, and there is an edge joining the two copies of each vertex. Let yf.v;i /;.w;i /g WD P xe for each e D fv; wg 2 E.G/ and i 2 f1; 2g, and let yf.v;1/;.v;2/g WD 1 e2ıG .v/ xe for each v 2 V .G/. We claim that y belongs to the perfect matching polytope of H . Considering the subgraph induced by f.v; 1/ W v 2 V .G/g, which is isomorphic to G, we then get that x is a convex combination of incidence vectors of matchings in G.

294

11 Weighted Matching V (G)

∈ V (G)}

{( , 1) :

∈ V (G)}

{( , 2) :

A

A1

A2

B

B1

B2

C

:X

Fig. 11.9.

P / Obviously, y 2 RE.H and e2ıH .v/ ye D 1 for all v 2 V .H /. To show C that y belongs to the perfect matching polytope Pof H , we use Theorem 11.15. So let X V .H / with jX j odd. We prove that e2ıH .X/ ye 1. Let A WD fv 2 V .G/ W .v; 1/ 2 X; .v; 2/ … X g, B WD fv 2 V .G/ W .v; 1/ 2 X; .v; 2/ 2 X g and C WD fv 2 V .G/ W .v; 1/ … X; .v; 2/ 2 X g. Since jX j is odd, either A or C must have odd cardinality, w.l.o.g. jAj is odd. We write Ai WD f.a; i / W a 2 Ag and Bi WD f.b; i / W b 2 Bg for i D 1; 2 (see Figure 11.9). Then X X X X X X ye ye 2 ye ye C ye v2A1 e2ıH .v/

e2ıH .X/

D

X

X

e2E.H ŒA1 /

ye 2

v2A1 e2ıH .v/

X

e2EH .A1 ;B1 /

e2EH .B2 ;A2 /

xe

e2E.GŒA/

jA1 j .jAj 1/ D 1: Indeed, we can prove the following stronger result: Theorem 11.17. (Cunningham and Marsh [1978]) For any undirected graph G the linear inequality system X xe 0 xe 1 e2ı.v/ X eA

is TDI.

xe

jAj1 2

.e 2 E.G// .v 2 V .G// .A 2 A; jAj > 1/

11.5

The Matching Polytope

295

P Proof: For c W E.G/ ! Z we consider the LP max e2E.G/ c.e/xe subject to the above constraints. The dual LP is: X X jAj 1 ´A min yv C 2 v2V .G/ A2A; jAj>1 X X s.t. yv C ´A c.e/ .e 2 E.G// v2e

A2A; eA

yv 0 ´A 0

.v 2 V .G// .A 2 A; jAj > 1/

Let .G; c/ be the smallest counterexample, i.e. there is no integral optimum dual P solution and jV .G/j C jE.G/j C e2E.G/ jc.e/j is minimum. Then c.e/ 1 for all e (otherwise we can delete any edge of nonpositive weight), and G has no isolated vertices (otherwise we can delete them). Moreover, for any optimum solution y; ´ we claim that y D 0. To prove this, suppose Pyv > 0 for some v 2 V .G/. Then by complementary slackness (Corollary 3.23) e2ı.v/ xe D 1 for every primal optimum solution x. But then decreasing c.e/ by one for each e 2 ı.v/ yields a smaller instance .G; c 0 /, whose optimum LP value is one less (here we use primal integrality, i.e. Theorem 11.16). Since .G; c/ is the smallest counterexample, there exists an integral optimum dual solution y 0 ; ´0 for .G; c 0 /. Increasing yv0 by one yields an integral optimum dual solution for .G; c/, a contradiction. Now let y D 0 and ´ be an optimum dual solution for which X jAj2 ´A (11.4) A2A; jAj>1

is as large as possible. We claim that F WD fA W ´A > 0g is laminar. To see this, suppose there are sets X; Y 2 F with X n Y 6D ;, Y n X 6D ; and X \ Y 6D ;. Let WD minf´X ; ´Y g > 0. 0 If jX \ Y j is odd, then jX [ Y j is also odd. Set ´X WD ´X , ´0Y WD ´Y , 0 0 ´X\Y WD ´X\Y C (unless jX \ Y j D 1), ´X[Y WD ´X[Y C and ´A0 WD ´A for all other sets A. y; ´0 is also a feasible dual solution; moreover it is optimum as well. This is a contradiction since (11.4) is larger. 0 If jX \ Y j is even, then jX n Y j and jY n X j are odd. Set ´X WD ´X , 0 0 0 ´Y WD ´Y , ´XnY WD ´XnY C (unless jX n Y j D 1), ´Y nX WD ´Y nX C (unless jY n X j D 1) and ´A0 WD ´A for all other sets A. Set yv0 WD for v 2 X \ Y and yv0 WD 0 for v … X \ Y . Then .y 0 ; ´0 / is a feasible dual solution with X v2V .G/

yv0 C

X A2A; jAj>1

X jAj 1 0 jAj 1 ´A D jX \ Y j C ´A 2 2 A2A; jAj>1 C jXnY2 j1 C jY nXj1 jXj1 2 2 D

X

A2A; jAj>1

jAj 1 ´A ; 2

jY j1 2

296

11 Weighted Matching

hence it is also optimum. This contradicts the fact that any optimum dual solution .y 0 ; ´0 / must have y 0 D 0. Now let A 2 F with ´A … Z and A maximal. Set WD ´A b´A c > 0. Let A1 ; : : : ; Ak be the maximal proper subsets of A in F ; they must be pairwise disjoint because F is laminar. Setting ´A0 WD ´A and ´A0 i WD ´Ai C for i D 1; : : : ; k 0 WD ´D for all other D 2 A) yields another feasible dual solution y D 0; ´0 (and ´D (since c is integral). We have X B2A; jBj>1

jBj 1 0 ´B < 2

X B2A; jBj>1

jBj 1 ´B ; 2

contradicting the optimality of the original dual solution y D 0; ´.

This proof is due to Schrijver [1983a]. For different proofs, see Lovász [1979] and P Schrijver [1983b]. The P latter does not use Theorem 11.16. Moreover, replacing e2ı.v/ xe 1 by e2ı.v/ xe D 1 for v 2 V .G/ in Theorem 11.17 yields an alternative description of the perfect matching polytope, which is also TDI (by Theorem 5.18). Theorem 11.15 can easily be derived from this; however, the linear inequality system of Theorem 11.15 is not TDI in general (K4 is a counterexample). Theorem 11.17 also implies the Berge-Tutte formula (Theorem 10.14; see Exercise 15). Generalizations will be discussed in Section 12.1.

Exercises 1. Use Theorem 11.4 to prove a weighted version of König’s Theorem 10.2. (Egerváry [1931]) 2. Describe the convex hull of the incidence vectors of all (a) vertex covers, (b) stable sets, (c) edge covers, in a bipartite graph G. Show how Theorem 10.2 and the statement of Exercise 2(c) of Chapter 10 follow. Hint: Use Theorem 5.25 and Corollary 5.21. 3. Prove the Birkhoff-von-Neumann Theorem 11.5 directly. 4. Let G be a graph and P the fractional perfect matching polytope of G. Prove that the vertices of P are exactly the vectors x with 8 1 ˆ < 2 if e 2 E.C1 / [ [ E.Ck / xe D 1 if e 2 M ; ˆ : 0 otherwise where C1 ; : : : ; Ck are vertex-disjoint odd circuits and M is a perfect matching in G .V .C1 / [ [ V .Ck //. (Balinski [1972]; see Lovász [1979])

Exercises :

297

5. Let G be a bipartite graph with bipartition V D A [ B and A D fa1 ; : : : ; ap g, B D fb1 ; : : : ; bq g. Let c W E.G/ ! R be weights on the edges. We look for the maximum weight order-preserving matching M , i.e. for any two edges fai ; bj g; fai 0 ; bj 0 g 2 M with i < i 0 we require j < j 0 . Solve this problem with an O.n3 /-algorithm. Hint: Use dynamic programming. 6. Prove that, at any stage of the WEIGHTED MATCHING ALGORITHM, jBj 32 n. 7. Let G be a graph with nonnegative weights c W E.G/ ! RC . Let M be the matching at any intermediate stage of the WEIGHTED MATCHING ALGORITHM. Let X be the set of vertices covered by M . Show that any matching covering X is at least as expensive as M . (Ball and Derigs [1983]) 8. A graph with integral weights on the edges is said to have the even circuit property if the total weight of every circuit is even. Show that the WEIGHTED MATCHING ALGORITHM applied to a graph with the even circuit property maintains this property (with respect to the slacks) and also maintains a dual solution that is integral. Conclude that for any graph there exists an optimum dual solution ´ that is half-integral (i.e. 2´ is integral). 9. When the WEIGHTED MATCHING ALGORITHM is restricted to bipartite graphs, it becomes much simpler. Show which parts are necessary even in the bipartite case and which are not. Note: One arrives at what is called the Hungarian method for the ASSIGNMENT PROBLEM (Kuhn [1955]). This algorithm can also be regarded as an equivalent description of the procedure proposed in the proof of Theorem 11.2. 10. Suppose G is a complete graph and c W E.G/ ! RC satisfies the triangle inequality, i.e., c.fx; ´g/ c.fx; yg/ C c.fy; ´g/ for all x; y; ´ 2 V .G/. Show that then there exists an optimum solution ´ to (11.2) with ´ 0. 11. How can the bottleneck matching problem (find a perfect matching M such that maxfc.e/ W e 2 M g is minimum) be solved in O.n3 / time? 12. Show how to solve the MINIMUM WEIGHT EDGE COVER PROBLEM in polynomial time: given an undirected graph G and weights c W E.G/ ! R, find a minimum weight edge cover. 13. Given an undirected graph G with weights c W E.G/ ! RC and two vertices s and t, we look for a shortest s-t-path with an even (or with an odd) number of edges. Reduce this to a MINIMUM WEIGHT PERFECT MATCHING PROBLEM. Hint: Take two copies of G, connect each vertex with its copy by an edge of zero weight and delete s and t (or s and the copy of t). (Grötschel and Pulleyblank [1981]) 14. Let G be a k-regular and .k 1/-edge-connected graph with an even number of vertices, and let c W E.G/ ! RC . Prove that there exists a perfect matching M in G with c.M / k1 c.E.G//. Hint: Show that k1 1l is in the perfect matching polytope. (Naddef and Pulleyblank [1981]) 15. Show that Theorem 11.17 implies: (a) the Berge-Tutte formula (Theorem 10.14);

298

11 Weighted Matching

(b) Theorem 11.15; (c) the existence of an optimum half-integral dual solution to the dual LP (11.2) (cf. Exercise 8). Hint: Use Theorem 5.18. 16. The fractional perfect matching polytope Q of G is identical to the perfect matching polytope if G is bipartite (Theorem 11.4). Consider the first GomoryChvátal-truncation Q0 of Q (Definition 5.29). Prove that Q0 is always identical to the perfect matching polytope.

References General Literature: Gerards, A.M.H. [1995]: Matching. In: Handbooks in Operations Research and Management Science; Volume 7: Network Models (M.O. Ball, T.L. Magnanti, C.L. Monma, G.L. Nemhauser, eds.), Elsevier, Amsterdam 1995, pp. 135–224 Lawler, E.L. [1976]: Combinatorial Optimization; Networks and Matroids. Holt, Rinehart and Winston, New York 1976, Chapters 5 and 6 Papadimitriou, C.H., and Steiglitz, K. [1982]: Combinatorial Optimization; Algorithms and Complexity. Prentice-Hall, Englewood Cliffs 1982, Chapter 11 Pulleyblank, W.R. [1995]: Matchings and extensions. In: Handbook of Combinatorics; Vol. 1 (R.L. Graham, M. Grötschel, L. Lovász, eds.), Elsevier, Amsterdam 1995

Cited References: Balinski, M.L. [1972]: Establishing the matching polytope. Journal of Combinatorial Theory 13 (1972), 1–13 Ball, M.O., and Derigs, U. [1983]: An analysis of alternative strategies for implementing matching algorithms. Networks 13 (1983), 517–549 Birkhoff, G. [1946]: Tres observaciones sobre el algebra lineal. Revista Universidad Nacional de Tucumán, Series A 5 (1946), 147–151 Burkard, R., Dell’Amico, M., and Martello, S. [2009]: Assignment Problems. SIAM, Philadelphia 2009 Cook, W., and Rohe, A. [1999]: Computing minimum-weight perfect matchings. INFORMS Journal of Computing 11 (1999), 138–148 Cunningham, W.H., and Marsh, A.B. [1978]: A primal algorithm for optimum matching. Mathematical Programming Study 8 (1978), 50–72 Edmonds, J. [1965]: Maximum matching and a polyhedron with (0,1) vertices. Journal of Research of the National Bureau of Standards B 69 (1965), 125–130 Egerváry, E. [1931]: Matrixok kombinatorikus tulajdonságairol. Matematikai és Fizikai Lapok 38 (1931), 16–28 [in Hungarian] Gabow, H.N. [1973]: Implementation of algorithms for maximum matching on non-bipartite graphs. Ph.D. Thesis, Stanford University, Dept. of Computer Science, 1973 Gabow, H.N. [1976]: An efficient implementation of Edmonds’ algorithm for maximum matching on graphs. Journal of the ACM 23 (1976), 221–234 Gabow, H.N. [1990]: Data structures for weighted matching and nearest common ancestors with linking. Proceedings of the 1st Annual ACM-SIAM Symposium on Discrete Algorithms (1990), 434–443

References

299

Grötschel, M., and Pulleyblank, W.R. [1981]: Weakly bipartite graphs and the max-cut problem. Operations Research Letters 1 (1981), 23–27 Kolmogorov, V. [2009]: Blossom V: a new implementation of a minimum cost perfect matching algorithm. Mathematical Programming Computation 1 (2009), 43–67 Kuhn, H.W. [1955]: The Hungarian method for the assignment problem. Naval Research Logistics Quarterly 2 (1955), 83–97 Lipton, R.J., and Tarjan, R.E. [1979]: A separator theorem for planar graphs. SIAM Journal on Applied Mathematics 36 (1979), 177–189 Lipton, R.J., and Tarjan, R.E. [1980]: Applications of a planar separator theorem. SIAM Journal on Computing 9 (1980), 615–627 Lovász, L. [1979]: Graph theory and integer programming. In: Discrete Optimization I; Annals of Discrete Mathematics 4 (P.L. Hammer, E.L. Johnson, B.H. Korte, eds.), NorthHolland, Amsterdam 1979, pp. 141–158 Mehlhorn, K., and Schäfer, G. [2000]: Implementation of O.nm log n/ weighted matchings in general graphs: the power of data structures. In: Algorithm Engineering; WAE-2000; LNCS 1982 (S. Näher, D. Wagner, eds.), pp. 23–38; also electronically in The ACM Journal of Experimental Algorithmics 7 (2002) Monge, G. [1784]: Mémoire sur la théorie des déblais et des remblais. Histoire de l’Académie Royale des Sciences 2 (1784), 666–704 Munkres, J. [1957]: Algorithms for the assignment and transportation problems. Journal of the Society for Industrial and Applied Mathematics 5 (1957), 32–38 Naddef, D., and Pulleyblank, W.R. [1981]: Matchings in regular graphs. Discrete Mathematics 34 (1981), 283–291 von Neumann, J. [1953]: A certain zero-sum two-person game equivalent to the optimal assignment problem. In: Contributions to the Theory of Games II; Ann. of Math. Stud. 28 (H.W. Kuhn, ed.), Princeton University Press, Princeton 1953, pp. 5–12 Schrijver, A. [1983a]: Short proofs on the matching polyhedron. Journal of Combinatorial Theory B 34 (1983), 104–108 Schrijver, A. [1983b]: Min-max results in combinatorial optimization. In: Mathematical Programming; The State of the Art – Bonn 1982 (A. Bachem, M. Grötschel, B. Korte, eds.), Springer, Berlin 1983, pp. 439–500 Varadarajan, K.R. [1998]: A divide-and-conquer algorithm for min-cost perfect matching in the plane. Proceedings of the 39th Annual IEEE Symposium on Foundations of Computer Science (1998), 320–329 Weber, G.M. [1981]: Sensitivity analysis of optimal matchings. Networks 11 (1981), 41–56

•

12 b-Matchings and T-Joins

In this chapter we introduce two more combinatorial optimization problems, the MAXIMUM WEIGHT b-MATCHING PROBLEM in Section 12.1 and the MINIMUM WEIGHT T -JOIN PROBLEM in Section 12.2. Both can be regarded as generalizations of the MINIMUM WEIGHT PERFECT MATCHING PROBLEM and also include other important problems. On the other hand, both problems can be reduced to the MINIMUM WEIGHT PERFECT MATCHING PROBLEM. They have combinatorial polynomial-time algorithms as well as polyhedral descriptions. Since in both cases the SEPARATION PROBLEM turns out to be solvable in polynomial time, we obtain another polynomial-time algorithm for these generalized matching problems (using the ELLIPSOID METHOD; see Section 4.6). In fact, the SEPARATION PROBLEM can be reduced to finding a minimum capacity T -cut in both cases; see Sections 12.3 and 12.4. This problem, finding a minimum capacity cut ı.X / such that jX \ T j is odd for a specified vertex set T , can be solved with network flow techniques.

12.1 b-Matchings Definition 12.1. Let G be an undirected graph with integral edge capacities u W E.G/ ! N [ f1g and numbers b W V .G/ ! N. Then a b-matching P in .G; u/ is a function f W E.G/ ! ZC with f .e/ u.e/ for all e 2 E.G/ and e2ı.v/ f .e/ b.v/ for all v 2 V .G/. In the caseP u 1 we speak of a simple b-matching in G. A b-matching f is called perfect if e2ı.v/ f .e/ D b.v/ for all v 2 V .G/. In the case b 1 the capacities are irrelevant, and we are back to ordinary matchings. A simple b-matching is sometimes also called a b-factor. It can be regarded as a subset of edges. In Chapter 21 we shall be interested in perfect simple 2-matchings, i.e. subsets of edges such that each vertex is incident to exactly two of them.

MAXIMUM WEIGHT b-MATCHING PROBLEM Instance: Task:

A graph G, capacities u W E.G/ ! N[f1g, weights c W E.G/ ! R, and numbers b W V .G/ ! N. P Find a b-matching f in .G; u/ whose weight e2E.G/ c.e/f .e/ is maximum.

B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__12, c Springer-Verlag Berlin Heidelberg 2012

301

302

12 b-Matchings and T -Joins

Edmonds’ WEIGHTED MATCHING ALGORITHM can be extended to solve this problem (Marsh [1979]). We shall not describe this algorithm here, but shall rather give a polyhedral description and show that the SEPARATION PROBLEM can be solved in polynomial time. This yields a polynomial-time algorithm via the E LLIPSOID M ETHOD (cf. Corollary 3.33). The b-matching polytope of .G; u/ is defined to be the convex hull of all bmatchings in .G; u/. We first consider the uncapacitated case (u 1): Theorem 12.2. (Edmonds [1965]) Let G be an undirected graph and b W V .G/ ! N. The b-matching polytope of .G; 1/ is the set of vectors x 2 RE.G/ satisfying C X xe b.v/ .v 2 V .G//I e2ı.v/

X

$ xe

e2E.GŒX/

1 2

X

% b.v/

.X V .G//:

v2X

Proof: Since any b-matching obviously satisfies these constraints, we only have P with e2ı.v/ xe b.v/ for all v 2 V .G/ to show one direction. So let x 2 RE.G/ C P ˘ P and e2E.GŒX/ xe 12 v2X b.v/ for all X V .G/. We show that x is a convex combination of b-matchings. We define a new graph H by splitting up each vertex v into b.v/Scopies: we define Xv WD f.v; i / W i 2 f1; : : : ; b.v/gg for v 2 V .G/, V .H / WD v2V .G/ Xv and E.H / WD ffv 0 ; w 0 g W fv; wg 2 E.G/; v 0 2 Xv ; w 0 2 Xw g. Let ye WD 1 0 0 0 0 b.v/b.w/ xfv;wg for each edge e D fv ; w g 2 E.H /, v 2 Xv ; w 2 Xw . We claim that y is a convex combination of incidence vectors of matchings in H . By contracting the sets Xv (v 2 V .G/) in H we then return to G and x, and conclude that x is a convex combination of b-matchings in G. P To prove that y is in the matching polytope of H we use Theorem 11.16. holds for each v 2 V .H /. Let C V .H / with jC j e2ı.v/ ye 1 obviously P odd. We show that e2E.H ŒC / ye 12 .jC j 1/. If Xv C or Xv \ C D ; for each v 2 V .G/, this follows directly from the inequalities assumed for x. Otherwise let a; b 2 Xv , a 2 C , b 62 C . Then X X X X 2 ye D ye C ye e2E.H ŒC /

c2C nfag e2E.fcg;C nfcg/

X

X

X

X

ye

c2C nfag e2ı.c/

D

X

X

X

ye C

c2C nfag e2ı.c/nffc;bgg

D

e2E.fag;C nfag/

ye

e2E.fag;C nfag/

X

e2E.fbg;C nfag/

ye C

X

ye

e2E.fag;C nfag/

ye

c2C nfag e2ı.c/

jC j 1:

12.1

b-Matchings

303

Note that this construction yields an algorithm which, however, P in general has an exponential running time. But we note that in the special case v2V .G/ b.v/ D O.n/ we can solve the uncapacitated MAXIMUM WEIGHT b-MATCHING PROBLEM in O.n3 / time (using the WEIGHTED M ATCHING A LGORITHM ; cf. Corollary 11.12). Pulleyblank [1973,1980] described the facets of this polytope and showed that the linear inequality system in Theorem 12.2 is TDI. The following generalization allows finite capacities: Theorem 12.3. (Edmonds and Johnson [1970]) Let G be an undirected graph, u W E.G/ ! N [ f1g and b W V .G/ ! N. The b-matching polytope of .G; u/ is the set of vectors x 2 RE.G/ satisfying C X xe u.e/ xe b.v/ e2ı.v/

X

xe C

e2E.GŒX/

X

$ xe

e2F

1 2

.e 2 E.G//I .v 2 V .G//I X

b.v/ C

v2X

X

!% .X V .G/, F ı.X //:

u.e/

e2F

Proof: First observe that every b-matching x satisfies the constraints. This is clear E.G/ except for the with xe u.e/ (e 2 P last one; but note that any vector x 2 RC E.G/) and e2ı.v/ xe b.v/ (v 2 V .G/) satisfies 1 0 X X X X 1 @X X xe C xe D xe C xe xe A 2 e2F v2X e2ı.v/ e2F e2E.GŒX/ e2ı.X/nF ! X 1 X b.v/ C u.e/ : 2 v2X

e2F

If x is integral, the left-hand side is an integer, so we may round down the right-hand side. P Now let x 2 RE.G/ be a vector with xe u.e/ for all e 2 E.G/, e2ı.v/ xe C b.v/ for all v 2 V .G/ and $ !% X X X 1 X xe C xe b.v/ C u.e/ 2 e2E.GŒX/

e2F

v2X

e2F

for all X V .G/ and F ı.X /. We show that x is a convex combination of b-matchings in .G; u/. Let H be the graph resulting from G by subdividing each edge e D fv; wg with u.e/ 6D 1 by means of two new vertices .e; v/; .e; w/. (Instead of e, H now contains the edges fv; .e; v/g, f.e; v/; .e; w/g and f.e; w/; wg.) Set b..e; v// WD b..e; w// WD u.e/ for the new vertices. For each subdivided edge e D fv; wg set yfv;.e;v/g WD yf.e;w/;wg WD xe and yf.e;v/;.e;w/g WD u.e/ xe . For each original edge e with u.e/ D 1 set ye WD xe . We claim that y is in the b-matching polytope P of .H; 1/.

304

12 b-Matchings and T -Joins

P / We use Theorem 12.2. Obviously y 2 RE.H and e2ı.v/ ye b.v/ for all C v 2 V .H /. Suppose there is a set A V .H / with $ % X 1X ye > b.a/ : (12.1) 2 a2A

e2E.H ŒA/

Let B WD A \ V .G/. For each e D fv; wg 2 E.GŒB/ we may assume .e; v/; .e; w/ 2 A, for otherwise the addition of .e; v/ and .e; w/ does not destroy (12.1). On the other hand, we may assume that .e; v/ 2 A implies v 2 A: If .e; v/; .e; w/ 2 A but v … A, we can delete .e; v/ and .e; w/ from A without destroying (12.1). If .e; v/ 2 A but v; .e; w/ … A, we can just delete .e; v/ from A. Figure 12.1 shows the remaining possible edge types. A

Fig. 12.1.

Let F WD fe D fv; wg 2 E.G/ W jA \ f.e; v/; .e; w/gj D 1g. We have X X X X xe C xe D ye u.e/ e2E.GŒB/

e2F

e2E.H ŒA/

$ >

%

e2E.GŒB/; u.e/ c.J 0 \ E.C // D c.E.C / n J /. This proposition can be regarded as a special case of Theorem 9.7. We now solve the MINIMUM WEIGHT T -JOIN PROBLEM with nonnegative weights by reducing it to the MINIMUM WEIGHT PERFECT MATCHING PROBLEM. The main idea is contained in the following lemma: Lemma 12.9. Let G be a graph, c W E.G/ ! RC , and T V .G/. Every optimum T -join in G is the disjoint union of the edge sets of jT2 j paths whose ends are distinct and in T , and possibly some zero-weight circuits. Proof: By induction on jT j. The case T D ; is trivial since the minimum weight of an ;-join is zero. Let J be any optimum T -join in G; w.l.o.g. J contains no zero-weight circuit. By Proposition 12.8 J contains no circuit of positive weight. As c is nonnegative, J thus forms a forest. Let x; y be two leaves of the same connected component of this forest, i.e. jJ \ ı.x/j D jJ \ ı.y/j D 1, and let P be the x-y-path with edges in J . We have x; y 2 T , and J n E.P / is a minimum cost .T n fx; yg/-join (a cheaper .T n fx; yg/-join J 0 would imply a T -join J 0 4E.P / that is cheaper than J ). The assertion now follows from the induction hypothesis. Theorem 12.10. (Edmonds and Johnson [1973]) In the case of nonnegative weights, the MINIMUM WEIGHT T -JOIN PROBLEM can be solved in O.n3 / time. Proof: Let .G; c; T / be an instance. We first solve an ALL PAIRS SHORTEST PATHS PROBLEM in .G; c/; more precisely: in the graph resulting by replacing each edge by a pair of oppositely directed edges with the same weight. By Theorem 7.8 N c/ this takes O.mn C n2 log n/ time. In particular, we obtain the metric closure .G; N of .G; c/ (cf. Corollary 7.10). N ; c/. Now we find a minimum weight perfect matching M in .GŒT N By Corollary 3 11.12, this takes O.n / time. By Lemma 12.9, c.M N / is at most the minimum weight of a T -join. We consider the shortest x-y-path in G for each fx; yg 2 M (which we have already computed). Let J be the symmetric difference of the edge sets of all these paths. Evidently, J is a T -join in G. Moreover, c.J / c.M N /, so J is optimum.

308

12 b-Matchings and T -Joins

This method no longer works if we allow negative weights, because we would introduce negative circuits. However, we can reduce the M INIMUM WEIGHT T -JOIN PROBLEM with arbitrary weights to that with nonnegative weights: Theorem 12.11. Let G be a graph with weights c W E.G/ ! R and T V .G/. Let E be the set of edges with negative weight, V the set of vertices that are incident with an odd number of negative edges, and d W E.G/ ! RC with d.e/ WD jc.e/j. Then J 4E is a minimum c-weight T -join if and only if J is a minimum d weight .T 4V /-join. Proof: As E is a V -join, Proposition 12.6 implies that J 4E is a T -join if and only if J is a .T 4V /-join. Moreover, for any subset J of E.G/ we have c.J 4E / D c.J n E / C c.E n J / D d.J n E / C c.E n J / C c.J \ E / C d.J \ E / D d.J / C c.E / : Since c.E / is constant, the theorem follows.

Corollary 12.12. The MINIMUM WEIGHT T -JOIN PROBLEM can be solved in O.n3 / time. Proof: This follows directly from Theorems 12.10 and 12.11.

We are finally able to solve the SHORTEST PATH PROBLEM in undirected graphs: Corollary 12.13. The problem of finding a shortest path between two specified vertices in an undirected graph with conservative weights can be solved in O.n3 / time. Proof: Let s and t be the two specified vertices. Set T WD fs; tg and apply Corollary 12.12. After deleting zero-weight circuits, the resulting T -join is the edge set of a shortest s-t-path. Of course this also implies an O.mn3 /-algorithm for finding a circuit of minimum total weight in an undirected graph with conservative weights (and in particular to compute the girth). If we are interested in the ALLPAIRS SHORTEST PATHS PROBLEM in undirected graphs, we do not have to do n2 independent weighted matching computations (which would give a running time of O.n5 /). Using the postoptimality results of Section 11.4 we can prove: Theorem 12.14. The problem of finding shortest paths for all pairs of vertices in an undirected graph G with conservative weights c W E.G/ ! R can be solved in O.n4 / time.

12.3

T -Joins and T -Cuts

309

Proof: By Theorem 12.11 and the proof of Corollary 12.13 we have to compute an optimum .fs; tg4V /-join with respect to the weights d.e/ WD jc.e/j for all s; t 2 V .G/, where V is the set of vertices incident to an odd number of negative edges. Let dN .fx; yg/ WD dist.G;d / .x; y/ for x; y 2 V .G/, and let HX be the complete graph on X 4V (X V .G/). By the proof of Theorem 12.10 it is sufficient to compute a minimum weight perfect matching in Hfs;t g ; dN for all s and t. Our O.n4 /-algorithm proceeds as follows. We first compute dN (cf. Corollary 7.10) and run the WEIGHTED MATCHING ALGORITHM for the instance H; ; dN . Up to now we have spent O.n3 / time. We show that we can now compute a minimum weight perfect matching of Hfs;t g ; dN in O.n2 / time, for any s and t. There are four cases: Case 1: s; t 62 V . Then we add these two vertices and reoptimize by Lemma 11.13. In O.n2 / time we obtain a minimum weight perfect matching in Hfs;t g; dN . Case 2: s; t 2 V . Then we construct H 0 by adding two auxiliary vertices s 0 ; t 0 and two edges fs; s 0 g; ft; t 0 g with arbitrary weight. We reoptimize by Lemma 11.13 and delete the two new edges from the resulting minimum weight perfect matching in H 0 . Case 3: s 2 V and t 62 V . Then we construct H 0 by adding t, an auxiliary vertex s 0 , and an edge fs; s 0 g (with arbitrary cost) in addition to the edges incident to t. We reoptimize by Lemma 11.13 and delete the edge fs; s 0 g from the resulting minimum weight perfect matching in H 0 . Case 4: s 62 V and t 2 V . Symmetric to Case 3. Gabow [1983] improved the running time to O.minfn3 ; nm log ng/.

12.3 T-Joins and T-Cuts In this section we shall derive a polyhedral description of the MINIMUM WEIGHT T -JOIN PROBLEM. In contrast to the description of the perfect matching polytope (Theorem 11.15), where we had a constraint for each cut ı.X / with jX j odd, we now need a constraint for each T -cut. A T-cut is a cut ı.X / with jX \ T j odd. The following simple observation is very useful: Proposition 12.15. Let G be an undirected graph and T V .G/ with jT j even. Then for any T -join J and any T -cut C we have J \ C 6D ;. Proof: Suppose C D ı.X /, then jX \ T j is odd. So the number of edges in J \ C must be odd, in particular nonzero. A stronger statement can be found in Exercise 12. Proposition 12.15 implies that the minimum cardinality of a T -join is not less than the maximum number of pairwise edge-disjoint T -cuts. In general, we do not have equality: consider G D K4 and T D V .G/. However, for bipartite graphs equality holds:

310

12 b-Matchings and T -Joins

Theorem 12.16. (Seymour [1981]) Let G be a bipartite graph and T V .G/ such that a T -join in G exists. Then the minimum cardinality of a T -join equals the maximum number of pairwise edge-disjoint T -cuts. Proof: (Seb˝o [1987]) We only have to prove “”. We use induction on jV .G/j. If T D ; (in particular if jV .G/j D 1), the statement is trivial. So we assume jV .G/j jT j 2. Denote by .G; T / the minimum cardinality of a T -join in G (and 1 if no T -join exists). We will use Proposition 12.8 (for unit weights) and Proposition 12.6 several times. We may assume that there exists a T -join in G because otherwise there is an empty T -cut that we can list an infinite number of times. Choose a; b 2 V .G/ such that .G; T 4fag4fbg/ is minimum. Let T 0 WD T 4fag4fbg. As one possible choice of a and b consists of the endpoints of an edge in a minimum T -join (note that T 6D ;), we have .G; T 0 / < .G; T / and hence a 6D b and T 0 D T 4fa; bg. Claim: For any minimum T -join J in G we have jJ \ ı.a/j D jJ \ ı.b/j D 1. To prove this claim, let J be a minimum T -join and J 0 a minimum T 0 -join. J 4J 0 is the edge-disjoint union of an a-b-path P and some circuits C1 ; : : : ; Ck . We have jE.Ci / \ J j D jE.Ci / \ J 0 j for each i , because both J and J 0 are minimum. So jJ 4E.P /j D jJ 0 j, and J 00 WD J 4E.P / is also a minimum T 0 -join. Now J 00 \ ı.a/ D J 00 \ ı.b/ D ;, because if, say, fb; b 0 g 2 J 00 , J 00 n ffb; b 0 gg is a .T 4fag4fb 0g/-join, and we have .G; T 4fag4fb 0g/ < jJ 00 j D jJ 0 j D .G; T 0 /, contradicting the choice of a and b. We conclude that jJ \ ı.a/j D jJ \ ı.b/j D 1, and the claim is proved. In particular, a; b 2 T . Now let J be a minimum T -join in G. Contract B WD fbg [ .b/ to a single vertex vB , and let the resulting graph be G . G is also bipartite. Let T WD T n B if jT \ Bj is even and T WD .T n B/ [ fvB g otherwise. The set J , resulting from J by the contraction of B, is obviously a T -join in G . Since .b/ is a stable set in G (as G is bipartite), the claim implies that jJ j D jJ j C 1. It suffices to prove that J is a minimum T -join in G , because then we have .G; T / D jJ j D jJ j C 1 D .G ; T / C 1, and the theorem follows by induction (observe that ı.b/ is a T -cut in G disjoint from E.G /). So suppose that J is not a minimum T -join in G . Then by Proposition 12.8 there is a circuit C in G with jJ \E.C /j > jE.C /nJ j. Since G is bipartite, jJ \ E.C /j jE.C / n J j C 2. E.C / corresponds to an edge set Q in G. Q cannot be a circuit, because jJ \ Qj > jQ n J j and J is a minimum T -join. Hence Q is an x-y-path in G for some x; y 2 .b/ with x 6D y. Let C be the circuit in G formed by Q together with fx; bg and fb; yg. Since J is a minimum T -join in G, jJ \ E.C /j jE.C / n J j jE.C / n J j C 2 jJ \ E.C /j jJ \ E.C /j: Thus we must have equality throughout, in particular fx; bg; fb; yg … J and jJ \ E.C /j D jE.C /nJ j. So JN WD J 4E.C / is also a minimum T -join and jJN \ı.b/j D 3. But this is impossible by the claim.

12.3

T -Joins and T -Cuts

311

Corollary 12.17. Let G be a graph, c W E.G/ ! ZC , and T V .G/ such that a T -join in G exists. Let k be the minimum cost of a T -join in G. Then there are T -cuts C1 ; : : : ; C2k such that each edge e 2 E.G/ is contained in at most 2c.e/ of them. Proof: Let E0 be the set of edges with weight zero. We construct a bipartite graph G 0 by contracting the connected components of .V .G/; E0 / and replacing each edge e by a path of length 2c.e/. Let T 0 be the set of vertices in G 0 corresponding to connected components X of .V .G/; E0 / with jX \ T j odd. Claim: The minimum cardinality of a T 0 -join in G 0 is 2k. To prove this, first note that it cannot be more than 2k as every T -join J in G corresponds to a T 0 -join in G 0 of cardinality at most 2c.J /. Conversely, let J 0 be a T 0 -join in G 0 . It corresponds to an edge set J in G. Let TN WD T 4fv 2 V .G/ W jı.v/\J j oddg. Then each connected component X of .V .G/; E0 / contains an even number of vertices of TN (as jı.X / \ J j jX \ T j .mod 2/). By Proposition 12.7 0 .V .G/; E0 / has a TN -join JN , and J [ JN is a T -join in G with weight c.J / D jJ2 j . The claim is proved. By Theorem 12.16, there are 2k pairwise edge-disjoint T 0 -cuts in G 0 . Back in G, this yields a list of 2k T -cuts in G such that every edge e is contained in at most 2c.e/ of these. Karzanov [1986] described an efficient algorithm for finding such a T -cut packing. T -cuts are also essential in the following description of the T -join polyhedron: Theorem 12.18. (Edmonds and Johnson [1973]) Let G be an undirected graph, c W E.G/ ! RC , and T V .G/ such that a T -join in G exists. Then the incidence vector of each minimum weight T -join is an optimum solution of the LP ( ) X min cx W x 0; xe 1 for all T -cuts C : e2C

(This polyhedron is called the T-join polyhedron of G.) Proof: By Proposition 12.15, the incidence vector of a T -join satisfies the constraints. Moreover, by Proposition 12.7, every 0-1-vector satisfying the constraints is the incidence vector of an edge set containing a T -join. Therefore, by (g) )(f) of Theorem 5.13, it suffices to show that the LP value is an integer for every integral c for which the minimum is finite, i.e., for every c W E.G/ ! ZC . So let c W E.G/ ! ZC , and let k be the minimum weight (with respect to c) of a T -join in G. By Corollary 12.17 there are T -cuts C1 ; : : : ; C2k in G such that every edge e is contained in at most 2c.e/ of these. So for any feasible solution x of the above LP we have 2cx

2k X X i D1 e2Ci

xe 2k;

312

12 b-Matchings and T -Joins

proving that the optimum value of the LP is k.

This implies Theorem 11.15: let G be a graph with a perfect matching and T WD V .G/. Then Theorem 12.18 implies that ( ) X min cx W x 0; xe 1 for all T -cuts C e2C

is an integer for each c 2 ZE.G/ for which the minimum is finite. By Theorem 5.13, the polyhedron is integral, and so is its face 9 8 = < X X W x 1 for all T -cuts C; x D 1 for all v 2 V .G/ : x 2 RE.G/ e e C ; : e2C

e2ı.v/

One can also derive a description of the convex hull of the incidence vectors of all T -joins (Exercise 16). Theorems 12.18 and 4.21 (along with Corollary 3.33) imply another polynomial-time algorithm for the M INIMUM WEIGHT T -JOIN PROBLEM if we can solve the SEPARATION PROBLEM for the above description. This is obviously equivalent to checking whether there exists a T -cut with capacity less than one (here x serves as capacity vector). So it suffices to solve the following problem:

MINIMUM CAPACITY T -CUT PROBLEM Instance: Task:

A graph G, capacities u W E.G/ ! RC , and a nonempty set T V .G/ of even cardinality. Find a minimum capacity T -cut in G.

Note that the MINIMUM CAPACITY T -CUT PROBLEM also solves the SEPARAPROBLEM for the perfect matching polytope (Theorem 11.15; T WD V .G/). The following theorem solves the MINIMUM CAPACITY T -CUT PROBLEM: it suffices to consider the fundamental cuts of a Gomory-Hu tree. Recall that we can find a Gomory-Hu tree for an undirected graph with capacities in O.n4 / time (Theorem 8.38). TION

Theorem 12.19. (Padberg and Rao [1982]) Let G be an undirected graph with capacities u W E.G/ ! RC . Let H be a Gomory-Hu tree for .G; u/. Let T V .G/ with jT j 2 even. Then there is a minimum capacity T -cut among the fundamental cuts of H . Hence a minimum capacity T -cut can be found in O.n4 / time. Proof: Let ıG .X / be a minimum capacity T -cut in .G; u/. Let J be the set of edges e of H for which P jCe \ T j is odd, where Ce is a connected component of H e. As jıJ .x/j e2ıH .x/ jCe \ T j jfxg \ T j .mod 2/ for all x 2 V .G/, J is a T -join in H . By Proposition 12.15, there exists an edge f 2 ıH .X / \ J . We have u.ıG .X // minfu.ıG .Y // W jY \ f j D 1g D u.ıG .Cf //; showing that ıG .Cf / is a minimum capacity T -cut.

12.4

The Padberg-Rao Theorem

313

12.4 The Padberg-Rao Theorem Theorem 12.19 was generalized by Letchford, Reinelt and Theis [2008]: Lemma 12.20. Let G be an undirected graph with at least one edge, T V .G/ with jT j even, and c; c 0 W E.G/ ! RC [ f1g. Then there is an O.n4 /-algorithm which finds sets X P V .G/ and F ı.X / such that jX \ T j C jF j is odd and P 0 e2ı.X/nF c.e/ C e2F c .e/ is minimum. Proof: Since adding edges e with c.e/ D 0 and c 0 .e/ D 1 does not change anything, we may assume that G is connected. Let d.e/ WD minfc.e/; c 0 .e/g (e 2 E.G/). Let E 0 WD fe 2 E.G/ W c 0 .e/ < c.e/g and V 0 WD fv 2 V .G/ W jıE 0 .v/j oddg. Let T 0 WD T 4V 0 . Note: for X V .G/ we have jX \ T j C jı.X / \ E 0 j jX \ T j C jX \ V 0 j jX \ T 0 j .mod 2/. The algorithm first computes a Gomory-Hu tree H for .G; d /. For each f 2 E.H /, let Xf be the vertex set of a connected component of H f . Let gf 2 ıG .Xf / with jc 0 .gf / c.gf /j minimum. Then let Ff WD ıG .Xf / \ E 0 if jXf \ T 0 j is odd andP Ff WD .ıG .Xf /\E 0 /4fg P f g otherwise. Finally, we choose an f 2 E.H / such that e2ıG .Xf /nFf c.e/C e2Ff c 0 .e/ is minimum, and output X WD Xf and F WD Ff . The total running time is clearly dominated by computing the Gomory-Hu tree. Let ı.X / be optimum sets, i.e. jX \ T j C jF j is odd P X V .G/ and F P and e2ıG .X /nF c.e/ C e2F c 0 .e/ is minimum. Case 1: jX \T 0 j is odd. Then the set of f 2 E.H / such that jXf \T 0 j is odd is a T 0 -join in H , and thus has nonempty intersection with the T 0 -cut ıH .X /. Let f 2 0 ıH .X / with jXP f \ T j odd. By definition P of the Gomory-Hu tree, d.ıG .Xf // d.ıG .X // and e2ıG .Xf /nFf c.e/ C e2Ff c 0 .e/ D d.ıG .Xf //. Case 2: jX \ T 0 j is even. Let g 2 ıG .X / with jc 0 .g / c.g /j min imum. The unique circuit P in H 0 C g contains an edge f 0 2 ıH .X /. Then P .e/ D d.ıG .X //P C jc .g / c.g /j e2ıG .X /nF c.e/ C e2F cP d.ıG .Xf // C jc 0 .g / c.g /j e2ıG .Xf /nFf c.e/ C e2Ff c 0 .e/. Here the first inequality follows from the definition of a Gomory-Hu tree (note that f 2 ıH .X /), and the second inequality follows from g 2 ıG .Xf /. With this we can solve the SEPARATION PROBLEM for the b-matching polytope (Theorem 12.3) in polynomial time. This result is known as Padberg-Rao Theorem. Letchford, Reinelt and Theis [2008] simplified the proof and improved the running time: Theorem 12.21. (Padberg and Rao [1982], Letchford, Reinelt and Theis [2008]) For undirected graphs G, u W E.G/ ! N [ f1g and b W V .G/ ! N, the SEPARATION PROBLEM for the b-matching polytope of .G; u/ can be solved in O.n4 / time. E.G/

Proof: Given a vector x 2 RC with xe u.e/ for all e 2 E.G/ and P e2ıG .v/ xe b.v/ for all v 2 V .G/ (these trivial inequalities can be checked

314

12 b-Matchings and T -Joins

in linear time), we have to check the last set of inequalities in Theorem 12.3. In the proof of Theorem 12.3 we saw that these inequalities are automatically satisfied whenever b.X / C u.F / is even. They are violated iff X X b.X / 2 xe C .u.e/ 2xe / < 1 e2F

e2E.GŒX/

for some X V .G/ and F ı.X / with b.X / C u.F / odd. We extend G to a graph GN by adding a new vertex ´ and Pedges f´; vg for all N W b.v/ oddg, where b.´/ WD v 2 V .G/. Let T WD fv 2 V .G/ v2V .G/ b.v/. Let E 0 WD fe 2 E.G/ W u.e/ finite and oddg. We define c.e/ WD xe and c 0 .e/ WD u.e/xe for e 2 E 0 , c.e/P WD minfxe ; u.e/xe g and c 0 .e/ WD 1 for e 2 E.G/nE 0 , and c.f´; vg/ WD b.v/ e2ıG .v/ xe and c 0 .f´; vg/ WD 1 for v 2 V .G/. For X V .G/ we write DX WD fe 2 ıG .X / n E 0 W u.e/ < 2xe g. For each X V .G/ and F ıG .X / \ E 0 we have: jX \ T j C jF j b.X / C u.F [ DX / .mod 2/ and c.ıGN .X / n F / C c 0 .F / D

X v2X

C

0 @b.v/

X

1

e2ıG .v/

X

X

e2E.GŒX/

xe C

xe

e2.ıG .X/\E 0 /nF

minfxe ; u.e/ xe g C

e2ıG .X/nE 0

D b.X / 2

X

xe A C

X

X

.u.e/ xe /

e2F

.u.e/ 2xe /:

e2F [DX

N and F ı N .X / with c.ı N .X / n We conclude: if there are sets X V .G/ G G 0 0 F / C c .F / < 1, then we have FP E and w.l.o.g. ´ … X (otherwise take the P complement), and hence b.X / 2 e2E.GŒX/ xe C e2F [DX .u.e/ 2xe / < 1. P P Conversely, if b.X / 2 e2E.GŒX/ xe C e2F .u.e/ 2xe / < 1 for some X V .G/ and F ıG .X /, then w.l.o.g. DX F DX [ E 0 , and hence c.ıGN .X / n .F n DX // C c 0 .F n DX / < 1. N and F Hence the separation problem reduces to finding sets X V .G/ 0 ıGN .X / with jX \ T j C jF j odd and c.ıGN .X / n F / C c .F / minimum. This can be done with Lemma 12.20. A generalization of this result has been found by Caprara and Fischetti [1996]. The Padberg-Rao Theorem implies: Corollary 12.22. The MAXIMUM WEIGHT b-MATCHING PROBLEM can be solved in polynomial time. Proof: By Corollary 3.33 we have to solve the LP given in Theorem 12.3. By Theorem 4.21 it suffices to have a polynomial-time algorithm for the SEPARATION PROBLEM. Such an algorithm is provided by Theorem 12.21.

Exercises

315

Marsh [1979] extended Edmonds’ WEIGHTED MATCHING ALGORITHM to the MAXIMUM WEIGHT b-MATCHING PROBLEM. This combinatorial algorithm is of course more practical than using the ELLIPSOID METHOD. But Theorem 12.21 is also interesting for other purposes (see e.g. Section 21.4). See also Gerards [1995]. Combinatorial algorithms with strongly polynomial running time were described by Anstee [1987], and for the unweighted case by Goldberg and Karzanov [2004].

Exercises

1. Show that a minimum weight perfect simple 2-matching in an undirected graph G can be found in O.n6 / time. 2. Let G be an undirected graph and b1 ; b2 W V .G/ P ! N. Describe the convex hull of functions f W E.G/ ! ZC with b1 .v/ e2ı.v/ f .e/ b2 .v/. Hint: For X; Y V .G/ with X \ Y D ; consider the constraint 6 0 17 6 7 X X X 61 X 7 f .e/ f .e/ 4 @ b2 .x/ b1 .y/A5 ; 2 e2E.GŒX/

3.

4.

5.

6.

7.

e2E.GŒY /[E.Y;Z/

x2X

y2Y

where Z WD V .G/ n .X [ Y /. Use Theorem 12.3. (Schrijver [1983]) Can one generalize the result of Exercise 2 further by introducing lower and upper capacities on the edges? Note: This can be regarded as an undirected version of the problem in Exercise 2 of Chapter 9. For a common generalization of both problems and also the MINIMUM WEIGHT T -JOIN PROBLEM see the papers of Edmonds and Johnson [1973], and Schrijver [1983]. Even here a description of the polytope that is TDI is known. Prove Theorem 12.4. Hint: For the sufficiency, use Tutte’s Theorem 10.13 and the constructions in the proofs of Theorems 12.2 and 12.3. The subgraph degree polytope of a graph G is defined to be the convex hull of V .G/ all vectors b 2 ZC such that G has a perfect simple b-matching. Prove that its dimension is jV .G/j k, where k is the number of connected components of G that are bipartite. Given an undirected graph, an odd cycle cover is defined to be a subset of edges containing at least one edge of each odd circuit. Show how to find in polynomial time a minimum weight odd cycle cover in a planar graph with nonnegative weights on the edges. Can you also solve the problem for general weights? Hint: Consider the UNDIRECTED CHINESE POSTMAN PROBLEM in the planar dual graph and use Theorem 2.26 and Corollary 2.45. Consider the MAXIMUM WEIGHT CUT PROBLEM in planar graphs: Given an undirected planar graph G with weights c W E.G/ ! RC , we look for a

316

12 b-Matchings and T -Joins

maximum weight cut. Can one solve this problem in polynomial time? Hint: Use Exercise 6. Note: For general graphs this problem is NP-hard; see Theorem 16.6. (Hadlock [1975]) 8. Given a graph G with weights c W E.G/ ! RC and a set T V .G/ with jT j even. We construct a new graph G 0 by setting V .G 0 / WD f.v; e/ W v 2 e 2 E.G/g [ fvN W v 2 V .G/; jıG .v/j C jfvg \ T j oddg; E.G 0 / WD ff.v; e/; .w; e/g W e D fv; wg 2 E.G/g [ ff.v; e/; .v; f /g W v 2 V .G/; e; f 2 ıG .v/; e 6D f g [ ffv; N .v; e/g W v 2 e 2 E.G/; vN 2 V .G 0 /g; and define c 0 .f.v; e/; .w; e/g/ WD c.e/ for e D fv; wg 2 E.G/ and c 0 .e 0 / D 0 for all other edges e 0 of G 0 . Show that a minimum weight perfect matching in G 0 corresponds to a minimum weight T -join in G. Is this reduction preferable to the one used in the proof of Theorem 12.10?

9. The following problem combines simple perfect b-matchings and T -joins. We are given an undirected graph G with weights c W E.G/ ! R, a partition of the : : vertex set V .G/ D R [ S [ T , and a function b W R ! ZC . We ask for a minimum weight subset of edges J E.G/ such that jJ \ ı.v/j D b.v/ for v 2 R, jJ \ı.v/j is even for v 2 S , and jJ \ı.v/j is odd for v 2 T . Show how to reduce this problem to a MINIMUM WEIGHT PERFECT MATCHING PROBLEM. Hint: Consider the constructions in Section 12.1 and Exercise 8. 10. We consider the UNDIRECTED MINIMUM MEAN CYCLE PROBLEM: Given an undirected graph G and weights c W E.G/ ! R, find a circuit C in G // whose mean weight c.E.C is minimum. Let .G; c/ be an instance. Let D be jE.C /j the set of ;-joins in G. For a 2 R and X 2 D let c a .X / WD c.X / ajX j and a. Prove: cNa .X / WD c.X/ jXj (a) For any a 2 R, we can find an element X 2 D with c a .X / minimum in O.n3 / time. (b) Let a 2 R such that c a .Y / 0 for all Y 2 D, and let X 2 D with c a .X / minimum. Then there exists a Y 2 D with c aCb .Y / 0, where b D cNa .X /. (c) Consider the following procedure. Start with a D maxfc.e/ W e 2 E.G/g. Compute an element X 2 D with c a .X / minimum. Stop if c a .X / D 0. Otherwise replace a by a C cNa .X / and iterate. Show that jX j is getting smaller in each iteration. (d) Show that the algorithm in (c) computes an optimum solution in O.n5 / time. Note: The running time can be improved to O.n2 m C n3 log n/. Essentially the same algorithm works also for other minimum ratio problems. (Karzanov [1985], Barahona [1993], Babenko and Karzanov [2009])

Exercises

317

11. Given a graph G and a set T V .G/, describe a linear-time algorithm to find a T -join in G or decide that none exists. Hint: Consider a maximal forest in G. 12. Let G be an undirected graph, T V .G/ with jT j even, and F E.G/. Prove: F has nonempty intersection with every T -join if and only if F contains a T -cut. F has nonempty intersection with every T -cut if and only if F contains a T -join. 13. Let G be a graph and F E.G/. Prove that there exists a set A with F A E.G/ such that .V .G/; A/ is Eulerian if and only if G contains no cut B with B F and jBj odd.

14. Let G be a planar 2-connected graph with a fixed embedding, let C be the circuit bounding the outer face, and let T be an even cardinality subset of V .C /. Prove that the minimum cardinality of a T -join equals the maximum number of pairwise edge-disjoint T -cuts. Hint: Colour the edges of C red and blue such that, when traversing C , colours change precisely at the vertices in T . Consider the planar dual graph, split the vertex representing the outer face into a red and a blue vertex, and apply Menger’s Theorem 8.9. 15. Prove Theorem 12.18 using Theorem 11.15 and the construction of Exercise 8. (Edmonds and Johnson [1973]) 16. Let G be an undirected graph and T V .G/ with jT j even. Prove that the convex hull of the incidence vectors of all T -joins in G is the set of all vectors x 2 Œ0; 1E.G/ satisfying X X xe C .1 xe / 1 e2ıG .X/nF

e2F

for all X V .G/ and F ıG .X / with jX \ T j C jF j odd. Hint: Use Theorems 12.18 and 12.11. 17. Let G be an undirected graph. Show that the cone generated by the incidence vectors of all circuits in G is 8 9 < = X x 2 RE.G/ W x 0; x.e 0 / x.e/ for all cuts C in G and e 2 C : : ; 0 e 2C nfeg

Hint: Use Exercise 16. 18. Describe the UNDIRECTED MINIMUM MEAN CYCLE PROBLEM as a linear program with polynomially many variables and constraints. Hint: Use Exercise 17, add the constraint x.E.G// D 1, and use the Max-FlowMin-Cut Theorem. (Barahona [1993]) Note: Since we need extra variables, this is called an extended formulation. Barahona [1993] also showed how to solve the MINIMUM WEIGHT T -JOIN PROBLEM by starting with any T -join and successively applying Proposition

318

12 b-Matchings and T -Joins

12.8, looking for a minimum mean weight circuit, where weights of the current T -join are multiplied by 1. The number of iterations can be bounded by O.m2 log n/. Hence one can solve the MINIMUM WEIGHT T -JOIN PROBLEM (and hence the MINIMUM WEIGHT PERFECT MATCHING PROBLEM) by solving a polynomial number of polynomial-size LPs. Nevertheless, no polynomialsize LP description for weighted matching is known (cf. Yannakakis [1991]). 19. Let G be an undirected graph and T V .G/ with jT j D 2k even. Prove that the minimum cardinality of a T -cut in G equals the maximum of minkiD1 si ;ti over all pairings T D fs1 ; t1 ; s2 ; t2 ; : : : ; sk ; tk g. (s;t denotes the maximum number of pairwise edge-disjoint s-t-paths.) Can you think of a weighted version of this min-max formula? Hint: Use Theorem 12.19. (Rizzi [2002]) 20. This exercise gives an algorithm for the MINIMUM CAPACITY T -CUT PROBLEM without using Gomory-Hu trees. The algorithm is recursive and – given G, u and T – proceeds as follows: 1. First wePfind a set X V .G/ with T \ X 6D ; and T n X 6D ;, such that u.X / WD e2ıG .X/ u.e/ is minimum (cf. Exercise 30 of Chapter 8). If jT \ X j happens to be odd, we are done (return X ). 2. Otherwise we apply the algorithm recursively first to G, u and T \ X , and then to G, u and T n X . We obtain a set Y V .G/ with j.T \ X / \ Y j odd and u.Y / minimum and a set Z V .G/ with j.T n X / \ Zj odd and u.Z/ minimum. W.l.o.g. T n X 6 Y and X \ T 6 Z (otherwise replace Y by V .G/ n Y and/or Z by V .G/ n Z). 3. If u.X \ Y / < u.Z n X / then return X \ Y else return Z n X . Show that this algorithm works correctly and that its running time is O.n5 /, where n D jV .G/j. 21. Show how to solve the MAXIMUM WEIGHT b-MATCHING PROBLEM for the special case when b.v/ is even for all v 2 V .G/ in strongly polynomial time. Hint: Reduction to a MINIMUM COST FLOW PROBLEM as in Exercise 10 of Chapter 9.

References General Literature: Cook, W.J., Cunningham, W.H., Pulleyblank, W.R., and Schrijver, A. [1998]: Combinatorial Optimization. Wiley, New York 1998, Sections 5.4 and 5.5 Frank, A. [1996]: A survey on T -joins, T -cuts, and conservative weightings. In: Combinatorics, Paul Erd˝os is Eighty; Volume 2 (D. Miklós, V.T. Sós, T. Sz˝onyi, eds.), Bolyai Society, Budapest 1996, pp. 213–252 Gerards, A.M.H. [1995]: Matching. In: Handbooks in Operations Research and Management Science; Volume 7: Network Models (M.O. Ball, T.L. Magnanti, C.L. Monma, G.L. Nemhauser, eds.), Elsevier, Amsterdam 1995, pp. 135–224

References

319

Lovász, L., and Plummer, M.D. [1986]: Matching Theory. Akadémiai Kiadó, Budapest 1986, and North-Holland, Amsterdam 1986 Schrijver, A. [1983]: Min-max results in combinatorial optimization; Section 6. In: Mathematical Programming; The State of the Art – Bonn 1982 (A. Bachem, M. Grötschel, B. Korte, eds.), Springer, Berlin 1983, pp. 439–500 Schrijver, A. [2003]: Combinatorial Optimization: Polyhedra and Efficiency. Springer, Berlin 2003, Chapters 29–33

Cited References: Anstee, R.P. [1987]: A polynomial algorithm for b-matchings: an alternative approach. Information Processing Letters 24 (1987), 153–157 Babenko, M.A. and Karzanov, A.V. [2009]: Minimum mean cycle problem in bidirected and skew-symmetric graphs. Discrete Optimization 6 (2009), 92–97 Barahona, F. [1993]: Reducing matching to polynomial size linear programming. SIAM Journal on Optimization 3 (1993), 688–695 Caprara, A., and Fischetti, M. [1996]: f0; 12 g-Chvátal-Gomory cuts. Mathematical Programming 74 (1996), 221–235 Edmonds, J. [1965]: Maximum matching and a polyhedron with (0,1) vertices. Journal of Research of the National Bureau of Standards B 69 (1965), 125–130 Edmonds, J., and Johnson, E.L. [1970]: Matching: A well-solved class of integer linear programs. In: Combinatorial Structures and Their Applications; Proceedings of the Calgary International Conference on Combinatorial Structures and Their Applications 1969 (R. Guy, H. Hanani, N. Sauer, J. Schönheim, eds.), Gordon and Breach, New York 1970, pp. 69–87 Edmonds, J., and Johnson, E.L. [1973]: Matching, Euler tours and the Chinese postman problem. Mathematical Programming 5 (1973), 88–124 Gabow, H.N. [1983]: An efficient reduction technique for degree-constrained subgraph and bidirected network flow problems. Proceedings of the 15th Annual ACM Symposium on Theory of Computing (1983), 448–456 Goldberg, A.V., and Karzanov, A.V. [2004]: Maximum skew-symmetric flows and matchings. Mathematical Programming A 100 (2004), 537–568 Guan, M. [1962]: Graphic programming using odd and even points. Chinese Mathematics 1 (1962), 273–277 Hadlock, F. [1975]: Finding a maximum cut of a planar graph in polynomial time. SIAM Journal on Computing 4 (1975), 221–225 Karzanov, A.V. [1985]: Minimum mean weight cuts and cycles in directed graphs. In: Kachestvennye i Priblizhennye Metody Issledovaniya Operatornykh Uravneni˘ı (V.S. Klimov, ed.), Yaroslavl State University Press, Yaroslavl 1985, pp. 72–83 [in Russian]. English translation: American Mathematical Society Translations Ser. 2, Vol. 158 (1994), 47–55 Karzanov, A.V. [1986]: An algorithm for determining a maximum packing of odd-terminus cuts and its applications. In: Isslidovaniya po Prikladno˘ı Teorii Grafov (A.S. Alekseev, ed.), Nauka Siberian Dept., Novosibirsk, 1986, pp. 126–140 [in Russian]. English translation: American Mathematical Society Translations Ser. 2, Vol. 158 (1994), 57–70 Letchford, A.N., Reinelt, G., and Theis, D.O. [2008]: Odd minimum cut sets and b-matchings revisited. SIAM Journal on Discrete Mathematics 22 (2008), 1480–1487 Marsh, A.B. [1979]: Matching algorithms. Ph.D. thesis, Johns Hopkins University, Baltimore 1979

320

12 b-Matchings and T -Joins

Padberg, M.W., and Rao, M.R. [1982]: Odd minimum cut-sets and b-matchings. Mathematics of Operations Research 7 (1982), 67–80 Pulleyblank, W.R. [1973]: Faces of matching polyhedra. Ph.D. thesis, University of Waterloo, 1973 Pulleyblank, W.R. [1980]: Dual integrality in b-matching problems. Mathematical Programming Study 12 (1980), 176–196 Rizzi, R. [2002]: Minimum T -cuts and optimal T -pairings. Discrete Mathematics 257 (2002), 177–181 Seb˝o, A. [1987]: A quick proof of Seymour’s theorem on T -joins. Discrete Mathematics 64 (1987), 101–103 Seymour, P.D. [1981]: On odd cuts and multicommodity flows. Proceedings of the London Mathematical Society (3) 42 (1981), 178–192 Tutte, W.T. [1952]: The factors of graphs. Canadian Journal of Mathematics 4 (1952), 314–328 Tutte, W.T. [1954]: A short proof of the factor theorem for finite graphs. Canadian Journal of Mathematics 6 (1954), 347–352 Yannakakis, M. [1991]: Expressing combinatorial optimization problems by linear programs. Journal of Computer and System Sciences 43 (1991), 441–466

13 Matroids

Many combinatorial optimization problems can be formulated as follows. Given a set system .E; F /, i.e. a finite set E and some F 2E , and a cost function c W F ! R, find an element of F whose cost is minimum or maximum. PIn the following we consider modular functions c, i.e. assume that c.X / D c.;/C x2X .c.fxg/c.;// for all X E; equivalently we are given a function c W E ! R and write c.X / D P e2X c.e/. In this chapter we restrict ourselves to those combinatorial optimization problems where F describes an independence system (i.e. is closed under subsets) or even a matroid. The results of this chapter generalize several results obtained in previous chapters. In Section 13.1 we introduce independence systems and matroids and show that many combinatorial optimization problems can be described in this context. There are several equivalent axiom systems for matroids (Section 13.2) and an interesting duality relation discussed in Section 13.3. The main reason why matroids are important is that a simple greedy algorithm can be used for optimization over matroids. We analyze greedy algorithms in Section 13.4 before turning to the problem of optimizing over the intersection of two matroids. As shown in Sections 13.5 and 13.7 this problem can be solved in polynomial time. This also solves the problem of covering a matroid by independent sets as discussed in Section 13.6.

13.1 Independence Systems and Matroids Definition 13.1. A set system .E; F / is an independence system if (M1) ; 2 F ; (M2) If X Y 2 F then X 2 F . The elements of F are called independent, the elements of 2E n F dependent. Minimal dependent sets are called circuits, maximal independent sets are called bases. For X E, the maximal independent subsets of X are called bases of X . Definition 13.2. Let .E; F / be an independence system. For X E we define the rank of X by r.X / WD maxfjY j W Y X; Y 2 F g. Moreover, we define the closure of X by .X / WD fy 2 E W r.X [ fyg/ D r.X /g.

B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__13, c Springer-Verlag Berlin Heidelberg 2012

321

322

13 Matroids

Throughout this chapter, .E; F / will be an independence system, and c W E ! R will be a cost function. We shall concentrate on the following two problems:

MAXIMIZATION PROBLEM FOR INDEPENDENCE SYSTEMS Instance: Task:

An independence system .E; F/ and c W E ! R. P Find an X 2 F such that c.X / WD e2X c.e/ is maximum.

MINIMIZATION PROBLEM FOR INDEPENDENCE SYSTEMS Instance:

An independence system .E; F/ and c W E ! R.

Task:

Find a basis B such that c.B/ is minimum.

The instance specification is somewhat vague. The set E and the cost function c are given explicitly as usual. However, the set F is usually not given by an explicit list of its elements. Rather one assumes an oracle which – given a subset F E – decides whether F 2 F . We shall return to this question in Section 13.4. The following list shows that many combinatorial optimization problems actually have one of the above two forms: (1) MAXIMUM WEIGHT STABLE SET PROBLEM Given a graph G and weights c W V .G/ ! R, find a stable set X in G of maximum weight. Here E D V .G/ and F D fF E W F is stable in Gg. (2) TSP Given a complete undirected graph G and weights c W E.G/ ! RC , find a minimum weight Hamiltonian circuit in G. Here E D E.G/ and F D fF E W F is a subset of edges of a Hamiltonian circuit in Gg. (3) SHORTEST PATH PROBLEM Given a graph G (directed or undirected), c W E.G/ ! R and s; t 2 V .G/ such that t is reachable from s, find a shortest s-t-path in G with respect to c. Here E D E.G/ and F D fF E W F is a subset of edges of an s-t-pathg. (4) KNAPSACK PROBLEM Given n 2 N and nonnegative .1 i n/ and W , find a subset P numbers ci ; wi P S f1; : : : ; ng such that j 2S wj W and j 2S cj is maximum. n o P Here E D f1; : : : ; ng and F D F E W j 2F wj W . (5) MINIMUM SPANNING TREE PROBLEM Given a connected undirected graph G and weights c W E.G/ ! R, find a minimum weight spanning tree in G. Here E D E.G/ and the elements of F are the edge sets of the forests in G. (6) MAXIMUM WEIGHT FOREST PROBLEM Given an undirected graph G and weights c W E.G/ ! R, find a maximum weight forest in G. Here .E; F / is as in (5).

13.1

Independence Systems and Matroids

323

(7) STEINER TREE PROBLEM Given a connected undirected graph G, weights c W E.G/ ! RC , and a set T V .G/ of terminals, find a Steiner tree for T , i.e. a tree S with T V .S / and E.S / E.G/, such that c.E.S // is minimum. Here E D E.G/ and F contains all subsets of edges of Steiner trees for T . (8) MAXIMUM WEIGHT BRANCHING PROBLEM Given a digraph G and weights c W E.G/ ! R, find a maximum weight branching in G. Here E D E.G/ and F contains the edge sets of the branchings in G. (9) MAXIMUM WEIGHT MATCHING PROBLEM Given an undirected graph G and weights c W E.G/ ! R, find a maximum weight matching in G. Here E D E.G/ and F is the set of matchings in G. This list contains NP-hard problems ((1),(2),(4),(7)) as well as polynomially solvable problems ((5),(6),(8),(9)). Problem (3) is NP-hard in the above form but polynomially solvable for nonnegative weights. (NP-hardness is introduced in Chapter 15.) Definition 13.3. An independence system is a matroid if (M3) If X; Y 2 F and jX j > jY j, then there is an x 2 X n Y with Y [ fxg 2 F . The name matroid points out that the structure is a generalization of matrices. This will become clear by our first example: Proposition 13.4. The following independence systems .E; F / are matroids: (a) E F (b) E F (c) E (d) E (s (e) E F

is the set of columns of a matrix A over some field, and WD fF E W The columns in F are linearly independent over that fieldg. is the set of edges of some undirected graph G and WD fF E W .V .G/; F / is a forestg. is a finite set, k a nonnegative integer, and F WD fF E W jF j kg. is the set of edges of some undirected graph G, S a stable set in G, ks 2 ZC 2 S ), and F WD fF E W jıF .s/j ks for all s 2 S g. is the set of edges of some digraph G, S V .G/, ks 2 ZC (s 2 S ), and WD fF E W jıF .s/j ks for all s 2 S g.

Proof: In all cases it is obvious that .E; F / is indeed an independence system. So it remains to show that (M3) holds. For (a) this is well-known from linear algebra, for (c) it is trivial. To prove (M3) for (b), let X; Y 2 F and suppose Y [ fxg 62 F for all x 2 X n Y . We show that jX j jY j. For each edge x D fv; wg 2 X , v and w are in the same connected component of .V .G/; Y /. Hence each connected component Z V .G/ of .V .G/; X / is a subset of a connected component of .V .G/; Y /. So the number p of connected components of the forest .V .G/; X / is greater than or equal to the number q of connected components of the forest .V .G/; Y /. But then jV .G/j jX j D p q D jV .G/j jY j, implying jX j jY j.

324

13 Matroids

To verify (M3) for (d), let X; Y 2 F with jX j > jY j. Let S 0 WD fs 2 S W jıY .s/j D ks g. As jX j > jY j and jıX .s/j ks for all s 2 S 0 , there exists an e 2 X n Y with e … ı.s/ for s 2 S 0 . Then Y [ feg 2 F . For (e) the proof is identical except for replacing ı by ı . Some of these matroids have special names: The matroid in (a) is called the vector matroid of A. Let M be a matroid. If there is a matrix A over the field F such that M is the vector matroid of A, then M is called representable over F . There are matroids that are not representable over any field. The matroid in (b) is called the cycle matroid of G and will sometimes be denoted by M.G/. A matroid that is the cycle matroid of some graph, which may contain loops, is called a graphic matroid. The matroids in (c) are called uniform matroids. In our list of independence systems at the beginning of this section, the only matroids are the graphic matroids in (5) and (6). To check that all the other independence systems in the above list are not matroids in general is easily proved with the help of the following theorem (Exercise 1): Theorem 13.5. Let .E; F / be an independence system. Then the following statements are equivalent: (M3) If X; Y 2 F and jX j > jY j, then there is an x 2 X n Y with Y [ fxg 2 F . (M30 ) If X; Y 2 F and jX j D jY jC1, then there is an x 2 X nY with Y [fxg 2 F. (M300 ) For each X E, all bases of X have the same cardinality. Proof: Trivially, (M3),(M30) and (M3))(M300). To prove (M300 ))(M3), let X; Y 2 F and jX j > jY j. By (M300 ), Y cannot be a basis of X [ Y . So there must be an x 2 .X [ Y / n Y D X n Y such that Y [ fxg 2 F . Sometimes it is useful to have a second rank function: Definition 13.6. Let .E; F / be an independence system. For X E we define the lower rank by .X / WD minfjY j W Y X; Y 2 F and Y [ fxg … F for all x 2 X n Y g: The rank quotient of .E; F / is defined by q.E; F / WD min

F E

.F / : r.F /

Proposition 13.7. Let .E; F / be an independence system. Then q.E; F / 1. Furthermore, .E; F / is a matroid if and only if q.E; F/ D 1. Proof: q.E; F / 1 follows from the definition. q.E; F / D 1 is obviously equivalent to (M300 ). To estimate the rank quotient, the following statement can be used:

13.2

Other Matroid Axioms

325

Theorem 13.8. (Hausmann, Jenkyns and Korte [1980]) Let .E; F / be an independence system. If, for any A 2 F and e 2 E, A [ feg contains at most p circuits, then q.E; F / p1 . jJ j Proof: Let F E and J; K two bases of F . We show jKj p1 . Let J n K D fe1 ; : : : ; e t g. We construct a sequence K D K0 ; K1 ; : : : ; K t of independent subsets of J [ K such that J \ K Ki , Ki \ fe1 ; : : : ; e t g D fe1 ; : : : ; ei g and jKi 1 n Ki j p for i D 1; : : : ; t. Since Ki [ fei C1 g contains at most p circuits and each such circuit must meet Ki n J (because J is independent), there is an X Ki n J such that jX j p and .Ki n X / [ fei C1g 2 F . We set Ki C1 WD .Ki n X / [ fei C1 g. Now J K t 2 F . Since J is a basis of F , J D K t . We conclude that

jK n J j D

t X

jKi 1 n Ki j pt D p jJ n Kj;

i D1

proving jKj p jJ j.

This shows that in example (9) we have q.E; F / 12 (see also Exercise 1 of Chapter 10). In fact q.E; F / D 12 iff G contains a path of length 3 as a subgraph (otherwise q.E; F / D 1). For the independence system in example (1) of our list, the rank quotient can become arbitrarily small (choose G to be a star). In Exercise 6, the rank quotients for other independence systems will be discussed.

13.2 Other Matroid Axioms In this section we consider other axiom systems defining matroids. They characterize fundamental properties of the family of bases, the rank function, the closure operator and the family of circuits of a matroid. Theorem 13.9. Let E be a finite set and B 2E . B is the set of bases of some matroid .E; F / if and only if the following holds: (B1) B 6D ;; (B2) For any B1 ; B2 2 B and x 2 B1 n B2 there exists a y 2 B2 n B1 with .B1 n fxg/ [ fyg 2 B. Proof: The set of bases of a matroid satisfies (B1) (by (M1)) and (B2): For bases B1 ; B2 and x 2 B1 n B2 we have that B1 n fxg is independent. By (M3) there is some y 2 B2 n B1 such that .B1 n fxg/ [ fyg is independent. Indeed, it must be a basis, because all bases of a matroid have the same cardinality. On the other hand, let B satisfy (B1) and (B2). We first show that all elements of B have the same cardinality: Otherwise let B1 ; B2 2 B with jB1 j > jB2 j such that jB1 \ B2 j is maximum. Let x 2 B1 n B2 . By (B2) there is a y 2 B2 n B1 with .B1 n fxg/ [ fyg 2 B, contradicting the maximality of jB1 \ B2 j.

326

13 Matroids

Now let F WD fF E W there exists a B 2 B with F Bg: .E; F / is an independence system, and B is the family of its bases. To show that .E; F / satisfies (M3), let X; Y 2 F with jX j > jY j. Let X B1 2 B and Y B2 2 B, where B1 and B2 are chosen such that jB1 \ B2 j is maximum. If B2 \ .X n Y / 6D ;, we are done because we can augment Y . We claim that the other case, B2 \ .X n Y / D ;, is impossible. Namely, with this assumption we get jB1 \ B2 j C jY n B1 j C j.B2 n B1 / n Y j D jB2 j D jB1 j jB1 \ B2 j C jX n Y j: Since jX n Y j > jY n X j jY n B1 j, this implies .B2 n B1 / n Y 6D ;. So let y 2 .B2 n B1 / n Y . By (B2) there exists an x 2 B1 n B2 with .B2 n fyg/ [ fxg 2 B, contradicting the maximality of jB1 \ B2 j. See Exercise 8 for a similar statement. A very important property of matroids is that the rank function is submodular: Theorem 13.10. Let E be a finite set and r W 2E ! ZC . Then the following statements are equivalent: (a) r is the rank function of a matroid .E; F / (and F D fF E W r.F / D jF jg). (b) For all X; Y E: (R1) r.X / jX j; (R2) If X Y then r.X / r.Y /; (R3) r.X [ Y / C r.X \ Y / r.X / C r.Y /. (c) For all X E and x; y 2 E: (R10 ) r.;/ D 0; (R20 ) r.X / r.X [ fyg/ r.X / C 1; (R30 ) If r.X [ fxg/ D r.X [ fyg/ D r.X / then r.X [ fx; yg/ D r.X /. Proof: (a))(b): If r is a rank function of an independence system .E; F /, (R1) and (R2) evidently hold. If .E; F / is a matroid, we can also show (R3): Let X; Y E, and let A be a basis of X \ Y . By (M3), A can be extended to : : a basis A [ B of X and to a basis .A [ B/ [ C of X [ Y . Then A [ C is an independent subset of Y , so r.X / C r.Y / jA [ Bj C jA [ C j D 2jAj C jBj C jC j D jA [ B [ C j C jAj D r.X [ Y / C r.X \ Y /: (b))(c): (R10 ) is implied by (R1). r.X / r.X [ fyg/ follows from (R2). By (R3) and (R1),

13.2

Other Matroid Axioms

327

r.X [ fyg/ r.X / C r.fyg/ r.X \ fyg/ r.X / C r.fyg/ r.X / C 1; proving (R20 ). (R30 ) is trivial for x D y. For x 6D y we have, by (R2) and (R3), 2r.X / r.X / C r.X [ fx; yg/ r.X [ fxg/ C r.X [ fyg/; implying (R30 ). (c))(a): Let r W 2E ! ZC be a function satisfying (R10 )–(R30 ). Let F WD fF E W r.F / D jF jg: We claim that .E; F / is a matroid. (M1) follows from (R10 ). (R20 ) implies r.X / jX j for all X E. If Y 2 F , y 2 Y and X WD Y n fyg, we have jX j C 1 D jY j D r.Y / D r.X [ fyg/ r.X / C 1 jX j C 1; so X 2 F. This implies (M2). Now let X; Y 2 F and jX j D jY j C 1. Let X n Y D fx1 ; : : : ; xk g. Suppose that (M30 ) is violated, i.e. r.Y [ fxi g/ D jY j for i D 1; : : : ; k. Then by (R30 ) r.Y [ fx1 ; xi g/ D r.Y / for i D 2; : : : ; k. Repeated application of this argument yields r.Y / D r.Y [ fx1 ; : : : ; xk g/ D r.X [ Y / r.X /, a contradiction. So .E; F / is indeed a matroid. To show that r is the rank function of this matroid, we have to prove that r.X / D maxfjY j W Y X; r.Y / D jY jg for all X E. So let X E, and let Y a maximum subset of X with r.Y / D jY j. For all x 2 X n Y we have r.Y [ fxg/ < jY j C 1, so by (R20 ) r.Y [ fxg/ D jY j. Repeated application of (R30 ) implies r.X / D jY j. Theorem 13.11. Let E be a finite set and W 2E ! 2E a function. is the closure operator of a matroid .E; F / if and only if the following conditions hold for all X; Y E and x; y 2 E: (S1) (S2) (S3) (S4)

X .X /; X Y E implies .X / .Y /; .X / D ..X //; If y … .X / and y 2 .X [ fxg/ then x 2 .X [ fyg/.

Proof: If is the closure operator of a matroid, then (S1) holds trivially. For X Y and ´ 2 .X / we have by (R3) and (R2) r.X / C r.Y / D r.X [ f´g/ C r.Y / r..X [ f´g/ \ Y / C r.X [ f´g [ Y / r.X / C r.Y [ f´g/; implying ´ 2 .Y / and thus proving (S2). By repeated application of (R30 ) we have r..X // D r.X / for all X , which implies (S3).

328

13 Matroids

To prove (S4), suppose that there are X; x; y with y … .X /, y 2 .X [ fxg/ and x … .X [fyg/. Then r.X [fyg/ D r.X /C1, r.X [fx; yg/ D r.X [fxg/ and r.X [fx; yg/ D r.X [fyg/C1. Thus r.X [fxg/ D r.X /C2, contradicting (R20 ). To show the converse, let W 2E ! 2E be a function satisfying (S1)–(S4). Let F WD fX E W x … .X n fxg/ for all x 2 X g: We claim that .E; F / is a matroid. (M1) is trivial. For X Y 2 F and x 2 X we have x … .Y n fxg/ .X n fxg/, so X 2 F and (M2) holds. To prove (M3) we need the following statement: Claim: For X 2 F and Y E with jX j > jY j we have X 6 .Y /. We prove the claim by induction on jY n X j. If Y X , then let x 2 X n Y . Since X 2 F we have x … .X n fxg/ .Y / by (S2). Hence x 2 X n .Y / as required. If jY n X j > 0, then let y 2 Y n X . By the induction hypothesis there exists an x 2 X n .Y n fyg/. If x 62 .Y /, then we are done. Otherwise x … .Y n fyg/ but x 2 .Y / D ..Y n fyg/ [ fyg/, so by (S4) y 2 ..Y n fyg/ [ fxg/. By (S1) we get Y ..Y n fyg/ [ fxg/ and thus .Y / ..Y n fyg/ [ fxg/ by (S2) and (S3). Applying the induction hypothesis to X and .Y n fyg/ [ fxg (note that x 6D y) yields X 6 ..Y n fyg/ [ fxg/, so X 6 .Y / as required. Having proved the claim we can easily verify (M3). Let X; Y 2 F with jX j>jY j. By the claim there exists an x 2 X n .Y /. Now for each ´ 2 Y [ fxg we have ´ … .Y n f´g/, because Y 2 F and x … .Y / D .Y n fxg/. By (S4) ´ … .Y n f´g/ and x … .Y / imply ´ … ..Y n f´g/ [ fxg/ ..Y [ fxg/ n f´g/. Hence Y [ fxg 2 F . So (M3) indeed holds and .E; F/ is a matroid, say with rank function r and closure operator 0 . It remains to prove that D 0 . By definition, 0 .X / D fy 2 E W r.X [ fyg/ D r.X /g and r.X / D maxfjY j W Y X; y … .Y n fyg/ for all y 2 Y g for all X E. Let X E. To show 0 .X / .X /, let ´ 2 0 .X / n X . Let Y be a basis of X . Since r.Y [ f´g/ r.X [ f´g/ D r.X / D jY j < jY [ f´gj we have y 2 ..Y [ f´g/ n fyg/ for some y 2 Y [ f´g. If y D ´, then we have ´ 2 .Y /. Otherwise (S4) and y … .Y n fyg/ also yield ´ 2 .Y /. Hence by (S2) ´ 2 .X /. Together with (S1) this implies 0 .X / .X /. Now let ´ … 0 .X /, i.e. r.X [ f´g/ > r.X /. Let now Y be a basis of X [ f´g. Then ´ 2 Y and jY n f´gj D jY j 1 D r.X [ f´g/ 1 D r.X /. Therefore Y n f´g is a basis of X , implying X 0 .Y nf´g/ .Y nf´g/, and thus .X / .Y nf´g/. As ´ … .Y n f´g/, we conclude that ´ 62 .X /. Theorem 13.12. Let E be a finite set and C 2E . C is the set of circuits of an independence system .E; F /, where F D fF E W there exists no C 2 C with C F g, if and only if the following conditions hold: (C1) ; … C;

13.3

Duality

329

(C2) For any C1 ; C2 2 C, C1 C2 implies C1 D C2 . Moreover, if C is the set of circuits of an independence system .E; F /, then the following statements are equivalent: (a) .E; F / is a matroid. (b) For any X 2 F and e 2 E, X [ feg contains at most one circuit. (C3) For any C1 ; C2 2 C with C1 6D C2 and e 2 C1 \ C2 there exists a C3 2 C with C3 .C1 [ C2 / n feg. (C30 ) For any C1 ; C2 2 C, e 2 C1 \ C2 and f 2 C1 n C2 there exists a C3 2 C with f 2 C3 .C1 [ C2 / n feg. Proof: By definition, the family of circuits of any independence system satisfies (C1) and (C2). If C satisfies (C1), then .E; F / is an independence system. If C also satisfies (C2), it is the set of circuits of this independence system. (a))(C30 ): Let C be the family of circuits of a matroid, and let C1 ; C2 2 C, e 2 C1 \ C2 and f 2 C1 n C2 . By applying (R3) twice we have jC1 j 1 C r..C1 [ C2 / n fe; f g/ C jC2 j 1 D r.C1 / C r..C1 [ C2 / n fe; f g/ C r.C2 / r.C1 / C r..C1 [ C2 / n ff g/ C r.C2 n feg/ r.C1 n ff g/ C r.C1 [ C2 / C r.C2 n feg/ D jC1 j 1 C r.C1 [ C2 / C jC2 j 1: So r..C1 [ C2 / n fe; f g/ D r.C1 [ C2 /. Let B be a basis of .C1 [ C2 / n fe; f g. Then B [ ff g contains a circuit C3 , with f 2 C3 .C1 [ C2 / n feg as required. (C30 ))(C3): trivial. (C3))(b): If X 2 F and X [ feg contains two circuits C1 ; C2 , (C3) implies .C1 [ C2 / n feg … F . However, .C1 [ C2 / n feg is a subset of X . (b))(a): Follows from Theorem 13.8 and Proposition 13.7. Especially property (b) will be used often. For X 2 F and e 2 E such that X [ feg 62 F we write C.X; e/ for the unique circuit in X [ feg. If X [ feg 2 F we write C.X; e/ WD ;.

13.3 Duality Another basic concept in matroid theory is duality. Definition 13.13. Let .E; F / be an independence system. We define the dual of .E; F / by .E; F /, where F D fF E W there is a basis B of .E; F / such that F \ B D ;g: It is obvious that the dual of an independence system is again an independence system.

330

13 Matroids

Proposition 13.14. .E; F / D .E; F /. Proof: F 2 F , there is a basis B of .E; F / such that F \ B D ; , there is a basis B of .E; F/ such that F \ .E n B/ D ; , F 2 F . Theorem 13.15. Let .E; F / be an independence system, .E; F / its dual, and let r and r be the corresponding rank functions. (a) .E; F / is a matroid if and only if .E; F / is a matroid. (Whitney [1935]) (b) If .E; F / is a matroid, then r .F / D jF j C r.E n F / r.E/ for F E. Proof: Due to Proposition 13.14 we have to show only one direction of (a). So let .E; F / be a matroid. We define q W 2E ! ZC by q.F / WD jF j C r.E n F / r.E/. We claim that q satisfies (R1), (R2) and (R3). By this claim and Theorem 13.10, q is the rank function of a matroid. Since obviously q.F / D jF j if and only if F 2 F , we conclude that q D r , and (a) and (b) are proved. Now we prove the above claim: q satisfies (R1) because r satisfies (R2). To check that q satisfies (R2), let X Y E. Since .E; F / is a matroid, (R3) holds for r, so r.E n X / C 0 D r..E n Y / [ .Y n X // C r.;/ r.E n Y / C r.Y n X /: We conclude that r.E n X / r.E n Y / r.Y n X / jY n X j D jY j jX j (note that r satisfies (R1)), so q.X / q.Y /. It remains to show that q satisfies (R3). Let X; Y E. Using the fact that r satisfies (R3) we have q.X [ Y / C q.X \ Y / D jX [ Y j C jX \ Y j C r.E n .X [ Y // C r.E n .X \ Y // 2r.E/ D jX j C jY j C r..E n X / \ .E n Y // C r..E n X / [ .E n Y // 2r.E/ jX j C jY j C r.E n X / C r.E n Y / 2r.E/ D q.X / C q.Y /: For any graph G we have introduced the cycle matroid M.G/ which of course has a dual. For an embedded planar graph G there is also a planar dual G (which in general depends on the embedding of G/. It is interesting that the two concepts of duality coincide: Theorem 13.16. Let G be a connected planar graph with an arbitrary planar embedding, and G the planar dual. Then M.G / D .M.G// :

13.3

Duality

331

(Formally, the two matroids are isomorphic: they are identical up to renaming the elements of the ground set.) Proof: For T E.G/ we write T WD fe W e 2 E.G/ n T g, where e is the dual of edge e. We have to prove the following: Claim: T is the edge set of a spanning tree in G iff T is the edge set of a spanning tree in G .

Since .G / D G (by Proposition 2.42) and .T / D T it suffices to prove one direction of the claim. So let T E.G/, where T is the edge set of a spanning tree in G . .V .G/; T / must be connected, for otherwise a connected component would define a cut, the dual of which contains a circuit in T (Theorem 2.43). On the other hand, if .V .G/; T / contains a circuit, then the dual edge set is a cut and .V .G /; T / is disconnected. Hence .V .G/; T / is indeed a spanning tree in G. This implies that if G is planar then .M.G// is a graphic matroid. If, for any graph G, .M.G// is a graphic matroid, say .M.G// D M.G 0 /, then G 0 is evidently an abstract dual of G. By Exercise 39 of Chapter 2, the converse is also true: G is planar if and only if G has an abstract dual (Whitney [1933]). This implies that .M.G// is graphic if and only if G is planar. Note that Theorem 13.16 quite directly implies Euler’s formula (Theorem 2.32): Let G be a connected planar graph with a planar embedding, and let M.G/ be the cycle matroid of G. By Theorem 13.15 (b), r.E.G// C r .E.G// D jE.G/j. Since r.E.G// D jV .G/j 1 (the number of edges in a spanning tree) and r .E.G// D jV .G /j1 (by Theorem 13.16), we obtain that the number of faces of G is jV .G /j D jE.G/j jV .G/j C 2, Euler’s formula. (However, we used Euler’s formula in the proof of Proposition 2.42, which was used in our proof of Theorem 13.16.) Duality of independence systems has also some nice applications in polyhedral combinatorics. A set system .E; F / is called a clutter if X 6 Y for all X; Y 2 F . If .E; F / is a clutter, then we define its blocking clutter by BL.E; F / WD .E; fX E W X \ Y 6D ; for all Y 2 F ; X minimal with this propertyg/: For an independence system .E; F / and its dual .E; F / let B and B be the family of bases, and C and C the family of circuits, respectively. (Every clutter arises in both of these ways except for F D ; or F D f;g.) It follows immediately from the definitions that .E; B / D BL.E; C/ and .E; C / D BL.E; B/. Together with Proposition 13.14 this implies BL.BL.E; F// D .E; F / for every clutter .E; F /. We give some examples for clutters .E; F / and their blocking clutters .E; F 0 /. In each case E D E.G/ for some graph G: (1) F is the set of spanning trees, F 0 is the set of minimal cuts; (2) F is the set of arborescences rooted at r, F 0 is the set of minimal r-cuts; (3) F is the set of s-t-paths, F 0 is the set of minimal cuts separating s and t (this example works in undirected graphs and in digraphs);

332

13 Matroids

(4) F is the set of circuits in an undirected graph, F 0 is the set of complements of maximal forests; (5) F is the set of circuits in a digraph, F 0 is the set of minimal feedback edge sets (a feedback edge set is a set of edges whose removal makes the digraph acyclic); (6) F is the set of minimal edge sets whose contraction makes the digraph strongly connected, F 0 is the set of minimal directed cuts; (7) F is the set of minimal T -joins, F 0 is the set of minimal T -cuts. All these blocking relations can be verified easily: (1) and (2) follow directly from Theorems 2.4 and 2.5, (3), (4) and (5) are trivial, (6) follows from Corollary 2.7, and (7) from Proposition 12.7. In some cases, the blocking clutter gives a polyhedral characterization of the MINIMIZATION PROBLEM FOR INDEPENDENCE SYSTEMS for nonnegative cost functions: Definition 13.17. Let .E; F / be a clutter, .E; F 0 / its blocking clutter and P the convex hull of the incidence vectors of the elements of F . We say that .E; F / has the Max-Flow-Min-Cut property if ) ( n o X E E 0 x C y W x 2 P; y 2 RC D x 2 RC W xe 1 for all B 2 F : e2B

Examples are (2) and (7) of our list above (by Theorems 6.15 and 12.18), but also (3) and (6) (see Exercise 11). The following theorem relates the above coveringtype formulation to a packing formulation of the dual problem and allows to derive certain min-max theorems from others: Theorem 13.18. (Fulkerson [1971], Lehman [1979]) Let .E; F / be a clutter and .E; F 0 / its blocking clutter. Then the following statements are equivalent: (a) .E; F / has the Max-Flow-Min-Cut property; (b) .E; F 0 / has the Max-Flow-Min-Cut property;P ˚ 0 (c) minfc.A/ W A 2 F g D max 1ly W y 2 RF B2F 0 We2B yB c.e/ C ; for all e 2 E for every c W E ! RC . Proof: Since BL.E; F 0 / D BL.BL.E; F // D .E; F / it suffices to prove (a))(c))(b). The other implication (b))(a) then follows by exchanging the roles of F and F 0 . (a))(c): By Corollary 3.33 we have for every c W E ! RC o n minfc.A/ W A 2 F g D minfcx W x 2 P g D min c.x C y/ W x 2 P; y 2 RE C ; where P is the convex hull of the incidence vectors of elements of F . From this, the Max-Flow-Min-Cut property and the LP Duality Theorem 3.20 we get (c). (c))(b): Let P 0 denote the convex hull of the incidence vectors of the elements of F 0 . We have to show that

13.4

n

x C y W x 2 P 0 ; y 2 RE C

(

o D

x 2 RE C W

X

The Greedy Algorithm

333

) xe 1 for all A 2 F :

e2A

Since “” is trivial from the definition of blocking clutters we only show the other P inclusion. So let c 2 RE be a vector with c 1 for all A 2 F . By (c) we e C e2A have 1 minfc.A/ W A 2 F g ( D max 1ly W y 2

0 RF C ;

X

) yB c.e/ for all e 2 E ;

B2F 0 We2B

P 0 so let y 2 RF C P be a vector with 1ly D 1 and B2F 0 We2B yB 0 c.e/ for all e 2 E. Then xe ˚WD B2F 0 We2B yB (e 2 E) defines a vector x 2 P with x c, proving that c 2 x C y W x 2 P 0 ; y 2 RE C . For example, this theorem implies the Max-Flow-Min-Cut Theorem 8.6 quite directly: Let .G; u; s; t/ be a network. By Exercise 1 of Chapter 7 the minimum length of an s-t-path in .G; u/ equals the maximum number of s-t-cuts such that each edge e is contained in at most u.e/ of them. Hence the clutter of s-t-paths (example (3) in the above list) has the Max-Flow-Min-Cut Property, and so has its blocking clutter. Now (c) applied to the clutter of minimal s-t-cuts implies the MaxFlow-Min-Cut Theorem. Note however that Theorem 13.18 does not guarantee an integral vector attaining the maximum in (c), even if c is integral. The clutter of T -joins for G D K4 and T D V .G/ shows that this does not exist in general.

13.4 The Greedy Algorithm Again, let .E; F / be an independence system and c W E ! RC . We consider the MAXIMIZATION PROBLEM for .E; F ; c/ and formulate two “greedy algorithms”. We do not have to consider negative weights since elements with negative weight never appear in an optimum solution. We assume that .E; F / is given by an oracle. For the first algorithm we simply assume an independence oracle, i.e. an oracle which, given a set F E, decides whether F 2 F or not.

BEST-IN-GREEDY ALGORITHM Input: Output:

An independence system .E; F /, given by an independence oracle. Weights c W E ! RC . A set F 2 F .

1

Sort E D fe1 ; e2 ; : : : ; en g such that c.e1 / c.e2 / c.en /.

2

Set F WD ;.

3

For i WD 1 to n do: If F [ fei g 2 F then set F WD F [ fei g.

334

13 Matroids

The second algorithm requires a more complicated oracle. Given a set F E, this oracle decides whether F contains a basis. Let us call such an oracle a basissuperset oracle.

WORST-OUT-GREEDY ALGORITHM Input: Output:

An independence system .E; F /, given by a basis-superset oracle. Weights c W E ! RC . A basis F of .E; F /.

1

Sort E D fe1 ; e2 ; : : : ; en g such that c.e1 / c.e2 / c.en /.

2

Set F WD E.

3

For i WD 1 to n do: If F n fei g contains a basis then set F WD F n fei g.

Before we analyse these algorithms, let us take a closer look at the oracles required. It is an interesting question whether such oracles are polynomially equivalent, i.e. whether one can be simulated by a polynomial-time oracle algorithm using the other. The independence oracle and the basis-superset oracle do not seem to be polynomially equivalent: If we consider the independence system for the TSP (example (2) of the list in Section 13.1), it is easy (and the subject of Exercise 14) to decide whether a set of edges is independent, i.e. the subset of a Hamiltonian circuit (recall that we are working with a complete graph). On the other hand, it is a difficult problem to decide whether a set of edges contains a Hamiltonian circuit (this is NP-complete; cf. Theorem 15.25). Conversely, in the independence system for the SHORTEST PATH PROBLEM (example (3)), it is easy to decide whether a set of edges contains an s-t-path. Here it is not known how to decide whether a given set is independent (i.e. subset of an s-t-path) in polynomial time (Korte and Monma [1979] proved NP-completeness). For matroids, both oracles are polynomially equivalent. Other equivalent oracles are the rank oracle and closure oracle, which return the rank and the closure of a given subset of E, respectively (Exercise 17). However, even for matroids there are other natural oracles that are not polynomially equivalent. For example, the oracle deciding whether a given set is a basis is weaker than the independence oracle. The oracle which for a given F E returns the minimum cardinality of a dependent subset of F is stronger than the independence oracle (Hausmann and Korte [1981]). One can analogously formulate both greedy algorithms for the M INIMIZATION PROBLEM. It is easy to see that the BEST-IN-GREEDY for the MAXIMIZATION PROBLEM for .E; F ; c/ corresponds to the WORST-OUT-GREEDY for the MINIMIZATION PROBLEM for .E; F ; c/: adding an element to F in the BEST-I N GREEDY corresponds to removing an element from F in the WORST-OUT-GREEDY. Observe that KRUSKAL’S ALGORITHM (see Section 6.1) is a BEST-IN-GREEDY algorithm for the M INIMIZATION PROBLEM in a cycle matroid.

13.4

The Greedy Algorithm

335

The rest of this section contains some results concerning the quality of a solution found by the greedy algorithms. Theorem 13.19. (Jenkyns [1976], Korte and Hausmann [1978]) Let .E; F / be an independence system. For c W E ! RC we denote by G.E; F ; c/ the cost of some solution found by the BEST-IN-GREEDY for the MAXIMIZATION PROBLEM, and by OPT.E; F ; c/ the cost of an optimum solution. Then q.E; F/

G.E; F ; c/ 1 OPT.E; F ; c/

for all c W E ! RC . There is a cost function where the lower bound is attained. Proof: Let E D fe1 ; e2 ; : : : ; en g, c W E ! RC , and c.e1 / c.e2 / : : : c.en /. Let Gn be the solution found by the BEST-IN-GREEDY (when sorting E like this), while On is an optimum solution. We define Ej WD fe1 ; : : : ; ej g, Gj WD Gn \ Ej and Oj WD On \ Ej (j D 0; : : : ; n). Set dn WD c.en / and dj WD c.ej / c.ej C1 / for j D 1; : : : ; n 1. Since Oj 2 F, we have jOj j r.Ej /. Since Gj is a basis of Ej , we have jGj j .Ej /. With these two inequalities we conclude that c.Gn / D

n X .jGj j jGj 1 j/ c.ej / j D1

D

n X

jGj j dj

j D1

n X

.Ej / dj

j D1

q.E; F /

n X

r.Ej / dj

(13.1)

j D1

q.E; F/

n X

jOj j dj

j D1

D q.E; F /

n X

.jOj j jOj 1 j/ c.ej /

j D1

D q.E; F / c.On /: Finally we show that the lower bound is tight. Choose F E and bases B1 ; B2 of F such that jB1 j D q.E; F /: jB2 j

336

13 Matroids

(

Define c.e/ WD

1 0

for e 2 F for e 2 E n F

and sort e1 ; : : : ; en such that c.e1 / c.e2 / : : : c.en / and B1 Dfe1 ; : : : ; ejB1 j g. Then G.E; F ; c/ D jB1 j and OPT.E; F ; c/ D jB2 j, and the lower bound is attained. In particular we have the so-called Edmonds-Rado Theorem: Theorem 13.20. (Rado [1957], Edmonds [1971]) An independence system .E; F/ is a matroid if and only if the BEST-IN-GREEDY finds an optimum solution for the MAXIMIZATION PROBLEM for .E; F ; c/ for all cost functions c W E ! RC . Proof: By Theorem 13.19 we have q.E; F / < 1 if and only if there exists a cost function c W E ! RC for which the BEST-IN-GREEDY does not find an optimum solution. By Proposition 13.7 we have q.E; F / < 1 if and only if .E; F / is not a matroid. This is one of the rare cases where we can define a structure by its algorithmic behaviour. We also obtain a polyhedral description: Theorem 13.21. (Edmonds [1970]) Let .E; F / be a matroid and r W 2E ! ZC its rank function. Then the matroid polytope of .E; F /, i.e. the convex hull of the incidence vectors of all elements of F , is equal to ( ) X E x 2 R W x 0; xe r.A/ for all A E : e2A

Proof: Obviously, this polytope contains all incidence vectors of independent sets. By Corollary 3.32 it remains to show that all vertices of this polytope are integral. By Theorem 5.13 this is equivalent to showing that ( ) X max cx W x 0; xe r.A/ for all A E (13.2) e2A

has an integral optimum solution for any c W E ! R. W.l.o.g. c.e/ 0 for all e, since for e 2 E with c.e/ < 0 any optimum solution x of (13.2) has xe DP0. Let x be an optimum solution of (13.2). In (13.1) we replace jOj j by e2Ej xe P (j D 0; : : : ; n). We obtain c.Gn / e2E c.e/xe . So the BEST-IN-GREEDY produces a solution whose incidence vector is another optimum solution of (13.2). When applied to graphic matroids, this also yields Theorem 6.13. As in this special case, we also have total dual integrality in general. A generalization of this result will be proved in Section 14.2.

13.4

The Greedy Algorithm

337

The above observation that the BEST-IN-GREEDY for the MAXIMIZATION PROBLEM for .E; F ; c/ corresponds to the WORST-OUT-GREEDY for the MINIMIZATION PROBLEM for .E; F ; c/ suggests the following dual counterpart of Theorem 13.19: Theorem 13.22. (Korte and Monma [1979]) Let .E; F / be an independence system. For c W E ! RC let G.E; F ; c/ denote a solution found by the WORST-OUTGREEDY for the MINIMIZATION PROBLEM. Then 1

G.E; F ; c/ jF j .F / max F E jF j r .F / OPT.E; F ; c/

(13.3)

for all c W E ! RC , where and r are the rank functions of the dual independence system .E; F /. There is a cost function where the upper bound is attained. Proof: We use the same notation as in the proof of Theorem 13.19. By construction, Gj [ .E n Ej / contains a basis of E, but .Gj [ .E n Ej // n feg does not contain a basis of E for any e 2 Gj (j D 1; : : : ; n). In other words, Ej n Gj is a basis of Ej with respect to .E; F /, so jEj j jGj j .Ej /. Since On E n .Ej n Oj / and On is a basis, Ej n Oj is independent in .E; F /, so jEj j jOj j r .Ej /. We conclude that jGj j jEj j .Ej / jOj j jEj j r .Ej /:

and

Now the same calculation as (13.1) provides the upper bound. To see that this bound is tight, consider ( 1 for e 2 F ; c.e/ WD 0 for e 2 E n F where F E is a set where the maximum in (13.3) is attained. Let B1 be a basis of F with respect to .E; F /, with jB1 j D .F /. If we sort e1 ; : : : ; en such that c.e1 / c.e2 / : : : c.en / and B1 D fe1 ; : : : ; ejB1 j g, we have G.E; F ; c/ D jF j jB1 j and OPT.E; F ; c/ D jF j r .F /.

1

2

M >> 2

Fig. 13.1.

If we apply the WORST-OUT-GREEDY to the MAXIMIZATION PROBLEM or the BEST-IN-GREEDY to the MINIMIZATION PROBLEM, there is no positive G.E;F ;c/ . To see this, consider the problem of finding lower/finite upper bound for OPT.E;F ;c/

338

13 Matroids

a minimal vertex cover of maximum weight or a maximal stable set of minimum weight in the simple graph shown in Figure 13.1. However in the case of matroids, it does not matter whether we use the BESTIN-GREEDY or the WORST-OUT-GREEDY: since all bases have the same cardinality, the MINIMIZATION PROBLEM for .E; F ; c/ is equivalent to the M AXIMIZATION PROBLEM for .E; F ; c 0 /, where c 0 .e/ WD M c.e/ for all e 2 E and M WD 1 C maxfc.e/ W e 2 Eg. Therefore KRUSKAL’S ALGORITHM (Section 6.1) solves the MINIMUM SPANNING TREE PROBLEM optimally. The Edmonds-Rado Theorem 13.20 also yields the following characterization of optimum k-element solutions of the MAXIMIZATION PROBLEM. Theorem 13.23. Let .E; F / be a matroid, c W E ! R, k 2 N and X 2 F with jX j D k. Then c.X / D maxfc.Y / W Y 2 F ; jY j D kg if and only if the following two conditions hold: (a) For all y 2 E nX with X [fyg … F and all x 2 C.X; y/ we have c.x/ c.y/; (b) For all y 2 E n X with X [ fyg 2 F and all x 2 X we have c.x/ c.y/. Proof: The necessity is trivial: if one of the conditions is violated for some y and x, the k-element set X 0 WD .X [ fyg/ n fxg 2 F has greater weight than X . To see the sufficiency, let F 0 WD fF 2 F W jF j kg and c 0 .e/ WD c.e/ C M for all e 2 E, where M D maxfjc.e/j W e 2 Eg. Sort E D fe1 ; : : : ; en g such that c 0 .e1 / c 0 .en / and, for any i , c 0 .ei / D c 0 .ei C1 / and ei C1 2 X imply ei 2 X (i.e. elements of X come first among those of equal weight). Let X 0 be the solution found by the BEST-IN-GREEDY for the instance .E; F 0 ; c 0 / where 1 sorts the elements as above. Since .E; F 0 / is a matroid, the Edmonds-Rado Theorem 13.20 implies: c.X 0 / C kM D c 0 .X 0 / D maxfc 0 .Y / W Y 2 F 0 g D maxfc.Y / W Y 2 F ; jY j D kg C kM: We conclude the proof by showing that X D X 0 . We know that jX j D k D jX 0 j. So suppose X 6D X 0 , and let ei 2 X 0 n X with i minimum. Then X \ fe1 ; : : : ; ei 1 g D X 0 \ fe1 ; : : : ; ei 1 g. Now if X [ fei g … F, then (a) implies C.X; ei / X 0 , a contradiction. If X [ fei g 2 F , then (b) implies X X 0 which is also impossible. We shall need this theorem in Section 13.7. The special case that .E; F / is a graphic matroid and k D r.E/ is part of Theorem 6.3.

13.5 Matroid Intersection Definition 13.24. Given two independence systems .E; F1 / and .E; F2 /, we define their intersection by .E; F1 \ F2 /.

13.5

Matroid Intersection

339

The intersection of a finite number of independence systems is defined analogously. It is clear that the result is again an independence system. Proposition 13.25. Any independence system .E; F/ is the intersection of a finite number of matroids. Proof: Each circuit C of .E; F / defines a matroid .E; fF E W C n F ¤ ;g/ by Theorem 13.12 (this also follows easily from the definition). The intersection of all these matroids is of course .E; F /. Since the intersection of matroids is not a matroid in general, we cannot hope to get an optimum common independent set by a greedy algorithm. However, the following result, together with Theorem 13.19, implies a bound for the solution found by the BEST-IN-GREEDY: Proposition 13.26. If .E; F / is the intersection of p matroids, then q.E; F /

1 . p

Proof: By Theorem 13.12(b), X [ feg contains at most p circuits for any X 2 F and e 2 E. The statement now follows from Theorem 13.8. Of particular interest are independence systems that are the intersection of two matroids. The prime example here is the matching problem in a bipartite graph : G D .A [ B; E/. If F WD fF E W F is a matching in Gg, then .E; F/ is the intersection of two matroids. Namely, let F1 WD fF E W jıF .x/j 1 for all x 2 Ag and F2 WD fF E W jıF .x/j 1 for all x 2 Bg: .E; F1 /; .E; F2 / are matroids by Proposition 13.4(d). Clearly, F D F1 \ F2 . A second example is the independence system consisting of all branchings in a digraph G (Example 8 of the list at the beginning of Section 13.1). Here one matroid contains all sets of edges such that each vertex has at most one entering edge (see Proposition 13.4(e)), while the second matroid is the cycle matroid M.G/ of the underlying undirected graph. We shall now describe Edmonds’ algorithm for the following problem:

MATROID INTERSECTION PROBLEM Instance:

Two matroids .E; F1 /; .E; F2 /, given by independence oracles.

Task:

Find a set F 2 F1 \ F2 such that jF j is maximum.

We start with the following lemma. Recall that, for X 2 F and e 2 E, C.X; e/ denotes the unique circuit in X [ feg if X [ feg … F , and C.X; e/ D ; otherwise. Lemma 13.27. (Frank [1981]) Let .E; F / be a matroid and X 2 F . Let x1 ; : : : ; xs 2 X and y1 ; : : : ; ys … X with (a) xk 2 C.X; yk / for k D 1; : : : ; s and

340

13 Matroids

(b) xj … C.X; yk / for 1 j < k s. Then .X n fx1 ; : : : ; xs g/ [ fy1 ; : : : ; ys g 2 F . Proof: Let Xr WD .X n fx1 ; : : : ; xr g/ [ fy1 ; : : : ; yr g. We show that Xr 2 F for all r by induction. For r D 0 this is trivial. Let us assume that Xr1 2 F for some r 2 f1; : : : ; sg. If Xr1 [ fyr g 2 F then we immediately have Xr 2 F . Otherwise Xr1 [ fyr g contains a unique circuit C (by Theorem 13.12(b)). Since C.X; yr / Xr1 [ fyr g (by (b)), we must have C D C.X; yr /. But then by (a) xr 2 C.X; yr / D C , so Xr D .Xr1 [ fyr g/ n fxr g 2 F . The idea behind E DMONDS’ MATROID INTERSECTION ALGORITHM is the following. Starting with X D ;, we augment X by one element in each iteration. Since in general we cannot hope for an element e such that X [ feg 2 F1 \ F2 , we shall look for “alternating paths”. To make this convenient, we define an auxiliary graph. We apply the notion C.X; e/ to .E; Fi / and write Ci .X; e/ (i D 1; 2). E\ X

X

SX (2)

AX

(1)

AX

TX

Fig. 13.2.

Given a set X 2 F1 \ F2 , we define a directed auxiliary graph GX by .1/

AX WD f .x; y/ W y 2 E n X; x 2 C1 .X; y/ n fyg g; .2/

AX WD f .y; x/ W y 2 E n X; x 2 C2 .X; y/ n fyg g; .1/

.2/

GX WD .E; AX [ AX /: We set SX WD fy 2 E n X W X [ fyg 2 F1 g; TX WD fy 2 E n X W X [ fyg 2 F2 g

13.5

Matroid Intersection

341

(see Figure 13.2) and look for a shortest path from SX to TX . Such a path will enable us to augment the set X . (If SX \ TX 6D ;, we have a path of length zero and we can augment X by any element in SX \ TX .) Lemma 13.28. Let X 2 F1 \ F2 . Let y0 ; x1 ; y1 ; : : : ; xs ; ys be the vertices of a shortest y0 -ys -path in GX (in this order), with y0 2 SX and ys 2 TX . Then X 0 WD .X [ fy0 ; : : : ; ys g/ n fx1 ; : : : ; xs g 2 F1 \ F2 : Proof: First we show that X [ fy0 g, x1 ; : : : ; xs and y1 ; : : : ; ys satisfy the requirements of Lemma 13.27 with respect to F1 . Observe that X [ fy0 g 2 F1 because .1/ y0 2 SX . (a) is satisfied because .xj ; yj / 2 AX for all j , and (b) is satisfied because otherwise the path could be shortcut. We conclude that X 0 2 F1 . Secondly, we show that X [ fys g, xs ; xs1 ; : : : ; x1 and ys1 ; : : : ; y1 ; y0 satisfy the requirements of Lemma 13.27 with respect to F2 . Observe that X [ fys g 2 F2 .2/ because ys 2 TX . (a) is satisfied because .yj 1 ; xj / 2 AX for all j , and (b) is satisfied because otherwise the path could be shortcut. We conclude that X 0 2 F2 . We shall now prove that if there exists no SX -TX -path in GX , then X is already maximum. We need the following simple fact: Proposition 13.29. Let .E; F1 / and .E; F2 / be two matroids with rank functions r1 and r2 . Then for any F 2 F1 \ F2 and any Q E we have jF j r1 .Q/ C r2 .E n Q/: Proof: F \ Q 2 F1 implies jF \ Qj r1 .Q/. Similarly F n Q 2 F2 implies jF n Qj r2 .E n Q/. Adding the two inequalities completes the proof. Lemma 13.30. X 2 F1 \ F2 is maximum if and only if there is no SX -TX -path in GX . Proof: If there is an SX -TX -path, there is also a shortest one. We apply Lemma 13.28 and obtain a set X 0 2 F1 \ F2 of greater cardinality. Otherwise let R be the set of vertices reachable from SX in GX (see Figure 13.3). We have R \ TX D ;. Let r1 and r2 be the rank function of F1 and F2 , respectively. We claim that r2 .R/ D jX \ Rj. If not, there would be a y 2 R n X with .X \ R/ [ fyg 2 F2 . Since X [ fyg … F2 (because y … TX ), the circuit C2 .X; y/ .2/ must contain an element x 2 X n R. But then .y; x/ 2 AX means that there is an edge leaving R. This contradicts the definition of R. Next we prove that r1 .E nR/ D jX nRj. If not, there would be a y 2 .E nR/nX with .X nR/[fyg 2 F1 . Since X [fyg … F1 (because y … SX ), the circuit C1 .X; y/ .1/ must contain an element x 2 X \ R. But then .x; y/ 2 AX means that there is an edge leaving R. This contradicts the definition of R. Altogether we have jX j D r2 .R/Cr1 .E nR/. By Proposition 13.29, this implies optimality.

342

13 Matroids E \ X

X

SX (2)

AX

R E \ R (1)

AX

TX

Fig. 13.3.

The last paragraph of this proof yields the following min-max-equality: Theorem 13.31. (Edmonds [1970]) Let .E; F1 / and .E; F2 / be two matroids with rank functions r1 and r2 . Then max fjX j W X 2 F1 \ F2 g D min fr1 .Q/ C r2 .E n Q/ W Q Eg :

We are now ready for a detailed description of the algorithm.

EDMONDS’ MATROID INTERSECTION ALGORITHM Input:

Two matroids .E; F1 / and .E; F2 /, given by independence oracles.

Output:

A set X 2 F1 \ F2 of maximum cardinality.

1

Set X WD ;.

2

For each y 2 E n X and i 2 f1; 2g do: Compute Ci .X; y/ WD fx 2 X [ fyg W X [ fyg … Fi ; .X [ fyg/ n fxg 2 Fi g. Compute SX , TX , and GX as defined above.

3 4 5

Apply BFS to find a shortest SX -TX -path P in GX . If none exists then stop. Set X WD X 4V .P / and go to . 2

Theorem 13.32. EDMONDS’ MATROID INTERSECTION ALGORITHM correctly solves the MATROID INTERSECTION PROBLEM in O.jEj3 / time, where is the maximum complexity of the two independence oracles.

13.6

Matroid Partitioning

343

Proof: The correctness follows from Lemmata 13.28 and 13.30. 2 and 3 can be done in O.jEj2 /, 4 in O.jEj2 / time. Since there are at most jEj augmentations, the overall complexity is O.jEj3 /. Faster matroid intersection algorithms are discussed by Cunningham [1986] and Gabow and Xu [1996]. We remark that the problem of finding a maximum cardinality set in the intersection of three matroids is an NP-hard problem; see Exercise 17(c) of Chapter 15.

13.6 Matroid Partitioning Instead of the intersection of matroids we now consider their union which is defined as follows: Definition 13.33. Let .E; F1 /; : : : ; .E; Fk / be k matroids. A set X E is called : : partitionable if there exists a partition X D X1 [ [ Xk with Xi 2 Fi for i D 1; : : : ; k. Let F be the family of partitionable subsets of E. Then .E; F / is called the union or sum of .E; F1 /; : : : ; .E; Fk /. We shall prove that the union of matroids is a matroid again. Moreover, we solve the following problem via matroid intersection:

MATROID PARTITIONING PROBLEM Instance: Task:

A number k 2 N, k matroids .E; F1 /; : : : ; .E; Fk /, given by independence oracles. Find a partitionable set X E of maximum cardinality.

The main theorem with respect to matroid partitioning is: Theorem 13.34. (Nash-Williams [1967]) Let .E; F1 /; : : : ; .E; Fk / be matroids with rank functions r1 ; : : : ; rk , and let .E; F / be their union. F / is a mat Then .E; Pk roid, and its rank function r is given by r.X / D minAX jX n Aj C i D1 ri .A/ . Proof: .E; F / is obviously an independence system. Let X E. We first prove Pk r.X / D minAX jX n Aj C i D1 ri .A/ . :

:

For any Y X such that Y is partitionable, i.e. Y D Y1 [ [ Yk with Yi 2 Fi (i D 1; : : : ; k), and any A X we have jY j D jY n Aj C jY \ Aj jX n Aj C

k X i D1

jYi \ Aj jX n Aj C

k X

ri .A/;

i D1

P so r.X / minAX jX n Aj C kiD1 ri .A/ . On the other hand, let X 0 WD X f1; : : : ; kg. We define two matroids on X 0 . For Q X 0 and i 2 f1; : : : ; kg we write Qi WD fe 2 X W .e; i / 2 Qg. Let

344

13 Matroids

I1 WD fQ X 0 W Qi 2 Fi for all i D 1; : : : ; kg and

I2 WD fQ X 0 W Qi \ Qj D ; for all i 6D j g:

Evidently, both .X 0 ; I1 / and .X 0 ; I2 / are matroids, ˇS and ˇtheir rank functions are Pk ˇ ˇ given by s1 .Q/ WD i D1 ri .Qi / and s2 .Q/ WD ˇ kiD1 Qi ˇ for Q X 0 . Now the family of partitionable subsets of X can be written as fA X W there is a function f W A ! f1; : : : ; kg with f.e; f .e// W e 2 Ag 2 I1 \ I2 g: So the maximum cardinality of a partitionable set is the maximum cardinality of a common independent set in I1 and I2 . By Theorem 13.31 this maximum cardinality equals min fs1 .Q/ C s2 .X 0 n Q/ W Q X 0 g. If Q X 0 attains this minimum, then for A WD Q1 \ \ Qk we have ˇ ˇ k k k ˇ ˇ X \ X ˇ ˇ 0 r.X / D s1 .Q/Cs2 .X nQ/ D ri .Qi /C ˇX n Qi ˇ ri .A/CjX nAj: ˇ ˇ i D1

i D1

i D1

P So we have found a set A X with kiD1 ri .A/ C jX n Aj r.X /. Having proved the formula for the rank function r, we finally show that r is submodular. By Theorem 13.10, this implies that .E; F / is a matroid. To show the submodularity, let X; Y E, and let A X , B Y with r.X / D jX n Aj C Pk Pk i D1 ri .A/ and r.Y / D jY n Bj C i D1 ri .B/. Then r.X / C r.Y / D jX n Aj C jY n Bj C

k X

.ri .A/ C ri .B//

i D1

j.X [ Y / n .A [ B/j C j.X \ Y / n .A \ B/j C

k X

.ri .A [ B/ C ri .A \ B//

i D1

r.X [ Y / C r.X \ Y /: The construction in the above proof (Edmonds [1970]) reduces the MATROID PARTITIONING PROBLEM to the MATROID INTERSECTION PROBLEM. A reduction in the other direction is also possible (Exercise 21), so both problems can be regarded as equivalent. Note that we can find a maximum independent set in the union of an arbitrary number of matroids efficiently, while the intersection of more than two matroids is intractable.

13.7

Weighted Matroid Intersection

345

13.7 Weighted Matroid Intersection Now we consider the more general weighted version of matroid intersection.

WEIGHTED MATROID INTERSECTION PROBLEM Instance: Task:

Two matroids .E; F1 / and .E; F2 /, given by independence oracles. Weights c W E ! R. Find a set X 2 F1 \ F2 whose weight c.X / is maximum.

We shall describe a primal-dual algorithm due to Frank [1981] for this problem. It generalizes EDMONDS’ MATROID INTERSECTION ALGORITHM. Again we start with X WD X0 D ; and increase the cardinality in each iteration by one. We obtain sets X0 ; : : : ; Xm 2 F1 \ F2 with jXk j D k (k D 0; : : : ; m) and m D maxfjX j W X 2 F1 \ F2 g. Each Xk will be optimum, i.e. c.Xk / D maxfc.X / W X 2 F1 \ F2 ; jX j D kg:

(13.4)

Hence at the end we just choose an optimum set among X0 ; : : : ; Xm . The main idea is to split up the weight function. At any stage we have two functions c1 ; c2 W E ! R with c1 .e/ C c2 .e/ D c.e/ for all e 2 E. For each k we shall guarantee ci .Xk / D maxfci .X / W X 2 Fi ; jX j D kg

.i D 1; 2/:

(13.5)

This condition obviously implies (13.4). To obtain (13.5) we use the optimality criterion of Theorem 13.23. Instead of GX , SX and TX only a subgraph GN and subsets SN , TN are considered.

WEIGHTED MATROID INTERSECTION ALGORITHM Input: Output:

Two matroids .E; F1 / and .E; F2 /, given by independence oracles. Weights c W E ! R. A set X 2 F1 \ F2 of maximum weight.

1

Set k WD 0 and X0 WD ;. Set c1 .e/ WD c.e/ and c2 .e/ WD 0 for all e 2 E.

2

For each y 2 E n Xk and i 2 f1; 2g do: Compute Ci .Xk ; y/ WD fx 2 Xk [ fyg W Xk [ fyg … Fi ; .Xk [ fyg/ n fxg 2 Fi g: Compute

3

A.1/ WD f .x; y/ W y 2 E n Xk ; x 2 C1 .Xk ; y/ n fyg g; A.2/ WD f .y; x/ W y 2 E n Xk ; x 2 C2 .Xk ; y/ n fyg g; S WD f y 2 E n Xk W Xk [ fyg 2 F1 g; T WD f y 2 E n Xk W Xk [ fyg 2 F2 g:

346

4

13 Matroids

Compute m1 WD maxfc1 .y/ W y 2 S g; m2 WD maxfc2 .y/ W y 2 T g; SN WD f y 2 S W c1 .y/ D m1 g; TN WD f y 2 T W c2 .y/ D m2 g; .1/ N A WD f .x; y/ 2 A.1/ W c1 .x/ D c1 .y/ g; AN.2/ WD f .y; x/ 2 A.2/ W c2 .x/ D c2 .y/ g; GN WD .E; AN.1/ [ AN.2/ /:

5 6 7

N Apply BFS to compute the set R of vertices reachable from SN in G. If R \ TN 6D ; then: Find an SN -TN -path P in GN with a minimum number of edges, set XkC1 WD Xk 4V .P / and k WD k C 1 and go to . 2 Compute "1 WD minfc1 .x/ c1 .y/ W .x; y/ 2 ıAC.1/ .R/g;

"2 WD minfc2 .x/ c2 .y/ W .y; x/ 2 ıAC.2/ .R/g; "3 WD minfm1 c1 .y/ W y 2 S n Rg; "4 WD minfm2 c2 .y/ W y 2 T \ Rg; " WD minf"1 ; "2 ; "3 ; "4 g

8

(where min ; WD 1). If " < 1 then: Set c1 .x/ WD c1 .x/ " and c2 .x/ WD c2 .x/ C " for all x 2 R. Go to . 4 If " D 1 then: Among X0 ; X1 ; : : : ; Xk , let X be the one with maximum weight. Stop.

See Edmonds [1979] and Lawler [1976] for earlier versions of this algorithm. To prove correctness, we need the following generalization of Lemma 13.27: Lemma 13.35. (Frank [1981]) Let .E; F / be a matroid, c W E ! R, and X 2 F. Let x1 ; : : : ; xl 2 X and y1 ; : : : ; yl … X with (a) xj 2 C.X; yj / and c.xj / D c.yj / for j D 1; : : : ; l, and (b) xi … C.X; yj / or c.xi / > c.yj / for 1 i; j l with i 6D j . Then .X n fx1 ; : : : ; xl g/ [ fy1 ; : : : ; yl g 2 F . Proof: We again use induction on l. The case l D 1 is trivial by (a). Let D minli D1 c.xi /, and let h be an index for which the minimum is attained. Let X 0 WD .X n fxh g/ [ fyh g. By (a), X 0 2 F. We show C.X 0 ; yj / D C.X; yj / for all j 6D h; then (a) and (b) hold also for X 0 and the remaining indices f1; : : : ; lg n fhg, and we are done by induction.

13.7

Weighted Matroid Intersection

347

Let j 6D h, and suppose that C.X 0 ; yj / 6D C.X; yj /. Then xh 2 C.X; yj /. But then (a) and (b) imply D c.xh / > c.yj / D c.xj / , a contradiction. Theorem 13.36. (Frank [1981]) The WEIGHTED MATROID INTERSECTION ALGORITHM correctly solves the WEIGHTED MATROID INTERSECTION PROBLEM in O.jEj4 C jEj3 / time, where is the maximum complexity of the two independence oracles. Proof: Let m be the final value of k (we will show later that the algorithm terminates). The algorithm computes sets X0 ; X1 ; : : : ; Xm . When the algorithm stops, we have "1 D "2 D "3 D "4 D 1, so T is not reachable from S in .E; A.1/ [ A.2/ /. Then Lemma 13.30 implies m D jXm j D maxfjX j W X 2 F1 \ F2 g. To prove correctness, we show that we have at any stage Xk 2 F1 \ F2 and (13.5). Since c D c1 C c2 always holds, this implies c.Xk / D maxfc.X / W X 2 F1 \ F2 ; jX j D kg for all k D 0; : : : ; m, and hence the correctness. Initially, k D 0, Xk D ; 2 F1 \ F2 , and (13.5) is trivial. We now show that each iteration of the algorithm preserves the properties. We first note that (13.5) and Theorem 13.23(a) imply (i) c1 .x/ > c1 .y/ for all .x; y/ 2 A.1/ n AN.1/ , and (ii) c2 .x/ > c2 .y/ for all .y; x/ 2 A.2/ n AN.2/ . We first consider an iteration in which R \ TN 6D ;. Then we find a path P in , 5 say with vertices y0 ; x1 ; y1 ; : : : ; xl ; yl in this order. Similarly as in Lemma 13.28, we show that .E; F1 /, X [ fy0 g, x1 ; : : : ; xl , and y1 ; : : : ; yl satisfy the requirements of Lemma 13.35: X [ fy0 g 2 F1 follows from y0 2 S . Condition (a) of Lemma 13.35 follows from .xj ; yj / 2 AN.1/ for j D N Hence 1; : : : ; l, and (b) follows from (i) and the fact that P is a shortest path in G. XkC1 2 F1 . Analogously, .E; F2 /, Xk [ fyl g, x1 ; : : : ; xl , and y0 ; : : : ; yl1 satisfy the requirements of Lemma 13.35. Here Xk [ fyl g 2 F2 follows from yl 2 T . Condition (a) of Lemma 13.35 follows from .yj 1 ; xj / 2 AN.2/ for j D 1; : : : ; l, and (b) N Hence XkC1 2 F2 . again follows from (ii) and the fact that P is a shortest path in G. So we have shown XkC1 2 F1 \ F2 . To show that XkC1 satisfies (13.5) we use Theorem 13.23. By definition of GN we have c1 .XkC1 / D c1 .Xk / C c1 .y0 / and c2 .XkC1 / D c2 .Xk / C c2 .ys /. Since Xk satisfies (13.5), conditions (a) and (b) of Theorem 13.23 must hold with respect to Xk and each of F1 and F2 . N both conditions continue to hold for Xk [ fy0 g By definition of SN and y0 2 S, and F1 . Therefore c1 .XkC1 / D c1 .Xk [ fy0 g/ D maxfc1 .Y / W Y 2 F1 ; jY j D k C 1g. Moreover, by definition of TN and yl 2 TN , (a) and (b) of Theorem 13.23 continue to hold for Xk [ fyl g and F2 , implying c2 .XkC1 / D c2 .Xk [ fyl g/ D maxfc2 .Y / W Y 2 F2 ; jY j D k C 1g. In other words, (13.5) indeed holds for XkC1 . Now consider an iteration in which R \ TN D ;, so we change c1 and c2 in . 8 C We first show that " > 0. Since by the definition of R we have ıG N .R/ D ;, (i) and (ii) directly imply "1 > 0 and "2 > 0.

348

13 Matroids

m1 c1 .y/ holds for all y 2 S . If in addition y … R then y … SN , so m1 > c1 .y/. Therefore "3 > 0. Similarly, "4 > 0 (using TN \ R D ;). We conclude that " > 0. We can now prove that 8 preserves (13.5). Let c10 be the modified c1 , i.e. ( c1 .x/ " if x 2 R 0 : c1 .x/ WD c1 .x/ if x … R We prove that Xk and c10 satisfy the conditions of Theorem 13.23 with respect to F1 . To prove (a), let y 2 E n Xk and x 2 C1 .Xk ; y/ n fyg. Suppose c10 .x/ < 0 c1 .y/. Since c1 .x/ c1 .y/ and " > 0, we must have x 2 R and y … R. Since also .x; y/ 2 A.1/ , we have " "1 c1 .x/ c1 .y/ D .c10 .x/ C "/ c10 .y/, a contradiction. To prove (b), let x 2 Xk and y 2 E n Xk with Xk [ fyg 2 F1 . Now suppose c10 .y/ > c10 .x/. Since c1 .y/ m1 c1 .x/, we must have x 2 R and y … R. Since y 2 S we have " "3 m1 c1 .y/ c1 .x/ c1 .y/ D .c10 .x/ C "/ c10 .y/, a contradiction. Let c20 be the modified c2 , i.e. ( c2 .x/ C " if x 2 R : c20 .x/ WD c2 .x/ if x … R We show that Xk and c20 satisfy the conditions of Theorem 13.23 with respect to F2 . To prove (a), let y 2 E n Xk and x 2 C2 .Xk ; y/ n fyg. Suppose c20 .x/ < c20 .y/. Since c2 .x/ c2 .y/, we must have y 2 R and x … R. Since also .y; x/ 2 A.2/ , we have " "2 c2 .x/ c2 .y/ D c20 .x/ .c20 .y/ "/, a contradiction. To prove (b), let x 2 Xk and y 2 E n Xk with Xk [ fyg 2 F2 . Now suppose c20 .y/ > c20 .x/. Since c2 .y/ m2 c2 .x/, we must have y 2 R and x … R. Since y 2 T we have " "4 m2 c2 .y/ c2 .x/ c2 .y/ D c20 .x/ .c20 .y/ "/, a contradiction. So we have proved that (13.5) is not violated during , 8 and thus the algorithm works correctly. We now consider the running time. Observe that after an update of the weights in , 8 the new sets SN , TN , and R, as computed subsequently in 4 and , 5 are supersets of the old SN , TN , and R, respectively. If " D "4 < 1, an augmentation (increase of k) follows. Otherwise the cardinality of R increases immediately (in ) 5 by at least one. So 4 – 8 are repeated less than jEj times between two augmentations. Since the running time of 4 – 8 is O.jEj2 /, the total running time between 3 two augmentations is O.jEj / plus O.jEj2 / oracle calls (in ). 2 Since there are m jEj augmentations, the stated overall running time follows. The running time can easily be improved to O.jEj3 / (Exercise 23).

Exercises

349

Exercises 1. Prove that all the independence systems apart from (5) and (6) in the list at the beginning of Section 13.1 are – in general – not matroids. 2. Show that the uniform matroid with four elements and rank 2 is not a graphic matroid. 3. Prove that every graphic matroid is representable over every field. 4. Let G be an undirected graph, K 2 N, and let F contain those subsets of E.G/ that are the union of K forests. Prove that .E.G/; F / is a matroid. : 5. Let G be a bipartite graph with bipartition V .G/ D A [ B and .A; F/ a matroid. Prove that then .B; fY B W Y D ; or 9X 2 F W GŒX [ Y has a perfect matchingg/ is a matroid. 6. Compute tight lower bounds for the rank quotients of the independence systems listed at the beginning of Section 13.1. 7. Let S be a finite family of finite sets. A set T is a transversal of S if there is a bijection ˆ W T ! S with t 2 ˆ.t/ for all t 2 T . (For a necessary and sufficient condition for the existence of a transversal, see Exercise 6 of Chapter 10.) Assume that S has a transversal. Prove that the family of transversals of S is the family of bases of a matroid. 8. Let E be a finite set and B 2E . Show that B is the set of bases of some matroid .E; F / if and only if the following holds: (B1) B 6D ;; (B2) For any B1 ; B2 2 B and y 2 B2 n B1 there exists an x 2 B1 n B2 with .B1 n fxg/ [ fyg 2 B. 9. Let G be a graph. Let F be the family of sets X V .G/, for which a maximum matching exists that covers no vertex in X . Prove that .V .G/; F / is a matroid. What is the dual matroid? 10. Show that M.G / D .M.G// also holds for disconnected graphs G, extending Theorem 13.16. Hint: Use Exercise 36(a) of Chapter 2. 11. Show that the clutters in (3) and (6) in the list of Section 13.3 have the MaxFlow-Min-Cut property. (Use Theorem 19.17.) Show that the clutters in (1), (4) and (5) do not have the Max-Flow-Min-Cut property in general. 12. A clutter .E; F / is called binary if for all X1 ; : : : ; Xk 2 F with k odd there exists a Y 2 F with Y X1 4 4Xk . Prove that the clutter of minimal T -joins and the clutter of minimal T -cuts (example (7) of the list in Section 13.3) are binary. Prove that a clutter is binary if and only if jA \ Bj is odd for all A 2 F and all B 2 F 0 , where .E; F 0 / is the blocking clutter. Conclude that a clutter is binary if and only if its blocking clutter is binary. Note: Seymour [1977] classified the binary clutters with the Max-Flow-MinCut property. 13. Let P be a polyhedron of blocking type, i.e. we have x C y 2 P for all x 2 P and y 0. The blocking polyhedron of P is defined to be B.P / WD f´ W ´> x 1 for all x 2 P g. Prove that B.P / is again a polyhedron of blocking type and

350

14. 15. 16.

17.

18.

19.

20.

21.

22.

23. 24.

13 Matroids

that B.B.P // D P . Note: Compare this with Theorem 4.22. How can one check (in polynomial time) whether a given set of edges of a complete graph G is a subset of some Hamiltonian circuit in G? Prove that if .E; F / is a matroid, then the BEST-IN-GREEDY maximizes any bottleneck function c.F / D minfce W e 2 F g over the bases. Let .E; F / be a matroid and c W E ! R such that c.e/ 6D c.e 0 / for all e 6D e 0 and c.e/ 6D 0 for all e. Prove that both the MAXIMIZATION and the MINIMIZATION PROBLEM for .E; F ; c/ have a unique optimum solution. Prove that for matroids the independence, basis-superset, closure and rank oracles are polynomially equivalent. Hint: To show that the rank oracle reduces to the independence oracle, use the BEST-IN-GREEDY. To show that the independence oracle reduces to the basissuperset oracle, use the WORST-OUT-GREEDY. (Hausmann and Korte [1981]) Given an undirected graph G, we wish to colour the edges with a minimum number of colours such that for any circuit C of G, the edges of C do not all have the same colour. Show that there is a polynomial-time algorithm for this problem. Let .E; F1 /; : : : ; .E; Fk / be matroids with rank functions r1 ; : : : ; rk . Prove that P a set X E is partitionable if and only if jAj kiD1 ri .A/ for all A X . Show that Theorem 6.20 is a special case. (Edmonds and Fulkerson [1965]) Let .E; F / be a matroid with rank function r. Prove (using Theorem 13.34): (a) .E; F / has k pairwise disjoint bases if and only if kr.A/CjE nAj kr.E/ for all A E. (b) .E; F / has k independent sets whose union is E if and only if kr.A/ jAj for all A E. Show that Theorem 6.20 and Theorem 6.17 are special cases. Let .E; F1 / and .E; F2 / be two matroids. Let X be a maximal partitionable : subset with respect to .E; F1 / and .E; F2 /: X D X1 [ X2 with X1 2 F1 and X2 2 F2 . Let B2 X2 be a basis of F2 . Prove that then X n B2 is a maximum-cardinality set in F1 \ F2 . (Edmonds [1970]) Let .E; S/ be a set system, and let .E; F / be a matroid with rank function r.S Show that S has a transversal that is independent in .E; F / if and only if r B2B B jBj for all B S. Hint: First describe the rank function of the matroid whose independent sets are all transversals (Exercise 7), using Theorem 13.34. Then apply Theorem 13.31. (Rado [1942]) Show that the running time of the WEIGHTED MATROID INTERSECTION ALGORITHM (cf. Theorem 13.36) can be improved to O.jEj3 /. Let .E; F1 / and .E; F2 / be two matroids, and c W E ! R. Let X0 ; : : : ; Xm 2 F1 \ F2 with jXk j D k and c.Xk / D maxfc.X / W X 2 F1 \ F2 ; jX j D kg for

References

351

all k. Prove that for k D 1; : : : ; m 2 c.XkC1 / c.Xk / c.Xk / c.Xk1 /: (Krogdahl [unpublished]) 25. Consider the following problem. Given a digraph G with edge weights, a vertex s 2 V .G/, and a number k, find a minimum weight subgraph H of G containing k edge-disjoint paths from s to each other vertex. Show that this reduces to the WEIGHTED MATROID INTERSECTION PROBLEM. Hint: See Exercise 26 of Chapter 6 and Exercise 4 of this chapter. (Edmonds [1970]; Frank and Tardos [1989]; Gabow [1995]) : 26. Let A and B be two finite sets of cardinality n 2 N, G D .A [ B; ffa; bg W a 2 A; b 2 Bg/ the complete bipartite graph, aN 2 A, and c W E.G/ ! R a cost function. Let T be the family of edge sets of all spanning trees T in G with jıT .a/j D 2 for all a 2 A n fag. N Show that a minimum cost element of T can be computed in O.n7 / time. How many edges will be incident to a? N

References General Literature: Bixby, R.E., and Cunningham, W.H. [1995]: Matroid optimization and algorithms. In: Handbook of Combinatorics; Vol. 1 (R.L. Graham, M. Grötschel, L. Lovász, eds.), Elsevier, Amsterdam, 1995 Cook, W.J., Cunningham, W.H., Pulleyblank, W.R., and Schrijver, A. [1998]: Combinatorial Optimization. Wiley, New York 1998, Chapter 8 Faigle, U. [1987]: Matroids in combinatorial optimization. In: Combinatorial Geometries (N. White, ed.), Cambridge University Press, 1987 Frank, A. [2011]: Connections in Combinatorial Optimization. Oxford University Press, Oxford 2011 Gondran, M., and Minoux, M. [1984]: Graphs and Algorithms. Wiley, Chichester 1984, Chapter 9 Lawler, E.L. [1976]: Combinatorial Optimization; Networks and Matroids. Holt, Rinehart and Winston, New York 1976, Chapters 7 and 8 Oxley, J.G. [1992]: Matroid Theory. Oxford University Press, Oxford 1992 von Randow, R. [1975]: Introduction to the Theory of Matroids. Springer, Berlin 1975 Recski, A. [1989]: Matroid Theory and its Applications. Springer, Berlin 1989 Schrijver, A. [2003]: Combinatorial Optimization: Polyhedra and Efficiency. Springer, Berlin 2003, Chapters 39–42 Welsh, D.J.A. [1976]: Matroid Theory. Academic Press, London 1976

Cited References: Cunningham, W.H. [1986] : Improved bounds for matroid partition and intersection algorithms. SIAM Journal on Computing 15 (1986), 948–957

352

13 Matroids

Edmonds, J. [1970]: Submodular functions, matroids and certain polyhedra. In: Combinatorial Structures and Their Applications; Proceedings of the Calgary International Conference on Combinatorial Structures and Their Applications 1969 (R. Guy, H. Hanani, N. Sauer, J. Schönheim, eds.), Gordon and Breach, New York 1970, pp. 69–87 Edmonds, J. [1971]: Matroids and the greedy algorithm. Mathematical Programming 1 (1971), 127–136 Edmonds, J. [1979]: Matroid intersection. In: Discrete Optimization I; Annals of Discrete Mathematics 4 (P.L. Hammer, E.L. Johnson, B.H. Korte, eds.), North-Holland, Amsterdam 1979, pp. 39–49 Edmonds, J., and Fulkerson, D.R. [1965]: Transversals and matroid partition. Journal of Research of the National Bureau of Standards B 69 (1965), 67–72 Frank, A. [1981]: A weighted matroid intersection algorithm. Journal of Algorithms 2 (1981), 328–336 Frank, A., and Tardos, É. [1989]: An application of submodular flows. Linear Algebra and Its Applications 114/115 (1989), 329–348 Fulkerson, D.R. [1971]: Blocking and anti-blocking pairs of polyhedra. Mathematical Programming 1 (1971), 168–194 Gabow, H.N. [1995]: A matroid approach to finding edge connectivity and packing arborescences. Journal of Computer and System Sciences 50 (1995), 259–273 Gabow, H.N., and Xu, Y. [1996]: Efficient theoretic and practical algorithms for linear matroid intersection problems. Journal of Computer and System Sciences 53 (1996), 129– 147 Hausmann, D., Jenkyns, T.A., and Korte, B. [1980]: Worst case analysis of greedy type algorithms for independence systems. Mathematical Programming Study 12 (1980), 120–131 Hausmann, D., and Korte, B. [1981]: Algorithmic versus axiomatic definitions of matroids. Mathematical Programming Study 14 (1981), 98–111 Jenkyns, T.A. [1976]: The efficiency of the greedy algorithm. Proceedings of the 7th S-E Conference on Combinatorics, Graph Theory, and Computing, Utilitas Mathematica, Winnipeg 1976, pp. 341–350 Korte, B., and Hausmann, D. [1978]: An analysis of the greedy algorithm for independence systems. In: Algorithmic Aspects of Combinatorics; Annals of Discrete Mathematics 2 (B. Alspach, P. Hell, D.J. Miller, eds.), North-Holland, Amsterdam 1978, pp. 65–74 Korte, B., and Monma, C.L. [1979]: Some remarks on a classification of oracle-type algorithms. In: Numerische Methoden bei graphentheoretischen und kombinatorischen Problemen; Band 2 (L. Collatz, G. Meinardus, W. Wetterling, eds.), Birkhäuser, Basel 1979, pp. 195–215 Lehman, A. [1979]: On the width-length inequality. Mathematical Programming 17 (1979), 403–417 Nash-Williams, C.S.J.A. [1967]: An application of matroids to graph theory. In: Theory of Graphs; Proceedings of an International Symposium in Rome 1966 (P. Rosenstiehl, ed.), Gordon and Breach, New York, 1967, pp. 263–265 Rado, R. [1942]: A theorem on independence relations. Quarterly Journal of Math. Oxford 13 (1942), 83–89 Rado, R. [1957]: Note on independence functions. Proceedings of the London Mathematical Society 7 (1957), 300–320

References

353

Seymour, P.D. [1977]: The matroids with the Max-Flow Min-Cut property. Journal of Combinatorial Theory B 23 (1977), 189–222 Whitney, H. [1933]: Planar graphs. Fundamenta Mathematicae 21 (1933), 73–84 Whitney, H. [1935]: On the abstract properties of linear dependence. American Journal of Mathematics 57 (1935), 509–533

•

14 Generalizations of Matroids

There are several interesting generalizations of matroids. We have already seen independence systems in Section 13.1, which arose from dropping the axiom (M3). In Section 14.1 we consider greedoids, arising by dropping (M2) instead. Moreover, certain polytopes related to matroids and to submodular functions, called polymatroids, lead to strong generalizations of important theorems; we shall discuss them in Section 14.2. In Sections 14.3 and 14.4 we consider two approaches to the problem of minimizing an arbitrary submodular function: one using the ELLIPSOID METHOD, and one with a combinatorial algorithm. For the important special case of symmetric submodular functions we mention a simpler algorithm in Section 14.5.

14.1 Greedoids By definition, set systems .E; F / are matroids if and only if they satisfy (M1) ; 2 F ; (M2) If X Y 2 F then X 2 F ; (M3) If X; Y 2 F and jX j > jY j, then there is an x 2 X n Y with Y [ fxg 2 F . If we drop (M3), we obtain independence systems, discussed in Sections 13.1 and 13.4. Now we drop (M2) instead: Definition 14.1. A greedoid is a set system .E; F/ satisfying (M1) and (M3). Instead of the subclusiveness (M2) we have accessibility: We call a set system .E; F/ accessible if ; 2 F and for any X 2 F n f;g there exists an x 2 X with X nfxg 2 F . Greedoids are accessible (accessibility follows directly from (M1) and (M3)). Though more general than matroids, they comprise a rich structure and, on the other hand, generalize many different, seemingly unrelated concepts. We start with the following result: Theorem 14.2. Let .E; F / be an accessible set system. The following statements are equivalent: (a) For any X Y E and ´ 2 E n Y with X [ f´g 2 F and Y 2 F we have Y [ f´g 2 F ; B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__14, c Springer-Verlag Berlin Heidelberg 2012

355

356

14 Generalizations of Matroids

(b) F is closed under union. Proof: (a) )(b): Let X; Y 2 F ; we show that X [ Y 2 F . Let Z be a maximal set with Z 2 F and X Z X [ Y . Suppose Y n Z 6D ;. By repeatedly applying accessibility to Y we get a set Y 0 2 F with Y 0 Z and an element y 2 Y n Z with Y 0 [ fyg 2 F . We apply (a) to Z, Y 0 and y and obtain Z [ fyg 2 F , contradicting the choice of Z. (b) )(a) is trivial. If the conditions in Theorem 14.2 hold, then .E; F / is called an antimatroid. Proposition 14.3. Every antimatroid is a greedoid. Proof: Let .E; F / be an antimatroid, i.e. accessible and closed under union. To prove (M3), let X; Y 2 F with jX j > jY j. Since .E; F / is accessible there is an order X D fx1 ; : : : ; xn g with fx1 ; : : : ; xi g 2 F for i D 0; : : : ; n. Let i 2 f1; : : : ; ng be the minimum index with xi … Y ; then Y [ fxi g D Y [ fx1 ; : : : ; xi g 2 F (since F is closed under union). Another equivalent definition of antimatroids is by a closure operator: Proposition 14.4. Let .E; F/ be a set system such that F is closed under union and ; 2 F. Define \ .A/ WD fX E W A X; E n X 2 F g Then is a closure operator, i.e. satisfies (S1)–(S3) of Theorem 13.11. Proof: Let X Y E. X .X/ .Y / is trivial. To prove (S3), assume that there exists a y 2 ..X// n .X/. Then y 2 Y for all Y E with .X/ Y and E n Y 2 F, but there exists a Z E n fyg with X Z and E n Z 2 F . This implies .X/ 6 Z, a contradiction. Theorem 14.5. Let .E; F/ be a set system such that F is closed under union and ; 2 F . Then .E; F / is accessible if and only if the closure operator of Proposition 14.4 satisfies the anti-exchange property: if X E, y; ´ 2 E n .X/, y 6D ´ and ´ 2 .X [ fyg/, then y … .X [ f´g/. Proof: If .E; F / is accessible, then (M3) holds by Proposition 14.3. To show the anti-exchange property, let X E, B WD E n .X/, and y; ´ 2 B with ´ … A WD E n .X [ fyg/. Observe that A 2 F , B 2 F and A B n fy; ´g. By applying (M3) to A and B we get an element b 2 B n A E n .X [ A/ with A [ fbg 2 F . A [ fbg cannot be a subset of E n .X [ fyg/ (otherwise .X [ fyg/ E n .A [ fbg/, contradicting .X [ fyg/ D E n A). Hence b D y. So we have A[fyg 2 F and thus .X [f´g/ E n.A[fyg/. We have proved y … .X [f´g/. To show the converse, let A 2 F n f;g and let X WD E n A. We have .X/ D X . Let a 2 A such that j.X [fag/j is minimum. We claim that .X [fag/ D X [fag, i.e. A n fag 2 F .

14.1

Greedoids

357

Suppose, on the contrary, that b 2 .X [ fag/ n .X [ fag/. By the anti-exchange property we have a … .X [ fbg/. Moreover, .X [ fbg/ ..X [ fag/ [ fbg/ D ..X [ fag// D .X [ fag/: Hence .X [ fbg/ is a proper subset of .X [ fag/, contradicting the choice of a. The anti-exchange property of Theorem 14.5 is different from (S4). While (S4) of Theorem 13.11 is a property of linear hulls in Rn , this is a property of convex hulls in Rn : if y 6D ´, ´ 62 conv.X / and ´ 2 conv.X [ fyg/, then clearly y … conv.X [f´g/. So for any finite set E Rn , .E; fX E W X \conv.E nX / D ;g/ is an antimatroid. Greedoids generalize matroids and antimatroids, but they also contain other interesting structures. One example is the blossom structure we used in EDMONDS’ CARDINALITY MATCHING ALGORITHM (Exercise 1). Another basic example is: Proposition 14.6. Let G be a graph (directed or undirected) and r 2 V .G/. Let F be the family of all edge sets of arborescences in G rooted at r, or trees in G containing r (not necessarily spanning). Then .E.G/; F / is a greedoid. Proof: (M1) is trivial. We prove (M3) for the directed case; the same argument applies to the undirected case. Let .X1 ; F1 / and .X2 ; F2 / be two arborescences in G rooted at r with jF1 j > jF2 j. Then jX1 j D jF1 j C 1 > jF2 j C 1 D jX2 j, so let x 2 X1 n X2 . The r-x-path in .X1 ; F1 / contains an edge .v; w/ with v 2 X2 and w … X2 . This edge can be added to .X2 ; F2 /, proving that F2 [ f.v; w/g 2 F . This greedoid is called the directed (undirected) branching greedoid of G. The problem of finding a maximum weight spanning tree in a connected graph G with nonnegative weights is the MAXIMIZATION PROBLEM for the cycle matroid M.G/. The BEST-IN-GREEDY ALGORITHM is in this case nothing but KRUSKAL’S ALGORITHM. Now we have a second formulation of the same problem: we are looking for a maximum weight set F with F 2 F , where .E.G/; F / is the undirected branching greedoid of G. We now formulate a general greedy algorithm for greedoids. In the special case of matroids, it is exactly the BEST-IN-GREEDY ALGORITHM discussed in Section 13.4. If we have an undirected branching greedoid with a modular cost function c, it is PRIM’S ALGORITHM:

GREEDY ALGORITHM FOR GREEDOIDS Input: Output:

A greedoid .E; F / and a function c W 2E ! R, given by an oracle which for any given X E says whether X 2 F and returns c.X /. A set F 2 F .

1

Set F WD ;.

2

Let e 2 E n F such that F [ feg 2 F and c.F [ feg/ is maximum; if no such e exists then stop. Set F WD F [ feg and go to . 2

3

358

14 Generalizations of Matroids

Even for modular cost functions c this algorithm does not always provide an optimal solution. At least we can characterize those greedoids where it works: Theorem 14.7. Let .E; F / be a greedoid. The GREEDY ALGORITHM FOR GREEDOIDS finds a set F 2 F of maximum weight for each modular weight function c W 2E ! RC if and only if .E; F / has the so-called strong exchange property: For all A 2 F , B maximal in F , A B and x 2 E n B with A [ fxg 2 F there exists a y 2 B n A such that A [ fyg 2 F and .B n fyg/ [ fxg 2 F . Proof: Suppose .E; F / is a greedoid with the strong exchange property. Let c W E ! RC , and let A D fa1 ; : : : ; al g be the solution found by the GREEDY ALGORITHM FOR GREEDOIDS, where the elements are chosen in the order a1 ; : : : ; al . : Let B D fa1 ; : : : ; ak g [ B 0 be an optimum solution such that k is maximum, and suppose that k < l. Then we apply the strong exchange property to fa1 ; : : : ; ak g, B and akC1 . We conclude that there exists a y 2 B 0 with fa1 ; : : : ; ak ; yg 2 F and .B n y/ [ fakC1 g 2 F . By the choice of akC1 in 2 of the GREEDY ALGORITHM FOR GREEDOIDS we have c.akC1 / c.y/ and thus c..B n y/ [ fakC1 g/ c.B/, contradicting the choice of B. Conversely, let .E; F / be a greedoid that does not have the strong exchange property. Let A 2 F , B maximal in F , A B and x 2 E n B with A [ fxg 2 F such that for all y 2 B n A with A [ fyg 2 F we have .B n y/ [ fxg … F. Let Y WD fy 2 B n A W A [ fyg 2 F g. We set c.e/ WD 2 for e 2 B n Y , and c.e/ WD 1 for e 2 Y [ fxg and c.e/ WD 0 for e 2 E n .B [ fxg/. Then the GREEDY ALGORITHM FOR GREEDOIDS might choose the elements of A first (they have weight 2) and then might choose x. It will eventually end up with a set F 2 F that cannot be optimal, since c.F / c.B [ fxg/ 2 < c.B [ fxg/ 1 D c.B/ and B 2 F . Indeed, optimizing modular functions over general greedoids is NP-hard. This follows from the following observation (together with Corollary 15.24): Proposition 14.8. The problem of deciding, given an undirected graph G and k 2 N, whether G has a vertex cover of cardinality k, linearly reduces to the following problem: Given a greedoid .E; F / (by a membership oracle) and a function c W E ! RC , find an F 2 F with c.F / maximum. :

Proof: Let G be any undirected graph and k 2 N. Let D WD V .G/ [ E.G/ and F WD fX D W for all e D fv; wg 2 E.G/ \ X we have v 2 X or w 2 X g: .D; F / is an antimatroid: it is accessible and closed under union. In particular, by Proposition 14.3, it is a greedoid. Now consider F 0 WD fX 2 F W jX j jE.G/j C kg. Since (M1) and (M3) are preserved, .D; F 0 / is also a greedoid. Set c.e/ WD 1 for e 2 E.G/ and c.v/ WD 0

14.2

Polymatroids

359

for v 2 V .G/. Then there exists a set F 2 F 0 with c.F / D jE.G/j if and only if G contains a vertex cover of size k. On the other hand, there are interesting functions that can be maximized over arbitrary greedoids, for example bottleneck functions c.F / WD minfc 0 .e/ W e 2 F g for some c 0 W E ! RC (Exercise 2). See the book by Korte, Lovász and Schrader [1991] for more results in this area.

14.2 Polymatroids From Theorem 13.10 we know the tight connection between matroids and submodular functions. Submodular functions define the following interesting class of polyhedra: Definition 14.9. A polymatroid is a polytope of type ( ) X P .f / WD x 2 RE W x 0; xe f .A/ for all A E e2A

where E is a finite set and f W 2E ! RC is a submodular function. It is not hard to see that for any polymatroid f can be chosen such that f .;/ D 0 and f is monotone (Exercise 6; a function f W 2E ! R is called monotone if f .X / f .Y / for X Y E). Edmonds’ original definition was different; see Exercise 7. Moreover, we mention that the term polymatroid is sometimes not used for the polytope but for the pair .E; f /. If f is the rank function of a matroid, P .f / is the convex hull of the incidence vectors of the independent sets of this matroid (Theorem 13.21). We know that the BEST-IN-GREEDY optimizes any linear function over a matroid polytope. A similar greedy algorithm also works for general polymatroids. We assume that f is monotone:

POLYMATROID GREEDY ALGORITHM Input: Output: 1 2

A finite set E and a submodular, monotone function f W 2E ! RC with f .;/ 0 (given by an oracle). A vector c 2 RE . A vector x 2 P .f / with cx maximum.

Sort E D fe1 ; : : : ; en g such that c.e1 / c.ek / > 0 c.ekC1 / c.en /. If k 1 then set x.e1 / WD f .fe1 g/. Set x.ei / WD f .fe1 ; : : : ; ei g/ f .fe1 ; : : : ; ei 1 g/ for i D 2; : : : ; k. Set x.ei / WD 0 for i D k C 1; : : : ; n.

360

14 Generalizations of Matroids

Proposition 14.10. Let E D fe1 ; : : : ; en g and f W 2E ! R be a submodular function with f .;/ 0. Let b W E ! R with b.e1 / Pf .fe1 g/ and b.ei / f .fe1 ; : : : ; ei g/ f .fe1 ; : : : ; ei 1 g/ for i D 2; : : : ; n. Then a2A b.a/ f .A/ for all A E. Proof: Induction on i D maxfj The assertion is trivial for A D ; P W ej 2 Ag. P and A D fe1 g. If i 2, then a2A b.a/ D a2Anfei g b.a/ C b.ei / f .A n fei g/ C b.ei / f .A n fei g/ C f .fe1 ; : : : ; ei g/ f .fe1 ; : : : ; ei 1 g/ f .A/, where the first inequality follows from the induction hypothesis and the third one from submodularity. Theorem 14.11. The POLYMATROID GREEDY ALGORITHM correctly finds an x 2 P .f / with cx maximum. If f is integral, then x is also integral. Proof: Let x 2 RE be the output of the POLYMATROID GREEDY ALGORITHM for E, f and c. By definition, if f is integral, then x is also integral. We have x 0 since f is monotone, and thus x 2 P .f / by Proposition 14.10. Now let y 2 RE C with cy > cx. Similarly as in the proof of Theorem 13.19 we set dj WD c.ej / c.ej C1 / (j D 1; : : : ; k 1) and dk WD c.ek /, and we have k X j D1

dj

j X

x.ei / D cx < cy

i D1

k X

c.ej /y.ej / D

j D1

k X j D1

dj

j X

y.ei /:

i D1

Pj Since dj 0 for all j there is an index j 2 f1; : : : ; kg with i D1 y.ei / > Pj Pj i D1 x.ei /; however, since i D1 x.ei / D f .fe1 ; : : : ; ej g/ this means that y … P .f /. As with matroids, we can also handle the intersection of two polymatroids. The following polymatroid intersection theorem has many implications: Theorem 14.12. (Edmonds [1970,1979]) Let E be a finite set, and let f; g W 2E ! RC be submodular functions. Then the system X x0 xe f .A/ e2A X xe g.A/

.A E/ .A E/

e2A

is TDI. Proof: Consider the primal-dual pair of LPs ) ( X X xe f .A/ and xe g.A/ for all A E max cx W x 0; e2A

e2A

14.2

and

8 <X .f .A/yA C g.A/´A / W y; ´ 0; min : AE

X

AE; e2A

Polymatroids

361

9 = .yA C ´A / ce for all e 2 E : ;

To show total dual integrality, we use Lemma 5.23. Let c W E.G/ ! Z, and let y; ´ be an optimum dual solution for which X .yA C ´A /jAjjE n Aj (14.1) AE

is as small as possible. We claim that F WD fA E W yA > 0g is a chain, i.e. for any A; B 2 F either A B or B A. To see this, suppose A; B 2 F with A \ B 6D A and A \ B 6D B. Let WD 0 0 minfyA ; yB g. Set yA0 WD yA , yB0 WD yB , yA\B WD yA\B C , yA[B WD 0 0 yA[B C , and y .S / WD y.S / for all other S E. Since y ; ´ is a feasible dual solution, it is also optimum (f is submodular) and contradicts the choice of y, because (14.1) is smaller for y 0 ; ´. By the same argument, F 0 WD fA E W ´A > 0g is a chain. Now let M and 0 M be the matrices whose columns are indexed with the elements of E and whose 0 rows are the incidence vectors the of elements of F and F , respectively. By Lemma M 5.23, it suffices to show that M 0 is totally unimodular. Here we use Ghouila-Houri’s Theorem 5.24. Let R be a set of rows, say R D fA1 ; : : : ; Ap ; B1 ; : : : ; Bq g with A1 Ap and B1 Bq . Let R1 WD fAi W i oddg [ fBi W i eveng and R2 WD R n R1 . Since for any e 2 E we have fR 2 R W e 2 Rg D fA1 ; : : : ; Ape g [ fB1 ; : : : ; Bqe g for some pe 2 f0; : : : ; pg and qe 2 f0; : : : ; qg, the sum of the rows in R1 minus the sum of the rows in R2 is a vector with entries 1; 0; 1 only. So the criterion of Theorem 5.24 is satisfied. One can optimize linear functions over the intersection of two polymatroids. However, this is not as easy as with a single polymatroid. But we can use the ELLIPSOID M ETHOD if we can solve the S EPARATION PROBLEM for each polymatroid. We return to this question in Section 14.3. Corollary 14.13. (Edmonds [1970]) Let .E; M1 / and .E; M2 / be two matroids with rank functions r1 and r2 . Then the convex hull of the incidence vectors of the elements of M1 \ M2 is the polytope ( ) X E x 2 RC W xe minfr1 .A/; r2 .A/g for all A E : e2A

Proof: As r1 and r2 are nonnegative and submodular (by Theorem 13.10), the above inequality system is TDI (by Theorem 14.12). Since r1 and r2 are integral, the polytope is integral (by Corollary 5.15). Since r1 .A/ jAj for all A E, the

362

14 Generalizations of Matroids

vertices (the convex hull of which the polytope is by Corollary 3.32) are 0-1-vectors, and thus incidence vectors of common independent sets (elements of M1 \ M2 ). On the other hand, each such incidence vector satisfies the inequalities (by definition of the rank function). Of course, the description of the matroid polytope (Theorem 13.21) follows from this by setting M1 D M2 . Theorem 14.12 has some further consequences: Corollary 14.14. (Edmonds [1970]) Let E be a finite set, and let f; g W 2E ! RC be submodular and monotone functions with f .;/ D g.;/ D 0. Then maxf1lx W x 2 P .f / \ P .g/g D min .f .A/ C g.E n A//: AE

Moreover, if f and g are integral, there exists an integral x attaining the maximum. Proof: By Theorem 14.12, the dual to maxf1lx W x 2 P .f / \ P .g/g; which is 8 <X min .f .A/yA Cg.A/´A / W y; ´ 0; : AE

X

9 = .yA C´A / 1 for all e 2 E

AE; e2A

;

;

S S has an integral optimum solution y; ´. Let B WD AWyA 1 A and C WD AW´A 1 A. We have B [ C D E. Since f and g are submodular and nonnegative, and f .;/ D g.;/ D 0, X .f .A/yA C g.A/´A / f .B/ C g.C /: AE

Since E n B C and g is monotone, this is at least f .B/ C g.E n B/, proving “”. The other inequality “” is trivial, because for any A E we obtain a feasible dual solution y; ´ by setting yA WD 1, ´E nA WD 1 and all other components to zero. The integrality follows directly from Theorem 14.12 and Corollary 5.15. Theorem 13.31 is a special case. Moreover we obtain: Corollary 14.15. (Frank [1982]) Let E be a finite set and f; g W 2E ! R such that f is supermodular, g is submodular and f g. Then there exists a modular function h W 2E ! R with f h g. If f and g are integral, h can be chosen integral. Proof: Let M WD 2 maxfjf .A/j C jg.A/j W A Eg. Let f 0 .A/ WD g.E/ f .E n A/ C M jAj and g 0 .A/ WD g.A/ f .;/ C M jAj for all A E. f 0 and g0 are nonnegative, submodular and monotone. An application of Corollary 14.14 yields

14.3

Minimizing Submodular Functions

363

maxf1lx W x 2 P .f 0 / \ P .g 0 /g D min .f 0 .A/ C g 0 .E n A// AE

D min .g.E/ f .E n A/ C M jAj C g.E n A/ f .;/ C M jE n Aj/ AE

g.E/ f .;/ C M jEj: .;/CM jEj. If f and g are integral, x So let x 2 P .f 0 /\P .g0 / with 1lx D g.E/f P can be chosen integral. Let h0 .A/ WD e2A xe and h.A/ WD h0 .A/ C f .;/ M jAj for all A E. The function h is modular. Moreover, for all A E we have h.A/ g 0 .A/Cf .;/M jAj D g.A/ and h.A/ D 1lxh0 .E nA/Cf .;/M jAj g.E/ C M jEj M jAj f 0 .E n A/ D f .A/. The analogy to convex and concave functions is obvious; see also Exercise 10.

14.3 Minimizing Submodular Functions The SEPARATION PPROBLEM for a polymatroid P .f / and a vector x asks for a set A with f .A/ < e2A x.e/. So this P problem reduces to finding a set A minimizing g.A/, where g.A/ WD f .A/ e2A x.e/. Note that if f is submodular, then g is also submodular. Therefore it is an interesting problem to minimize submodular functions. Another motivation might be that submodular functions can be regarded as the discrete analogue of convex functions (Corollary 14.15 and Exercise 10). We have already solved a special case in Section 8.7: finding the minimum cut in an undirected graph can be regarded as minimizing a certain symmetric submodular function f W 2U ! RC over 2U n f;; U g. Before returning to this special case we first show how to minimize general submodular functions. For simplicity we restrict ourselves to integer-valued submodular functions:

SUBMODULAR FUNCTION MINIMIZATION PROBLEM Instance: Task:

A finite set U . A submodular function f W 2U ! Z (given by an oracle). Find a subset X U with f .X / minimum.

Grötschel, Lovász and Schrijver [1981] showed how this problem can be solved with the help of the E LLIPSOID METHOD. The idea is to determine the minimum by binary search; this will reduce the problem to the SEPARATION PROBLEM for a polymatroid. Using the equivalence of separation and optimization (Section 4.6), it thus suffices to optimize linear functions over polymatroids. However, this can be done easily by the POLYMATROID GREEDY ALGORITHM. We first need an upper bound on jf .S /j for S U : Proposition 14.16. For any submodular function f W 2U ! Z and any S U we have

364

14 Generalizations of Matroids

f .U /

X

maxf0; f .fug/f .;/g f .S / f .;/C

u2U

X

maxf0; f .fug/f .;/g:

u2U

In particular, a number B with jf .S /j B for all S U can be computed in linear time, with jU j C 2 oracle calls to f . Proof: By repeated application of submodularity we get for ; 6D S U (let x 2 S ): X f .S / f .;/Cf .S nfxg/Cf .fxg/ jS jf .;/Cf .;/C f .fxg/; x2S

and for S U (let y 2 U n S ): f .S / f .fyg/ C f .S [ fyg/ C f .;/ X f .fyg/ C f .U / C jU n S jf .;/: y2U nS

Proposition 14.17. The following problem can be solved in polynomial time: Given a finite set U , a submodular and monotone function f W 2U ! ZC (by an oracle) with f .S / > 0 for S 6D ;, a number B 2 N with f .S / B for all S U , andPa vector x 2 ZU C , decide if x 2 P .f / and otherwise return a set S U with v2S x.v/ > f .S /. Proof: This is the SEPARATION PROBLEM for the polymatroid P .f /. We will use Theorem 4.23, because we have already solved the optimization problem for P .f /: the POLYMATROID GREEDY ALGORITHM maximizes any linear function over P .f / (Theorem 14.11). We have to check the prerequisites of Theorem 4.23. Since the zero vector and the unit vectors are all in P .f /, we can take x0 WD 1l as a point in the interior, 1 where D jU jC1 . We have size.x0 / D O.jU j log jU j/. Moreover, each vertex of P .f / is produced by the POLYMATROID GREEDY ALGORITHM (for some objective function; cf. Theorem 14.11) and thus has size O.jU j.2 C log B//. We conclude that the SEPARATION PROBLEM can be solved in polynomial time. By Theorem 4.23, we get a facet-defining inequality of P .f / violated by x if x … P .f /. This P corresponds to a set S U with v2S x.v/ > f .S /. If f is not monotone, we cannot apply this result directly. Instead we consider a different function: Proposition 14.18. Let f W 2U ! R be a submodular function and ˇ 2 R. Then g W 2U ! R, defined by X .f .U n feg/ f .U //; g.X / WD f .X / ˇ C e2X

is submodular and monotone.

14.4

Schrijver’s Algorithm

365

Proof: The submodularity of g follows directly from the submodularity of f . To show that g is monotone, let X U and e 2 U n X . We have g.X [ feg/ g.X / D f .X [ feg/ f .X / C f .U n feg/ f .U / 0 since f is submodular. Theorem 14.19. The SUBMODULAR FUNCTION MINIMIZATION PROBLEM can be solved in time polynomial in jU j C log maxfjf .S /j W S U g. Proof: Let U be a finite set; suppose we are given f by an oracle. First compute a number B 2 N with jf .S /j B for all S U (cf. Proposition 14.16). Since f is submodular, we have for each e 2 U and for each X U n feg: f .feg/ f .;/ f .X [ feg/ f .X / f .U / f .U n feg/:

(14.2)

If, for some e 2 U , f .feg/ f .;/ 0, then by (14.2) there is an optimum set S containing e. In this case we consider the instance .U 0 ; B; f 0 / defined by U 0 WD U n feg and f 0 .X / WD f .X [ feg/ for X U n feg, find a set S 0 U 0 with f 0 .S 0 / minimum and output S WD S 0 [ feg. Similarly, if f .U / f .U n feg/ 0, then by (14.2) there is an optimum set S not containing e. In this case we simply minimize f restricted to U n feg. In both cases we have reduced the size of the ground set. So we may assume that f .feg/ f .;/ > 0 and f .U n feg/ f .U / > 0 for all e 2 U . Let x.e/ WD f .U n feg/ f P .U /. For each integer ˇ with B ˇ f .;/ we define g.X / WD f .X / ˇ C e2X x.e/. By Proposition 14.18, g is submodular and monotone. Furthermore we have g.;/ D f .;/ ˇ 0 and g.feg/ D f .feg/ ˇ C x.e/ > 0 for all e 2 U , and thus g.X / > 0 for all ; 6D X U . Now we apply Proposition 14.17 and check if x 2 P .g/. If yes, we have f .X / ˇ for all X U and we are done. Otherwise we get a set S with f .S / < ˇ. Now we apply binary search: by choosing ˇ appropriately each time, we need O.log.2B// iterations to find the number ˇ 2 fB; B C 1; : : : ; f .;/g for which f .X / ˇ for all X U but f .S / < ˇ C 1 for some S U . This set S minimizes f . The first strongly polynomial-time algorithm has been designed by Grötschel, Lovász and Schrijver [1988], also based on the ellipsoid method. Combinatorial algorithms to solve the SUBMODULAR FUNCTION MINIMIZATION PROBLEM in strongly polynomial time have been found by Schrijver [2000] and independently by Iwata, Fleischer and Fujishige [2001]. In the next section we describe Schrijver’s algorithm.

14.4 Schrijver’s Algorithm For a finite set U and a submodular function f W 2U ! Z, assume w.l.o.g. that U D f1; : : : ; ng and f .;/ D 0. At each stage, Schrijver’s [2000] algorithm maintains a point x in the so-called base polyhedron of f , defined by

366

14 Generalizations of Matroids

( U

x2R W

X

x.u/ f .A/ for all A U;

u2A

X

) x.u/ D f .U / :

u2U

We mention that the set of vertices of this base polyhedron is precisely the set of vectors b for all total orders of U , where we define b .u/ WD f .fv 2 U W v ug/ f .fv 2 U W v ug/ (u 2 U ). This fact, which we will not need here, can be proved in a similar way as Theorem 14.11 (Exercise 14). The point x is always written as an explicit convex combination x D 1 b 1 C C k b k of these vertices. Initially, one can choose k D 1 and any total order. For a total order and s; u 2 U , we denote by s;u the total order that results from by moving u just before s. Moreover, let u denote the incidence vector of u (u 2 U ).

SCHRIJVER’S ALGORITHM Input: Output:

A finite set U D f1; : : : ; ng. A submodular function f W 2U ! Z with f .;/ D 0 (given by an oracle). A subset X U with f .X / minimum.

1

Set k WD 1, let 1 be any total order on U , and set x WD b 1 .

2

Set D WD .U; A/, where A D f.u; v/ W u i v for some i 2 f1; : : : ; kgg.

3

Let P WD fv 2 U W x.v/ > 0g and N WD fv 2 U W x.v/ < 0g, and let X be the set of vertices not reachable from P in the digraph D. If N X , then stop else let d.v/ denote the distance from P to v in D. Choose the vertex t 2 N reachable from P with .d.t/; t/ lexicographically maximum. Choose the maximal vertex s with .s; t/ 2 A and d.s/ D d.t/ 1. Let i 2 f1; : : : ; kg such that ˛ WD jfv W s i v i tgj is maximum (the number of indices attaining this maximum will be denoted by ˇ).

4

5

6

Compute a number with 0 x.t/ and write x 0 WD x C .t s / as an explicit convex combination of at most n vectors, chosen among s;u b 1 ; : : : ; b k and b i for all u 2 U with s i u i t, with the additional i property that b does not occur if x 0 .t/ < 0. Set x WD x 0 , rename the vectors in the convex combination of x as b 1 ; : : : ; b k0 , set k WD k 0 , and go to . 2

Theorem 14.20. (Schrijver [2000]) SCHRIJVER’S ALGORITHM works correctly. Proof: The algorithm terminates if D contains no path from P to N and outputs of vertices not reachable from P . Clearly N X U n P , so P the set X P u2X x.u/ u2W x.u/ for each W U . Moreover, no edge enters X , so either X D ; or for each j 2 f1; : : : ; kg there exists a v 2 X with X D fu 2 U W u j vg.

14.4

Schrijver’s Algorithm

367

P j Hence, by definition, P u2X b .u/ D f .X / for all j 2 f1; : : : ; kg. Moreover, by Proposition 14.10, u2W b j .u/ f .W / for all W U and j 2 f1; : : : ; kg. Therefore, for each W U , f .W /

k X j D1

X

X

j

b j .u/ D

k XX

j b j .u/ D

u2W j D1

u2W k XX

x.u/ D

x.u/

u2W

j b j .u/ D

u2X j D1

u2X

X

k X j D1

j

X

b j .u/ D f .X /;

u2X

proving that X is an optimum solution.

Lemma 14.21. (Schrijver [2000]) Each iteration can be performed in O.n3 C n2 / time, where is the time for an oracle call. Proof: It suffices to show that 5 can be done in O.n3 C n2 / time. Let x D 1 k 1 b C C k b and s i t. We first show: Claim: ı.t s /, for some ı 0, can be written as a convex combination of s;v the vectors b i b i for s i v i t in O. n2 / time. To prove this, we need some preliminaries. Let s i v i t. By definition, s;v b i .u/ D b i .u/ for u i s or u i v. As f is submodular, we have for s i u i v: s;v

b i .u/ D f .fw 2 U W w s;v ug/ f .fw 2 U W w s;v ug/ i i

f .fw 2 U W w i ug/ f .fw 2 U W w i ug/ D b i .u/:

Moreover, for u D v we have: s;v

b i .v/ D f .fw 2 U W w s;v vg/ f .fw 2 U W w s;v vg/ i i D f .fw 2 U W w i sg [ fvg/ f .fw 2 U W w i sg/ f .fw 2 U W w i vg/ f .fw 2 U W w i vg/ D b i .v/: P P s;v Finally, observe that u2U b i .u/ D f .U / D u2U b i .u/. s;v As the claim is trivial if b i D b i for some s i v i t, we may assume s;v b i .v/ > b i .v/ for all s i v i t. We recursively set v WD

tv

P

s;w

vi wi t

s;v

w .b i .v/ b i .v//

b i .v/ b i .v/

0

P s;v for s i v i t, and obtain si vi t v .b i b i / D t s , because P P s;v s;v i .u/ b i .u// D i .u/ b i .u// D t for u si vi t v .b ui vi t v .b all s i u i t, and the sum over all components is zero.

368

14 Generalizations of Matroids

By setting ı WD

P

1 si vi t

v

and multiplying each u by ı, we see that the claim

follows. Now consider WD minfi ı; x.t/g and x 0 WD x C .t s /. If D i ı P P s;v x.t/, then we have x 0 D jkD1 j b j Ci si vi t v .b i b i /, i.e. we have s;v

written x 0 as a convex combination of b j (j 2 f1; : : : ; kg n fi g) and b i (s i v i t). If D x.t/, we may additionally use b i in the convex combination. We finally reduce this convex combination to at most n vectors in O.n3 / time, as shown in Exercise 5 of Chapter 4. Lemma 14.22. (Vygen [2003]) O.n5 / iterations.

SCHRIJVER’S ALGORITHM terminates after s;v

Proof: If an edge .v; w/ is introduced after a new vector b i has been added in 5 of an iteration, then s i w i v i t in this iteration. Thus d.w/ d.s/ C 1 D d.t/ d.v/ C 1 in this iteration, and the introduction of the new edge cannot make the distance from P to any u 2 U smaller. As 5 makes sure that no element is ever added to P , the distance d.u/ never decreases for any u 2 U . Call a block a sequence of iterations where the pair .t; s/ remains constant. Note that each block has O.n2 / iterations, because .˛; ˇ/ decreases lexicographically in each iteration within each block. It remains to prove that there are O.n3 / blocks. A block can end only because of at least one of the following reasons (by the choice of t and s, since an iteration with t D t does not add any edge whose head is t , and since a vertex v can enter N only if v D s and hence d.v/ < d.t/): (a) the distance d.v/ increases for some v 2 U . (b) t is removed from N . (c) .s; t/ is removed from A. We now count the number of blocks of these three types. Clearly there are O.n2 / blocks of type (a). Now consider type (b). We claim that for each t 2 U there are O.n2 / iterations with t D t and x 0 .t/ D 0. This is easy to see: between every two such iterations, d.v/ must change for some v 2 U , and this can happen O.n2 / times as d -values can only increase. Thus there are O.n3 / blocks of type (b). We finally show that there are O.n3 / blocks of type (c). It suffices to show that d.t/ will change before the next such block with the pair .s; t/. For s; t 2 U , we say that s is t-boring if .s; t/ … A or d.t/ d.s/. Let s ; t 2 U , and consider the time period after a block with s D s and t D t ending because .s ; t / is removed from A, until the subsequent change of d.t /. We prove that each v 2 fs ; : : : ; ng is t -boring throughout this period. Applying this for v D s concludes the proof. At the beginning of the period, each v 2 fs C 1; : : : ; ng is t -boring due to the choice of s D s in the iteration immediately preceding the period. s is also t -boring as .s ; t / is removed from A. As d.t / remains constant within the considered time period and d.v/ never decreases for any v, we only have to check the introduction of new edges.

14.5

Symmetric Submodular Functions

369

Suppose that, for some v 2 fs ; : : : ; ng, the edge .v; t / is added to A after an iteration that chooses the pair .s; t/. Then, by the initial remarks of this proof, s i t i v i t in this iteration, and thus d.t / d.s/ C 1 D d.t/ d.v/ C 1. Now we distinguish two cases: If s > v, then we have d.t / d.s/: either because t D s, or as s was t -boring and .s; t / 2 A. If s < v, then we have d.t/ d.v/: either because t D v, or by the choice of s and since .v; t/ 2 A. In both cases we conclude that d.t / d.v/, and v remains t -boring. Theorem 14.20, Lemma 14.21 and Lemma 14.22 imply: Theorem 14.23. The SUBMODULAR FUNCTION MINIMIZATION PROBLEM can be solved in O.n8 C n7 / time, where is the time for an oracle call. Iwata [2002] described a fully combinatorial algorithm (using only additions, subtractions, comparisons and oracle calls, but no multiplication or division). He also improved the running time (Iwata [2003]). The currently fastest strongly polynomial-time algorithm was found by Orlin [2007]; it runs in O.n6 C n5 / time.

14.5 Symmetric Submodular Functions A submodular function f W 2U ! R is called symmetric if f .A/ D f .U n A/ for all A U . In this special case the SUBMODULAR FUNCTION MINIMIZATION PROBLEM is trivial, since 2f .;/ D f .;/Cf .U / f .A/Cf .U nA/ D 2f .A/ for all A U , implying that the empty set is optimal. Hence the problem is interesting only if this trivial case is excluded: one looks for a nonempty proper subset A of U such that f .A/ is minimum. Generalizing the algorithm of Section 8.7, Queyranne [1998] has found a relatively simple combinatorial algorithm for this problem using only O.n3 / oracle calls. The following lemma is a generalization of Lemma 8.41 (Exercise 16): Lemma 14.24. Given a symmetric submodular function f W 2U ! R with n WD jU j 2, we can find two elements x; y 2 U with x 6D y and f .fxg/ D minff .X / W x 2 X U n fygg in O.n2 / time, where is the time bound of the oracle for f . Proof: We construct an order U D fu1 ; : : : ; un g by doing the following for k D 1; : : : ; n 1. Suppose that u1 ; : : : ; uk1 are already constructed; let Uk1 WD fu1 ; : : : ; uk1 g. For C U we define 1 wk .C / WD f .C / .f .C n Uk1 / C f .C [ Uk1 / f .Uk1 //: 2 Note that wk is also symmetric. Let uk be an element of U n Uk1 that maximizes wk .fuk g/. Finally, let un be the only element in U n fu1 ; : : : ; un1 g. Obviously the construction of the order u1 ; : : : ; un can be done in O.n2 / time.

370

14 Generalizations of Matroids

Claim: For all k D 1; : : : ; n 1 and all x; y 2 U n Uk1 with x 6D y and wk .fxg/ wk .fyg/ we have wk .fxg/ D minfwk .C / W x 2 C U n fygg: We prove the claim by induction on k. For k D 1 the assertion is trivial since w1 .C / D 12 f .;/ for all C U . Let now k > 1 and x; y 2 U n Uk1 with x 6D y and wk .fxg/ wk .fyg/. Moreover, let Z U with uk1 … Z, and let ´ 2 Z n Uk1 . By the choice of uk1 we have wk1 .f´g/ wk1 .fuk1 g/; thus by the induction hypothesis we get wk1 .f´g/ wk1 .Z/. Furthermore, the submodularity of f implies .wk .Z/ wk1 .Z// .wk .f´g/ wk1 .f´g// 1 D .f .Z [ Uk2 / f .Z [ Uk1 / f .Uk2 / C f .Uk1 // 2 1 .f .f´g [ Uk2 / f .f´g [ Uk1 / f .Uk2 / C f .Uk1 // 2 1 D .f .Z [ Uk2 / C f .f´g [ Uk1 / f .Z [ Uk1 / f .f´g [ Uk2 // 2 0: Hence wk .Z/ wk .f´g/ wk1 .Z/ wk1 .f´g/ 0. To conclude the proof of the claim, let C U with x 2 C and y … C . There are two cases: Case 1: uk1 … C . Then the above result for Z D C and ´ D x yields wk .C / wk .fxg/ as required. Case 2: uk1 2 C . Then we apply the above to Z D U n C and ´ D y and get wk .C / D wk .U n C / wk .fyg/ wk .fxg/. This completes the proof of the claim. Applying it to k D n 1, x D un and y D un1 we get wn1 .fun g/ D minfwn1 .C / W un 2 C U n fun1 gg: Since wn1 .C / D f .C / 12 .f .fun g/ C f .U n fun1 g/ f .Un2 // for all C U with un 2 C and un1 … C , the lemma follows (set x WD un and y WD un1 ). The above proof is due to Fujishige [1998]. Now we can proceed analogously to the proof of Theorem 8.42: Theorem 14.25. (Queyranne [1998]) Given a symmetric submodular function f W 2U ! R, a nonempty proper subset A of U such that f .A/ is minimum can be found in O.n3 / time where is the time bound of the oracle for f . Proof: If jU j D 1, the problem is trivial. Otherwise we apply Lemma 14.24 and find two elements x; y 2 U with f .fxg/ D minff .X / W x 2 X U n fygg in O.n2 / time. Next we recursively find a nonempty proper subset of U n fxg minimizing the function f 0 W 2U nfxg ! R, defined by f 0 .X / WD f .X / if y … X

Exercises

371

and f 0 .X / WD f .X [ fxg/ if y 2 X . One readily observes that f 0 is symmetric and submodular. Let ; 6D Y U n fxg be a set minimizing f 0 ; w.l.o.g. y 2 Y (as f 0 is symmetric). We claim that either fxg or Y [ fxg minimizes f (over all nonempty proper subsets of U ). To see this, consider any C U with x 2 C . If y … C , then we have f .fxg/ f .C / by the choice of x and y. If y 2 C , then f .C / D f 0 .C n fxg/ f 0 .Y / D f .Y [ fxg/. Hence f .C / minff .fxg/; f .Y [ fxg/g for all nonempty proper subsets C of U . To achieve the asserted running time we of course cannot compute f 0 explicitly. Rather we store a partition of U , initially consisting of the singletons. At each step of the recursion we build the union of those two sets of the partition that contain x and y. In this way f 0 can be computed efficiently (using the oracle for f ). This result has been further generalized by Nagamochi and Ibaraki [1998] and by Rizzi [2000].

Exercises 1. Let G be an undirected graph and M a maximum matching in G. Let F be the family of those subsets X E.G/ for which there exists a special blossom forest F with respect to M with E.F / n M D X . Prove that .E.G/ n M; F / is a greedoid. Hint: Use Exercise 24 of Chapter 10. 2. Let .E; F / be a greedoid and c 0 W E ! RC . We consider the bottleneck function c.F / WD minfc 0 .e/ W e 2 F g for F E. Show that the GREEDY ALGORITHM FOR G REEDOIDS , when applied to .E; F / and c, finds an F 2 F with c.F / maximum. 3. This exercise shows that greedoids can also be defined as languages (cf. Definition 15.1). Let E be a finite set. A language L over the alphabet E is called a greedoid language if (a) L contains the empty string; (b) xi 6D xj for all .x1 ; : : : ; xn / 2 L and 1 i < j n; (c) .x1 ; : : : ; xn1 / 2 L for all .x1 ; : : : ; xn / 2 L; (d) If .x1 ; : : : ; xn /; .y1 ; : : : ; ym / 2 L with m < n, then there exists an i 2 f1; : : : ; ng such that .y1 ; : : : ; ym ; xi / 2 L. L is called an antimatroid language if it satisfies (a), (b), (c) and (d0 ) If .x1 ; : : : ; xn /; .y1 ; : : : ; ym / 2 L with fx1 ; : : : ; xn g 6 fy1 ; : : : ; ym g, then there exists an i 2 f1; : : : ; ng such that .y1 ; : : : ; ym ; xi / 2 L. Prove: A language L over the alphabet E is a greedoid language (an antimatroid language) if and only if the set system .E; F / is a greedoid (antimatroid), where F WD ffx1 ; : : : ; xn g W .x1 ; : : : ; xn / 2 Lg. 4. Let U be a finite set and f W 2U ! R. Prove that f is submodular if and only if f .X [ fy; ´g/ f .X [ fyg/ f .X [ f´g/ f .X / for all X U and y; ´ 2 U with y 6D ´.

372

14 Generalizations of Matroids

5. Let .G; u; s; t/ be a network and U WD ı C .s/. Let P WD fx 2 RU C W there is an s-t-flow f in .G; u/ with f .e/ D xe for all e 2 U g. Prove that P is a polymatroid. 6. Let P be a polymatroid. Show that then there is a submodular and monotone function f with f .;/ D 0 and P D P .f /. 7. Prove that a nonempty compact set P RnC is a polymatroid if and only if (a) For all 0 x y 2 P we have x 2 P . (b) For all x 2 RnC and all y; ´ x with y; ´ 2 P that are maximal with this property (i.e. y w x and w 2 P implies w D y, and ´ w x and w 2 P implies w D ´) we have 1ly D 1l´. Note: This is the original definition of Edmonds [1970]. 8. Prove that the P OLYMATROID GREEDY ALGORITHM, when applied to a vector E c 2 RE C and a submodular but not necessarily monotone function f W 2 ! R with f .;/ 0, solves ( ) X max cx W xe f .A/ for all A E : e2A

9. Prove Theorem 14.12 for the special case that f and g are rank functions of matroids by constructing an integral optimum dual solution from c1 and c2 as generated by the WEIGHTED MATROID INTERSECTION ALGORITHM. (Frank [1981])

10. Let S be a finite set and f W 2S ! R. Define f 0 W RSC ! R as follows. For any x 2 RSC there are unique k 2 ZC , 1 ; : : : ; k > 0 and ; T1 T2 P Tk S such that x D kiD1 i Ti , where Ti is the incidence vector of Ti . P Then f 0 .x/ WD kiD1 i f .Ti /. Prove that f is submodular if and only if f 0 is convex. (Lovász [1983]) 11. Let E be a finite set and f W 2E ! RC a submodular function with f .feg/ 2 for all e 2 E. (The pair .E; f / is sometimes called a 2-polymatroid.) The POLYMATROID MATCHING PROBLEM asks for a maximum cardinality set X E with f .X / D 2jX j. (f is of course given by an oracle.) Let E1 ; : : : ; Ek be pairwise disjoint unordered pairs and let .E; F / be a matroid (given by an independence oracle), where E D E1 [ [ Ek . The MATROID PARITY PROBLEM asks for a maximum cardinality set I f1; : : : ; kg with S i 2I Ei 2 F . (a) Show that the MATROID PARITY PROBLEM polynomially reduces to the POLYMATROID MATCHING PROBLEM.

(b) Show that the POLYMATROID MATCHING PROBLEM polynomially reduces to the MATROID PARITY PROBLEM. Hint: Use an algorithm for the SUBMODULAR FUNCTION MINIMIZATION PROBLEM.

(c) Show that there is no algorithm for the POLYMATROID MATCHING PROBLEM whose running time is polynomial in jEj. (Jensen and Korte [1982], Lovász [1981])

Exercises

373

(A problem polynomially reduces to another one if the former can be solved with a polynomial-time oracle algorithm using an oracle for the latter; see Chapter 15.) Note: A polynomial-time algorithm for an important special case was given by Lovász [1980,1981]. 12. A function f W 2S ! R[f1g is called crossing submodular if f .X /Cf .Y / f .X [Y /Cf .X \Y / for any two sets X; Y S with X \Y 6D ; and X [Y 6D S . The SUBMODULAR FLOW PROBLEM is as follows: Given a digraph G, functions l W E.G/ ! R [ f1g, u W E.G/ ! R [ f1g, c W E.G/ ! R, and a crossing submodular function b W 2V .G/ ! R [ f1g. Then a feasible submodular flow is a function f W E.G/ ! R with l.e/ f .e/ u.e/ for all e 2 E.G/ and X X f .e/ f .e/ b.X / e2ı .X/

e2ı C .X/

for all X V .G/. The taskPis to decide whether a feasible flow exists and, if yes, to find one whose cost e2E.G/ c.e/f .e/ is minimum possible. Show that this problem generalizes the MINIMUM COST FLOW PROBLEM and the problem of optimizing a linear function over the intersection of two polymatroids. Note: The SUBMODULAR FLOW PROBLEM, introduced by Edmonds and Giles [1977], can be solved in strongly polynomial time; see Fujishige, Röck and Zimmermann [1989]. See also Fleischer and Iwata [2000].

13. Show that the inequality system describing a feasible submodular flow (Exercise 12) is TDI. Show that this implies Theorems 14.12 and 19.17. (Edmonds and Giles [1977]) 14. Prove that the set of vertices of the base polyhedron of a submodular function f with f .;/ D 0 is precisely the set of vectors b for all total orders of U , where b .u/ WD f .fv 2 U W v ug/ f .fv 2 U W v ug/ (u 2 U ). Hint: See the proof of Theorem 14.11. 15. Let f W2U ! R be a submodular function with f .;/D0, and let˚P B.f / denote its base polyhedron. Prove that minff .X / W X U g D max u2U ´.u/ W ˚P ´.A/ minf0; f .A/g for all AU D max minf0; y.u/g W y 2 B.f / . u2U Hint: Use Corollary 14.14 or the correctness of SCHRIJVER’S ALGORITHM. 16. Show that Lemma 8.41 is a special case of Lemma 14.24. 17. Let f W 2U ! R be a submodular function. Let R be a random subset of U , where each element is chosen independently with probability 12 . Prove: (a) Exp.f .R// 12 .f .;/ C f .U //. (b) For each A U we have Exp.f .R// 14 .f .;/ C f .A/ C f .U n A/ C f .U //. Hint: Apply (a) twice. (c) If f is nonnegative, then Exp.f .R// 14 maxAU f .A/. Note: Part (c) implies a randomized 4-factor approximation algorithm for (nonnegative) submodular function maximization. This problem cannot be solved

374

14 Generalizations of Matroids

optimally with a polynomial number of oracle calls. (Feige, Mirrokni and Vondrák [2011]; they also prove stronger results.)

References General Literature: Bixby, R.E., and Cunningham, W.H. [1995]: Matroid optimization and algorithms. In: Handbook of Combinatorics; Vol. 1 (R.L. Graham, M. Grötschel, L. Lovász, eds.), Elsevier, Amsterdam, 1995 Björner, A., and Ziegler, G.M. [1992]: Introduction to greedoids. In: Matroid Applications (N. White, ed.), Cambridge University Press, Cambridge 1992 Frank, A. [2011]: Connections in Combinatorial Optimization. Oxford University Press, Oxford 2011 Fujishige, S. [2005]: Submodular Functions and Optimization. Second Edition. Elsevier, Amsterdam 2005 Iwata, S. [2008]: Submodular function minimization. Mathematical Programming B 112 (2008), 45–64 Korte, B., Lovász, L., and Schrader, R. [1991]: Greedoids. Springer, Berlin 1991 McCormick, S.T. [2004]: Submodular function minimization. In: Discrete Optimization (K. Aardal, G.L. Nemhauser, R. Weismantel, eds.), Elsevier, Amsterdam 2005 Schrijver, A. [2003]: Combinatorial Optimization: Polyhedra and Efficiency. Springer, Berlin 2003, Chapters 44–49

Cited References: Edmonds, J. [1970]: Submodular functions, matroids and certain polyhedra. In: Combinatorial Structures and Their Applications; Proceedings of the Calgary International Conference on Combinatorial Structures and Their Applications 1969 (R. Guy, H. Hanani, N. Sauer, J. Schönheim, eds.), Gordon and Breach, New York 1970, pp. 69–87 Edmonds, J. [1979]: Matroid intersection. In: Discrete Optimization I; Annals of Discrete Mathematics 4 (P.L. Hammer, E.L. Johnson, B.H. Korte, eds.), North-Holland, Amsterdam 1979, pp. 39–49 Edmonds, J., and Giles, R. [1977]: A min-max relation for submodular functions on graphs. In: Studies in Integer Programming; Annals of Discrete Mathematics 1 (P.L. Hammer, E.L. Johnson, B.H. Korte, G.L. Nemhauser, eds.), North-Holland, Amsterdam 1977, pp. 185–204 Feige, U., Mirrokni, V.S., and Vondrák, J. [2011]: Maximizing non-monotone submodular functions. SIAM Journal on Computing 40 (2011), 1133–1153 Fleischer, L., and Iwata, S. [2000]: Improved algorithms for submodular function minimization and submodular flow. Proceedings of the 32nd Annual ACM Symposium on Theory of Computing (2000), 107–116 Frank, A. [1981]: A weighted matroid intersection algorithm. Journal of Algorithms 2 (1981), 328–336 Frank, A. [1982]: An algorithm for submodular functions on graphs. In: Bonn Workshop on Combinatorial Optimization; Annals of Discrete Mathematics 16 (A. Bachem, M. Grötschel, B. Korte, eds.), North-Holland, Amsterdam 1982, pp. 97–120

References

375

Fujishige, S. [1998]: Another simple proof of the validity of Nagamochi and Ibaraki’s min-cut algorithm and Queyranne’s extension to symmetric submodular function minimization. Journal of the Operations Research Society of Japan 41 (1998), 626–628 Fujishige, S., Röck, H., and Zimmermann, U. [1989]: A strongly polynomial algorithm for minimum cost submodular flow problems. Mathematics of Operations Research 14 (1989), 60–69 Grötschel, M., Lovász, L., and Schrijver, A. [1981]: The ellipsoid method and its consequences in combinatorial optimization. Combinatorica 1 (1981), 169–197 Grötschel, M., Lovász, L., and Schrijver, A. [1988]: Geometric Algorithms and Combinatorial Optimization. Springer, Berlin 1988 Iwata, S. [2002]: A fully combinatorial algorithm for submodular function minimization. Journal of Combinatorial Theory B 84 (2002), 203–212 Iwata, S. [2003]: A faster scaling algorithm for minimizing submodular functions. SIAM Journal on Computing 32 (2003), 833–840 Iwata, S., Fleischer, L., and Fujishige, S. [2001]: A combinatorial, strongly polynomial-time algorithm for minimizing submodular functions. Journal of the ACM 48 (2001), 761–777 Jensen, P.M., and Korte, B. [1982]: Complexity of matroid property algorithms. SIAM Journal on Computing 11 (1982), 184–190 Lovász, L. [1980]: Matroid matching and some applications. Journal of Combinatorial Theory B 28 (1980), 208–236 Lovász, L. [1981]: The matroid matching problem. In: Algebraic Methods in Graph Theory; Vol. II (L. Lovász, V.T. Sós, eds.), North-Holland, Amsterdam 1981, 495–517 Lovász, L. [1983]: Submodular functions and convexity. In: Mathematical Programming: The State of the Art – Bonn 1982 (A. Bachem, M. Grötschel, B. Korte, eds.), Springer, Berlin 1983 Nagamochi, H., and Ibaraki, T. [1998]: A note on minimizing submodular functions. Information Processing Letters 67 (1998), 239–244 Orlin, J.B. [2007]: A faster strongly polynomial time algorithm for submodular function minimization. Mathematical Programming 118 (2009), 237–251 Queyranne, M. [1998]: Minimizing symmetric submodular functions. Mathematical Programming B 82 (1998), 3–12 Rizzi, R. [2000]: On minimizing symmetric set functions. Combinatorica 20 (2000), 445–450 Schrijver, A. [2000]: A combinatorial algorithm minimizing submodular functions in strongly polynomial time. Journal of Combinatorial Theory B 80 (2000), 346–355 Vygen, J. [2003]: A note on Schrijver’s submodular function minimization algorithm. Journal of Combinatorial Theory B 88 (2003), 399–402

•

15 NP-Completeness

For many combinatorial optimization problems a polynomial-time algorithm is known; the most important ones are presented in this book. However, there are also many important problems for which no polynomial-time algorithm is known. Although we cannot prove that none exists we can show that a polynomialtime algorithm for one “hard” (more precisely: NP-hard) problem would imply a polynomial-time algorithm for almost all problems discussed in this book (more precisely: all NP-easy problems). To formalize this concept and prove the above statement we need a machine model, i.e. a precise definition of a polynomial-time algorithm. Therefore we discuss Turing machines in Section 15.1. This theoretical model is not suitable to describe more complicated algorithms. However we shall argue that it is equivalent to our informal notion of algorithms: every algorithm in this book can, theoretically, be written as a Turing machine, with a loss in efficiency that is polynomially bounded. We indicate this in Section 15.2. In Section 15.3 we introduce decision problems, and in particular the classes P and NP. While NP contains most decision problems appearing in this book, P contains only those for which there are polynomial-time algorithms. It is an open question whether P D NP. Although we shall discuss many problems in NP for which no polynomial-time algorithm is known, nobody can (so far) prove that none exists. We specify what it means that one problem reduces to another, or that one problem is at least as hard as another one. In this notion, the hardest problems in NP are the NP-complete problems; they can be solved in polynomial time if and only if P D NP. In Section 15.4 we exhibit the first NP-complete problem, SATISFIABILITY. In Section 15.5 some more decision problems, more closely related to combinatorial optimization, are proved to be NP-complete. In Sections 15.6 and 15.7 we shall discuss related concepts, also extending to optimization problems.

15.1 Turing Machines In this section we present a very simple model for computation: the Turing machine. It can be regarded as a sequence of simple instructions working on a string. The input and the output will be a binary string: B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__15, c Springer-Verlag Berlin Heidelberg 2012

377

378

15 NP-Completeness

Definition 15.1. An alphabet is a finite set with at least two elements, not containing the special symbol t (which we shall use for blanks). For an alphabet A we denote by a string over A aS finite sequence of elements of A, by An the set of strings of length n, and by A WD n2ZC An the set of all strings over A. We use the convention that A0 contains exactly one element, the empty string. A language over A is a subset of A . The elements of a language are often called words. If x 2 An we write size.x/ WD n for the length of the string. We shall often work with the alphabet A D f0; 1g and the set f0; 1g of all 01-strings (or binary strings). The components of a 0-1-string are sometimes called its bits. So there is exactly one 0-1-string of zero length, the empty string. A Turing machine gets as input a string x 2 A for some fixed alphabet A. The input is completed by blank symbols (denoted by t) to a two-way infinite string s 2 .A [ ftg/Z . This string s can be regarded as a tape with a read-write head; only a single position can be read and modified at each step, and the read-write head can be moved by one position in each step. A Turing machine consists of a set of N C 1 instructions numbered 0; : : : ; N . In the beginning instruction 0 is executed and the current position of the string is position 1. Now each instruction is of the following type. Read the bit at the current position, and depending on its value do the following: overwrite the current bit by some element of A [ ftg, possibly move the current position by one to the left or to the right, and go to an instruction which will be executed next. There is a special instruction denoted by 1 which marks the end of the computation. The components of our infinite string s indexed by 1; 2; 3; : : : up to the first t then yield the output string. Formally we define a Turing machine as follows: Definition 15.2. (Turing [1936]) Let A be an alphabet and AN WD A [ ftg. A Turing machine (with alphabet A) is defined by a function ˆ W f0; : : : ; N g AN ! f1; : : : ; N g AN f1; 0; 1g for some N 2 ZC . The computation of ˆ on input x, where x 2 A , is the finite or infinite sequence of triples .n.i / ; s .i / ; .i / / with n.i / 2 f1; : : : ; N g, s .i / 2 ANZ and .i / 2 Z (i D 0; 1; 2; : : :) defined recursively as follows (n.i / denotes the current instruction, s .i / represents the string, and .i / is the current position): .0/ .0/ n.0/ WD 0. sj WD xj for 1 j size.x/, and sj WD t for all j 0 and j > size.x/. .0/ WD 1. If .n.i / ; s .i / ; .i / / is already defined, we distinguish two cases. If n.i / 6D 1, then let .m; ; ı/ WD ˆ n.i / ; s.i.i/ / and set n.i C1/ WD m, s.i.iC1/ WD , sj.i C1/ WD sj.i / / for j 2 Z n f .i / g, and .i C1/ WD .i / C ı. If n.i / D 1, then this is the end of the sequence. We then define time.´L; x/ WD i ˚ .i / and output.´L; x/ 2 Ak , where k WD min j 2 N W sj D t 1, by output.´L; x/j .i /

WD sj for j D 1; : : : ; k.

15.2

Church’s Thesis

379

If this sequence is infinite (i.e. n.i / 6D 1 for all i ), then we set time.ˆ; x/ WD 1. In this case output.´L; x/ is undefined. Of course we are interested mostly in Turing machines whose computation is finite or even polynomially bounded: Definition 15.3. Let A be an alphabet. A computational problem is a pair .X; R/, where X A is a language and R X A is a relation such that for every x 2 X there exists a y 2 A with .x; y/ 2 R. Let ˆ be a Turing machine with alphabet A such that time.´L; x/ < 1 and .x; output.´L; x// 2 R for each x 2 X . Then we say that ˆ computes .X; R/. If there exists a polynomial p such that for all x 2 X we have time.´L; x/ p.size.x//, then ˆ is a polynomial-time Turing machine. If jfy 2 A W .x; y/ 2 Rgj D 1 for all x 2 X , we can define f W X ! A by .x; f .x// 2 R and say that ˆ computes f . In the case X D A and f W X ! f0; 1g we say that ˆ decides the language L WD fx 2 X W f .x/ D 1g. If there exists some polynomial-time Turing machine computing a function f (or deciding a language L), then we say that f is computable in polynomial time (or L is decidable in polynomial time, respectively). To make these definitions clear we give an example. The following Turing machine ˆ W f0; : : : ; 3g f0; 1; tg ! f1; : : : ; 3g f0; 1; tg f1; 0; 1g computes the successor function n 7! n C 1 (n 2 N), where the numbers are coded by their usual binary representation. ˆ.0; 0/ D .0; 0; 1/ ˆ.0; 1/ D .0; 1; 1/ ˆ.0; t/ D .1; t; 1/ ˆ.1; 1/ D .1; 0; 1/ ˆ.1; 0/ D .1; 1; 0/ ˆ.1; t/ D .2; t; 1/ ˆ.2; 0/ D .3; 1; 1/ ˆ.3; 0/ D .3; 0; 1/ ˆ.3; t/ D .1; 0; 0/

0 While s 6D t do WD C 1. Set WD 1. 1 While s D 1 do s WD 0 and WD 1. If s D 0 then s WD 1 and stop. Set WD C 1. 2 Set s WD 1 and WD C 1. 3 While s D 0 do WD C 1. Set s WD 0 and stop.

Note that several values of ˆ are not specified as they are never used in any computation. The comments on the right-hand side illustrate the computation. Instructions 2 and 3 are used only if the input consists of 1’s only, i.e. n D 2k 1 for some k 2 N. We have time.´L; x/ 3size.x/ C 3 for all inputs x, so ˆ is a polynomial-time Turing machine. In the next section we shall show that the above definition is consistent with our informal definition of a polynomial-time algorithm in Section 1.2: each polynomialtime algorithm in this book can be simulated by a polynomial-time Turing machine.

380

15 NP-Completeness

15.2 Church’s Thesis The Turing machine is the most customary theoretical model for algorithms. Although it seems to be very restricted, it is as powerful as any other reasonable model: the set of computable functions, and also the set of functions computable in polynomial time, is always the same. This statement, known as Church’s thesis, is of course too imprecise to be proved. However, there are strong results supporting this claim. For example, each program in a common programming language like C can be modelled by a Turing machine. In particular, all algorithms in this book can be rewritten as Turing machines. This is usually very inconvenient (thus we shall never do it), but theoretically it is possible. Moreover, any function computable in polynomial time by a C program is also computable in polynomial time by a Turing machine (and vice versa). Since it is not a trivial task to implement more complicated programs on a Turing machine we consider as an intermediate step a Turing machine with two strings (tapes) and two independent read-write heads, one for each tape: Definition 15.4. Let A be an alphabet and AN WD A [ ftg. A two-tape Turing machine is defined by a function ˆ W f0; : : : ; N g AN2 ! f1; : : : ; N g AN2 f1; 0; 1g2 for some N 2 ZC . The computation of ˆ on input x, where x 2 A , is the finite or infinite sequence of 5-tuples .n.i / ; s .i / ; t .i / ; .i / ; .i / / with n.i / 2 f1; : : : ; N g, s .i / ; t .i / 2 ANZ and .i / ; .i / 2 Z (i D 0; 1; 2; : : :) defined recursively as follows: .0/ .0/ n.0/ WD 0. sj WD xj for 1 j size.x/, and sj WD t for all j 0 and .0/

j > size.x/. tj WD t for all j 2 Z. .0/ WD 1 and .0/ WD 1. If .n.i / ; s .i / ; t .i / ; .i / ; .i / / isalready defined, we distinguish two cases. If n.i / 6D 1, then let .m; ; ; ı; / WD ˆ n.i / ; s.i.i/ / ; t.i.i// and set n.i C1/ WD m, s.i.iC1/ WD , /

WD , tj.i C1/ WD tj.i / for j 2 Z n f.i /g, sj.i C1/ WD sj.i / for j 2 Z n f .i / g, t.i.iC1/ / .i C1/ WD .i / C ı, and .i C1/ WD .i / C . If n.i / D 1, then this is the end of the sequence. time .ˆ; x/ and output .ˆ; x/ are defined as with the one-tape Turing machine.

Turing machines with more than two tapes can be defined analogously, but we shall not need them. Before we show how to perform standard operations with a twotape Turing machine, let us note that a two-tape Turing machine can be simulated by an ordinary (one-tape) Turing machine. Theorem 15.5. Let A be an alphabet, and let ˆ W f0; : : : ; N g .A [ ftg/2 ! f1; : : : ; N g .A [ ftg/2 f1; 0; 1g2 be a two-tape Turing machine. Then there exists an alphabet B A and a (onetape) Turing machine

15.2

Church’s Thesis

381

ˆ0 W f0; : : : ; N 0 g .B [ ftg/ ! f1; : : : ; N 0 g .B [ ftg/ f1; 0; 1g such that output.´L0 ; x/ D output.´L; x/ and time.´L0 ; x/ D O.time.´L; x//2 for x 2 A . Proof: We use the letters s and t for the two strings of ˆ, and denote by and the positions of the read-write heads, as in Definition 15.4. The string of ˆ0 will be denoted by u and its read-write head position by . We have to encode both strings s; t and both read-write head positions ; in one string u. To make this possible each symbol uj of u is a 4-tuple .sj ; pj ; tj ; rj /, where sj and tj are the corresponding symbols of s and t, and pj ; rj 2 f0; 1g indicate whether the read-write heads of the first and second string currently scans position j ; i.e. we have pj D 1 iff D j , and rj D 1 iff D j . So we define BN WD .AN f0; 1g AN f0; 1g/; then we identify a 2 AN with .a; 0; t; 0/ to allow inputs from A . The first step of ˆ0 consists in initializing the marks p1 and r1 to 1: ˆ0 .0; .:; 0; :; 0// D .1; .:; 1; :; 1/; 0/

0 Set WD

and WD

.

Here a dot stands for an arbitrary value (which is not modified). Now we show how to implement a general instruction ˆ.m; ; / D .m0 ; 0 ; 0 , ı; /. We first have to find the positions and . It is convenient to assume that our single read-write head is already at the leftmost of the two positions and ; i.e. D minf; g. We have to find the other position by scanning the string u to the right, we have to check whether s D and t D and, if so, perform the operation required (write new symbols to s and t, move and , jump to the next instruction). The following block implements one instruction ˆ.m; ; / D .m0 ; 0 ; 0 ; ı; / N 2 such blocks, one for each choice of and . for m D 0; for each m we have jAj 13 the first block for m0 with , M where The second block for m D 0 starts with , 2 0 2 0 N N M WD 12jAj m C 1. All in all we get N D 12.N C 1/jAj . A dot again stands for an arbitrary value which is not modified. Similarly, and stand for an arbitrary element of AN n fg and AN n fg, respectively. We assume that 10 11 and 12 guarantee that this property also D minf; g initially; note that , holds at the end. ˆ0 .1; .; 1; :; :// ˆ0 .1; .:; :; ; 1// ˆ0 .1; .; 1; ; 1// ˆ0 .1; .; 1; :; 0// ˆ0 .1; .:; 0; ; 1// ˆ0 .2; .:; :; :; 0// ˆ0 .2; .:; :; ; 1//

D D D D D D D

13 .13; .; 1; :; :/; 0/ 1 If D and s 6D then go to . 13 .13; .:; :; ; 1/; 0/ If D and t 6D then go to . .2; .; 1; ; 1/; 0/ If D then go to . 2 .2; .; 1; :; 0/; 0/ .6; .:; 0; ; 1/; 0/ If D then go to . 6 .2; .:; :; :; 0/; 1/ While D 6 do WD C 1. 2 .12; .:; :; ; 1/; 1/ If t 6D then set WD 1 12 and go to . 0 0 0 ˆ .2; .:; :; ; 1// D .3; .:; :; ; 0/; / Set t WD and WD C .

382

15 NP-Completeness

ˆ0 .3; .:; :; :; 0// ˆ0 .4; .:; 0; :; :// ˆ0 .4; .; 1; :; :// ˆ0 .5; .:; 0; :; ://

D D D D

ˆ0 .6; .:; 0; :; :// D ˆ0 .6; .; 1; :; :// D ˆ0 .6; .; 1; :; :; // ˆ0 .7; .:; 0; :; :// ˆ0 .8; .:; :; :; 0// ˆ0 .8; .:; :; ; 1// ˆ0 .9; .:; :; :; 0// ˆ0 .10; .:; :; :; :// ˆ0 .11; .:; 0; :; 0// ˆ0 .11; .:; 1; :; :// ˆ0 .11; .:; 0; :; 1// ˆ0 .12; .:; 0; :; 0// ˆ0 .12; .:; 1; :; :// ˆ0 .12; .:; :; :; 1//

D D D D D D D D D D D D

.4; .:; :; :; 1/; 1/ .4; .:; 0; :; :/; 1/ .5; . 0 ; 0; :; :/; ı/ .10; .:; 1; :; :/; 1/

3 Set WD and WD C 1. 4 While 6D do WD 1. Set s WD 0 and WD C ı. 5 Set WD and WD 1. 10 Go to . .6; .:; 0; :; :/; 1/ 6 While 6D do WD C 1. .12; .; 1; :; :/; 1/ If s 6D then set WD 1 12 and go to . 0 0 .7; . ; 0; :; :/; ı/ Set s WD and WD C ı. .8; .:; 1; :; :/; 1/ Set WD and WD C 1. 7 .8; .:; :; :; 0/; 1/ 8 While 6D do WD 1. .9; .:; :; 0 ; 0/; / Set t WD 0 and WD C . .10; .:; :; :; 1/; 1/ 9 Set WD and WD 1. 10 Set .11; .:; :; :; :/; 1/ WD 1. 11 While .11; .:; 0; :; 0/; 1/ 62 f; g do WD C 1. M .M; .:; 1; :; :/; 0/ Go to . .M; .:; 0; :; 1/; 0/ 12 While .12; .:; 0; :; 0/; 1/ 62 f; g do WD 1. .13; .:; 1; :; :/; 0/ .13; .:; :; :; 1/; 0/ 2

N blocks like the above for Any computation of ˆ0 passes through at most jAj each computation step of ˆ. The number of computation steps within each block is N is a constant and j j is bounded by time.´L; x/ we at most 2j jC10. Since jAj conclude that the whole computation of ˆ is simulated by ˆ0 with O .time.´L; x//2 steps. Finally we have to clean up the output: replace each symbol .; :; :; :/ by .; 0; t; 0/. Obviously this at most doubles the total number of steps. With a two-tape Turing machine it is not too difficult to implement more complicated instructions, and thus arbitrary algorithms: We use the alphabet A D f0; 1; #g and model an arbitrary number of variables by the string x0 ##1#x1##10#x2 ##11#x3##100#x4##101#x5## : : :

(15.1)

which we store on the first tape. Each group (except the first one) contains a binary representation of the index i followed by the value of xi , which we assume to be a binary string. The first variable x0 and the second tape are used only as registers for intermediate results of computation steps. Random access to variables is not possible in constant time with a Turing machine, no matter how many tapes we have. If we simulate an arbitrary algorithm

15.2

Church’s Thesis

383

by a two-tape Turing machine, we will have to scan the first tape quite often. Moreover, if the length of the string in one variable changes, the substring to the right has to be shifted. Nevertheless each standard operation (i.e. each elementary step of an algorithm) can be simulated with O.l 2 / computation steps of a two-tape Turing machine, where l is the current length of the string (15.1). We try to make this clearer with a concrete example. Consider the following instruction: Add to x5 the value of the variable whose index is given by x2 . To get the value of x5 we scan the first tape for the substring ##101#. We copy the substring following this up to #, exclusively, to the second tape. This is easy since we have two separate read-write heads. Then we copy the string from the second tape to x0 . If the new value of x0 is shorter or longer than the old one, we have to shift the rest of the string (15.1) to the left or to the right appropriately. Next we have to search for the variable index that is given by x2 . To do this, we first copy x2 to the second tape. Then we scan the first tape, checking each variable index (comparing it with the string on the second tape bitwise). When we have found the correct variable index, we copy the value of this variable to the second tape. Now we add the number stored in x0 to that on the second tape. A Turing machine for this task, using the standard method, is not hard to design. We can overwrite the number on the second tape by the result while computing it. Finally we have the result on the second tape and copy it back to x5 . If necessary we shift the substring to the right of x5 appropriately. All the above can be done by a two-tape Turing machine in O.l 2 / computation steps (in fact all but shifting the string (15.1) can be done in O.l/ steps). It should be clear that the same holds for all other standard operations, including multiplication and division. By Definition 1.4 an algorithm is said to run in polynomial time if there is a k 2 N such that the number of elementary steps is bounded by O.nk / and any number in intermediate computation can be stored with O.nk / bits, where n is the input size. Moreover, we store at most O.nk / numbers at any time. Hence we can bound the length of each of the two strings in a two-tape Turing machine simulating such an algorithm by l D O.nk nk / D O.n2k /, and hence its running time by O.nk .n2k /2 / D O.n5k /. This is still polynomial in the input size. Recalling Theorem 15.5 we may conclude that for any function f there is a polynomial-time algorithm computing f if and only if there is a polynomial-time Turing machine computing f . Hence we will use the terms algorithm and Turing machine interchangeably in the rest of this chapter. Hopcroft and Ullman [1979], Lewis and Papadimitriou [1981], and van Emde Boas [1990] provide more details about the equivalence of different machine models. Another common model (which is close to our informal model of Section 1.2) is the RAM machine (cf. Exercise 3) which allows arithmetic operations on integers in constant time. Other models allow only operations on bits (or integers of fixed length) which is more realistic when dealing with large numbers. Obviously, addition and comparison of natural numbers with n bits can be done with O.n/

384

15 NP-Completeness

bit operations. For multiplication (and division) the obvious method takes O.n2 / bit operations, but the algorithm of Schönhage and Strassen [1971] needs only O.n log n log log n/ bit operations for multiplying two n-bit integers, and this was improved further by Fürer [2009]. This of course implies algorithms for the addition and comparison of rational numbers with the same time complexity. As far as polynomial-time computability is concerned all models are equivalent, but of course the running time measures are quite different. The model of encoding the entire input by 0-1-strings (or strings over any fixed alphabet) does not in principle exclude certain types of real numbers, e.g. algebraic numbers (if x 2 R is the k-th smallest root of a polynomial p, then x can be coded by listing k and the degree and the coefficients of p). However, there is no way of representing arbitrary real numbers in a digital computer since there are uncountably many real numbers but only countably many 0-1-strings. We take the classical approach and restrict ourselves to rational input in this chapter. We close this section by giving a formal definition of oracle algorithms, based on two-tape Turing machines. We may call an oracle at any stage of the computation; we use the second tape for writing the oracle’s input and reading its output. We introduce a special instruction 2 for oracle calls: Definition 15.6. Let A be an alphabet and AN WD A [ ftg. Let .X; R/ be a computational problem with X A . An oracle Turing machine using .X; R/ is a function ˆ W f0; : : : ; N g AN2 ! f2; : : : ; N g AN2 f1; 0; 1g2 for some N 2 ZC . Its computation is defined as for a two-tape Turing machine, but .0/ with the following differences: initially we set time WD 0. If, for some computation .i / .i / .i / step i , ˆ n ; s .i / ; t.i / D .2; ; ; ı; / for some ; ; ı; , then consider the n o string on the second tape x 2 Ak , k WD min j 2 N W tj.i / D t 1, given by xj WD tj.i / for j D 1; : : : ; k. If x 2 X , then the second tape is overwritten by tj.i C1/ D yj

.i C1/ for j D 1; : : : ; size.y/ and tsize.y/C1 D t for some y 2 A with .x; y/ 2 R, and we set time.iC1/ WD time.i/ C 1 C size.y/. The rest remains unchanged, and in all other cases we set time.iC1/ WD time.i/ C 1. The computation continues with n.i C1/ WD n.i / C 1 until n.i / D 1. We then finally set time.´L; x/ WD time.i/ . The output is defined as with the two-tape Turing machine.

All definitions with respect to Turing machines can be extended to oracle Turing machines. The output of an oracle is not necessarily unique; hence there can be several possible computations for the same input. When proving the correctness or estimating the running time of an oracle algorithm we have to consider all possible computations, i.e. all choices of the oracle. By the results of this section the existence of a polynomial-time (oracle) algorithm is equivalent to the existence of a polynomial-time (oracle) Turing machine.

15.3

P and NP

385

15.3 P and NP Most of complexity theory is based on decision problems. Decision problems are special computational problems. Any language L f0; 1g can be interpreted as decision problem: given a 0-1-string, decide whether it belongs to L. However, we are more interested in problems like the following:

HAMILTONIAN CIRCUIT Instance:

An undirected graph G.

Question: Has G a Hamiltonian circuit? We will always assume a fixed efficient encoding of the input as a binary string; occasionally we extend our alphabet by other symbols. For example we assume that a graph is given by an adjacency list, and such a list can be coded as a binary string of length O.n log m C m log n/, where n and m denote the number of vertices and edges. We always assume an efficient encoding, i.e. one whose length is polynomially bounded by the minimum possible encoding length. Not all binary strings are instances of HAMILTONIAN CIRCUIT but only those representing an undirected graph. For most interesting decision problems the instances are a proper subset of the 0-1-strings. We require that we can decide in polynomial time whether an arbitrary string is an instance or not: Definition 15.7. A decision problem is a pair P D .X; Y /, where X is a language decidable in polynomial time and Y X . The elements of X are called instances of P; the elements of Y are yes-instances, those of X n Y are no-instances. A decision problem .X; Y / can be regarded as the computational problem .X; f.x; 1/ W x 2 Y g [ f.x; 0/ W x 2 X n Y g/. Hence an algorithm for a decision problem .X; Y / is an algorithm computing the function f W X ! f0; 1g, defined by f .x/ D 1 for x 2 Y and f .x/ D 0 for x 2 X n Y . We give two more examples, the decision problems corresponding to LINEAR PROGRAMMING and INTEGER PROGRAMMING:

LINEAR INEQUALITIES Instance:

A matrix A 2 Zmn and a vector b 2 Zm .

Question: Is there a vector x 2 Qn such that Ax b?

INTEGER LINEAR INEQUALITIES Instance:

A matrix A 2 Zmn and a vector b 2 Zm .

Question: Is there a vector x 2 Zn such that Ax b? Definition 15.8. The class of all decision problems for which there is a polynomial-time algorithm is denoted by P.

386

15 NP-Completeness

In other words, a member of P is a pair .X; Y / with Y X f0; 1g where both X and Y are languages decidable in polynomial time. To prove that a problem is in P one usually describes a polynomial-time algorithm. By the results of Section 15.2 there is a polynomial-time Turing machine for each problem in P. By Khachiyan’s Theorem 4.18, LINEAR INEQUALITIES belongs to P. It is not known whether I NTEGER LINEAR INEQUALITIES or HAMILTONIAN CIRCUIT belong to P. We shall now introduce another class, called NP, which contains these problems, and in fact most decision problems discussed in this book. We do not insist on a polynomial-time algorithm, but we require that for each yes-instance there is a certificate which can be checked in polynomial time. For example, for the HAMILTONIAN CIRCUIT problem a possible certificate is simply a Hamiltonian circuit. It is easy to check whether a given string is the binary encoding of a Hamiltonian circuit. Note that we do not require a certificate for no-instances. Formally we define: Definition 15.9. A decision problem P D .X; Y / belongs to NP if there is a polynomial p and a decision problem P 0 D .X 0 ; Y 0 / in P, where o n X 0 WD x#c W x 2 X; c 2 f0; 1gbp.size.x//c ; such that Y D

n

o y 2 X W there exists a string c 2 f0; 1gbp.size.y//c with y#c 2 Y 0 :

Here x#c denotes the concatenation of the string x, the symbol # and the string c. A string c with y#c 2 Y 0 is called a certificate for y (since c proves that y 2 Y ). An algorithm for P 0 is called a certificate-checking algorithm. Proposition 15.10. P NP. Proof: One can choose p to be identically zero. An algorithm for P 0 just deletes the last symbol of the input “x#” and then applies an algorithm for P. It is not known whether P D NP. In fact, this is the most important open problem in complexity theory. As an example for problems in NP that are not known to be in P we have: Proposition 15.11. HAMILTONIAN CIRCUIT belongs to NP. Proof: For each yes-instance G we take any Hamiltonian circuit of G as a certificate. To check whether a given edge set is in fact a Hamiltonian circuit of a given graph is obviously possible in polynomial time. Proposition 15.12. INTEGER LINEAR INEQUALITIES belongs to NP. Proof: As a certificate we just take a solution vector. If there exists a solution, there exists one of polynomial size by Corollary 5.7.

15.3

P and NP

387

The name NP stands for “nondeterministic polynomial”. To explain this we have to define what a nondeterministic algorithm is. This is a good opportunity to define randomized algorithms in general, a concept which has already been mentioned before. The common feature of randomized algorithms is that their computation does not only depend on the input but also on some random bits. Definition 15.13. A randomized algorithm for computing a function f W S ! T is an algorithm computing a function g W fs#r W s 2 S; r 2 f0; 1gk.s/g ! T , where k W S ! ZC . So for each instance s 2 S the algorithm can use k.s/ 2 ZC random bits. We measure the running time dependency on size.s/ only; thus randomized algorithms running in polynomial time can read only a polynomial number of random bits. Naturally we are interested in such a randomized algorithm only if f and g are related. In the ideal case, if g.s#r/ D f .s/ for all s 2 S and all r 2 f0; 1gk.s/, we speak of a Las Vegas algorithm. A Las Vegas algorithm always computes the correct result, but the running time may vary for different runs on the same input s. Sometimes even less reliable algorithms are interesting: if there is at least a positive probability p of a correct answer, independent of the instance, i.e. p WD inf

s2S

jfr 2 f0; 1gk.s/ W g.s#r/ D f .s/gj > 0; 2k.s/

then we have a Monte Carlo algorithm. If T D f0; 1g, and for each s 2 S with f .s/ D 0 we have g.s#r/ D 0 for all r 2 f0; 1gk.s/, then we have a randomized algorithm with one-sided error. If in addition for each s 2 S with f .s/ D 1 there is at least one r 2 f0; 1gk.s/ with g.s#r/ D 1, then the algorithm is called a nondeterministic algorithm. Alternatively a randomized algorithm can be regarded as an oracle algorithm where the oracle produces a random bit (0 or 1) whenever called. A nondeterministic algorithm for a decision problem always answers “no” for a no-instance, and for each yes-instance there is a chance that it answers “yes”. The following observation is easy: Proposition 15.14. A decision problem belongs to NP if and only if it has a polynomial-time nondeterministic algorithm. Proof: Let P D .X; Y / be a decision problem in NP, and let P 0 D .X 0 ; Y 0 / be defined as in Definition 15.9. Then a polynomial-time algorithm for P 0 is in fact also a nondeterministic algorithm for P: the unknown certificate is simply replaced by random bits. Since the number of random bits is bounded by a polynomial in size.x/, x 2 X , so is the running time of the algorithm. Conversely, if P D .X; Y / has a polynomial-time nondeterministic algorithm using k.x/ random bits for instance x, then there˚is a polynomial p such that k.x/ p.size.x// for each instance x. We define X 0 WD x#c W x 2 X; c 2 f0; 1gbp.size.x//c and Y 0 WD fx#c 2 X 0 W g.x#r/ D 1; r consists of the first k.x/ bits of cg.

388

15 NP-Completeness

Then by the definition of nondeterministic algorithms we have .X 0 ; Y 0 / 2 P and n o Y D y 2 X W there exists a string c 2 f0; 1gbp.size.y//c with y#c 2 Y 0 : Most decision problems encountered in combinatorial optimization belong to NP. For many of them it is not known whether they have a polynomial-time algorithm. However, one can say that certain problems are not easier than others. To make this precise we introduce the important concept of polynomial reductions, which works for general computational problems. Definition 15.15. Let P1 and P2 be computational problems. We say that P1 polynomially reduces to P2 if there exists a polynomial-time oracle algorithm for P1 using P2 . The following observation is the main reason for this concept: Proposition 15.16. If P1 polynomially reduces to P2 and there is a polynomialtime algorithm for P2 , then there is a polynomial-time algorithm for P1 . Proof: Let A2 be an algorithm for P2 with time.A2 ; y/ p2 .size.y// for all instances y of P2 . Let A1 be an oracle algorithm for P1 using P2 with time.A1 ; x/ p1 .size.x// for all instances x of P1 . Then replacing the oracle calls in A1 by subroutines equivalent to A2 yields an algorithm A3 for P1 . For any instance x of P1 with size.x/ D n we have time.A3 ; x/ p1 .n/ p2 .p1 .n//: there can be at most p1 .n/ oracle calls in A1 , and none of the instances of P2 produced by A1 can be longer than p1 .n/. Since we can choose p1 and p2 to be polynomials we conclude that A3 is a polynomial-time algorithm. The theory of NP-completeness is based on a special kind of polynomial-time reduction, which is defined only for decision problems: Definition 15.17. Let P1 D .X1 ; Y1 / and P2 D .X2 ; Y2 / be decision problems. We say that P1 polynomially transforms to P2 if there is a function f W X1 ! X2 computable in polynomial time such that f .x1 / 2 Y2 for all x1 2 Y1 and f .x1 / 2 X2 n Y2 for all x1 2 X1 n Y1 . In other words, yes-instances are transformed to yes-instances, and no-instances are transformed to no-instances. Obviously, if a problem P1 polynomially transforms to P2 , then P1 also polynomially reduces to P2 . Polynomial transformations are sometimes called Karp reductions, while general polynomial reductions are also known as Turing reductions. Both are easily seen to be transitive. Definition 15.18. A decision problem P 2 NP is called NP-complete if all other problems in NP polynomially transform to P.

15.4

Cook’s Theorem

389

By Proposition 15.16 we know that if there is a polynomial-time algorithm for any NP-complete problem, then P D NP. Of course, the above definition would be meaningless if no NP-complete problems existed. The next section consists of a proof that there is an NP-complete problem.

15.4 Cook’s Theorem In his pioneering work, Cook [1971] proved that a certain decision problem, called SATISFIABILITY, is in fact NP-complete. We need some definitions: Definition 15.19. Let X be a finite set of Boolean variables. A truth assignment : for X is a function T W X ! ftrue; falseg. We extend T to the set L WD X [ fx W x 2 X g by setting T .x/ WD true if T .x/ WD false and vice versa (x can be regarded as the negation of x). The elements of L are called the literals over X . A clause over X is a set of literals over X . A clause represents the disjunction of those literals and is satisfied by a truth assignment iff at least one of its members is true. A family of clauses over X is satisfiable iff there is some truth assignment simultaneously satisfying all of its clauses. Since we consider the conjunction of disjunctions of literals, we also speak of Boolean formulas (cf. Exercise 21) in conjunctive normal form. For example, the family ffx1 ; x2 g, fx2 ; x3 g, fx1 ; x2 ; x3 g, fx1 ; x3 gg corresponds to the Boolean formula .x1 _ x2 / ^ .x2 _ x3 / ^ .x1 _ x2 _ x3 / ^ .x1 _ x3 /. It is satisfiable as the truth assignment T .x1 / WD true, T .x2 / WD false and T .x3 / WD true shows. We are now ready to specify the satisfiability problem:

SATISFIABILITY Instance:

A set X of variables and a family Z of clauses over X .

Question: Is Z satisfiable? Theorem 15.20. (Cook [1971]) SATISFIABILITY is NP-complete. Proof: SATISFIABILITY belongs to NP because a satisfying truth assignment serves as a certificate for any yes-instance, which of course can be checked in polynomial time. Let now P D .X; Y / be any other problem in NP. We have to show that P polynomially transforms to SATISFIABILITY. 0 By Definition 15.9 there a decision problem P D ˚ is a polynomial p and 0 0 0 bp.size.x//c .X ; Y / in P, where X WD x#c W x 2 X; c 2 f0; 1g and o n Y D y 2 X W there exists a string c 2 f0; 1gbp.size.y//c with y#c 2 Y 0 :

390

15 NP-Completeness

Let ˆ W f0; : : : ; N g AN ! f1; : : : ; N g AN f1; 0; 1g be a polynomial-time Turing machine for P 0 with alphabet A; let AN WD A [ ftg. Let q be a polynomial such that time.´L; x#c/ q.size.x#c// for all instances x#c 2 X 0 . Note that size.x#c/ D size.x/ C 1 C bp.size.x//c. We will now construct a collection Z.x/ of clauses over some set V .x/ of Boolean variables for each x 2 X , such that Z.x/ is satisfiable if and only if x 2 Y . We abbreviate Q WD q.size.x/ C 1 C bp.size.x//c/. Q is an upper bound on the length of any computation of ˆ on input x#c, for any c 2 f0; 1gbp.size.x//c . V .x/ contains the following Boolean variables: N a variable vij for all 0 i Q, Q j Q and 2 A; a variable wij n for all 0 i Q, Q j Q and 1 n N . The intended meaning is: vij indicates whether at time i (i.e. after i steps of the computation) the j -th position of the string contains the symbol . wij n indicates whether at time i the j -th position of the string is scanned and the n-th instruction is executed. So if .n.i / ; s .i / ; .i / /i D0;1;::: is a computation of ˆ then we intend to set vij to .i / true iff sj D and wij n to true iff .i / D j and n.i / D n. The collection Z.x/ of clauses to be constructed will be satisfiable if and only if there is a string c with output.´L; x#c/ D 1. Z.x/ contains the following clauses to model the following conditions: At any time each position of the string contains a unique symbol: N fvij W 2 Ag for 0 i Q and Q j Q; fvij ; vij g for 0 i Q, Q j Q and ; 2 AN with 6D . At any time a unique position of the string is scanned and a single instruction is executed: fwij n W Q j Q; 1 n N g for 0 i Q; fwij n ; wij 0 n0 g for 0 i Q, Q j; j 0 Q and 1 n; n0 N with .j; n/ 6D .j 0 ; n0 /. The algorithm starts correctly with input x#c for some c 2 f0; 1gbp.size.x//c :

fv0;j;xj g for 1 j size.x/; fv0;size.x/C1;# g; fv0;size.x/C1Cj;0 ; v0;size.x/C1Cj;1 g for 1 j bp.size.x//c; fv0;j;t g for Q j 0 and size.x/ C 2 C bp.size.x//c j Q; fw010 g. The algorithm works correctly:

fvij ; wij n ; vi C1;j; g, fvij ; wij n ; wi C1;j Cı;m g for 0 i < Q, Q j Q, 2 AN and 0 n N , where ˆ.n; / D .m; ; ı/.

15.4

Cook’s Theorem

391

When the algorithm reaches instruction 1, it stops: fwi;j;1 ; wi C1;j;1 g, fwi;j;1 ; vi;j; ; vi C1;j; g N for 0 i < Q, Q j Q and 2 A. Positions not being scanned remain unchanged: fvij ; wij 0 n ; vi C1;j; g N 1 n N , and Q j; j 0 Q with j 6D j 0 . for 0 i Q, 2 A, The output of the algorithm is 1: fvQ;1;1 g; fvQ;2;t g. The encoding length of Z.x/ is O.Q 3 log Q/: there are O.Q3 / occurrences of literals, whose indices require O.log Q/ space. Since Q depends polynomially on size.x/ we conclude that there is a polynomial-time algorithm which, given x, constructs Z.x/. Note that p, ˆ and q are fixed and not part of the input of this algorithm. It remains to show that Z.x/ is satisfiable if and only if x 2 Y . If Z.x/ is satisfiable, consider a truth assignment T satisfying all clauses. Let c 2 f0; 1gbp.size.x//c with cj D 1 for all j with T .v0;size.x/C1Cj;1 / D true and cj D 0 otherwise. By the above construction the variables reflect the computation of ˆ on input x#c. Hence we may conclude that output.´L; x#c/ D 1. Since ˆ is a certificate-checking algorithm, this implies that x is a yes-instance. Conversely, if x 2 Y , let c be any certificate for x. Let .n.i / ; s .i / ; .i / /i D0;1;:::;m be the computation of ˆ on input x#c. Then we define T .vi;j; / WD true iff sj.i / D and T .wi;j;n/ D true iff .i / D j and n.i / D n. For i WD m C 1; : : : ; Q we set T .vi;j; / WD T .vi 1;j; / and T .wi;j;n/ WD T .wi 1;j;n / for all j , n and . Then T is a truth assignment satisfying Z.x/, completing the proof. SATISFIABILITY is not the only NP-complete problem; we will encounter many others in this book. Now that we already have one NP-complete problem at hand, it is much easier to prove NP-completeness for another problem. To show that a certain decision problem P is NP-complete, we shall just prove that P 2 NP and that SATISFIABILITY (or any other problem which we know already to be NP-complete) polynomially transforms to P. Since polynomial transformability is transitive, this will be sufficient. The following restriction of SATISFIABILITY will prove very useful for several NP-completeness proofs:

3SAT A set X of variables and a collection Z of clauses over X , each containing exactly three literals. Question: Is Z satisfiable? Instance:

To show NP-completeness of 3SAT we observe that any clause can be replaced equivalently by a set of 3SAT-clauses:

392

15 NP-Completeness

Proposition 15.21. Let X be a set of variables and Z a clause over X with k literals. Then there is a set Y of at most maxfk 3; 2g new variables and a family : Z 0 of at most maxfk 2; 4g clauses over X [ Y such that each element of Z 0 has exactly three literals, and for each family W of clauses over X we have that W [ fZg is satisfiable if and only if W [ Z 0 is satisfiable. Moreover, such a family Z 0 can be computed in O.k/ time. Proof: If Z has three literals, we set Z 0 WD fZg. If Z has more than three literals, say Z D f 1 ; : : : ; k g, we choose a set Y D fy1 ; : : : ; yk3 g of k 3 new variables and set ˚ Z 0 WD f 1 ; 2 ; y1 g; fy1 ; 3 ; y2 g; fy2 ; 4 ; y3 g; : : : ; fyk4 ; k2 ; yk3 g; fyk3 ; k1 ; k g : If Z D f 1 ; 2 g, we choose a new variable y1 (Y WD fy1 g) and set Z 0 WD ff 1 ; 2 ; y1 g; f 1 ; 2 ; y1 gg : If Z D f 1 g, we choose a set Y D fy1 ; y2 g of two new variables and set Z 0 WD ff 1 ; y1 ; y2 g; f 1 ; y1 ; y2 g; f 1 ; y1 ; y2 g; f 1 ; y1 ; y2 gg: Observe that in each case Z can be equivalently replaced by the clauses in Z 0 in any instance of SATISFIABILITY. Theorem 15.22. (Cook [1971]) 3SAT is NP-complete. Proof: As a restriction of SATISFIABILITY, 3SAT is certainly in NP. We now show that SATISFIABILITY polynomially transforms to 3SAT. Consider any collection Z of clauses Z1 ; : : : ; Zm . We shall construct a new collection Z 0 of clauses with three literals per clause such that Z is satisfiable if and only if Z 0 is satisfiable. To do this, we replace each clause Zi by an equivalent set of clauses, each with three literals. This is possible in linear time by Proposition 15.21. If we restrict each clause to consist of just two literals, the problem (called 2SAT) can be solved in linear time (Exercise 8).

15.5 Some Basic NP-Complete Problems Karp [1972] discovered the wealth of consequences of Cook’s work for combinatorial optimization problems. As a start, we consider the following problem:

STABLE SET Instance:

A graph G and an integer k.

Question: Is there a stable set of k vertices?

15.5

Some Basic NP-Complete Problems

393

Theorem 15.23. (Karp [1972]) STABLE SET is NP-complete. Proof: Obviously, STABLE SET 2 NP. We show that SATISFIABILITY polynomially transforms to STABLE SET. Let Z be a collection of clauses Z1 ; : : : ; Zm with Zi D f i1 ; : : : ; i ki g (i D 1; : : : ; m), where the ij are literals over some set X of variables. We shall construct a graph G such that G has a stable set of size m if and only if there is a truth assignment satisfying all m clauses. x1

x3

x1

x1

x2

x2

x3

x3

x2

x3

Fig. 15.1.

For each clause Zi , we introduce a clique of ki vertices according to the literals in this clause. Vertices corresponding to different clauses are connected by an edge if and only if the literals contradict each other. Formally, let V .G/ WD fvij W 1 i m; 1 j ki g and ˚ E.G/ WD fvij ; vkl g W .i D k and j 6D l/ or . ij D x and kl D x for some x 2 X / : See Figure 15.1 for an example (m D 4, Z1 D fx1 ; x2 ; x3 g, Z2 D fx1 ; x3 g, Z3 D fx2 ; x3 g and Z4 D fx1 ; x2 ; x3 g). Suppose G has a stable set of size m. Then its vertices specify pairwise compatible literals belonging to different clauses. Setting each of these literals to be true (and setting variables not occurring there arbitrarily) we obtain a truth assignment satisfying all m clauses. Conversely, if some truth assignment satisfies all m clauses, then we choose a literal which is true out of each clause. The set of corresponding vertices then defines a stable set of size m in G. It is essential that k is part of the input: for each fixed k it can be decided in O.nk / time whether a given graph with n vertices has a stable set of size k (simply

394

15 NP-Completeness

by testing all vertex sets with k elements). Two interesting related problems are the following:

VERTEX COVER Instance:

A graph G and an integer k.

Question: Is there a vertex cover of cardinality k?

CLIQUE Instance:

A graph G and an integer k.

Question: Has G a clique of cardinality k? Corollary 15.24. (Karp [1972]) VERTEX COVER and CLIQUE are NP-complete. Proof: By Proposition 2.2, STABLE SET polynomially transforms to both VERTEX COVER and CLIQUE . We now turn to the famous Hamiltonian circuit problem (already defined in Section 15.3). Theorem 15.25. (Karp [1972]) HAMILTONIAN CIRCUIT is NP-complete. Proof: Membership in NP is obvious. We prove that 3SAT polynomially transforms to HAMILTONIAN CIRCUIT. Given a collection Z of clauses Z1 ; : : : ; Zm over X D fx1 ; : : : ; xn g, each clause containing three literals, we shall construct a graph G such that G is Hamiltonian iff Z is satisfiable.

a u

u

b u

u

A

Fig. 15.2.

We first define two gadgets which will appear several times in G. Consider the graph shown in Figure 15.2(a), which we call A. We assume that it is a subgraph of G and no vertex of A except u; u0 ; v; v 0 is incident to any other edge of G. Then any Hamiltonian circuit of G must traverse A in one of the ways shown in

15.5

a u

u

Some Basic NP-Complete Problems

b u

395 u

Fig. 15.3.

Figure 15.3(a) and (b). So we can replace A by two edges with the additional restriction that any Hamiltonian circuit of G must contain exactly one of them (Figure 15.2(b)).

a

b

u

u

e1

e2

B

e3

u

u

Fig. 15.4.

Now consider the graph B shown in Figure 15.4(a). We assume that it is a subgraph of G, and no vertex of B except u and u0 is incident to any other edge of G. Then no Hamiltonian circuit of G traverses all of e1 ; e2 ; e3 . Moreover, one easily checks that for any S fe1 ; e2 ; e3 g there is a Hamiltonian path from u to u0 in B that contains S but none of fe1 ; e2 ; e3 g n S . We represent B by the symbol shown in Figure 15.4(b). We are now able to construct G. For each clause, we introduce a copy of B, joined one after another. Between the first and the last copy of B, we insert two vertices for each variable, all joined one after another. We then double the edges between the two vertices of each variable x; these two edges will correspond to x and x, respectively.

396

15 NP-Completeness

B

A

A A

A B

A A

A A

B

A

Fig. 15.5.

The edges e1 , e2 , and e3 in each copy of B are now connected via a copy of A to the edges corresponding to the first, second, and third literal of the corresponding clause, respectively. These constructions are done consecutively: when introducing a copy of subgraph A at an edge e D fu; vg corresponding to a literal, the edge incident to u in Figure 15.2(a) takes the role of e: it is now the edge corresponding to that literal. The overall construction is illustrated by Figure 15.5 with the example ffx1 ; x2 ; x3 g; fx1 ; x2 ; x3 g; fx1 ; x2 ; x3 gg. Now we claim that G is Hamiltonian if and only if Z is satisfiable. Let C be a Hamiltonian circuit. We define a truth assignment by setting a literal true iff C contains the corresponding edge. By the properties of the gadgets A and B each clause contains a literal that is true. Conversely, any satisfying truth assignment defines a set of edges corresponding to literals that are true. Since each clause contains a literal that is true this set of edges can be completed to a tour in G.

15.5

Some Basic NP-Complete Problems

397

This proof is essentially due to Papadimitriou and Steiglitz [1982]. The problem of deciding whether a given graph contains a Hamiltonian path is also NP-complete (Exercise 17(a)). Moreover, one can easily transform the undirected versions to the directed Hamiltonian circuit or Hamiltonian path problem by replacing each undirected edge by a pair of oppositely directed edges. Thus the directed versions are also NP-complete. There is another fundamental NP-complete problem:

3-DIMENSIONAL MATCHING (3DM) Disjoint sets U; V; W of equal cardinality and T U V W .

Instance:

Question: Is there a subset M of T with jM j D jU j such that for distinct .u; v; w/; .u0 ; v 0 ; w 0 / 2 M one has u 6D u0 , v 6D v 0 and w 6D w 0 ? Theorem 15.26. (Karp [1972]) 3DM is NP-complete. Proof: Membership in NP is obvious. We shall polynomially transform SATISFIABILITY to 3DM. Given a collection Z of clauses Z1 ; : : : ; Zm over X D fx1 ; : : : ; xn g, we construct an instance .U; V; W; T / of 3DM which is a yes-instance if and only if Z is satisfiable. We define: j

U WD fxi ; xi j W i D 1; : : : ; nI j D 1; : : : ; mg

V WD faij W i D 1; : : : ; nI j D 1; : : : ; mg [ fv j W j D 1; : : : ; mg [ fckj W k D 1; : : : ; n 1I j D 1; : : : ; mg

W WD fbij W i D 1; : : : ; nI j D 1; : : : ; mg [ fw j W j D 1; : : : ; mg j

j

[ fdk W k D 1; : : : ; n 1I j D 1; : : : ; mg j

j

j C1

T1 WD f.xi ; ai ; bi /; .xi j ; ai

where aimC1 WD ai1

j

; bi / W i D 1; : : : ; nI j D 1; : : : ; mg;

T2 WD f.xij ; v j ; w j / W i D 1; : : : ; nI j D 1; : : : ; mI xi 2 Zj g

[ f.xi j ; v j ; w j / W i D 1; : : : ; nI j D 1; : : : ; mI xi 2 Zj g

j

j

j

j

j

T3 WD f.xi ; ck ; dk /; .xi j ; ck ; dk / W i D 1; : : : ; nI j D 1; : : : ; mI k D 1; : : : ; n1g T WD T1 [ T2 [ T3 : For an illustration of this construction, see Figure 15.6. Here m D 2, Z1 D fx1 ; x2 g, Z2 D fx1 ; x2 g. Each triangle corresponds to an element of T1 [ T2 . The elements ckj , dkj and the triples in T3 are not shown. Suppose .U; V; W; T / is a yes-instance, so let M T be a solution. Since the j ai ’s and bij ’s appear only in elements of T1 , for each i we have either M \ T1 f.xij ; aij ; bij / W j D 1; : : : ; mg or M \ T1 f.xi j ; aij C1 ; bij / W j D 1; : : : ; mg. In the first case we set xi to false, in the second case to true.

398

15 NP-Completeness

x1 1

x2 1 b 11

a 21

a 22 x 11

x 21

x 22

a 11

b 21

b 12 x 12

b 22

a 12 x2 2

x1 2

Fig. 15.6.

Furthermore, for each clause Zj we have . j ; v j ; w j / 2 M for some literal 2 Zj . Since j does not appear in any element of M \ T1 this literal is true; hence we have a satisfying truth assignment. Conversely, a satisfying truth assignment suggests a set M1 T1 of cardinality nm and a set M2 T2 of cardinality m such that for distinct .u; v; w/; .u0 ; v 0 ; w 0 / 2 M1 [ M2 we have u 6D u0 , v 6D v 0 and w 6D w 0 . It is easy to complete M1 [ M2 by .n 1/m elements of T3 to a solution of the 3DM instance. A problem which looks simple but is not known to be solvable in polynomial time is the following:

SUBSET-SUM Instance:

Natural numbers c1 ; : : : ; cn ; K.

Question: Is there a subset S f1; : : : ; ng such that

P

j 2S cj

DK?

Corollary 15.27. (Karp [1972]) SUBSET-SUM is NP-complete. Proof: It is obvious that SUBSET-SUM is in NP. We prove that 3DM polynomially transforms to SUBSET-SUM. So let .U; V; W; T / be an instance of 3DM. W.l.o.g. let U [ V [ W D fu1 ; : : : ; u3m g. We write S WD ffa; b; cg W .a; b; c/ 2 T g and S D fs1 ; : : : ; sn g. Define

15.5

cj WD

X

.n C 1/i 1

Some Basic NP-Complete Problems

399

.j D 1; : : : ; n/; and

ui 2sj

K WD

3m X .n C 1/i 1 : i D1

Written in .n C 1/-ary form, the number cj can be regarded as the incidence vector of sj (j D 1; : : : ; n), and K consists of 1’s only. Therefore P each solution to the 3DM instance corresponds to a subset R of S such that sj 2R cj D K, and vice versa. Moreover, size.cj / size.K/ D O.m log n/, so the above is indeed a polynomial transformation. An important special case is the following problem:

PARTITION Instance:

Natural numbers c1 ; : : : ; cn .

Question: Is there a subset S f1; : : : ; ng such that

P

j 2S cj

D

P

j …S cj

?

Corollary 15.28. (Karp [1972]) PARTITION is NP-complete. Proof: We show that SUBSET-SUM polynomially transforms to PARTITION. So c1 ; : : : ; cn ; Kˇ be an instance of SUBSET-SUM. We add an element cnC1 WD ˇlet ˇPn ci 2K ˇ (unless this number is zero) and have an instance c1 ; : : : ; cnC1 of i D1 PARTITION. P Case 1: 2K niD1 ci . Then for any I f1; : : : ; ng we have X X X ci D K if and only if ci D ci : i 2I

Case 2:

2K > X

i 2I [fnC1g

Pn

i D1 ci .

ci D K

i 2I

i 2f1;:::;ngnI

Then for any I f1; : : : ; ng we have X X if and only if ci D ci : i 2I

i 2f1;:::;nC1gnI

In both cases we have constructed a yes-instance of PARTITION if and only if the original instance of SUBSET-SUM is a yes-instance. We finally note: Theorem 15.29. INTEGER LINEAR INEQUALITIES is NP-complete. Proof: We already mentioned the membership in NP in Proposition 15.12. Any of the above problems can easily be formulated as an instance of I NTEGER LINEAR INEQUALITIES. For example a PARTITION instance c1 ; : : : ; cn is a yes-instance if and only if fx 2 Zn W 0 x 1l; 2c > x D c > 1lg is nonempty.

400

15 NP-Completeness

15.6 The Class coNP The definition of NP is not symmetric with respect to yes-instances and noinstances. For example, it is an open question whether the following problem belongs to NP: given a graph G, is it true that G is not Hamiltonian? We introduce the following definitions: Definition 15.30. For a decision problem P D .X; Y / we define its complement to be the decision problem .X; X nY /. The class coNP consists of all problems whose complements are in NP. A decision problem P 2 coNP is called coNP-complete if all other problems in coNP polynomially transform to P. Trivially, the complement of a problem in P is also in P. On the other hand, NP 6D coNP is commonly conjectured (though not proved). For this conjecture the NP-complete problems play a special role: Theorem 15.31. A decision problem is coNP-complete if and only if its complement is NP-complete. Unless NP D coNP, no coNP-complete problem is in NP. Proof: The first statement follows directly from the definition. Suppose P D .X; Y / 2 NP is a coNP-complete problem. Let Q D .V; W / be an arbitrary problem in coNP. We show that Q 2 NP. Since P is coNP-complete, Q polynomially transforms to P. So there is a polynomial-time algorithm which transforms any instance v of Q to an instance x D f .v/ of P such that x 2 Y if and only if v 2 W . Note that size.x/ p.size.v// for some fixed polynomial p. Since P 2 NP, there exists a polynomial q and a decision problem P 0 D ˚ 0 0 0 bq.size.x//c .X ; Y / in P, where X WD x#c W x 2 X; c 2 f0; 1g , such that o n Y D y 2 X W there exists a string c 2 f0; 1gbq.size.y//c with y#c 2 Y 0 ˚ (cf. Definition 15.9). We define a decision problem .V 0 ; W 0 / by V 0 WD v#c W v 2 V; c 2 f0; 1gbq.p.size.v///c , and v#c 2 W 0 if and only if f .v/#c 0 2 Y 0 where c 0 consists of the first bq.size.f .v///c components of c. Observe that .V 0 ; W 0 / 2 P. Therefore, by definition, Q 2 NP. We conclude coNP NP and hence, by symmetry, NP D coNP. If one can show that a problem is in NP \ coNP, we say that the problem has a good characterization (Edmonds [1965]). This means that for yes-instances as well as for no-instances there are certificates that can be checked in polynomial time. Theorem 15.31 indicates that a problem with a good characterization is probably not NP-complete. To give examples, Proposition 2.9, Theorem 2.24, and Proposition 2.27 provide good characterizations for the problems of deciding whether a given graph is acyclic, whether it has an Eulerian walk, and whether it is bipartite, respectively. Of course, this is not very interesting since all these problems can be solved easily in polynomial time. But consider the decision version of LINEAR PROGRAMMING:

15.6

The Class coNP

401

Theorem 15.32. LINEAR INEQUALITIES is in NP \ coNP. Proof: This immediately follows from Theorem 4.4 and Corollary 3.24.

Of course, this theorem also follows from any polynomial-time algorithm for LINEAR PROGRAMMING, e.g. Theorem 4.18. However, before the E LLIPSOID METHOD had been discovered, Theorem 15.32 was the only theoretical evidence that LINEAR INEQUALITIES is probably not NP-complete. This gave hope to find a polynomial-time algorithm for LINEAR PROGRAMMING (which can be reduced to LINEAR INEQUALITIES by Proposition 4.16); a justified hope as we know today. The following famous problem has a similar history:

PRIME Instance:

A number n 2 N (in its binary representation).

Question: Is n a prime? It is obvious that PRIME belongs to coNP. Pratt [1975] proved that PRIME also belongs to NP. Finally, Agrawal, Kayal and Saxena [2004] proved that P RIME 2 P by finding a surprisingly simple O.log7:5C n/-algorithm (for any > 0). Before, the best known deterministic algorithm for PRIME wasdue to Adleman, Pomerance and Rumely [1983], running in O .log n/c log log log n time for some constant c. Since the input size is O.log n/, this is not polynomial.

NP-complete

coNP-complete

NP ∩ coNP NP

coNP

P

Fig. 15.7.

We close this section by sketching the inclusions of NP and coNP (Figure 15.7). Ladner [1975] showed that, unless P D NP, there are problems in NPnP that are not NP-complete. However, until the P 6D NP conjecture is resolved, it is still possible that all regions drawn in Figure 15.7 collapse to one.

402

15 NP-Completeness

15.7 NP-Hard Problems Now we extend our results to general computational problems, and in particular to optimization problems. Definition 15.33. A computational problem P is called NP-hard if all problems in NP polynomially reduce to P. Note that the definition also applies to decision problems, and it is symmetric (in contrast to NP-completeness): a decision problem is NP-hard if and only if its complement is. NP-hard problems are at least as hard as the hardest problems in NP. But some may be harder than any problem in NP. A problem which polynomially reduces to some problem in NP is called NP-easy. A problem which is both NPhard and NP-easy is NP-equivalent. In other words, a problem is NP-equivalent if and only if it is polynomially equivalent to SATISFIABILITY, where two problems P and Q are called polynomially equivalent if P polynomially reduces to Q, and Q polynomially reduces to P. We note: Proposition 15.34. Let P be an NP-equivalent computational problem. Then P has an exact polynomial-time algorithm if and only if P D NP. Of course, all NP-complete problems and all coNP-complete problems are NPequivalent. Almost all problems discussed in this book are NP-easy since they polynomially reduce to I NTEGER PROGRAMMING; this is usually a trivial observation which we do not even mention. We now formally define the type of optimization problems we are interested in: Definition 15.35. An NP optimization problem is a quadruple P D .X; .Sx /x2X ; c; goal/, where X is a language over f0; 1g decidable in polynomial time; Sx is a nonempty subset of f0; 1g for each x 2 X ; there exists a polynomial p with size.y/ p.size.x// for all x 2 X and y 2 Sx , and the language f.x; y/ W x 2 X; y 2 Sx g is decidable in polynomial time; c W f.x; y/ W x 2 X; y 2 Sx g ! Q is a function computable in polynomial time; and goal 2 fmax; ming. The elements of X are called instances of P. For each instance x, the elements of Sx are called feasible solutions of x. We write OPT.x/ WD goalfc.x; y/ W y 2 Sx g. An optimum solution of x is a feasible solution y of x with c.x; y/ D OPT.x/. A heuristic for P is an algorithm A which computes for each input x 2 X with Sx 6D ; a feasible solution y 2 Sx . We sometimes write A.x/ WD c.x; y/. If A.x/ D OPT.x/ for all x 2 X with Sx 6D ;, then A is an exact algorithm for P.

15.7

NP-Hard Problems

403

Depending on the context, c.x; y/ is often called the cost, the weight, the profit or the length of y. If c is nonnegative, then we say that the optimization problem has nonnegative weights. The values of c are rational numbers; we assume an encoding into binary strings as usual. Most interesting optimization problems fall into this class, but there are some exceptions (e.g., Exercise 24). An optimization problem .X; .Sx /x2X ; c, goal/ can be regarded as the computational problem .X; f.x; y/ W x 2 X; y 2 Sx ; c.x; y/ D OPT.x/g/. Hence polynomial reductions also apply to optimization problems. Theorem 15.36. Every NP optimization problem is NP-easy. Proof: Let P D .X; .Sx /x2X ; c; goal/ be an NP optimization problem. We polynomially reduce P to a decision problem Q 2 NP. As usual we call a string y 2 f0; 1gp , p 2 ZC , lexicographically greater than a string s 2 f0; 1gq , q 2 ZC , iff y 6D s and yj > sj for j D minfi 2 N W yi 6D si g, where yi WD 1 for i > p and si WD 1 for i > q. If goal D max, then Q is defined as follows: Given x 2 X , 2 Q, and s 2 f0; 1g, is there a y 2 Sx such that c.x; y/ and y is equal to or lexicographically greater than s? If goal D min, then c.x; y/ is replaced by c.x; y/ . Observe that Q belongs to NP (y serves as certificate). We polynomially reduce P to Q as follows. As c is computable in polynomial time, there is a constant d 2 N such that size.c.x; y// .size.x/ C p.size.x///d DW k.x/ for all x 2 X and y 2 Sx . Hence OPT.x/ 2 Œ2k.x/ ; 2k.x/ , and jc.x; y/ c.x; y 0 /j is an integral multiple of 2k.x/ for all x 2 X and y; y 0 2 Sx . Given an instance x 2 X , we first compute k.x/ and then determine OPT.x/ by binary search. We start with ˛ WD 2k.x/ and ˇ WD 2k.x/ . In each iteration we apply and s0 is the empty string. If the answer is the oracle to .x; ; s0 /, where D ˛Cˇ 2 yes, we set ˛ WD , otherwise ˇ WD . After 2k C 2 iterations we have ˇ ˛ < 2k.x/ . Then we fix WD ˛ and use another 2p.size.x// oracle calls to compute a solution y 2 Sx with c.x; y/ ˛. For i WD 1; : : : ; p.size.x// we call the oracle to .x; ˛; si01 / and .x; ˛; si11 /, where s j results from the string s by appending the symbol j 2 f0; 1g. If the both answers are yes, then we set si WD si11 , if only the first answer is yes, then we set si WD si01 , and if both answers are no, then we set si WD si 1 . We conclude that sp.size.x// is the lexicographically maximal string y with y 2 Sx and c.x; y/ D OPT.x/. Most problems that we discuss from now on are also NP-hard, and we shall usually prove this by describing a polynomial reduction from an NP-complete problem. As a first example we consider MAX-2SAT: given an instance of SATISFIABILITY with exactly two literals per clause, find a truth assignment that maximizes the number of satisfied clauses. Theorem 15.37. (Garey, Johnson and Stockmeyer [1976]) MAX-2SAT is NPhard.

404

15 NP-Completeness

Proof: By reduction from 3SAT. Given an instance I of 3SAT with clauses C1 ; : : : ; Cm , we construct an instance I 0 of MAX-2SAT by adding new variables y1 ; ´1 ; : : : ; ym ; ´m and replacing each clause Ci D f 1 ; 2 ; 3 g by the fourteen clauses f 1 ; ´i g; f 1 ; ´N i g; f 2 ; ´i g; f 2 ; ´N i g; f 3 ; ´i g; f 3 ; ´N i g; fyi ; ´i g; fyi ; ´N i g; f 1 ; yNi g; f 2 ; yNi g; f 3 ; yNi g; f N 1 ; N 2 g; f N 1 ; N 3 g; f N 2 ; N 3 g: Note that no truth assignment satisfies more than 11 of these 14 clauses. Moreover, if 11 of these clauses are satisfied, then at least one of 1 ; 2 ; 3 must be true. On the other hand, if one of 1 ; 2 ; 3 is true we can set yi WD 1 ^ 2 ^ 3 and ´i WD true in order to satisfy 11 of these clauses. We conclude that I has a truth assignment satisfying all m clauses if and only if I 0 has a truth assignment that satisfies 11m clauses. It is an open question whether each NP-hard decision problem P 2 NP is NPcomplete (recall the difference between polynomial reduction and polynomial transformation; Definitions 15.15 and 15.17). Exercises 22 and 23 discuss two NP-hard decision problems that appear not to be in NP. See also Exercise 2 of Chapter 19. Unless P D NP there is no exact polynomial-time algorithm for any NP-hard problem. There might, however, be a pseudopolynomial algorithm: Definition 15.38. Let P be a decision problem or an optimization problem such that each instance x consists of a list of nonnegative integers. We denote by largest.x/ the largest of these integers. An algorithm for P is called pseudopolynomial if its running time is bounded by a polynomial in size.x/ and largest.x/. For example there is a trivial pseudopolynomial algorithm for PRIME which divides the natural number n to be tested for primality by each integer from 2 to p b nc. Another example is: Theorem 15.39. There is a pseudopolynomial algorithm for SUBSET-SUM. Proof: Given an instance c1 ; : : : ; cn ; K of SUBSET-SUM, we construct a digraph G with vertex set f0; : : : ; ng f0; 1; 2; : : : ; Kg. For each j 2 f1; : : : ; ng we add edges ..j 1; i /; .j; i // (i D 0; 1; : : : ; K) and ..j 1; i /; .j; i C cj // (i D 0; 1; : : : ; K cj ). Observe thatPany path from .0; 0/ to .j; i / corresponds to a subset S f1; : : : ; j g with k2S ck D i , and vice versa. Therefore we can solve our SUBSETSUM instance by checking whether G contains a path from .0; 0/ to .n; K/. With the GRAPH SCANNING ALGORITHM this can be done in O.nK/ time, so we have a pseudopolynomial algorithm. above is also a pseudopolynomial algorithm for PARTITION because PThe n n c i D1 i 2 largest.c1 ; : : : ; cn /. We shall discuss an extension of this algorithm in Section 17.2. If the numbers are not too large, a pseudopolynomial algorithm can be quite efficient. Therefore the following definition is useful: 1 2

15.7

NP-Hard Problems

405

Definition 15.40. For a decision problem P D .X; Y / or an optimization problem P D .X; .Sx /x2X ; c; goal/, and a subset X 0 X of instances we define the restriction of P to X 0 by P 0 D .X 0 ; X 0 \ Y / or P 0 D .X 0 ; .Sx /x2X 0 ; c; goal/, respectively. Let P be a decision or optimization problem such that each instance consists of a list of numbers. For a polynomial p let Pp be the restriction of P to instances x consisting of nonnegative integers with largest.x/ p.size.x//. P is called strongly NP-hard if there is a polynomial p such that Pp is NP-hard. P is called strongly NP-complete if P 2 NP and there is a polynomial p such that Pp is NP-complete. Proposition 15.41. Unless P D NP there is no exact pseudopolynomial algorithm for any strongly NP-hard problem. We give some famous examples: Theorem 15.42. INTEGER PROGRAMMING is strongly NP-hard. Proof: For an undirected graph G the integer program maxf1lx W x 2 ZV .G/ ; 0 x 1l; xv C xw 1 for fv; wg 2 E.G/g has optimum value at least k if and only if G contains a stable set of cardinality k. Since k jV .G/j for all nontrivial instances .G; k/ of STABLE SET, the result follows from Theorem 15.23.

TRAVELING SALESMAN PROBLEM (TSP) Instance: Task:

A complete graph Kn (n 3) and weights c W E.Kn / ! RC . P Find a Hamiltonian circuit T whose weight e2E.T / c.e/ is minimum.

The vertices of a TSP-instance are often called cities, the weights are also referred to as distances. Theorem 15.43. The TSP is strongly NP-hard. Proof: We show that the TSP is NP-hard even when restricted to instances where all distances are 1 or 2. We describe a polynomial reduction from the H AMILTONIAN CIRCUIT problem. Given a graph G on n 3 vertices, we construct the following instance of TSP: Take one city for each vertex of G, and let the distances be 1 whenever the edge is in E.G/ and 2 otherwise. It is then obvious that G is Hamiltonian if and only if the length of an optimum TSP tour is n. The proof also shows that the following decision problem is not easier than the TSP itself: Given an instance of the TSP and an integer k, is there a tour of length k or less? A similar statement is true for a large class of discrete optimization problems: Proposition 15.44. Let F and F 0 be (infinite) families of finite sets, and let P be the following optimization problem: given a set E 2 F and a function c W E ! Z, find a set F E with F 2 F 0 and c.F / minimum (or decide that no such F exists).

406

15 NP-Completeness

Then P can be solved in polynomial time if and only if the following decision problem can be solved in polynomial time: given an instance .E; c/ of P and an integer k, is OPT..E; c// k? If the optimization problem is NP-hard, then so is this decision problem. Proof: It suffices to show that there is an oracle algorithm for the optimization problem using the decision problem (the converse is trivial). Let .E; c/ be an instance of P. P We first determine OPT..E; c// by binary search. Since there are at most 1 C e2E jc.e/j 2size.c/ possible values we can do this with O.size.c// iterations, each including one oracle call. Then we successively check for each element of E whether there exists an optimum solution without this element. This can be done by increasing its weight (say by one) and checking whether this also increases the value of an optimum solution. If so, we keep the old weight, otherwise we indeed increase the weight. After checking all elements of E, those elements whose weight we did not change constitute an optimum solution. Examples where this result applies are the TSP, the MAXIMUM WEIGHT CLIQUE PROBLEM, the SHORTEST PATH PROBLEM, the KNAPSACK PROBLEM, and many others. Schulz [2009] and Orlin, Punnen and Schulz [2009] proved similar results for INTEGER PROGRAMMING.

Exercises 1. Observe that there are more languages than Turing machines. Conclude that there are languages that cannot be decided by a Turing machine. Turing machines can also be encoded by binary strings. Consider the famous HALTING PROBLEM: given two binary strings x and y, where x encodes a Turing machine ˆ, is time.´L; y/ < 1? Prove that the HALTING PROBLEM is undecidable (i.e. there is no algorithm for it). Hint: Assuming that there is such an algorithm A, construct a Turing machine which, on input x, first runs the algorithm A on input .x; x/ and then terminates if and only if output.A; .x; x// D 0. 2. Describe a Turing machine which compares two strings: it should accept as input a string a#b with a; b 2 f0; 1g and output 1 if a D b and 0 if a 6D b. 3. A well-known machine model is the RAM machine. It works with an infinite sequence of registers x1 ; x2 ; : : : and one special register, the accumulator Acc. Each register can store an arbitrarily large integer, possibly negative. A RAM program is a sequence of instructions. There are ten types of instructions (the meaning is illustrated on the right-hand side):

Exercises

WRITE k

Acc WD k:

LOAD k LOADI k

Acc WD xk : Acc WD xxk :

STORE k STOREI k

xk WD Acc: xxk WD Acc:

ADD k SUBTR k

Acc WD Acc C xk : Acc WD Acc xk :

HALF

Acc WD bAcc=2c:

IFPOS HALT

i

407

If Acc > 0 then go to . i Stop.

A RAM program is a sequence of m instructions; each is one of the above, where k 2 Z and i 2 f1; : : : ; mg. The computation starts with instruction 1; it then proceeds as one would expect; we do not give a formal definition. The above list of instructions may be extended. We say that a command can be simulated by a RAM program in time n if it can be substituted by RAM commands so that the total number of steps in any computation increases by at most a factor of n. (a) Show that the following commands can be simulated by small RAM programs in constant time: IFNEG i IFZERO i

If Acc < 0 then go to . i If Acc D 0 then go to . i

(b) Show that the SUBTR and HALF commands can be simulated by RAM programs using only the other eight commands in O.size.xk // time and O.size.Acc// time, respectively. (c) Show that the following commands can be simulated by RAM programs in O.n/ time, where n D maxfsize.xk /; size.Acc/g: MULT k DIV k MOD k

Acc WD Acc xk : Acc WD bAcc=xk c: Acc WD Acc mod xk :

4. Let f W f0; 1g ! f0; 1g be a mapping. Show that if there is a Turing machine ˆ computing f , then there is a RAM program (cf. Exercise 3) such that the computation on input x (in Acc) terminates after O.size.x/ C time.´L; x// steps with Acc D f .x/. Show that if there is a RAM machine which, given x in Acc, computes f .x/ in Acc in at most g.size.x// steps, then there is a Turing machine computing f with time.´L; x/ D O.g.size.x//3 /. 5. Prove that the following decision problems are in NP: (a) Given two graphs G and H , is G isomorphic to a subgraph of H ?

408

6. 7. 8.

9. 10.

11.

12.

13.

14.

15.

15 NP-Completeness

(b) Given a natural number n (in binary encoding), is there a prime number p with n D p p ? (c) Given a matrix A 2 Zmn and a vector b 2 Zm , is the polyhedron P D fx W Ax bg bounded? (d) Given a matrix A 2 Zmn and a vector b 2 Zm , is the polyhedron P D fx W Ax bg unbounded? Prove: If P 2 NP, then there exists a polynomial p suchthat P can be solved by a (deterministic) algorithm having time complexity O 2p.n/ . Prove that the set of decision problems in NP is countable. Let Z be a 2SAT instance, i.e. a collection of clauses over X with two literals each. Consider a digraph G.Z/ as follows: V .G/ n is theoset of literals over X . There is an edge . 1 ; 2 / 2 E.G/ iff the clause 1 ; 2 is a member of Z. (a) Show that if, for some variable x, x and x are in the same strongly connected component of G.Z/, then Z is not satisfiable. (b) Show the converse of (a). (c) Give a linear-time algorithm for 2SAT. Describe a linear-time algorithm which for any instance of SATISFIABILITY finds a truth assignment satisfying at least half of the clauses. Consider instances of SATISFIABILITY in which each clause has one of the forms fxg, fxg, N or fx; N yg, where x and y are variables. Given such an instance and a nonnegative weight for each clause, find (in polynomial time) a truth assignment that maximizes the total weight of the satisified clauses. Hint: Reduce this to the M INIMUM CAPACITY CUT PROBLEM. Consider 3-OCCURRENCE SAT, which is SATISFIABILITY restricted to instances where each clause contains at most three literals and each variable occurs in at most three clauses. Prove that even this restricted version is NP-complete. Let W f0; 1gm ! f0; 1gm be a (not necessarily bijective) mapping, m 2. For x D .x1 ; : : : ; xn / 2 f0; 1gm f0; 1gm D f0; 1gnm let .x/ WD . .x n //, and for a decision problem P D .X; Y / with X S 1 /; : : : ; .x nm f0; 1g let .P/ WD .f .x/ W x 2 X g; f .x/ W x 2 Y g/. Prove: n2ZC (a) For all codings and all P 2 NP we have also .P/ 2 NP. (b) If .P/ 2 P for all codings and all P 2 P, then P D NP. (Papadimitriou [1994]) Prove that STABLE SET is NP-complete even if restricted to graphs whose maximum degree is 4. Hint: Use Exercise 11. Prove that the following problem, called DOMINATING SET, is NP-complete. Given an undirected graph G and a number k 2 N, is there a set X V .G/ with jX j k such that X [ .X / D V .G/ ? Hint: Transformation from VERTEX COVER. The decision problem CLIQUE is NP-complete. Is it still NP-complete (provided that P 6D NP) if restricted to (a) bipartite graphs,

Exercises

16.

17.

18.

19.

20.

21.

409

(b) planar graphs, (c) 2-connected graphs? Show for each of the following decision problems either membership in P or NP-completeness. Given an undirected graph G, does G contain (a) a circuit of length at least 17? (b) a circuit containing at least half of the vertices? (c) a circuit of odd length? (d) a clique containing at least half of the vertices? (e) two cliques such that each vertex belongs to at least one of them? Prove that the following problems are NP-complete: (a) HAMILTONIAN PATH and DIRECTED HAMILTONIAN PATH Given a graph G (directed or undirected), does G contain a Hamiltonian path? (b) SHORTEST PATH Given a graph G (directed or undirected), weights c W E.G/ ! Z, two vertices s; t 2 V .G/, and an integer k. Is there an s-t-path of weight at most k? (c) 3-MATROID INTERSECTION Given three matroids .E; F1 /; .E; F2 /; .E; F3 / (by independence oracles) and a number k 2 N, decide whether there is a set F 2 F1 \ F2 \ F3 with jF j k. (d) CHINESE POSTMAN PROBLEM Given undirected graphs G and H with V .G/ D V .H /, weights c W E.H / ! ZC and an integer k. Is there a subset F E.H / with c.F / k : such that .V .G/; E.G/ [ F / is connected and Eulerian? Either find a polynomial-time algorithm or prove NP-completeness for the following decision problems: (a) Given an undirected graph G and some T V .G/, is there a spanning tree in G such that all vertices in T are leaves? (b) Given an undirected graph G and some T V .G/, is there a spanning tree in G such that all leaves are elements of T ? (c) Given a digraph G, weights c W E.G/ ! R, a set T V .G/ and a number k, is there a branching B with jıBC .x/j 1 for all x 2 T and c.B/ k? Prove that the following decision problem belongs to coNP: given a matrix A 2 Qmn and a vector b 2 Qn , is the polyhedron fx W Ax bg integral? Hint: Use Proposition 3.9, Lemma 5.11, and Theorem 5.13. Note: The problem is not known to be in NP. Prove that the following problem belongs to coNP: given a matrix A 2 Zmn and a vector b 2 Zm , decide whether the polyhedron P D fx 2 Rn W Ax bg is integral. Note: In fact the problem is coNP-complete, as was shown by Papadimitriou and Yannakakis [1990]. Let us define Boolean formulas. Let X be a set of variables. Then true and false are the Boolean formulas over X of length zero, the literals are the Boolean

410

15 NP-Completeness

formulas over X of length one, and the Boolean formulas over X of length k 2 are the strings . ^ 0 / and . _ 0 / for all Boolean formulas of length l 2 N and 0 of length l 0 2 N with l C l 0 D k. Given a truth assignment T W X ! ftrue; falseg, we extend it to the Boolean formulas over X by setting T .. ^ 0 // WD T . / ^ T . 0 / and T .. _ 0 // WD T . / _ T . 0 /. Two Boolean formulas and 0 over X are equivalent if T . / D T . 0 / for all truth assignments T W X ! ftrue; falseg. Prove that the following problem, called BOOLEAN EQUIVALENCE , is coNPcomplete: given two Boolean formulas over a variable set X , are they equivalent? 22. Show that the following problem is NP-hard (it is not known to be in NP): given an instance of SATISFIABILITY, does the majority of all truth assignments satisfy all the clauses? 23. Show that PARTITION polynomially transforms to the following problem (which is thus NP-hard; it is not known to be in NP):

K-TH HEAVIEST SUBSET Instance:

Integers c1 ; : : : ; cn ; K; L.

Question: Are P there K distinct subsets S1 ; : : : ; SK f1; : : : ; ng such that j 2Si cj L for i D 1; : : : ; K ? 24. Prove that the following problem, called L OGIC MINIMIZATION, can be solved in polynomial time if and only if P D NP: given a set X of variables and a Boolean formula over X , find an equivalent Boolean formula over X with minimum length. Hint: Use Exercise 21. Note: The problem is not known to be NP-easy.

References General Literature: Aho, A.V., Hopcroft, J.E., and Ullman, J.D. [1974]: The Design and Analysis of Computer Algorithms. Addison-Wesley, Reading 1974 Arora, S., and Barak, B. [2009]: Computational Complexity: A Modern Approach. Cambridge University Press, New York 2009 Ausiello, G., Crescenzi, P., Gambosi, G., Kann, V., Marchetti-Spaccamela, A., and Protasi, M. [1999]: Complexity and Approximation: Combinatorial Optimization Problems and Their Approximability Properties. Springer, Berlin 1999 Bovet, D.B., and Crescenzi, P. [1994]: Introduction to the Theory of Complexity. PrenticeHall, New York 1994 Garey, M.R., and Johnson, D.S. [1979]: Computers and Intractability: A Guide to the Theory of NP-Completeness. Freeman, San Francisco 1979, Chapters 1–3, 5, and 7 Goldreich, O. [2008]: Computational Complexity: A Conceptual Perspective. Cambrige University Press, New York 2008

References

411

Horowitz, E., and Sahni, S. [1978]: Fundamentals of Computer Algorithms. Computer Science Press, Potomac 1978, Chapter 11 Johnson, D.S. [1981]: The NP-completeness column: an ongoing guide. Journal of Algorithms starting with Vol. 4 (1981) Karp, R.M. [1975]: On the complexity of combinatorial problems. Networks 5 (1975), 45–68 Papadimitriou, C.H. [1994]: Computational Complexity. Addison-Wesley, Reading 1994 Papadimitriou, C.H., and Steiglitz, K. [1982]: Combinatorial Optimization: Algorithms and Complexity. Prentice-Hall, Englewood Cliffs 1982, Chapters 15 and 16 Wegener, I. [2005]: Complexity Theory: Exploring the Limits of Efficient Algorithms. Springer, Berlin 2005

Cited References: Adleman, L.M., Pomerance, C., and Rumely, R.S. [1983]: On distinguishing prime numbers from composite numbers. Annals of Mathematics 117 (1983), 173–206 Agrawal, M., Kayal, N., and Saxena, N. [2004]: PRIMES is in P. Annals of Mathematics 160 (2004), 781–793 Cook, S.A. [1971]: The complexity of theorem proving procedures. Proceedings of the 3rd Annual ACM Symposium on the Theory of Computing (1971), 151–158 Edmonds, J. [1965]: Minimum partition of a matroid into independent subsets. Journal of Research of the National Bureau of Standards B 69 (1965), 67–72 van Emde Boas, P. [1990]: Machine models and simulations. In: Handbook of Theoretical Computer Science; Volume A; Algorithms and Complexity (J. van Leeuwen, ed.), Elsevier, Amsterdam 1990, pp. 1–66 Fürer, M. [2009]: Faster integer multiplication. SIAM Journal on Computing 39 (2009), 979–1005 Garey, M.R., Johnson, D.S., and Stockmeyer, L. [1976]: Some simplified NP-complete graph problems. Theoretical Computer Science 1 (1976), 237–267 Hopcroft, J.E., and Ullman, J.D. [1979]: Introduction to Automata Theory, Languages, and Computation. Addison-Wesley, Reading 1979 Karp, R.M. [1972]: Reducibility among combinatorial problems. In: Complexity of Computer Computations (R.E. Miller, J.W. Thatcher, eds.), Plenum Press, New York 1972, pp. 85–103 Ladner, R.E. [1975]: On the structure of polynomial time reducibility. Journal of the ACM 22 (1975), 155–171 Lewis, H.R., and Papadimitriou, C.H. [1981]: Elements of the Theory of Computation. Prentice-Hall, Englewood Cliffs 1981 Orlin, J.B., Punnen, A.P., and Schulz, A.S. [2009]: Integer programming: optimization and evaluation are equivalent. In: Algorithms and Data Structures – Proceedings of the 11th Algorithms and Data Structures Symposium; LNCS 5664 (F. Dehne, M. Gavrilova, J.-R. Sack, C.D. Tóth, eds.), Springer, Berlin 2009, pp. 519–529 Papadimitriou, C.H., and Yannakakis, M. [1990]: On recognizing integer polyhedra. Combinatorica 10 (1990), 107–109 Pratt, V. [1975]: Every prime has a succinct certificate. SIAM Journal on Computing 4 (1975), 214–220 Schönhage, A., and Strassen, V. [1971]: Schnelle Multiplikation großer Zahlen. Computing 7 (1971), 281–292

412

15 NP-Completeness

Schulz, A.S. [2009]: On the relative complexity of 15 problems related to 0/1-integer programming. In: Research Trends in Combinatorial Optimization (W.J. Cook, L. Lovász, J. Vygen, eds.), Springer, Berlin 2009, pp. 399–428 Turing, A.M. [1936]: On computable numbers, with an application to the Entscheidungsproblem. Proceedings of the London Mathematical Society (2) 42 (1936), 230–265 and 43 (1937), 544–546

16 Approximation Algorithms

In this chapter we introduce the important concept of approximation algorithms. So far we have dealt mostly with polynomially solvable problems. In the remaining chapters we shall indicate some strategies to cope with NP-hard combinatorial optimization problems. Here approximation algorithms must be mentioned in the first place. The ideal case is when the solution is guaranteed to differ from the optimum solution by a constant only: Definition 16.1. An absolute approximation algorithm for an optimization problem P is a polynomial-time algorithm A for P for which there exists a constant k such that jA.I / OPT.I /j k for all instances I of P. Unfortunately, an absolute approximation algorithm is known for very few classical NP-hard optimization problems. We shall discuss two major examples, the EDGE-COLOURING PROBLEM and the VERTEX-COLOURING PROBLEM in planar graphs in Section 16.3. In most cases we must be satisfied with relative performance guarantees. Here we have to restrict ourselves to problems with nonnegative weights. Definition 16.2. Let P be an optimization problem with nonnegative weights and k 1. A k-factor approximation algorithm for P is a polynomial-time algorithm A for P such that 1 OPT.I / A.I / kOPT.I / k for all instances I of P. We also say that A has performance ratio (or performance guarantee) k. The first inequality applies to maximization problems, the second one to minimization problems. Note that for instances I with OPT.I / D 0 we require an exact solution. The 1-factor approximation algorithms are precisely the exact polynomialtime algorithms. Sometimes the above definition is extended to the case where k is a function of the instance I , rather than a constant. We will see an example in the next section. B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__16, c Springer-Verlag Berlin Heidelberg 2012

413

414

16 Approximation Algorithms

In Section 13.4 we saw that the BEST-IN-GREEDY ALGORITHM for the MAXIMIZATION PROBLEM for an independence system .E; F / has performance 1 ratio q.E;F / (Theorem 13.19). In the following sections and chapters we shall illustrate the above definitions and analyse the approximability of various NP-hard problems. We start with covering problems.

16.1 Set Covering In this section we focus on the following quite general problem:

MINIMUM WEIGHT SET COVER PROBLEM S

S D U , weights c W S ! RC .

Instance:

A set system .U; S/ with

Task:

Find a minimum weight set cover of .U; S/, i.e. a subfamily R S S such that R2R R D U .

S2S

For c 1, the problem is called MINIMUM SET COVER PROBLEM. Another interesting special case arises if jfS 2 S W x 2 S gj D 2 for all x 2 U ; this is the MINIMUM WEIGHT VERTEX COVER PROBLEM: given a graph G and cWV .G/ ! RC , the corresponding set covering instance is defined by U WDE.G/, S WD fı.v/ W v 2 V .G/g and c.ı.v// WD c.v/ for all v 2 V .G/. As the MINIMUM WEIGHT VERTEX COVER PROBLEM is NP-hard even for unit weights (Theorem 15.24), so is the MINIMUM SET COVER PROBLEM. Johnson [1974] and Lovász [1975] proposed a simple greedy algorithm for the MINIMUM SET COVER PROBLEM: in each iteration, pick a set which covers a maximum number of elements not already covered. Chvátal [1979] generalized this algorithm to the weighted case:

GREEDY ALGORITHM FOR SET COVER Input:

A set system .U; S/ with

Output:

A set cover R of .U; S/.

S

S2S

S D U , weights c W S ! RC .

1

Set R WD ; and W WD ;.

2

While W 6D U do: Choose a set R 2 S n R for which R n W 6D ; and Set R WD R [ fRg and W WD W [ R.

c.R/ jRnW j

is minimum.

The running time is obviously O.jU jjSj/. The following performance guarantee can be proved: Theorem 16.3. (Chvátal [1979]) For any instance .U; S; c/ of the MINIMUM WEIGHT SET COVER PROBLEM, the GREEDY ALGORITHM FOR SET COVER finds a set cover whose weight is at most H.r/OPT.U; S; c/, where r WD maxS2S jS j and H.r/ D 1 C 12 C C 1r .

16.1

Set Covering

415

Proof: Let .U; S; c/ be an instance of the MINIMUM WEIGHT SET COVER PROBLEM, and let R D fR1 ; : : : ; Rk g be the solution found by the above algorithm, where Ri is the set chosen in the i -th iteration. For j D 0; : : : ; k let Wj WD Sj i D1 Ri . For each e 2 U let j.e/ WD minfj 2 f1; : : : ; kg W e 2 Rj g be the iteration where e is covered. Let c.Rj.e/ / : y.e/ WD jRj.e/ n Wj.e/1 j Let S 2 S be fixed, and let k 0 WD maxfj.e/ W e 2 S g. We have X

0

y.e/ D

k X

X

y.e/

i D1 e2SWj.e/Di

e2S

0

D

k X i D1 0

D

k X i D1 0

k X i D1

c.Ri / jS \ .Wi n Wi 1 /j jRi n Wi 1 j c.Ri / .jS n Wi 1 j jS n Wi j/ jRi n Wi 1 j c.S / .jS n Wi 1 j jS n Wi j/ jS n Wi 1 j

by the choice of the Ri in 2 (observe that S n Wi 1 6D ; for i D 1; : : : ; k 0 ). By writing si WD jS n Wi 1 j we get X e2S

0

k X si si C1 y.e/ c.S / si i D1

k X 1 0

c.S /

i D1

1 1 CC C si si 1 si C1 C 1

0

k X D c.S / .H.si / H.si C1 // i D1

D c.S /.H.s1 / H.sk 0 C1 // c.S /H.s1 /: Since s1 D jS j r, we conclude that X y.e/ c.S /H.r/: e2S

416

16 Approximation Algorithms

We sum over all S 2 O for an optimum set cover O and obtain XX y.e/ c.O/H.r/ S2O e2S

X

y.e/

e2U

D

k X

X

y.e/

i D1 e2U Wj.e/Di

D

k X

c.Ri / D c.R/:

i D1

For a slightly tighter analysis of the non-weighted case, see Slavík [1997]. Raz and Safra [1997] discovered that there exists a constant c > 0 such that, unless P D NP, no performance ratio of c ln jU j can be achieved. Indeed, a performance ratio of c ln jU j cannot be achieved for any c < 1 unless each problem in NP can be solved in O nO.log log n/ time (Feige [1998]). The MINIMUM WEIGHT EDGE COVER PROBLEM is obviously a special case of the MINIMUM WEIGHT SET COVER PROBLEM. Here we have r D 2 in Theorem 16.3, hence the above algorithm is a 32 -factor approximation algorithm in this special case. However, the problem can also be solved optimally in polynomial time; cf. Exercise 12 of Chapter 11. For the MINIMUM VERTEX COVER PROBLEM, the above algorithm reads as follows:

GREEDY ALGORITHM FOR VERTEX COVER Input:

A graph G.

Output:

A vertex cover R of G.

1

Set R WD ;.

2

While E.G/ 6D ; do: Choose a vertex v 2 V .G/ n R with maximum degree. Set R WD R [ fvg and delete all edges incident to v.

This algorithm looks reasonable, so one might ask for which k it is a k-factor approximation algorithm. It may be surprising that there is no such k. Indeed, the bound given in Theorem 16.3 is almost best possible: Theorem 16.4. (Johnson [1974], Papadimitriou and Steiglitz [1982]) For all n3 there is an instance G of the MINIMUM VERTEX COVER PROBLEM such that nH.n 1/ C 2 jV .G/j nH.n 1/ C n, the maximum degree of G is n 1, OPT.G/ D n, and the above algorithm can find a vertex cover containing all but n vertices.

16.1

Proof: For each n 3 and i n we define Ain WD o n V .Gn / WD a1 ; : : : ; aAn1 : ; b ; : : : ; b ; c ; : : : ; c 1 n 1 n n

Pi

j D2

Set Covering

417

j k n j

and

E.Gn / WD ffbi ; ci g W i D 1; : : : ; ng [ i

An [

n1 [

˚ faj ; bk g W .j Ani 1 1/i C 1 k .j Ani 1 /i :

i D2 j DAin1 C1 n1 nH.n 1/ n and An1 nH.n Observe that jV .Gn /j D 2n C An1 n , An n 1/ n .n 2/. Figure 16.1 shows G6 .

c1

c2

c3

c4

c5

c6

b1

b2

b3

b4

b5

b6

a1

a2

a3

a4

a5

a6

a7

Fig. 16.1.

If we apply our algorithm to Gn , it may first choose vertex aAn1 (because it has n maximum degree), and subsequently the vertices aAn1 ; a ; n1 1 An 2 : : : ; a1 . After n this there are n pairwise disjoint edges left, so n more vertices are needed. Hence the constructed vertex cover consists of An1 C n vertices, while the optimum vertex n cover fb1 ; : : : ; bn g has size n. There are, however, 2-factor approximation algorithms for the MINIMUM VERCOVER PROBLEM. The simplest one is due to Gavril (see Garey and Johnson [1979]): just find any maximal matching M and take the ends of all edges in M . This is obviously a vertex cover and contains 2jM j vertices. Since any vertex cover must contain jM j vertices (no vertex covers two edges of M ), this is a 2-factor approximation algorithm. This performance guarantee is tight: simply think of a graph consisting of many pairwise disjoint edges. It may be surprising that the above is the best known approximation algorithm for the MINIMUM VERTEX COVER PROBLEM. Later we shall show that there is a number k > 1 such that no k-factor approximation algorithm exists unless P D NP (Theorem 16.46). Indeed, a 1:36-factor approximation algorithm does not exist unless P D NP (Dinur and Safra [2002]). See also Khot and Regev [2008]. TEX

418

16 Approximation Algorithms

At least Gavril’s algorithm can be extended to the weighted case. We present the algorithm of Bar-Yehuda and Even [1981], which is applicable to the general MINIMUM WEIGHT SET COVER PROBLEM:

BAR-YEHUDA-EVEN ALGORITHM Input:

A set system .U; S/ with

Output:

A set cover R of .U; S/.

1 2

S

S2S

S D U , weights c W S ! RC .

Set R WD ; and W WD ;. Set y.e/ WD 0 for all e 2 U . Set c 0 .S / WD c.S / for all S 2 S. While W 6D U do: Choose an element e 2 U n W . Let R 2 S with e 2 R and c 0 .R/ minimum. Set y.e/ WD c 0 .R/. Set c 0 .S / WD c 0 .S / y.e/ for all S 2 S with e 2 S . Set R WD R [ fRg and W WD W [ R.

Theorem 16.5. (Bar-Yehuda and Even [1981]) For any instance .U; S; c/ of the MINIMUM WEIGHT SET COVER PROBLEM, the BAR-YEHUDA-EVEN ALGORITHM finds a set cover whose weight is at most pOPT.U; S; c/, where p WD maxe2U jfS 2 S W e 2 S gj. Proof: The MINIMUM WEIGHT SET COVER PROBLEM can be written as the integer linear program ˚ min cx W Ax 1l; x 2 f0; 1gS ; where A is the matrix whose rows correspond to the elements of U and whose columns are the incidence vectors of the sets in S. The optimum of the LP relaxation min fcx W Ax 1l; x 0g is a lower bound for OPT.U; S; c/ (the omission of the constraints x 1l does not change the optimum value of this LP). Hence, by Proposition 3.13, the optimum of the dual LP maxfy1l W yA c; y 0g is also a lower bound for OPT.U; S; c/. Now observe that c 0 .S / 0 for all S 2 S at any P stage of the algorithm. Let yN be the vector y at termination. We have yN 0 and e2S y.e/ N c.S / for all S 2 S, i.e. yN is a feasible solution of the dual LP and y1 N l maxfy1l W yA c; y 0g OPT.U; S; c/:

16.2

The Max-Cut Problem

419

Finally observe that c.R/ D

X

c.R/

R2R

D

XX

y.e/ N

R2R e2R

X

p y.e/ N

e2U

D p y1 Nl pOPT.U; S; c/:

Since we have p D 2 in the vertex cover case, this is a 2-factor approximation algorithm for the M INIMUM WEIGHT VERTEX COVER PROBLEM. The first 2-factor approximation algorithm was due to Hochbaum [1982]. She proposed finding an optimum solution y of the dual LP in the above proof and taking all sets S with P e2S y.e/ D c.S /. Alternatively, one could find an optimum solution x of the primal LP and take all sets S with xS p1 . The advantage of the BAR-YEHUDA-EVEN ALGORITHM is that it does not explicitly use linear programming. In fact it can easily be implemented with P O jS j time. It is our first example of a primal-dual approximation S2S algorithm; more complicated examples will follow in Sections 20.4 and 22.3.

16.2 The Max-Cut Problem In this section we consider another basic problem:

MAXIMUM WEIGHT CUT PROBLEM Instance:

An undirected graph G and weights c W E.G/ ! RC .

Task:

Find a cut in G with maximum total weight.

This problem is often called MAX-CUT for short. In contrast to minimum weight cuts, discussed in Section 8.7, this is a difficult problem. It is strongly NP-hard; even the special case where c 1 (the MAXIMUM CUT PROBLEM) is hard: Theorem 16.6. (Garey, Johnson and Stockmeyer [1976]) The MAXIMUM CUT PROBLEM is NP-hard. Proof: By reduction from MAX-2SAT (cf. Theorem 15.37). Given an instance of MAX-2SAT with n variables and m clauses, we construct a graph G whose vertices are the literals plus an extra vertex ´. For each variable x we add 3m parallel edges between x and x. N For each clause f; 0 g we add three edges f; 0 g, f; ´g and 0 f ; ´g. So G has 2n C 1 vertices and 3m.n C 1/ edges.

420

16 Approximation Algorithms

We claim that the maximum cardinality of a cut in G is 3mn C 2t, where t is the maximum number of clauses satisfied by any truth assignment. Indeed, given a truth assignment satisfying t clauses, let X be the set of true literals. Then jıG .X /j D 3mn C 2t. Conversely, if there is a set X V .G/ with jıG .X /j 3mn C a, then w.l.o.g. ´ … X (otherwise replace X by V .G/ n X ), and for each variable x we have jX \ fx; xgj N D 1 (otherwise replace X by X 4fxg and increase the cut). Thus we can set all literals in X to be true and get a truth assignment satisfying at least a2 clauses. It is very easy to find a 2-factor approximation algorithm for the MAXWEIGHT CUT PROBLEM: If V .G/ D fv P1 ; : : : ; vn g, start with X WD fv g, and for i D 3; : : : ; n add v to X if i e2E.vi ;fv1 ;:::;vi 1 g\X/ c.e/ < P1 c.e/. (The simple analysis of this algorithm is left as Exere2E.vi ;fv1 ;:::;vi 1 gnX/ cise 9.) For a long time no better approximation algorithm was known. Then Goemans and Williamson [1995] found a much better one using semidefinite programming; the rest of this section is based on their paper. Let G be an undirected graph and c W E.G/ ! RC . W.l.o.g., V .G/ D f1; : : : ; ng. For 1 i; j n let cij WD c.fi; j g/ if fi; j g 2 E.G/ and cij WD 0 otherwise. Then the MAXIMUM P WEIGHT CUT PROBLEM consists of finding a subset S f1; : : : ; ng maximizing i 2S; j 2f1;:::;ngnS cij . Expressing S by y 2 f1; 1gn with yi D 1 iff i 2 S , we can formulate the problem as follows: IMUM

1 2

max s.t.

X

cij .1 yi yj /

1i <j n

yi 2 f1; 1g

.i D 1; : : : ; n/

The variables yi can be regarded as one-dimensional vectors of unit norm. By relaxing them to multidimensional vectors of unit Euclidean norm we get a very interesting relaxation:

max s.t.

1 2

X

cij .1 yi> yj /

1i <j n

yi 2 Sm

(16.1)

.i D 1; : : : ; n/

where m 2 N and Sm D fx 2 Rm W jjxjj2 D 1g denotes the unit sphere in Rm . For example, for the triangle (n D 3, c12 D c13 D c23 D 1) the optimum is obtained by points on the unit sphere in R2 that arepvertices of an equilateral p triangle, e.g. y1 D .0; 1/, y2 D . 23 ; 12 /, and y3 D . 23 ; 12 /, giving an optimum value of 94 , in contrast to the maximum weight of a cut, which is 2. However, the interesting fact is that we can solve (16.1) almost optimally in polynomial time. The trick is not to consider the variables yi directly, not even their dimension. Instead, we consider the n n-matrix .yi> yj /i;j D1;:::;n . As a matrix X is symmetric

16.2

The Max-Cut Problem

421

and positive semidefinite if and only if it can be written as B > B for some matrix B, we can write equivalently max s.t.

1 2

X

cij .1 xij /

1i <j n

(16.2)

xi i D 1 .i D 1; : : : ; n/ X D .xij /1i;j n symmetric and positive semidefinite

From a solution to (16.2) we can obtain a solution to (16.1) with m n and almost the same objective function value by Cholesky factorization in O.n3 / time (we have to accept an arbitrarily small rounding error; cf. Exercise 6 of Chapter 4). Problem (16.2) is called a semidefinite programming relaxation. It can be solved approximately in polynomial time by the ELLIPSOID METHOD, applying Theorem 4.19, as we shall show now. First observe that we optimize a linear objective function over the convex set ˚ P WD X D .xij /1i;j n 2 Rnn W X symmetric and positive semidefinite; xi i D 1 .i D 1; : : : ; n/ : 2

By projecting P to the n 2n free variables we obtain ˚ P 0 WD .xij /1i <j n W .xij /1i;j n 2 P with xi i WD 1 and xj i WD xij for i < j : Note that neither P nor P 0 is a polyhedron. However, P 0 is convex, bounded, and full-dimensional: Proposition 16.7. P 0 is convex. Moreover, B.0; n1 / P 0 B.0; n/. Proof: Convexity follows from the simple fact that convex combinations of positive semidefinite matrices are positive semidefinite. For the first inclusion, observe that for a symmetric n n-matrix X whose diagonal entries are 1 and whose off-diagonal entries have absolute value at most n1 we have, for any d 2 Rn , d > Xd D

n X

xij di dj

i;j D1

1 X .xi i di2 C xjj dj2 .2n 2/jxij jjdi dj j/ 2n 2 i 6Dj n

1 X 2 .di C dj2 2jdi dj j/ 2n 2 i 6Dj n

1 X .jdi j jdj j/2 D 2n 2 i 6Dj

0; i.e. X is positive semidefinite.

422

16 Approximation Algorithms

For the second inclusion, note that all off-diagonal entries of a matrix in P have absolute value at most 1, and thus the Euclidean norm of the vector of upper diagonal entries is at most n. It remains to show that the SEPARATION PROBLEM for P 0 can be solved in polynomial time. This is achieved by GAUSSIAN ELIMINATION: Theorem 16.8. Given a symmetric matrix X 2 Qnn , we can decide in polynomial time whether X is positive semidefinite, and find a vector d 2 Qn with d > Xd < 0 if one exists. Proof: If xnn < 0, then we set d D .0; : : : ; 0; 1/ and have d > Xd < 0. If xnn D 0 x and xnj 6D 0 for some j < n, then we can define d by dj WD 1, dn WD 2xjjnj C xnj , x

and di WD 0 for i 2 f1; : : : ; n1gnfj g, and have d > Xd D xjj 2xnj . 2xjjnj Cxnj / D

2.xnj /2 < 0, again proving that X is not positive semidefinite. In the other cases we reduce the dimension. If xnj D 0 for all j , then the last row and column can be deleted: X is positive semidefinite if and only if X 0 WD .xij /i;j D1;:::;n1 is positive semidefinite. Moreover, if c 2 Qn1 satisfies c > X 0 c < 0, we set d WD . 0c / and have d > Xd < 0. Hence let us now assume that xnn > 0. Then we consider X 0 WD .xij xni xnj /i;j D1;:::;n1 ; this corresponds to one iteration of GAUSSIAN ELIMINATION. xnn Note that X 0 is positive semidefinite if and only if X is positive semidefinite. c For a vector c 2 Qn1 with c > X 0 c < 0 we set d WD . x 1 Pn1 /. Then i D1 ci xni nn

>

d Xd D

n1 X i;j D1

n1 X xni 0 di xij C xnj dj C 2 dn xnj dj C dn2 xnn xnn

D c> X 0c C

j D1

n1 X i;j D1

>

ci

xni xnj cj .1 2 C 1/ xnn

0

Dc Xc < 0: This defines a polynomial-time algorithm. To see that the numbers involved in the computation of d are not too large, let X .n/ ; X .n1/ ; : : : ; X .k/ be the considered matrices (X .i / 2 Qi i ), and assume that we observe in iteration n C 1 k that the matrix X .k/ D .yij /i;j D1;:::;k is not positive semidefinite (i.e. ykk < 0 or ykk D 0 and ykj 6D 0 for some j < k). We have a vector c 2 Qk with c > X .k/ c < 0 and size.c/ 2size.X .k/ /. Now a vector d 2 Qn with d > Xd < 0 can be constructed as above; note that d is a solution of the linear equation system M d D . 0c /, where the j -th row of M is

the j -th unit vector if j k,

the j -th unit vector if j > k and the j -th row of X .j / is zero,

the j -th row of X .j / , followed by zeros, otherwise.

16.2

The Max-Cut Problem

423

Hence, with Theorem 4.4, we have size.d / 4n.size.M / C size.c//, which is polynomial by Theorem 4.10. Corollary 16.9. The SEPARATION PROBLEM for P 0 can be solved in polynomial time. Proof: Let .yij /1i <j n be given, and let Y D .yij /1i;j n be the symmetric matrix defined by yi i D 1 for all i and yj i WD yij for i < j . Apply Theorem 16.8. If Y is positive semidefinite, we are done. P 2 Otherwise we findPa vector d 2 Qn with P d > Yd < 0. Then niP D1 di > P n n > 2 d Yd i D1 di D 1i <j n 2di dj yij , but 1i <j n 2di dj ´ij i D1 di2 for all ´ 2 P 0 . Thus .di dj /1i <j n constitutes a separating hyperplane. We can now conclude: Theorem 16.10. For any instance of the MAXIMUM WEIGHT CUT PROBLEM, we can find a matrix Y D .yij /1i;j n 2 P with 8 9 < X = X cij .1 yij / max cij .1 xij / W .xij /1i;j n 2 P : ; 1i <j n

1i <j n

in time polynomial in n, size..cij /1i <j n /, and size./. Proof: We apply Theorem 4.19, using Proposition 16.7 and Corollary 16.9.

Semidefinite programs such as (16.2) can also be solved approximately by interior point algorithms, which are more efficient than the ELLIPSOID METHOD. See Alizadeh [1995] for details. As mentioned above, from an almost optimum solution to (16.2) we can derive a solution to (16.1) with almost the same objective function value by Cholesky factorization. This solution consists of a set of vectors yi 2 Rm (i D 1; : : : ; n) for some m n. As (16.1) P is a relaxation of our original problem, we have that the optimum is at most 12 1i <j n cij .1 yi> yj / C . The vectors yi lie on a unit sphere. The idea is now to take a random hyperplane through the origin, and define S to be the set of indices i for which yi is on one side of this hyperplane. A random hyperplane through the origin is given by a random point on the .m 1/-dimensional sphere. This can be chosen by drawing m real numbers independently from the standard normal distribution, which in turn can be done using independent random numbers uniformly distributed in Œ0; 1. See Knuth [1969] (Section 3.4.1) for details. The algorithm by Goemans and Williamson now reads as follows.

424

16 Approximation Algorithms

GOEMANS-WILLIAMSON MAX-CUT-ALGORITHM Input:

A number n 2 N, numbers cij 0 for 1 i < j n.

Output:

A set S f1; : : : ; ng.

1

Solve (16.2) approximately; i.e. find a symmetric positive semidefinite matrix X D .xij /1i;j n with xi i D 1 for i D 1; : : : ; n, such that P 1i <j n cij .1 xij / 0:9995 OPT.16.2/.

2

Apply Cholesky factorization to X in order to obtain vectors y1 ; : : : ; yn 2 Rm with m n and yi> yj xij for all i; j 2 f1; : : : ; ng.

3

Choose a random point a on the unit sphere fx 2 Rm W jjxjj2 D 1g.

4

Set S WD fi 2 f1; : : : ; ng W a> yi 0g.

Theorem 16.11. The GOEMANS-WILLIAMSON MAX-CUT-ALGORITHM runs in polynomial time. Proof: See the preceding discussion. The most difficult step, , 1 canPbe solved in polynomial time by Theorem 16.10. Here we can choose D 0:00025 1i <j n cij P as 12 1i <j n cij is a lower bound on the optimum objective value (attained by randomly choosing S f1; : : : ; ng) and thus on the optimum value of (16.2). We now prove the performance guarantee: Theorem 16.12. (Goemans and Williamson [1995]) The GoemansWilliamson Max-Cut-Algorithm returns a set S for which the expected value of P i 2S; j …S cij is at least 0:878 times the maximum possible value. Proof: Let Sm again denote the unit sphere in Rm , and let H.y/ WD fx 2 Sm W x > y 0g be the hemisphere with pole y, for y 2 Sm . For a subset volume .A/ A Sm let .A/ WD volume .Sm / ; this defines a probability measure on Sm . We have jS \ fi; j gj D 1 with probability .H.yi /4H.yj //, where 4 denotes the symmetric difference. Note that H.yi /4H.yj / is the union of two spherical digons, each with angle arccos.yi> yj /. As the volume is proportional to the angle, we have .H.yi /4H.yj // D 1 arccos.yi> yj /. Claim: 1 arccos ˇ 0:8785 1ˇ 2 for all ˇ 2 Œ1; 1. For ˇ D 1 we have equality. Moreover, elementary calculus yields min

1ˇ 1:38. As 1:38 > 0:8785 , this proves the claim. 2 P Thus the expected value of i 2S; j …S cij is

16.3

X

X

cij .H.yi /4H.yj // D

1i <j n

cij

1i <j n

0:8785

1 2

1 0:8785 2

Colouring

425

1 arccos.yi> yj / X

cij .1 yi> yj /

1i <j n

X

cij .1 xij /

1i <j n

0:8785 0:9995 OPT.16.2/ > 0:878 OPT.16.2/ 9 8 = < X cij W S f1; : : : ; ng : 0:878 max ; : i 2S; j …S

Therefore we have a randomized approximation algorithm with performance 1 < 1:139. Mahajan and Ramesh [1999] showed how to derandomize ratio 0:878 this algorithm, thus obtaining a deterministic 1:139-factor approximation algorithm. However, there is no 1:062-factor approximation algorithm unless P D NP (Hastad [2001], Papadimitriou and Yannakakis [1991]). See Lovász [2003] for other interesting connections of semidefinite programming and combinatorial optimization.

16.3 Colouring In this section we briefly discuss two more well-known special cases of the MINIMUM SET COVER PROBLEM : we want to partition the vertex set of a graph into stable sets, or the edge set of a graph into matchings: Definition 16.13. Let G be an undirected graph. A vertex-colouring of G is a mapping f W V .G/ ! N with f .v/ 6D f .w/ for all fv; wg 2 E.G/. An edgecolouring of G is a mapping f W E.G/ ! N with f .e/ 6D f .e 0 / for all e; e 0 2 E.G/ with e 6D e 0 and e \ e 0 6D ;. The number f .v/ or f .e/ is called the colour of v or e. In other words, the set of vertices or edges with the same colour (f -value) must be a stable set, or a matching, respectively. Of course we are interested in using as few colours as possible:

VERTEX-COLOURING PROBLEM Instance:

An undirected graph G.

Task:

Find a vertex-colouring f W V .G/ ! f1; : : : ; kg of G with minimum k.

426

16 Approximation Algorithms

EDGE-COLOURING PROBLEM Instance:

An undirected graph G.

Task:

Find an edge-colouring f W E.G/ ! f1; : : : ; kg of G with minimum k.

Reducing these problems to the MINIMUM SET COVER PROBLEM is not very useful: for the VERTEX-COLOURING PROBLEM we would have to list the maximal stable sets, and for the EDGE-COLOURING PROBLEM the maximal matchings; in both cases we would have to reckon with exponentially many. The optimum value of the VERTEX-COLOURING PROBLEM (i.e. the minimum number of colours) is called the chromatic number of the graph. The optimum value of the EDGE-COLOURING PROBLEM is called the edge-chromatic number or sometimes the chromatic index. Both colouring problems are NP-hard: Theorem 16.14. The following decision problems are NP-complete: (a) (Holyer [1981]) Decide whether a given simple graph has edge-chromatic number 3. (b) (Stockmeyer [1973]) Decide whether a given planar graph has chromatic number 3. The problems remain NP-hard even when the graph has maximum degree three in (a), and maximum degree four in (b). Proposition 16.15. For any given graph we can decide in linear time whether the chromatic number is less than 3, and if so, find an optimum colouring. The same holds for the edge-chromatic number. Proof: A graph has chromatic number 1 iff it has no edges. By definition, the graphs with chromatic number at most 2 are precisely the bipartite graphs. By Proposition 2.27 we can check in linear time whether a graph is bipartite and in the positive case find a bipartition, i.e. a vertex-colouring with two colours. To check whether the edge-chromatic number of a graph G is less than 3 (and, if so, find an optimum edge-colouring) we simply consider the VERTEX-COLOURING PROBLEM in the line graph of G. This is obviously equivalent. For bipartite graphs, the EDGE-COLOURING PROBLEM can be solved, too: Theorem 16.16. (König [1916]) The edge-chromatic number of a bipartite graph G equals the maximum degree of a vertex in G. Proof: By induction on jE.G/j. Let G be a graph with maximum degree k, and let e D fv; wg be an edge. By the induction hypothesis, G e has an edge-colouring f with k colours. There are colours i; j 2 f1; : : : ; kg such that f .e 0 / 6D i for all e 0 2 ı.v/ and f .e 0 / 6D j for all e 0 2 ı.w/. If i D j , we are done since we can extend f to G by giving e colour i .

16.3

Colouring

427

The graph H D .V .G/; fe 0 2 E.G/ n feg W f .e 0 / 2 fi; j gg/ has maximum degree 2, and v has degree at most 1 in H . Consider the maximal path P in H with endpoint v. The colours alternate on P ; hence the other endpoint of P cannot be w. Exchange the colours i and j on P and extend the edge-colouring to G by giving e colour j . The maximum degree of a vertex is an obvious lower bound on the edgechromatic number of any graph. It is not always attained as the triangle K3 shows. The following theorem shows how to find an edge-colouring of a given simple graph which needs at most one more colour than necessary: Theorem 16.17. (Vizing [1964]) Let G be an undirected simple graph with maximum degree k. Then G has an edge-colouring with at most k C 1 colours, and such a colouring can be found in polynomial time. Proof: By induction on jE.G/j. If G has no edges, the assertion is trivial. Otherwise let e D fx; y0 g be any edge; by the induction hypothesis there exists an edge-colouring f of G e with k C 1 colours. For each vertex v choose a colour n.v/ 2 f1; : : : ; k C 1g n ff .w/ W w 2 ıGe .v/g missing at v. Starting from y0 , construct a maximal sequence y0 ; y1 ; : : : ; y t of distinct neighbours of x such that n.yi 1 / D f .fx; yi g/ for i D 1; : : : ; t. If no edge incident to x is coloured n.y t /, then we construct an edge-colouring f 0 of G from f by setting f 0 .fx; yi 1 g/ WD f .fx; yi g/ (i D 1; : : : ; t) and f 0 .fx; y t g/ WD n.y t /. So we assume that there is an edge incident to x with colour n.y t /; by the maximality of t we have f .fx; ys g/ D n.y t / for some s 2 f1; : : : ; t 1g. ys−1

y2

n(ys−2)

n(y1)

y1

n(ys−1)=n(yt)

n(y0) y0

ys

x n(yt−1)

yt n(x)

P

n(yt)

n(x)

n(yt)

Fig. 16.2.

Consider the maximum path P starting at y t in the graph .V .G/; fe 0 2 E.G e/ W f .e 0 / 2 fn.x/; n.y t /gg/ (this graph has maximum degree 2; cf. Figure 16.2). We distinguish three cases. In each case we construct an edge-colouring f 0 of G.

428

16 Approximation Algorithms

If P ends in x, then fys ; xg is the last edge of P . We construct f 0 from f by exchanging colours n.x/ and n.y t / on P , and setting f 0 .fx; yi 1 g/ WD f .fx; yi g/ (i D 1; : : : ; s). If P ends in ys1 , then the last edge of P has colour n.x/, since colour n.y t / D f .fx; ys g/ D n.ys1 / is missing at ys1 . We construct f 0 from f as follows: exchange colours n.x/ and n.y t / on P , set f 0 .fx; yi 1 g/ WD f .fx; yi g/ (i D 1; : : : ; s 1) and f 0 .fx; ys1 g/ WD n.x/. If P ends neither in x nor in ys1 , then we can construct f 0 from f by exchanging colours n.x/ and n.y t / on P , and setting f 0 .fx; yi 1 g/ WD f .fx; yi g/ (i D 1; : : : ; t) and f 0 .fx; y t g/ WD n.x/. Vizing’s Theorem implies an absolute approximation algorithm for the E DGECOLOURING PROBLEM in simple graphs. If we allow parallel edges the statement of Vizing’s Theorem is no longer true: by replacing each edge of the triangle K3 by r parallel edges we obtain a 2r-regular graph with edge-chromatic number 3r. We now turn to the VERTEX-COLOURING PROBLEM. The maximum degree also gives an upper bound on the chromatic number: Theorem 16.18. Let G be an undirected graph with maximum degree k. Then G has an vertex-colouring with at most k C 1 colours, and such a colouring can be found in linear time. Proof: The following GREEDY COLOURING ALGORITHM obviously finds such a colouring.

GREEDY COLOURING ALGORITHM Input:

An undirected graph G.

Output:

A vertex-colouring of G.

1

Let V .G/ D fv1 ; : : : ; vn g.

2

For i WD 1 to n do: Set f .vi / WD minfk 2 N W k 6D f .vj / for all j < i with vj 2 .vi /g.

For complete graphs and for odd circuits one evidently needs k C 1 colours, where k is the maximum degree. For all other connected graphs k colours suffice, as Brooks [1941] showed. However, the maximum degree is not a lower bound on the chromatic number: any star K1;n (n 2 N) has chromatic number 2. Therefore these results do not lead to an approximation algorithm. In fact, no algorithms for the VERTEX-COLOURING PROBLEM with a reasonable performance guarantee for general graphs are known; see Khanna, Linial and Safra [2000]. Zuckerman [2007] showed that, unless P D NP, no polynomial-time algorithm computes the chromatic number of any graph with n vertices up to a factor of n1 for any fixed > 0. Since the maximum degree is not a lower bound for the chromatic number one can consider the maximum size of a clique. Obviously, if a graph G contains

16.3

Colouring

429

a clique of size k, then the chromatic number of G is at least k. As the pentagon (circuit of length five) shows, the chromatic number can exceed the maximum clique size. Indeed, there are graphs with arbitrarily large chromatic number that contain no K3 . This motivates the following definition, which is due to Berge [1961,1962]: Definition 16.19. A graph G is perfect if .H / D !.H / for every induced subgraph H of G, where .H / is the chromatic number and !.H / is the maximum cardinality of a clique in H . It follows immediately that the decision problem whether a given perfect graph has chromatic number k has a good characterization (belongs to NP \ coNP). Some examples of perfect graphs can be found in Exercise 15. A polynomial-time algorithm for recognizing perfect graphs has been found by Chudnovsky et al. [2005]. Berge [1961] conjectured that a graph is perfect if and only if it contains neither an odd circuit of length at least five nor the complement of such a circuit as an induced subgraph. This so-called strong perfect graph theorem has been proved by Chudnovsky et al. [2006]. Long before, Lovász [1972] proved the weaker assertion that a graph is perfect iff its complement is perfect. This is known as the weak perfect graph theorem; to prove it we need a lemma: Lemma 16.20. Let G be a perfect graph and x 2 V .G/. Then the graph G 0 WD : : .V .G/ [ fyg; E.G/ [ ffy; vg W v 2 fxg [ .x/g/, resulting from G by adding a new vertex y which is joined to x and to all neighbours of x, is perfect. Proof: By induction on jV .G/j. The case jV .G/j D 1 is trivial since K2 is perfect. Now let G be a perfect graph with at least two vertices. Let x 2 V .G/, and let G 0 arise by adding a new vertex y adjacent to x and all its neighbours. It suffices to prove that !.G 0 / D .G 0 /, since for proper subgraphs H of G 0 this follows from the induction hypothesis: either H is a subgraph of G and thus perfect, or it arises from a proper subgraph of G by adding a vertex y as above. Since we can colour G 0 with .G/ C 1 colours easily, we may assume that !.G 0 / D !.G/. Then x is not contained in any maximum clique of G. Let f be a vertex-colouring of G with .G/ colours, and let X WD fv 2 V .G/ W f .v/ D f .x/g. We have !.G X / D .G X / D .G/ 1 D !.G/ 1 and thus !.G .X n fxg// D !.G/ 1 (as x does not belong to any maximum clique of G). Since .X n fxg/ [ fyg D V .G 0 / n V .G .X n fxg// is a stable set, we have .G 0 / D .G .X n fxg// C 1 D !.G .X n fxg// C 1 D !.G/ D !.G 0 /: Theorem 16.21. (Lovász [1972], Fulkerson [1972], Chvátal [1975]) For a simple graph G the following statements are equivalent: (a) G is perfect.

430

16 Approximation Algorithms

(b) The complement of G is perfect. (c) The stable set polytope, i.e. the convex hull of the incidence vectors of the stable sets of G, is given by: ( x2

RVC.G/

W

X

) xv 1 for all cliques S in G :

(16.3)

v2S

Proof: We prove (a))(c))(b). This suffices, since applying (a))(b) to the complement of G yields (b))(a). (a))(c): Evidently the stable set polytope is contained in (16.3). To prove the other inclusion, let x be a rational vector in the polytope (16.3); we may write xv D pv q , where q 2 N and pv 2 ZC for v 2 V .G/. Replace each vertex v by a clique of size pv ; i.e. consider G 0 defined by V .G 0 / WD f.v; i / W v 2 V .G/; 1 i pv g; E.G 0 / WD ff.v; i /; .v; j /g W v 2 V .G/; 1 i < j pv g [ ff.v; i /; .w; j /g W fv; wg 2 E.G/; 1 i pv ; 1 j pw g: Lemma 16.20 implies that G 0 is perfect. For an arbitrary clique X 0 in G 0 let X WD fv 2 V .G/ W .v; i / 2 X 0 for some i g be its projection to G (also a clique); we have X X jX 0 j pv D q xv q: v2X 0

v2X

0

So !.G / q. Since G is perfect, it thus has a vertex-colouring f with at most q colours. For v 2 V .G/ and i DP1; : : : ; q let ai;v WD 1 if f ..v; j // D i for some j q and ai;v WD 0 otherwise. Then i D1 ai;v D pv for all v 2 V .G/ and hence x D

pv q

D v2V .G/

q 1X ai q i D1

is a convex combination of incidence vectors of stable sets, where ai D .ai;v /v2V .G/ . (c))(b): We show by induction on jV .G/j that if (16.3) is integral then the complement of G is perfect. Since graphs with less than three vertices are perfect, let G be a graph with jV .G/j 3 where (16.3) is integral. We have to show that the vertex set of any induced subgraph H of G can be partitioned into ˛.H / cliques, where ˛.H / is the size of a maximum stable set in H . For proper subgraphs H this follows from the induction hypothesis, since (by Theorem 5.13) every face of the integral polytope (16.3) is integral, in particular the face defined by the supporting hyperplanes xv D 0 (v 2 V .G/ n V .H /). So it remains to prove that V .G/ can be partitioned into ˛.G/ cliques. The equation 1lx D ˛.G/ defines a supporting hyperplane of (16.3), so 8 9 < = X X V .G/ x 2 RC W xv 1 for all cliques S in G; xv D ˛.G/ (16.4) : ; v2S

v2V .G/

16.3

Colouring

431

is a face of (16.3). This face is contained in some facets, which cannot all be of the form fx 2 .16.3/ W xv D 0g for some v (otherwise the origin P would belong to the intersection). Hence there is some clique S in G such that v2S xv D 1 for all x in (16.4). Hence this clique S intersects each maximum stable set of G. Now by the induction hypothesis, the vertex set of G S can partitioned into ˛.G S / D ˛.G/ 1 cliques. Adding S concludes the proof. This proof is due to Lovász [1979b]. Indeed, the inequality system defining (16.3) is TDI for perfect graphs (Exercise 16). With some more work one can prove that for perfect graphs the VERTEX-COLOURING PROBLEM, the MAXIMUM WEIGHT STABLE SET PROBLEM and the MAXIMUM WEIGHT CLIQUE PROBLEM can be solved in strongly polynomial time. Although these problems are all NPhard for general graphs (Theorem 15.23, Corollary 15.24, Theorem 16.14(b)), there is a number (the so-called theta-function of the complement graph, introduced by Lovász [1979a]) which is always between the maximum clique size and the chromatic number, and which can be computed in polynomial time for general graphs using the ELLIPSOID METHOD. The details are a bit involved; see Grötschel, Lovász and Schrijver [1988]. One of the best-known problems in graph theory has been the four colour problem: is it true that every planar map can be coloured with four colours such that no two countries with a common border have the same colour? If we consider the countries as regions and switch to the planar dual graph, this is equivalent to asking whether every planar graph has a vertex-colouring with four colours. Appel and Haken [1977] and Appel, Haken and Koch [1977] proved that this is indeed true: every planar graph has chromatic number at most 4. For a simpler proof of this Four Colour Theorem (which nevertheless is based on a case checking by a computer) see Robertson et al. [1997]. We prove the following weaker result, known as the Five Colour Theorem: Theorem 16.22. (Heawood [1890]) Any planar graph has a vertex-colouring with at most five colours, and such a colouring can be found in polynomial time. Proof: By induction on jV .G/j.We may assume that G is simple, and we fix an arbitrary planar embedding ˆ D ; .Je /e2E.G/ of G. By Corollary 2.33, G has a vertex v of degree five or less. By the induction hypothesis, G v has a vertexcolouring f with at most 5 colours. We may assume that v has degree 5 and all neighbours have different colours; otherwise we can easily extend the colouring to G. Let w1 ; w2 ; w3 ; w4 ; w5 be the neighbours of v in the cyclic order in which the polygonal arcs Jfv;wi g leave v. We first claim that there are no vertex-disjoint paths P from w1 to w3 and Q from w2 to w4 in G v. To prove this, let P be a w1 -w3 -path, and let C be the circuit in G consisting of P and the edges fv; w1 g; fv; w3 g. By Theorem 2.30 R2 n S e2E.C / Je splits into two connected regions, and v is on the boundary of both regions. Hence w2 and w4 belong to different regions of that set, implying that every w2 -w4 -path in G v must contain a vertex of C .

432

16 Approximation Algorithms

Let X be the connected component of the graph GŒfx 2 V .G/ n fvg W f .x/ 2 ff .w1 /; f .w3 /gg which contains w1 . If X does not contain w3 , we can exchange the colours in X and afterwards extend the colouring to G by colouring v with the old colour of w1 . So we may assume that there is a w1 -w3 -path P containing only vertices coloured with f .w1 / or f .w3 /. Analogously, we are done if there is no w2 -w4 -path Q containing only vertices coloured with f .w2 / or f .w4 /. But the contrary assumption means that there are vertex-disjoint paths P from w1 to w3 and Q from w2 to w4 in G v, a contradiction. Hence this is a second NP-hard problem which has an absolute approximation algorithm. Indeed, the Four Colour Theorem implies that the chromatic number of a non-bipartite planar graph can only be 3 or 4. Using the polynomial-time algorithm of Robertson et al. [1996], which colours any given planar graph with four colours, one obtains an absolute approximation algorithm which uses at most one colour more than necessary. Fürer and Raghavachari [1994] detected a third natural problem which can be approximated up to an additive error of one: Given an undirected graph, they look for a spanning tree whose maximum degree is minimum among all the spanning trees (the problem is a generalization of the HAMILTONIAN PATH PROBLEM and thus NP-hard). Their algorithm also extends to a general case corresponding to the STEINER TREE PROBLEM: given a set T V .G/, find a tree S in G with V .T / V .S / such that the maximum degree of S is minimum. Singh and Lau [2007] found an extension to minimum weight spanning trees with bounded degrees. On the other hand, the following theorem tells that many problems do not have absolute approximation algorithms unless P D NP: Proposition 16.23. Let F and F 0 be (infinite) families of finite sets, and let P be the following optimization problem: Given a set E 2 F and a function c W E ! Z, find a set F E with F 2 F 0 and c.F / minimum (or decide that no such F exists). Then P has an absolute approximation algorithm if and only if P can be solved in polynomial time. Proof: Suppose there is a polynomial-time algorithm A and an integer k such that jA..E; c// OPT..E; c//j k for all instances .E; c/ of P. We show how to solve P exactly in polynomial time. Given an instance .E; c/ of P, we construct a new instance .E; c 0 /, where 0 c .e/ WD .k C 1/c.e/ for all e 2 E. Obviously the optimum solutions remain the same. But if we now apply A to the new instance, jA..E; c 0 // OPT..E; c 0 //j k and thus A..E; c 0 // D OPT..E; c 0 //.

16.4

Approximation Schemes

433

Examples are the MINIMIZATION PROBLEM FOR INDEPENDENCE SYSTEMS and the MAXIMIZATION PROBLEM FOR INDEPENDENCE SYSTEMS (multiply c by 1), and thus all problems in the list of Section 13.1.

16.4 Approximation Schemes Recall the absolute approximation algorithm for the EDGE-COLOURING PROBLEM discussed in the previous section. This also implies a relative performance guarantee: Since one can easily decide if the edge-chromatic number is 1 or 2 (Proposition 16.15), Vizing’s Theorem yields a 43 -factor approximation algorithm. On the other hand, Theorem 16.14(a) implies that no k-factor approximation algorithm exists for any k < 43 (unless P D NP). Hence the existence of an absolute approximation algorithm does not imply the existence of a k-factor approximation algorithm for all k > 1. We shall meet a similar situation with the BIN-PACKING PROBLEM in Chapter 18. This consideration suggests the following definition: Definition 16.24. Let P be an optimization problem with nonnegative weights. An asymptotic k-factor approximation algorithm for P is a polynomial-time algorithm A for P for which there exists a constant c such that 1 OPT.I / c A.I / kOPT.I / C c k for all instances I of P. We also say that A has asymptotic performance ratio k. The (asymptotic) approximation ratio of an optimization problem P with nonnegative weights is defined to be the infimum of all numbers k for which there exists an (asymptotic) k-factor approximation algorithm for P, or 1 if there is no (asymptotic) approximation algorithm at all. For example, the above-mentioned EDGE-COLOURING PROBLEM has approximation ratio 43 (unless P D NP), but asymptotic approximation ratio 1 (not only in simple graphs; see Sanders and Steurer [2008]). Optimization problems with (asymptotic) approximation ratio 1 are of particular interest. For these problems we introduce the following notion: Definition 16.25. Let P be an optimization problem with nonnegative weights. An approximation scheme for P is an algorithm A accepting as input an instance I of P and an > 0 such that, for each fixed , A is a .1 C /-factor approximation algorithm for P. An asymptotic approximation scheme for P is a pair of algorithms .A; A0 / with the following properties: A0 is a polynomial-time algorithm accepting a number > 0 as input and computing a number c . A accepts an instance I of P and an > 0 as input, and its output consists of a feasible solution for I satisfying

434

16 Approximation Algorithms

1 OPT.I / c A.I; / .1 C / OPT.I / C c : 1C For each fixed , the running time of A is polynomially bounded in size.I /. An (asymptotic) approximation scheme is called a fully polynomial (asymptotic) approximation scheme if the running time as well as the maximum size of any number occurring in the computation is bounded by a polynomial in size.I / C size./ C 1 . In some other texts one finds the abbreviations PTAS for (polynomial-time) approximation scheme and FPAS or FPTAS for fully polynomial approximation scheme. Apart from absolute approximation algorithms, a fully polynomial approximation scheme can be considered the best we may hope for when faced with an NPhard optimization problem, at least if the cost of any feasible solution is a nonnegative integer (which can be assumed in many cases without loss of generality): Proposition 16.26. Let P D .X; .Sx /x2X ; c; goal/ be an optimization problem where the values of c are nonnegative integers. Let A be an algorithm which, given an instance I of P and a number > 0, computes a feasible solution of I with 1 OPT.I / A.I; / .1 C /OPT.I / 1C and whose running time is bounded by a polynomial in size.I / C size./. Then P can be solved exactly in polynomial time. 1 Proof: Given an instance I , we first run A on .I; 1/. We set WD 1C2A.I;1/ and observe that OPT.I / < 1. Now we run A on .I; /. Since size./ is polynomially bounded in size.I /, this procedure constitutes a polynomial-time algorithm. If P is a minimization problem, we have

A.I; / .1 C /OPT.I / < OPT.I / C 1; which, since c is integral, implies optimality. Similarly, if P is a maximization problem, we have A.I; /

1 OPT.I / > .1 /OPT.I / > OPT.I / 1: 1C

Unfortunately, a fully polynomial approximation scheme exists only for very few problems (see Theorem 17.11). Moreover we note that even the existence of a fully polynomial approximation scheme does not imply an absolute approximation algorithm; the KNAPSACK PROBLEM is an example. In Chapters 17 and 18 we shall discuss two problems (KNAPSACK and BINPACKING) which have a fully polynomial approximation scheme and a fully polynomial asymptotic approximation scheme, respectively. For many problems the two types of approximation schemes coincide:

16.5

Maximum Satisfiability

435

Theorem 16.27. (Papadimitriou and Yannakakis [1993]) Let P be an optimization problem with nonnegative weights. Suppose that for each constant k there is a polynomial-time algorithm which decides whether a given instance has optimum value at most k, and, if so, finds an optimum solution. Then P has an approximation scheme if and only if P has an asymptotic approximation scheme. Proof: The only-if-part is trivial, so suppose that P has an asymptotic approximation scheme .A; A0 /. We describe an approximation scheme for P. 2 Let a fixed > 0 be given; we may assume < 1. We set 0 WD 2CC 2 < 2 0 0 and first run A on the input , yielding a constant c0 . 2c For a given instance I we next test whether OPT.I / is at most 0 . This is a constant for each fixed , so we can decide this in polynomial time and find an 2c optimum solution if OPT.I / 0 . Otherwise we apply A to I and 0 and obtain a solution of value V , with 1 OPT.I / c0 V .1 C 0 / OPT.I / C c0 : 1 C 0 We claim that this solution is good enough. Indeed, we have c0 < 2 OPT.I / which implies V .1 C 0 / OPT.I / C c0 < 1 C OPT.I / C OPT.I / D .1 C /OPT.I / 2 2 and 1 OPT.I / OPT.I / 0 .1 C / 2 2 2CC OPT.I / OPT.I / D 2 C 2 2 1 C OPT.I / OPT.I / D 1C 2 2 1 D OPT.I /: 1C

V

So the definition of an asymptotic approximation scheme is meaningful only for problems (such as bin-packing or colouring problems) whose restriction to a constant optimum value is still difficult. For many problems this restriction can be solved in polynomial time by some kind of complete enumeration.

16.5 Maximum Satisfiability The SATISFIABILITY Problem was our first NP-complete problem. In this section we analyse the corresponding optimization problem:

436

16 Approximation Algorithms

MAXIMUM SATISFIABILITY (MAX-SAT) Instance: Task:

A set X of variables, a family Z of clauses over X , and a weight function c W Z ! RC . Find a truth assignment T of X such that the total weight of the clauses in Z that are satisfied by T is maximum.

As we shall see, approximating MAX-SAT is a nice example (and historically one of the first) for the algorithmic use of the probabilistic method. Let us first consider the following trivial randomized algorithm: set each variable independently true with probability 12 . Obviously this algorithm satisfies each clause Z with probability 1 2jZj . Let us write r for random variables which are true with probability 12 and false otherwise, and let R D .r; r; : : : ; r/ be the random variable uniformly distributed over all truth assignments (several copies of r are independent of each other). If we write c.T / for the total weight of the clauses satisfied by the truth assignment T , the expected total weight of the clauses satisfied by R is X Exp .c.R// D c.Z/Prob.R satisfies Z/ Z2Z

D

X

c.Z/ 1 2jZj

Z2Z

.1 2p /

X

(16.5)

c.Z/;

Z2Z

where p WD minZ2Z jZj; Exp and ProbPdenote expectation and probability. Since the optimum cannot exceed Z2Z c.Z/, R is expected to yield a solution within a factor 121p of the optimum. But what we would really like to have is a deterministic approximation algorithm. In fact, we can turn our (trivial) randomized algorithm into a deterministic algorithm while preserving the performance guarantee. This step is often called derandomization. Let us fix the truth assignment step by step. Suppose X D fx1 ; : : : ; xn g, and we have already fixed a truth assignment T for x1 ; : : : ; xk (0 k < n). If we now set xkC1 ; : : : ; xn randomly, setting each variable independently true with probability 12 , we will satisfy clauses of expected total weight e0 D Exp.c.T .x1 /; : : : ; T .xk /; r; : : : ; r//. If we set xkC1 true (false), and then set xkC2 ; : : : ; xn randomly, the satisfied clauses will have some expected total weight e1 (e2 , respectively). e1 and e2 can be thought of as conditional expectations. Triv2 ially e0 D e1 Ce , so at least one of e1 ; e2 must be at least e0 . We set xkC1 to be true 2 if e1 e2 and false otherwise. This is sometimes called the method of conditional probabilities.

16.5

Maximum Satisfiability

437

JOHNSON’S ALGORITHM FOR MAX-SAT Input: Output:

A set X D fx1 ; : : : ; xn g of variables, a family Z of clauses over X , and a weight function c W Z ! RC . A truth assignment T W X ! ftrue; falseg.

For k WD 1 to n do: If Exp.c.T .x1 /; : : : ; T .xk1 /; true; r; : : : ; r// Exp.c.T .x1 /; : : : ; T .xk1 /; false; r; : : : ; r// then set T .xk / WD true else set T .xk / WD false.

1

The expectations can be easily computed with (16.5). Theorem 16.28. (Johnson [1974]) JOHNSON’S ALGORITHM FOR MAX-SAT is a 121p -factor approximation algorithm for MAX-SAT, where p is the minimum cardinality of a clause. Proof: Let us define the conditional expectation sk WD Exp.c.T .x1 /; : : : ; T .xk /; r; : : : ; r// for k D 0; : : : ; n. Observe that sn D c.T / is the total weight P of the clauses satisfied by our algorithm, while s0 D Exp.c.R// .1 2p / Z2Z c.Z/ by (16.5). Furthermore, si Psi 1 by the choice of T .xi / in D 1; : : : ; n). So 1 (for i P sn s0 .1 2p / Z2Z c.Z/. Since the optimum is at most Z2Z c.Z/, the proof is complete. Since p 1, we have a 2-factor approximation algorithm. However, this is not too interesting as there is a much simpler 2-factor approximation algorithm: either set all variables true or all false, whichever is better. However, Chen, Friesen and Zheng [1999] showed that JOHNSON’S ALGORITHM FOR MAX-SAT is indeed a 3 -factor approximation algorithm. 2 If there are no one-element clauses (p 2), it is a 43 -factor approximation algorithm (by Theorem 16.28), for p 3 it is an 87 -factor approximation algorithm. Yannakakis [1994] found a 43 -factor approximation algorithm for the general case using network flow techniques. We shall describe a simpler 43 -factor approximation algorithm due to Goemans and Williamson [1994]. It is straightforward to translate MAX-SAT into an integer linear program: If we have variables X D fx1 ; : : : ; xn g, clauses Z D fZ1 ; : : : ; Zm g, and weights c1 ; : : : ; cm , we can write max

m X

cj ´j

j D1

s.t.

´j

X i Wxi 2Zj

yi ; ´j 2 f0; 1g

yi C

X

.1 yi / .j D 1; : : : ; m/

i Wxi 2Zj

.i D 1; : : : ; n; j D 1; : : : ; m/:

438

16 Approximation Algorithms

Here yi D 1 means that variable xi is true, and ´j D 1 means that clause Zj is satisfied. Now consider the LP relaxation: max

m X

cj ´j

j D1

s.t.

X

´j

i Wxi 2Zj

yi yi ´j ´j

yi C

X

.1 yi /

.j D 1; : : : ; m/ (16.6)

i Wxi 2Zj

1 0 1 0

.i D 1; : : : ; n/ .i D 1; : : : ; n/ .j D 1; : : : ; m/ .j D 1; : : : ; m/:

Let .y ; ´ / be an optimum solution of (16.6). Now independently set each variable xi true with probability yi . This step is known as randomized rounding, a technique which has been introduced by Raghavan and Thompson [1987]. The above method constitutes another randomized algorithm for MAX-SAT, which can be derandomized as above. Let rp be the random variable which is true with probability p and false otherwise.

GOEMANS-WILLIAMSON ALGORITHM FOR MAX-SAT Input: Output:

A set X D fx1 ; : : : ; xn g of variables, a family Z of clauses over X , and a weight function c W Z ! RC . A truth assignment T W X ! ftrue; falseg.

1

Solve the linear program (16.6); let .y ; ´ / be an optimum solution.

2

For k WD 1 to n do: If Exp.c.T .x1 /; : : : ; T .xk1 /; true; rykC1 ; : : : ; ryn / Exp.c.T .x1 /; : : : ; T .xk1 /; false; rykC1 ; : : : ; ryn / then set T .xk / WD true else set T .xk / WD false.

Theorem 16.29. (Goemans and Williamson [1994]) The GOEMANS-WILLIAM 1 q -factor approximation algorithm, SON A LGORITHM FOR M AX -SAT is a 1 1 1 q

where q is the maximum cardinality of a clause. Proof: Let us write sk WD Exp.c.T .x1 /; : : : ; T .xk /; rykC1 ; : : : ; ryn //

for k D 0; : : : ; n. We again have si si 1 for i D 1; : : : ; n and sn D c.T / is the total weight of clauses satisfied by our algorithm. So it remains to estimate s0 D Exp.c.Ry //, where Ry D .ry1 ; : : : ; ryn /. For j D 1; : : : ; m, the probability that the clause Zj is satisfied by Ry is

16.5

0 1@

1 0

Y

.1 yi /A @

i Wxi 2Zj

Maximum Satisfiability

Y

439

1 yi A :

i Wxi 2Zj

Since the geometric mean is always less than or equal to the arithmetic mean, this probability is at least 0

0

1@

1 @ jZj j

0

X

.1 yi / C

i Wxi 2Zj

X

11jZj j yi AA

i Wxi 2Zj

11jZj j X X 1 @ D 1 @1 yi C .1 yi /AA jZj j 0

i Wxi 2Zj

1 1

´j

i Wxi 2Zj

!jZj j

jZj j ! 1 jZj j ´j : 1 1 jZj j

To prove the last inequality, observe that for any 0 a 1 and any k 2 N ! a k 1 k 1 1 a 1 1 k k holds: both sides of the inequality are equal for a 2 f0; 1g, and the left-hand side (as a function of a) is concave, while the right-hand side is linear. So we have s0 D Exp.c.Ry // D

m X

cj Prob.Ry satisfies Zj /

j D1

! 1 jZj j ´j cj 1 1 jZj j j D1 m 1 q X 1 1 cj ´j q m X

j D1

(observe that the sequence

1

1 k k k2N

is monotonously increasing and conP verges to 1e ). Since the optimum is less than or equal to jmD1 ´j cj , the optimum value of the LP relaxation, the proof is complete. q e e Since 1 q1 < 1e , we have an e1 -factor approximation algorithm ( e1 is about 1:582).

440

16 Approximation Algorithms

We now have two similar algorithms that behave differently: the first one is better for long clauses, while the second is better for short clauses. Hence it is natural to combine them: Theorem 16.30. (Goemans and Williamson [1994]) The following is a 43 -factor approximation algorithm for MAX-SAT: run both JOHNSON’S ALGORITHM FOR MAX-SAT and the GOEMANS-WILLIAMSON ALGORITHM FOR MAX-SAT and choose the better of the two solutions. Proof: We use the notation of the above proofs. The algorithm returns a truth assignment satisfying clauses of total weight at least maxfExp.c.R//; Exp.c.Ry //g 1 Exp.c.R// C Exp.c.Ry // 2 ! jZj j ! m 1 1X 1 2jZj j cj C 1 1 ´j cj 2 jZj j j D1 jZj j ! m 1 1X 2 2jZj j 1 ´j cj 2 jZj j j D1 m

3X ´j cj : 4 j D1

k 32 for all k 2 N: for For the last inequality observe that 2 2k 1 k1 1 k 1 1 3 k k 2 f1; 2g we have equality; for Pkm 3we have 22 1 k 2 8 e > 2 . Since the optimum is at least j D1 ´j cj , the theorem is proved. Slightly better approximation algorithms for MAX-SAT (using semidefinite programming) have been found; see Goemans and Williamson [1995], Mahajan and Ramesh [1999], Feige and Goemans [1995], and Asano [2006]. The currently best known algorithm achieves a performance ratio of 1:256 (Avidor, Berkovitch and Zwick [2006]). Indeed, Bellare and Sudan [1994] showed that approximating MAX-SAT to within a factor of 74 is NP-hard. Even for MAX-3SAT (which is MAX-SAT restricted 73 to instances where each clause has exactly three literals) no approximation scheme exists (unless P D NP), as we shall show in the next section.

16.6 The PCP Theorem Many non-approximability results are based on a deep theorem which gives a new characterization of the class NP. Recall that a decision problem belongs to NP if and

16.6

The PCP Theorem

441

only if there is a polynomial-time certificate-checking algorithm. Now we consider randomized certificate-checking algorithms that read the complete instance but only a small part of the certificate to be checked. They always accept yes-instances with correct certificates but sometimes also accept no-instances. Which bits of the certificate are read is decided randomly in advance; more precisely this decision depends on the instance x and on O.log.size.x/// random bits. We now formalize this concept. If s is a string and t 2 Nk , then s t denotes the string of length k whose i -th component is the ti -th component of s (i D 1; : : : ; k). Definition 16.31. A decision problem .X; Y / belongs to the class PCP(log n,1) if there is a polynomial p and a constant k 2 N, a function n o f W .x; r/ W x 2 X; r 2 f0; 1gblog.p.size.x///c ! Nk computable in polynomial time, with f .x; r/ 2 f1; : : : ; bp.size.x//cgk for all x and r, and a decision problem .X 0 ; Y 0 / in P, where X 0 WD f.x; ; / W x 2 X; 2 f1; : : : ; bp.size.x//cgk ; 2 f0; 1gk g, such that for any instance x 2 X: If x 2 Y then there exists a c 2 f0; 1gbp.size.x//c with Prob .x; f .x; r/; cf .x;r/ /2Y 0 D 1. If x … Y then Prob .x; f .x; r/; cf .x;r/ / 2 Y 0 < 12 for all c 2 f0; 1gbp.size.x//c . Here the probability is taken over the uniform distribution of random strings r 2 f0; 1gblog.p.size.x///c . The letters “PCP” stand for “probabilistically checkable proof ”. The parameters log n and 1 reflect that, for an instance of size n, O.log n/ random bits are used and O.1/ bits of the certificate are read. For any yes-instance there is a certificate which is always accepted; while for no-instances no string is accepted as a certificate with probability 12 or more. Note that this error probability 12 can be replaced equivalently by any number between zero and one (Exercise 19). Proposition 16.32. PCP.log n; 1/ NP. Proof: Let .X; Y / 2 PCP.log n; 1/, and let p; k; f; .X 0 ; Y 0/ be given as in Defi˚ 00 nition 16.31. Let X WD .x; c/ W x 2 X; c 2 f0; 1gbp.size.x//c , and let ˚ Y 00 WD .x; c/ 2 X 00 W Prob .x; f .x; r/; cf .x;r/ / 2 Y 0 D 1 : To show that .X; Y / 2 NP it suffices to show that .X 00 ; Y 00 / 2 P. But since there are only 2blog.p.size.x///c , i.e. at most p.size.x// many strings r 2 f0; 1gblog.p.size.x///c , we can try them all. For each one we compute f .x; r/ and test whether .x; f .x; r/, cf .x;r/ / 2 Y 0 (we use that .X 0 ; Y 0 / 2 P). The overall running time is polynomial in size.x/. Now the surprising result is that these randomized verifiers, which read only a constant number of bits of the certificate, are as powerful as the standard (deterministic) certificate-checking algorithms which have the full information. This is the so-called PCP Theorem:

442

16 Approximation Algorithms

Theorem 16.33. (Arora et al. [1998]) NP D PCP.log n; 1/:

The proof of NP PCP.log n; 1/ is very difficult and beyond the scope of this book. It is based on earlier (and weaker) results of Feige et al. [1996] and Arora and Safra [1998]. For a self-contained proof of the PCP Theorem 16.33, see also Arora [1994], Hougardy, Prömel and Steger [1994], or Ausiello et al. [1999]. Stronger results were found subsequently by Bellare, Goldreich and Sudan [1998] and Hastad [2001]. For example, the number k in Definition 16.31 can be chosen to be 9. A new proof of the PCP Theorem was proposed by Dinur [2007]. We show some of its consequences for the non-approximability of combinatorial optimization problems. We start with the MAXIMUM CLIQUE PROBLEM and the MAXIMUM STABLE SET PROBLEM: given an undirected graph G, find a clique, or a stable set, of maximum cardinality in G. Recall Proposition 2.2 (and Corollary 15.24): The problems of finding a maximum clique, a maximum stable set, or a minimum vertex cover are all equivalent. However, the 2-factor approximation algorithm for the M INIMUM VERTEX COVER PROBLEM (Section 16.1) does not imply an approximation algorithm for the MAXIMUM STABLE SET PROBLEM or the M AXIMUM CLIQUE PROBLEM . Namely, it can happen that the algorithm returns a vertex cover C of size n 2, while the optimum is n2 1 (where n D jV .G/j). The complement V .G/ n C is then a stable set of cardinality 2, but the maximum stable set has cardinality n2 C 1. This example shows that transferring an algorithm to another problem via a polynomial transformation does not in general preserve its performance guarantee. We shall consider a restricted type of transformation in the next section. Here we deduce a non-approximability result for the MAXIMUM CLIQUE PROBLEM from the PCP Theorem: Theorem 16.34. (Arora and Safra [1998]) Unless P D NP there is no 2-factor approximation algorithm for the MAXIMUM CLIQUE PROBLEM. Proof: Let P D .X; Y / be some NP-complete problem. By the PCP Theorem 16.33, P 2 PCP.log n; 1/, so let p, k, f , P 0 WD .X 0 ; Y 0 / be as in Definition 16.31. For any given x 2 X we construct a graph Gx as follows. Let o n V .Gx / WD .r; a/ W r 2 f0; 1gblog.p.size.x///c ; a 2 f0; 1gk ; .x; f .x; r/; a/ 2 Y 0 (representing all “accepting runs” of the randomized certificate checking algorithm). Two vertices .r; a/ and .r 0 ; a0 / are joined by an edge if ai D aj0 whenever the i -th component of f .x; r/ equals the j -th component of f .x; r 0 /. Since P 0 2 P and there are only a polynomial number of random strings, Gx can be computed in polynomial time (and has polynomial size).

16.6

The PCP Theorem

443

If x 2 Y then by definition there exists a certificate c 2 f0; 1gbp.size.x//c such that .x; f .x; r/; cf .x;r/ / 2 Y 0 for all r 2 f0; 1gblog.p.size.x///c . Hence there is a clique of size 2blog.p.size.x///c in Gx . On the other hand, if x … Y then there is no clique of size 12 2blog.p.size.x///c in Gx : Suppose .r .1/ ; a.1/ /; : : : ; .r .t / ; a.t / / are the vertices of a clique. Then r .1/ ; : : : ; r .t / are pairwise different. We set ci WD ak.j / whenever the k-th component of f .x; r .j / / equals i , and set the remaining components of c (if any) arbitrarily. This way we obtain a certificate c with .x; f .x; r .i / /; cf .x;r .i / / / 2 Y 0 for all i D 1; : : : ; t. If x … Y we have t < 12 2blog.p.size.x///c . So any 2-factor approximation algorithm for the MAXIMUM CLIQUE PROBLEM is able to decide if x 2 Y , i.e. to solve P. Since P is NP-complete, this is possible only if P D NP. The reduction in the above proof is due to Feige et al. [1996]. Since the error probability 12 in Definition 16.31 can be replaced by any number between 0 and 1 (Exercise 19), we get that there is no -factor approximation algorithm for the MAXIMUM CLIQUE PROBLEM for any 1 (unless P D NP). With more effort Zuckerman [2007] showed that, unless P D NP, no polynomial-time algorithm computes the maximum size of a clique in any graph with n vertices up to a factor of n1 , for any fixed > 0. The best known algorithm k log3 n guarantees to find a clique of size n.log in this case (Feige [2004]). Of course, log n/2 all this also holds for the MAXIMUM STABLE SET PROBLEM (by considering the complement of the given graph). Now we turn to the following restriction of MAX-SAT:

MAX-3SAT Instance: Task:

A set X of variables and a family Z of clauses over X , each with exactly three literals. Find a truth assignment T of X such that the number of clauses in Z that are satisfied by T is maximum.

In Section 16.5 we had a simple 87 -factor approximation algorithm for M AX3SAT, even for the weighted form (Theorem 16.28). Hastad [2001] showed that this is best possible: no -factor approximation algorithm for M AX-3SAT can exist for any < 87 unless P D NP. Here we prove the following weaker result: Theorem 16.35. (Arora et al. [1998]) Unless P D NP there is no approximation scheme for MAX-3SAT. Proof: Let P D .X; Y / be some NP-complete problem. By the PCP Theorem 16.33, P 2 PCP.log n; 1/, so let p, k, f , P 0 WD .X 0 ; Y 0 / be as in Definition 16.31. For any given x 2 X we construct a 3SAT-instance Jx . Namely, for each random string r 2 f0; 1gblog.p.size.x///c we define a family Zr of 3SAT-clauses (the union of all these families will be Jx ). We first construct a family Zr0 of clauses with an arbitrary number of literals and then apply Proposition 15.21.

444

16 Approximation Algorithms

So let r 2 f0; 1gblog.p.size.x///c and f .x; r/ D .t1 ; : : : ; tk /. Let fa.1/ ; : : : ; a.sr / g be the set of strings a 2 f0; 1gk for which .x; f .x; r/; a/ 2 Y 0 . If sr D 0 then we simply set Z 0 WD ffyg; fygg, N where y is some variable not used anywhere else. Otherwise let c 2 f0; 1gbp.size.x//c . We have that .x; f .x; r/; cf .x;r/ / 2 Y 0 if and only if ! sr k _ ^ .j / c ti D ai : j D1

i D1

This is equivalent to ^ .i1 ;:::;isr /2f1;:::;kgsr

0

1 sr _ / A @ c tij D ai.j : j j D1

This conjunction of clauses can be constructed in polynomial time because P 0 2 P and k is a constant. By introducing Boolean variables 1 ; : : : ; bp.size.x//c representing the bits c1 ; : : : ; cbp.size.x//c we obtain a family Zr0 of k sr clauses (each with sr literals) such that Zr0 is satisfied if and only if .x; f .x; r/; cf .x;r/ / 2 Y 0 . By Proposition 15.21, we can rewrite each Zr0 equivalently as a conjunction of 3SAT-clauses, where the number of clauses increases by at most a factor of maxfsr 2; 4g. Let this family of clauses be Zr . Since sr 2k , each Zr consists of at most k l WD k 2 maxf2k 2; 4g 3SAT-clauses. Our 3SAT-instance Jx is the union of all the families Zr for all r. Note that Jx can be computed in polynomial time. Now if x is a yes-instance, then there exists a certificate c as in Definition 16.31. This c immediately defines a truth assignment satisfying Jx . On the other hand, if x is a no-instance, then only 12 of the formulas Zr are simultaneously satisfiable. So in this case any truth assignment leaves at least a 1 fraction of 2l of the clauses unsatisfied. 2l So any k-factor approximation algorithm for M AX-3SAT with k < 2l1 satisfies 2l1 1 more than a fraction of 2l D 1 2l of the clauses of any satisfiable instance. Hence such an algorithm can decide whether x 2 Y or not. Since P is NP-complete, such an algorithm cannot exist unless P D NP.

16.7 L-Reductions Our goal is to show, for other problems than M AX-3SAT, that they have no approximation scheme unless P D NP. As with the NP-completeness proofs (Section 15.5), it is not necessary to have a direct proof using the definition of PCP.log n; 1/ for each problem. Rather we use a certain type of reduction which preserves approximability (general polynomial transformations do not): Definition 16.36. Let PD.X; .Sx /x2X ; c; goal/ and P 0 D.X 0 ; .Sx0 /x2X 0 ; c 0 ; goal0 / be two optimization problems with nonnegative weights. An L-reduction from P to

16.7

L-Reductions

445

P 0 is a pair of functions f and g, both computable in polynomial time, and two constants ˛; ˇ > 0 such that for any instance x of P: (a) f .x/ is an instance of P 0 with OPT.f .x// ˛OPT.x/; (b) For any feasible solution y 0 of f .x/, g.x; y 0 / is a feasible solution of x such that jc.x; g.x; y 0 // OPT.x/j ˇjc 0 .f .x/; y 0 / OPT.f .x//j. We say that P is L-reducible to P 0 if there is an L-reduction from P to P 0 . The letter “L” in the term L-reduction stands for “linear”. L-reductions were introduced by Papadimitriou and Yannakakis [1991]. The definition immediately implies that L-reductions can be composed: Proposition 16.37. Let P, P 0 , P 00 be optimization problems with nonnegative weights. If .f; g; ˛; ˇ/ is an L-reduction from P to P 0 and .f 0 ; g 0 ; ˛ 0 ; ˇ 0 / is an Lreduction from P 0 to P 00 , then their composition .f 00 ; g 00 ; ˛˛ 0 ; ˇˇ 0 / is an L-reduction from P to P 00 , where f 00 .x/ D f 0 .f .x// and g 00 .x; y 00 / D g.x; g 0 .x 0 ; y 00 //. The decisive property of L-reductions is that they preserve approximability: Theorem 16.38. (Papadimitriou and Yannakakis [1991]) Let P and P 0 be two optimization problems with nonnegative weights. Let .f; g; ˛; ˇ/ be an L-reduction from P to P 0 . If there is an approximation scheme for P 0 , then there is an approximation scheme for P. Proof: Given an instance x of P and a number 0 < < 1, we apply the approx imation scheme for P 0 to f .x/ and 0 WD 2˛ˇ . We obtain a feasible solution y 0 of 0 f .x/ and finally return y WD g.x; y /, a feasible solution of x. Since jc.x; y/ OPT.x/j ˇjc 0 .f .x/; y 0 / OPT.f .x//j n ˇ max .1 C 0 /OPT.f .x// OPT.f .x//; o 1 OPT.f .x// OPT.f .x// 0 1C ˇ 0 OPT.f .x// ˛ˇ 0 OPT.x/ D OPT.x/ 2 we get c.x; y/ OPT.x/ C jc.x; y/ OPT.x/j and c.x; y/ OPT.x/ jOPT.x/ c.x; y/j

OPT.x/ 1C 2

1 1 OPT.x/ > OPT.x/; 2 1C

so this constitutes an approximation scheme for P.

This theorem together with Theorem 16.35 motivates the following definition:

446

16 Approximation Algorithms

Definition 16.39. An optimization problem P with nonnegative weights is called MAXSNP-hard if MAX-3SAT is L-reducible to P. The name MAXSNP refers to a class of optimization problems introduced by Papadimitriou and Yannakakis [1991]. Here we do not need this class, so we omit its (nontrivial) definition. Corollary 16.40. Unless P D NP there is no approximation scheme for any MAXSNP-hard problem. Proof: Directly from Theorems 16.35 and 16.38.

We shall show MAXSNP-hardness for several problems by describing Lreductions. We start with a restricted version of MAX-3SAT:

3-OCCURRENCE MAX-SAT PROBLEM Instance:

Task:

A set X of variables and a family Z of clauses over X , each with at most three literals, such that no variable occurs in more than three clauses. Find a truth assignment T of X such that the number of clauses in Z that are satisfied by T is maximum.

That this problem is NP-hard can be proved by a simple transformation from 3SAT (or MAX-3SAT), cf. Exercise 11 of Chapter 15. Since this transformation is not an L-reduction, it does not imply MAXSNP-hardness. We need a more complicated construction, using so-called expander graphs: Definition 16.41. Let G be an undirected graph and > 0 a constant. G is a -expander if for each A V .G/ with jAj jV .G/j we have j.A/j jAj. 2 For example, a complete graph is a 1-expander. However, one is interested in expanders with a small number of edges. We cite the following theorem without its quite complicated proof: Theorem 16.42. (Ajtai [1994]) There exists a positive constant such that for any given even integer n 4, a 3-regular -expander with n vertices can be constructed in O.n3 log3 n/ time. The following corollary was mentioned (and used) by Papadimitriou [1994], and a correct proof was given by Fernández-Baca and Lagergren [1998]: Corollary 16.43. For any given integer n 3, a digraph G with O.n/ vertices and a set S V .G/ of cardinality n with the following properties can be constructed in O.n3 log3 n/ time: jı .v/j C jı C .v/j 3 for each v 2 V .G/; jı .v/j C jı C .v/j D 2 for each v 2 S ; and jı C .A/j minfjS \ Aj; jS n Ajg for each A V .G/.

16.7

L-Reductions

447

l m Proof: Let > 0 be the constant of Theorem 16.42, and let k WD 1 . We first construct a 3-regular -expander H with n or n C 1 vertices, using Theorem 16.42. We replace each edge fv; wg by k parallel edges .v; w/ and k parallel edges .w; v/. Let the resulting digraph be H 0 . Note that for any A V .H 0 / with jAj jV .H 0 /j we have 2 C jıH 0 .A/j D kjıH .A/j kjH .A/j kjAj jAj:

Similarly we have for any A V .H 0 / with jAj >

jV .H 0 /j : 2

C 0 0 jıH 0 .A/j D kjıH .V .H / n A/j kjH .V .H / n A/j

kjV .H 0 / n Aj jV .H 0 / n Aj:

C 0 So in both cases we have jıH 0 .A/j minfjAj; jV .H / n Ajg. 0 Now we split up each vertex v 2 V .H / into 6kC1 vertices xv;i (i D 0; : : : ; 6k) such that each vertex except xv;0 has degree 1. For each vertex xv;i we now add vertices wv;i;j and yv;i;j (j D 0; : : : ; 6k) connected by a path of length 12k C 2 with vertices wv;i;0 ; wv;i;1 ; : : : ; wv;i;6k ; xv;i ; yv;i;0 ; : : : ; yv;i;6k in this order. Finally we add edges .yv;i;j ; wv;j;i / for all v 2 V .H 0 /, all i 2 f0; : : : ; 6kg and all j 2 f0; : : : ; 6kg n fi g. Altogether we have a vertex set Zv of cardinality .6k C 1/.12k C 3/ for each v 2 V .H 0 /. The overall resulting graph G has jV .H 0 /j.6k C 1/.12k C 3/ D O.n/ vertices, each of degree two or three. By the construction, GŒZv contains minfjX1 j; jX2 jg vertex-disjoint paths from X1 to X2 for any pair of disjoint subsets X1 ; X2 of fxv;i W i D 0; : : : ; 6kg. We choose S to be an n-element subset of fxv;0 W v 2 V .H 0 /g; note that each of these vertices has one entering and one leaving edge. It remains to prove that jı C .A/j minfjS \ Aj; jS n Ajg for each A V .G/. We prove this byS induction on jfv 2 V .H 0 / W ; 6D A \ Zv 6D Zv gj. If this number is zero, i.e. A D v2B Zv for some B V .H 0 /, then we have C C 0 jıG .A/j D jıH 0 .B/j minfjBj; jV .H / n Bjg minfjS \ Aj; jS n Ajg:

Otherwise let v 2 V .H 0 / with ; 6D A \ Zv 6D Zv . Let P WD fxv;i W i D 0; : : : ; 6kg \ A and Q WD fxv;i W i D 0; : : : ; 6kg n A. If jP j 3k, then by the property of GŒZv we have C .Zv \ A; Zv n A/j jP j D jP n S j C jP \ S j jEG

C jEG .A n Zv ; A \ Zv /j C jP \ S j:

By applying the induction hypothesis to A n Zv we therefore get C C .A/j jıG .A n Zv /j C jP \ S j jıG

minfjS \ .A n Zv /j; jS n .A n Zv /jg C jP \ S j minfjS \ Aj; jS n Ajg:

448

16 Approximation Algorithms

Similarly, if jP j 3k C 1, then jQj 3k and by the property of GŒZv we have C jEG .Zv \ A; Zv n A/j jQj D jQ n S j C jQ \ S j

C jEG .Zv n A; V .G/ n .A [ Zv //j C jQ \ S j:

By applying the induction hypothesis to A [ Zv we therefore get C C jıG .A/j jıG .A [ Zv /j C jQ \ S j

minfjS \ .A [ Zv /j; jS n .A [ Zv /jg C jQ \ S j minfjS \ Aj; jS n Ajg: Now we can prove: Theorem 16.44. (Papadimitriou and Yannakakis [1991], Papadimitriou [1994], Fernández-Baca and Lagergren [1998]) The 3-OCCURRENCE MAX-SAT PROBLEM is MAXSNP-hard. Proof: We describe an L-reduction .f; g; ˛; ˇ/ from MAX-3SAT. To define f , let .X; Z/ be an instance of MAX-3SAT. For each variable x 2 X which occurs in more than three, say in k clauses, we modify the instance as follows. We replace x by a new and distinct variable in each clause. This way we introduce new variables x1 ; : : : ; xk . We introduce additional constraints (and further variables) which ensure, roughly speaking, that it is favourable to assign the same truth value to all the variables x1 ; : : : ; xk . We construct G and S as in Corollary 16.43 and rename the vertices such that S D f1; : : : ; kg. Now for each vertex v 2 V .G/ n S we introduce a new variable xv , and for each edge .v; w/ 2 E.G/ we introduce a clause fxv ; xw g. In total we have added at most

2 3 1 1 1 .k C 1/ 6 C1 12 C 3 315 k 2 new clauses, where is again the constant of Theorem 16.42. Applying the above substitution for each variable we obtain an instance .X 0 ; Z 0 / D f .X; Z/ of the 3-OCCURRENCE MAX-SAT PROBLEM with jZ 0 j jZj C 315

2 2 1 1 3jZj 946 jZj:

Hence 2 2 1 1 OPT.X ; Z / jZ j 946 jZj 1892 OPT.X; Z/; 0

0

0

16.7

L-Reductions

449

because at least half of the clauses of a MAX-SAT-instance can be satisfied (either l m2 by setting all variables true or all false). So we can set ˛ WD 1892 1 . To describe g, let T 0 be a truth assignment of X 0 . We first construct a truth assignment T 00 of X 0 satisfying at least as many clauses of Z 0 as T 0 , and satisfying all new clauses (corresponding to edges of the graphs G above). Namely, for any variable x occurring more than three times in .X; Z/, let G be the graph constructed above, and let A WD fv 2 V .G/ W T 0 .xv / D trueg. If jS \ Aj jS n Aj then we set T 00 .xv / WD true for all v 2 V .G/, otherwise we set T 00 .xv / WD false for all v 2 V .G/. It is clear that all new clauses (corresponding to edges) are satisfied. There are at most minfjS \ Aj; jS n Ajg old clauses satisfied by T 0 but not by 00 T . On the other hand, T 0 does not satisfy any of the clauses fxv ; xw g for .v; w/ 2 C ıG .A/. By the properties of G, the number of these clauses is at least minfjS \ Aj; jS n Ajg. Now T 00 yields a truth assignment T D g.X; Z; T 0 / of X in the obvious way: Set T .x/ WD T 00 .x/ D T 0 .x/ for x 2 X \ X 0 and T .x/ WD T 00 .xi / if xi is any variable replacing x in the construction from .X; Z/ to .X 0 ; Z 0 /. T violates as many clauses as T 00 . So if c.X; Z; T / denotes the number of clauses in instance .X; Z/ that are satisfied by T , we conclude jZj c.X; Z; T / D jZ 0 j c.X 0 ; Z 0 ; T 00 / jZ 0 j c.X 0 ; Z 0 ; T 0 /:

(16.7)

On the other hand, any truth assignment T of X leads to a truth assignment T 0 of X 0 violating the same number of clauses (by setting the variables xv (v 2 V .G/) uniformly to T .x/ for each variable x and the corresponding graph G in the above construction). Hence jZj OPT.X; Z/ jZ 0 j OPT.X 0 ; Z 0 /:

(16.8)

Combining (16.7) and (16.8) we get jOPT.X; Z/ c.X; Z; T /j D .jZj c.X; Z; T // .jZj OPT.X; Z// OPT.X 0 ; Z 0 / c.X 0 ; Z 0 ; T 0 / D jOPT.X 0 ; Z 0 / c.X 0 ; Z 0 ; T 0 /j; where T D g.X; Z; T 0 /. So .f; g; ˛; 1/ is indeed an L-reduction.

This result is the starting point of several MAXSNP-hardness proofs. For example: Corollary 16.45. (Papadimitriou and Yannakakis [1991]) The MAXIMUM STABLE SET PROBLEM restricted to graphs with maximum degree 4 is MAXSNP-hard. Proof: The construction of the proof of Theorem 15.23 defines an L-reduction from the 3-OCCURRENCE MAX-SAT PROBLEM to the MAXIMUM STABLE SET PROBLEM restricted to graphs with maximum degree 4: for each instance .X; Z/

450

16 Approximation Algorithms

a graph G is constructed such that from each truth assignment satisfying k clauses one easily obtains a stable set of cardinality k, and vice versa. Indeed, the MAXIMUM STABLE SET PROBLEM is MAXSNP-hard even when restricted to 3-regular graphs (Berman and Fujito [1999]). On the other hand, a simple greedy algorithm, which in each step chooses a vertex v of minimum degree and deletes v and all its neighbours, is a .kC2/ 3 -factor approximation algorithm for the MAXIMUM STABLE SET PROBLEM in graphs with maximum degree k (Halldórsson and Radhakrishnan [1997]). For k D 4 this gives a performance ratio of 2 which is better than the ratio 8 we get from the following proof (using the 2-factor approximation algorithm for the MINIMUM VERTEX COVER PROBLEM). Theorem 16.46. (Papadimitriou and Yannakakis [1991]) The MINIMUM VERTEX COVER PROBLEM restricted to graphs with maximum degree 4 is MAXSNPhard. Proof: Consider the trivial transformation from the MAXIMUM STABLE SET PROBLEM (Proposition 2.2) with f .G/ WD G and g.G; X / WD V .G/ n X for all graphs G and all X V .G/. Although this is not an L-reduction in general, it is an L-reduction if restricted to graphs with maximum degree 4, as we shall show. If G has maximum degree 4, there exists a stable set of cardinality at least jV .G/j . 5 So if we denote by ˛.G/ the maximum cardinality of a stable set and by .G/ the minimum cardinality of a vertex cover we have ˛.G/

1 1 .jV .G/j ˛.G// D .G/ 4 4

and ˛.G/ jX j D jV .G/ n X j .G/ for any stable set X V .G/. Hence .f; g; 4; 1/ is an L-reduction. See Clementi and Trevisan [1999] and Chlebík and Chlebíková [2006] for stronger statements. In particular, there is no approximation scheme for the M INIMUM V ERTEX COVER PROBLEM (unless P D NP). We shall prove MAXSNPhardness of other problems in later chapters; see also Exercise 22.

Exercises 1. Formulate a 2-factor approximation algorithm for the following problem. Given a digraph with edge weights, find an acyclic subgraph of maximum weight. Note: No k-factor approximation algorithm for this problem is known for k R. (b) Use (a) to describe a 2-factor approximation algorithm for the k-CENTER PROBLEM. (Hochbaum and Shmoys [1985]) (c) Show that there is no r-factor approximation algorithm for the k-CENTER PROBLEM for any r < 2. Hint: Use Exercise 14 of Chapter 15. (Hsu and Nemhauser [1979]) Can one find a minimum vertex cover (or a maximum stable set) in a bipartite graph in polynomial time? Show that the performance guarantee in Theorem 16.5 is tight. Show that the following is a 2-factor approximation algorithm for the M INIMUM V ERTEX COVER PROBLEM : compute a DFS-tree and output all its vertices with nonzero out-degree. (Bar-Yehuda [unpublished]) Show that the LP relaxation minfcx W M > x 1l; x 0g of the MINIMUM WEIGHT VERTEX COVER PROBLEM, where M is the incidence matrix of an undirected graph and c 2 RVC.G/ , always has a half-integral optimum solution (i.e. one with entries 0; 12 ; 1 only). Derive another 2-factor approximation algorithm from this fact. Consider the MINIMUM WEIGHT FEEDBACK VERTEX SET PROBLEM: given an undirected graph G and weights c W V .G/ ! RC , find a vertex set X V .G/ of minimum weight such that G X is a forest. Consider the following recursive algorithm A: If E.G/ D ;, then return A.G; c/ WD ;. If jıG .x/j 1 for some x 2 V .G/, then return A.G; c/ WD A.G x; c/. If c.x/ D 0 for some x 2 V .G/, then return A.G; c/ WD fxg [ A.G x; c/. Otherwise let WD

c.v/ x2V .G/ jı.v/j min

and c 0 .v/ WD c.v/ jı.v/j (v 2 V .G/). Let X WD A.G; c 0 /. For each x 2 X do: If G .X n fxg/ is a forest, then set X WD X n fxg. Return A.G; c/ WD x. Prove that this is a 2-factor approximation algorithm for the M INIMUM WEIGHT FEEDBACK VERTEX SET PROBLEM. (Becker and Geiger [1996]) 8. Show that the MAXIMUM CUT PROBLEM is NP-hard even for simple graphs. 9. Prove that the simple greedy algorithm for MAX-CUT described at the beginning of Section 16.2 is a 2-factor approximation algorithm. 10. Consider the following local search algorithm for the MAXIMUM CUT PROBLEM. Start with any nonempty proper subset S of V .G/. Now check iteratively if some vertex can be added to S or deleted from S such that jı.S /j increases. Stop if no such improvement is possible. (a) Prove that the above is a 2-factor approximation algorithm. (Recall Exercise 13 of Chapter 2.)

452

16 Approximation Algorithms

(b) Can the algorithm be extended to the MAXIMUM WEIGHT CUT PROBLEM, where we have nonnegative edge weights? (c) Does the algorithm always find an optimum solution for planar graphs, or for bipartite graphs? For both classes there is a polynomial-time algorithm (Exercise 7 of Chapter 12 and Proposition 2.27). 11. In the DIRECTED MAXIMUM WEIGHT CUT PROBLEM we are given a digraph G with P weights c W E.G/ ! RC , and we look for a set X V .G/ such that e2ı C .X/ c.e/ is maximum. Show that there is a 4-factor approximation algorithm for this problem. Hint: Use Exercise 10. Note: There is a 1.165-factor but no 1.09-factor approximation algorithm unless P D NP (Feige and Goemans [1995], Hastad [2001]). 12. Show that . 1 arccos.yi> yj //1i;j n is a convex combination of cut semimetrics R R D 1 if jR \ fi; j gj D 1 and ıi;j D 0 otherwise. ı R , R f1; : : : ; ng, where ıi;j Hint: Write 0 1 X \ [ ..H.yi /4H.yj ///1i;j n D @ H.yi / n H.yi /A ı R : Rf1;:::;ng

i 2R

i …R

Note: See Deza and Laurent [1997] for a lot of related information. 13. Show that for each n 2 N there is a bipartite graph on 2n vertices for which the GREEDY COLOURING ALGORITHM needs n colours. So the algorithm may give arbitrarily bad results. However, show that there always exists an order of the vertices for which the algorithm finds an optimum colouring. p 14. Show that one can colour any 3-colourable graph G with at most 2 2n colours in polynomial time, where n WD jV .G/j. p Hint: As long as there is a vertex v of degree at least 2n, colour .v/ optimally with at most two colours (not to be used again), and delete these vertices. Finally use the GREEDY COLOURING ALGORITHM. (Wigderson [1983]) 15. Show that the following graphs are perfect: (a) bipartite graphs; (b) interval graphs: .fv1 ; : : : ; vn g; ffvi ; vj g W i 6D j; Œai ; bi \ Œaj ; bj 6D ;g/, where Œa1 ; b1 ; : : : ; Œan ; bn is a set of closed intervals; (c) chordal graphs (see Exercise 36 of Chapter 8). 16. Let G be an undirected graph. Prove that the following statements are equivalent: (a) G is perfect. (b) For any weight function c W V .G/ ! ZC the maximum weight of a clique in G equals the minimum number of stable sets such that each vertex v is contained in c.v/ of them. (c) For any weight function c W V .G/ ! ZC the maximum weight of a stable set in G equals the minimum number of cliques such that each vertex v is contained in c.v/ of them. (d) The inequality system defining (16.3) is TDI.

Exercises

453

(e) The clique polytope of G, i.e. the convex hull of the incidence vectors of all cliques in G, is given by ( ) X V .G/ x 2 RC W xv 1 for all stable sets S in G : (16.9) v2S

(f) The inequality system defining (16.9) is TDI. Note: The polytope (16.9) is called the antiblocker of the polytope (16.3). 17. An instance of MAX-SAT is called k-satisfiable if any k of its clauses can be simultaneously satisfied. Let rk be the infimum of the fraction of clauses that one can satisfy in any k-satisfiable instance. (a) Prove that r1 D 12 . p

18.

19.

20.

21. 22.

(b) Prove that r2 D 51 2 . (Hint: Some variables occur in one-element clauses (w.l.o.g. all oneelement clauses are positive), set them true with probability a (for some 1 1 2 < a < 1), and set the other variables true with probability 2 . Apply the derandomization technique and choose a appropriately.) (c) Prove that r3 23 . (Lieberherr and Specker [1981]) Erd˝os [1967] showed the following: for each constant k 2 N, the (asymptotically) best fraction of the edges that we can guarantee to be in a maximum cut is 12 , even if we restrict attention to graphs without odd circuits of length k or less. (Compare Exercise 10(a).) (a) What about k D 1? (b) Show how the MAXIMUM CUT PROBLEM can be reduced to MAX-SAT. Hint: Use a variable for each vertex and two clauses fx; yg; fx; N yg N for each edge fx; yg. (c) Use (b) and Erd˝os’ Theorem in order to prove that rk 34 for all k. (For a definition of rk , see Exercise 17.) Note: Trevisan [2004] proved that limk!1 rk D 34 . Prove that the error probability 12 in Definition 16.31 can be replaced equivalently by any number between 0 and 1. Deduce from this (and the proof of Theorem 16.34) that there is no -factor approximation algorithm for the M AXIMUM CLIQUE PROBLEM for any 1 (unless P D NP). Prove that the MAXIMUM CLIQUE PROBLEM is L-reducible to the SET PACKING PROBLEM : given a set system .U; S/, find a maximum cardinality subfamily R S whose elements are pairwise disjoint. Prove that the M INIMUM VERTEX COVER PROBLEM has no absolute approximation algorithm (unless P D NP). Prove that MAX-2SAT is MAXSNP-hard. Hint: Use Corollary 16.45. (Papadimitriou and Yannakakis [1991])

454

16 Approximation Algorithms

References General Literature: Asano, T., Iwama, K., Takada, H., and Yamashita, Y. [2000]: Designing high-quality approximation algorithms for combinatorial optimization problems. IEICE Transactions on Communications/Electronics/Information and Systems E83-D (2000), 462–478 Ausiello, G., Crescenzi, P., Gambosi, G., Kann, V., Marchetti-Spaccamela, A., and Protasi, M. [1999]: Complexity and Approximation: Combinatorial Optimization Problems and Their Approximability Properties. Springer, Berlin 1999 Garey, M.R., and Johnson, D.S. [1979]: Computers and Intractability; A Guide to the Theory of NP-Completeness. Freeman, San Francisco 1979, Chapter 4 Hochbaum, D.S. [1996]: Approximation Algorithms for NP-Hard Problems. PWS, Boston, 1996 Horowitz, E., and Sahni, S. [1978]: Fundamentals of Computer Algorithms. Computer Science Press, Potomac 1978, Chapter 12 Shmoys, D.B. [1995]: Computing near-optimal solutions to combinatorial optimization problems. In: Combinatorial Optimization; DIMACS Series in Discrete Mathematics and Theoretical Computer Science 20 (W. Cook, L. Lovász, P. Seymour, eds.), AMS, Providence 1995 Papadimitriou, C.H. [1994]: Computational Complexity, Addison-Wesley, Reading 1994, Chapter 13 Vazirani, V.V. [2001]: Approximation Algorithms. Springer, Berlin, 2001 Williamson, D.P., and Shmoys, D.B. [2011]: The Design of Approximation Algorithms. Cambridge University Press, Cambridge 2011

Cited References: Ajtai, M. [1994]: Recursive construction for 3-regular expanders. Combinatorica 14 (1994), 379–416 Alizadeh, F. [1995]: Interior point methods in semidefinite programming with applications to combinatorial optimization. SIAM Journal on Optimization 5 (1995), 13–51 Appel, K., and Haken, W. [1977]: Every planar map is four colorable; Part I; Discharging. Illinois Journal of Mathematics 21 (1977), 429–490 Appel, K., Haken, W., and Koch, J. [1977]: Every planar map is four colorable; Part II; Reducibility. Illinois Journal of Mathematics 21 (1977), 491–567 Arora, S. [1994]: Probabilistic checking of proofs and the hardness of approximation problems, Ph.D. thesis, U.C. Berkeley, 1994 Arora, S., Lund, C., Motwani, R., Sudan, M., and Szegedy, M. [1998]: Proof verification and hardness of approximation problems. Journal of the ACM 45 (1998), 501–555 Arora, S., and Safra, S. [1998]: Probabilistic checking of proofs. Journal of the ACM 45 (1998), 70–122 Asano, T. [2006]: An improved analysis of Goemans and Williamson’s LP-relaxation for MAX SAT. Theoretical Computer Science 354 (2006), 339–353 Avidor, A., Berkovitch, I., and Zwick, U. [2006]: Improved approximation algorithms for MAX NAE-SAT and MAX SAT. Approximation and Online Algorithms – Proceedings of the 3rd WAOA workshop (2005); LNCS 3879 (Erlebach, T., Persiano, G., eds.), Springer, Berlin 2006, pp. 27–40 Bar-Yehuda, R., and Even, S. [1981]: A linear-time approximation algorithm for the weighted vertex cover problem. Journal of Algorithms 2 (1981), 198–203

References

455

Becker, A., and Geiger, D. [1996]: Optimization of Pearl’s method of conditioning and greedy-like approximation algorithms for the vertex feedback set problem. Artificial Intelligence Journal 83 (1996), 1–22 Bellare, M., and Sudan, M. [1994]: Improved non-approximability results. Proceedings of the 26th Annual ACM Symposium on the Theory of Computing (1994), 184–193 Bellare, M., Goldreich, O., and Sudan, M. [1998]: Free bits, PCPs and nonapproximability – towards tight results. SIAM Journal on Computing 27 (1998), 804–915 Berge, C. [1961]: Färbung von Graphen, deren sämtliche bzw. deren ungerade Kreise starr sind. Wissenschaftliche Zeitschrift, Martin Luther Universität Halle-Wittenberg, Mathematisch-Naturwissenschaftliche Reihe (1961), 114–115 Berge, C. [1962]: Sur une conjecture relative au problème des codes optimaux. Communication, 13ème assemblée générale de l’URSI, Tokyo 1962 Berman, P., and Fujito, T. [1999]: On approximation properties of the independent set problem for low degree graphs. Theory of Computing Systems 32 (1999), 115–132 Brooks, R.L. [1941]: On colouring the nodes of a network. Proceedings of the Cambridge Philosophical Society 37 (1941), 194–197 Chen, J., Friesen, D.K., and Zheng, H. [1999]: Tight bound on Johnson’s algorithm for maximum satisfiability. Journal of Computer and System Sciences 58 (1999), 622–640 Chlebík, M. and Chlebíková, J. [2006]: Complexity of approximating bounded variants of optimization problems. Theoretical Computer Science 354 (2006), 320-338 Chudnovsky, M., Cornuéjols, G., Liu, X., Seymour, P., and Vu˘skovi´c, K. [2005]: Recognizing Berge graphs. Combinatorica 25 (2005), 143–186 Chudnovsky, M., Robertson, N., Seymour, P., and Thomas, R. [2006]: The strong perfect graph theorem. Annals of Mathematics 164 (2006), 51–229 Chvátal, V. [1975]: On certain polytopes associated with graphs. Journal of Combinatorial Theory B 18 (1975), 138–154 Chvátal, V. [1979]: A greedy heuristic for the set cover problem. Mathematics of Operations Research 4 (1979), 233–235 Clementi, A.E.F., and Trevisan, L. [1999]: Improved non-approximability results for minimum vertex cover with density constraints. Theoretical Computer Science 225 (1999), 113–128 Deza, M.M., and Laurent, M. [1997]: Geometry of Cuts and Metrics. Springer, Berlin 1997 Dinur, I. [2007]: The PCP theorem by gap amplification. Journal of the ACM 54 (2007), Article 12 Dinur, I., and Safra, S. [2002]: On the hardness of approximating minimum vertex cover. Annals of Mathematics 162 (2005), 439–485 Erd˝os, P. [1967]: On bipartite subgraphs of graphs. Mat. Lapok. 18 (1967), 283–288 Feige, U. [1998]: A threshold of ln n for approximating set cover. Journal of the ACM 45 (1998), 634–652 Feige, U. [2004]: Approximating maximum clique by removing subgraphs. SIAM Journal on Discrete Mathematics 18 (2004), 219–225 Feige, U., and Goemans, M.X. [1995]: Approximating the value of two prover proof systems, with applications to MAX 2SAT and MAX DICUT. Proceedings of the 3rd Israel Symposium on Theory of Computing and Systems (1995), 182–189 Feige, U., Goldwasser, S., Lovász, L., Safra, S., and Szegedy, M. [1996]: Interactive proofs and the hardness of approximating cliques. Journal of the ACM 43 (1996), 268–292 Fernández-Baca, D., and Lagergren, J. [1998]: On the approximability of the Steiner tree problem in phylogeny. Discrete Applied Mathematics 88 (1998), 129–145

456

16 Approximation Algorithms

Fulkerson, D.R. [1972]: Anti-blocking polyhedra. Journal of Combinatorial Theory B 12 (1972), 50–71 Fürer, M., and Raghavachari, B. [1994]: Approximating the minimum-degree Steiner tree to within one of optimal. Journal of Algorithms 17 (1994), 409–423 Garey, M.R., and Johnson, D.S. [1976]: The complexity of near-optimal graph coloring. Journal of the ACM 23 (1976), 43–49 Garey, M.R., Johnson, D.S., and Stockmeyer, L. [1976]: Some simplified NP-complete graph problems. Theoretical Computer Science 1 (1976), 237–267 Goemans, M.X., and Williamson, D.P. [1994]: New 3/4-approximation algorithms for the maximum satisfiability problem. SIAM Journal on Discrete Mathematics 7 (1994), 656–666 Goemans, M.X., and Williamson, D.P. [1995]: Improved approximation algorithms for maximum cut and satisfiability problems using semidefinite programming. Journal of the ACM 42 (1995), 1115–1145 Grötschel, M., Lovász, L., and Schrijver, A. [1988]: Geometric Algorithms and Combinatorial Optimization. Springer, Berlin 1988 Halldórsson, M.M., and Radhakrishnan, J. [1997]: Greed is good: approximating independent sets in sparse and bounded degree graphs. Algorithmica 18 (1997), 145–163 Hastad, J. [2001]: Some optimal inapproximability results. Journal of the ACM 48 (2001), 798–859 Heawood, P.J. [1890]: Map colour theorem. Quarterly Journal of Pure Mathematics 24 (1890), 332–338 Hochbaum, D.S. [1982]: Approximation algorithms for the set covering and vertex cover problems. SIAM Journal on Computing 11 (1982), 555–556 Hochbaum, D.S., and Shmoys, D.B. [1985]: A best possible heuristic for the k-center problem. Mathematics of Operations Research 10 (1985), 180–184 Holyer, I. [1981]: The NP-completeness of edge-coloring. SIAM Journal on Computing 10 (1981), 718–720 Hougardy, S., Prömel, H.J., and Steger, A. [1994]: Probabilistically checkable proofs and their consequences for approximation algorithms. Discrete Mathematics 136 (1994), 175–223 Hsu, W.L., and Nemhauser, G.L. [1979]: Easy and hard bottleneck location problems. Discrete Applied Mathematics 1 (1979), 209–216 Johnson, D.S. [1974]: Approximation algorithms for combinatorial problems. Journal of Computer and System Sciences 9 (1974), 256–278 Khanna, S., Linial, N., and Safra, S. [2000]: On the hardness of approximating the chromatic number. Combinatorica 20 (2000), 393–415 Khot, S., and Regev, O. [2008]: Vertex cover might be hard to approximate to within 2 . Journal of Computer and System Sciences 74 (2008), 335–349 Knuth, D.E. [1969]: The Art of Computer Programming; Vol. 2. Seminumerical Algorithms. Addison-Wesley, Reading 1969 (third edition: 1997) König, D. [1916]: Über Graphen und ihre Anwendung auf Determinantentheorie und Mengenlehre. Mathematische Annalen 77 (1916), 453–465 Lieberherr, K., and Specker, E. [1981]: Complexity of partial satisfaction. Journal of the ACM 28 (1981), 411–421 Lovász, L. [1972]: Normal hypergraphs and the perfect graph conjecture. Discrete Mathematics 2 (1972), 253–267 Lovász, L. [1975]: On the ratio of optimal integral and fractional covers. Discrete Mathematics 13 (1975), 383–390

References

457

Lovász, L. [1979a]: On the Shannon capacity of a graph. IEEE Transactions on Information Theory 25 (1979), 1–7 Lovász, L. [1979b]: Graph theory and integer programming. In: Discrete Optimization I; Annals of Discrete Mathematics 4 (P.L. Hammer, E.L. Johnson, B.H. Korte, eds.), NorthHolland, Amsterdam 1979, pp. 141–158 Lovász, L. [2003]: Semidefinite programs and combinatorial optimization. In: Recent Advances in Algorithms and Combinatorics (B.A. Reed, C. Linhares Sales, eds.), Springer, New York 2003, pp. 137–194 Mahajan, S., and Ramesh, H. [1999]: Derandomizing approximation algorithms based on semidefinite programming. SIAM Journal on Computing 28 (1999), 1641–1663 Papadimitriou, C.H., and Steiglitz, K. [1982]: Combinatorial Optimization; Algorithms and Complexity. Prentice-Hall, Englewood Cliffs 1982, pp. 406–408 Papadimitriou, C.H., and Yannakakis, M. [1991]: Optimization, approximation, and complexity classes. Journal of Computer and System Sciences 43 (1991), 425–440 Papadimitriou, C.H., and Yannakakis, M. [1993]: The traveling salesman problem with distances one and two. Mathematics of Operations Research 18 (1993), 1–12 Raghavan, P., and Thompson, C.D. [1987]: Randomized rounding: a technique for provably good algorithms and algorithmic proofs. Combinatorica 7 (1987), 365–374 Raz, R., and Safra, S. [1997]: A sub constant error probability low degree test, and a sub constant error probability PCP characterization of NP. Proceedings of the 29th Annual ACM Symposium on Theory of Computing (1997), 475–484 Robertson, N., Sanders, D.P., Seymour, P., and Thomas, R. [1996]: Efficiently four-coloring planar graphs. Proceedings of the 28th Annual ACM Symposium on the Theory of Computing (1996), 571–575 Robertson, N., Sanders, D.P., Seymour, P., and Thomas, R. [1997]: The four colour theorem. Journal of Combinatorial Theory B 70 (1997), 2–44 Sanders, P., and Steurer, D. [2008]: An asymptotic approximation scheme for multigraph edge coloring. ACM Transactions on Algorithms 4 (2008), Article 21 Singh, M. and Lau, L.C. [2007]: Approximating minimum bounded degree spanning trees to within one of optimal. Proceedings of the 39th Annual ACM Symposium on Theory of Computing (2007), 661–670 Slavík, P. [1997]: A tight analysis of the greedy algorithm for set cover. Journal of Algorithms 25 (1997), 237–254 Stockmeyer, L.J. [1973]: Planar 3-colorability is polynomial complete. ACM SIGACT News 5 (1973), 19–25 Trevisan, L. [2004]: On local versus global satisfiability. SIAM Journal on Discrete Mathematics 17 (2004), 541–547 Vizing, V.G. [1964]: On an estimate of the chromatic class of a p-graph. Diskret. Analiz 3 (1964), 23–30 [in Russian] Wigderson, A. [1983]: Improving the performance guarantee for approximate graph coloring. Journal of the ACM 30 (1983), 729–735 Yannakakis, M. [1994]: On the approximation of maximum satisfiability. Journal of Algorithms 17 (1994), 475–502 Zuckerman, D. [2007]: Linear degree extractors and the inapproximability of Max Clique and Chromatic Number. Theory of Computing 3 (2007), 103–128

•

17 The Knapsack Problem

The MINIMUM WEIGHT PERFECT MATCHING PROBLEM and the WEIGHTED MATROID INTERSECTION PROBLEM discussed in earlier chapters are among the “hardest" problems for which a polynomial-time algorithm is known. In this chapter we deal with the following problem which turns out to be, in a sense, the “easiest" NP-hard problem:

KNAPSACK PROBLEM Instance: Task:

Nonnegative integers n, c1 ; : : : ; cn , w1 ; : : : ; wn and W . P P Find a subset S f1; : : : ; ng such that j 2S wj W and j 2S cj is maximum.

Applications arise whenever we want to select an optimum subset of bounded weight from a set of elements each of which has a weight and a profit. We start by considering the fractional version in Section 17.1, which turns out to be solvable in linear time. The integral knapsack problem is NP-hard as shown in Section 17.2, but a pseudopolynomial algorithm solves it optimally. Combined with a rounding technique this can be used to design a fully polynomial approximation scheme, which is the subject of Section 17.3. In Section 17.4 we discuss a multidimensional generalization.

17.1 Fractional Knapsack and Weighted Median Problem We consider the following problem:

FRACTIONAL KNAPSACK PROBLEM Instance: Task:

Nonnegative integers n, c1 ; : : : ; cn , w1 ; : : : ; wn and W . P Find numbers x1 ; : : : ; xn 2 Œ0; 1 such that jnD1 xj wj W and Pn j D1 xj cj is maximum.

The following observation suggests a simple algorithm which requires sorting the elements appropriately: Proposition 17.1. (Dantzig P [1957]) Let c1 ; : : : ; cn , w1 ; : : : ; wn and W be nonnegative integers with niD1 wi > W , f1 i n W wi D 0g D f1; : : : ; hg, B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__17, c Springer-Verlag Berlin Heidelberg 2012

459

460

17 The Knapsack Problem

and

chC2 cn chC1 ; whC1 whC2 wn

and let

( k WD min j 2 f1; : : : ; ng W

j X

) wi > W

:

i D1

Then an optimum solution of the given instance of the FRACTIONAL KNAPSACK PROBLEM is defined by xj WD 1 xk WD

W

Pk1 j D1

for j D 1; : : : ; k 1; wj

wk

xj WD 0

; for j D k C 1; : : : ; n:

Sorting the elements takes O.n log n/ time (Theorem 1.5), and computing k can be done in O.n/ time by simple linear scanning. Although this algorithm is quite fast, one can do even better. Observe that the problem reduces to a weighted median search: DefinitionP 17.2. Let n 2 N, ´1 ; : : : ; ´n 2 R, w1 ; : : : ; wn 2 RC and W 2 R with 0 < W niD1 wi . Then the .w1 ; : : : ; wn I W /-weighted median with respect to .´1 ; : : : ; ´n / is defined to be the unique number ´ for which X X wi < W wi : i W´i ´m for i D l C 1; : : : ; n.

4

If

k X i D1

If

l X

wi < W

l X

wi then stop (´ WD ´m ).

i D1

l X wi < W then find recursively the wlC1 ; : : : ; wn I W wi -

i D1

i D1

weighted median with respect to .´lC1 ; : : : ; ´n /. Stop. k X If wi W then find recursively the w1 ; : : : ; wk I W -weighted i D1

median with respect to .´1 ; : : : ; ´k /. Stop. Theorem 17.3. The WEIGHTED MEDIAN ALGORITHM works correctly and takes O.n/ time only. Proof: The correctness is easily checked. Let us denote the worst-case running time for n elements by f .n/. We obtain l m l n m 1 lnm 1 n f .n/ D O.n/ C f C O.n/ C f 5C 2 ; 5 2 5 2 5 because the recursive call in 4 omits at least three elements out of at least half of the five-element blocks. The above recursion formula yields f .n/ D O.n/: ˙n as 9 9 7 9 n for all n 37, one obtains f .n/ cn C f n C f n for a 5 41 41 2 41 suitable c and n 37. Given this, f .n/ .82c C f .36//n can be verified easily by induction. So indeed the overall running time is linear. We immediately obtain the following corollaries: Corollary 17.4. (Blum et al. [1973]) The SELECTION PROBLEM can be solved in O.n/ time.

462

17 The Knapsack Problem

Proof: Set wi WD 1 for i D 1; : : : ; n and W WD k and apply Theorem 17.3.

Corollary 17.5. The FRACTIONAL KNAPSACK PROBLEM can be solved in linear time. Proof: Setting ´i WD wcii (i D 1; : : : ; n) reduces the FRACTIONAL KNAPSACK PROBLEM to the WEIGHTED MEDIAN PROBLEM.

17.2 A Pseudopolynomial Algorithm We now turn to the (integral) KNAPSACK PROBLEM. The techniques of the previous section are also of some use here: Proposition 17.6. Let c1 ; :P : : ; cn , w1 ; : : : ; wn and W be nonnegative integers with wj W for j D 1; : : : ; n, niD1 wi > W , and c1 c2 cn : w1 w2 wn Let

( k WD min j 2 f1; : : : ; ng W

j X

) wi > W

:

i D1

Then choosing the better of the two feasible solutions f1; : : : ; k 1g and fkg constitutes a 2-factor approximation algorithm for the KNAPSACK PROBLEM with running time O.n/. Proof: Given any instance of the KNAPSACK PROBLEM, elementsPi 2 f1; : : : ; ng with wi > W are of no use and can be deleted beforehand. Now if niD1 wi W , then f1; : : : ; ng is an optimum solution. Otherwise we compute the number k in O.n/ time without sorting: this is just a WEIGHTED MEDIAN PROBLEM as above (Theorem 17.3). P By Proposition 17.1, kiD1 ci is an upper bound on the optimum value of the FRACTIONAL KNAPSACK PROBLEM, hence also for the integral KNAPSACK PROBLEM. Therefore the better of the two feasible solutions f1; : : : ; k 1g and fkg achieves at least half the optimum value. But we are more interested in an exact solution of the KNAPSACK PROBLEM. However, we have to make the following observation: Theorem 17.7. (Karp [1972]) The KNAPSACK PROBLEM is NP-hard. Proof: We prove that the related decision problem defined as follows is NPcomplete: given nonnegative integers ; : : : ; wn , W and K, is there P n, c1 ; : : : ; cn , w1P a subset S f1; : : : ; ng such that j 2S wj W and j 2S cj K ? This decision problem obviously belongs to NP. To show that it is NPcomplete, we transform SUBSET-SUM (see Corollary 15.27) to it. Given an instance

17.2

A Pseudopolynomial Algorithm

463

c1 ; : : : ; cn ; K of SUBSET-SUM, define wj WD cj .j D 1; : : : ; n/ and W WD K. Obviously this yields an equivalent instance of the above decision problem. Since we have not shown the KNAPSACK PROBLEM to be strongly NP-hard there is hope for a pseudopolynomial algorithm. Indeed, the algorithm given in the proof of Theorem 15.39 can easily be generalized by introducing weights on the edges and solving a shortest path problem. This leads to an algorithm with running time O.nW / (Exercise 3). By a similar P trick we can also get an algorithm with an O.nC / running time, where C WD jnD1 cj . We describe this algorithm in a direct way, without constructing a graph and referring to shortest paths. Since the algorithm is based on simple recursion formulas we speak of a dynamic programming algorithm. It is basically due to Bellman [1956,1957] and Dantzig [1957].

DYNAMIC PROGRAMMING KNAPSACK ALGORITHM Input: Output:

Nonnegative integers n, c1 ; : : : ; cn , w1 ; : : : ; wn and W . P P A subset S f1; : : : ; ng such that j 2S wj W and j 2S cj is maximum.

1

Let C bePany upper bound on the value of the optimum solution, e.g. C WD jnD1 cj .

2

Set x.0; 0/ WD 0 and x.0; k/ WD 1 for k D 1; : : : ; C .

3

For j WD 1 to n do: For k WD 0 to C do: Set s.j; k/ WD 0 and x.j; k/ WD x.j 1; k/. For k WD cj to C do: If x.j 1; k cj / C wj minfW; x.j; k/g then: Set x.j; k/ WD x.j 1; k cj / C wj and s.j; k/ WD 1.

4

Let k D maxfi 2 f0; : : : ; C g W x.n; i / < 1g. Set S WD ;. For j WD n down to 1 do: If s.j; k/ D 1 then set S WD S [ fj g and k WD k cj .

Theorem 17.8. The DYNAMIC PROGRAMMING KNAPSACK ALGORITHM finds an optimum solution in O.nC / time. Proof: The running time is obvious. The variablePx.j; k/ denotes thePminimum total weight of a subset S f1; : : : ; j g with i 2S wi W and i 2S ci D k. The algorithm correctly computes these values using the recursion formulas 8 ˆ <x.j 1; k cj / C wj if cj k and x.j; k/ D x.j 1; k cj / C wj minfW; x.j 1; k/g ˆ : x.j 1; k/ otherwise

464

17 The Knapsack Problem

for j D 1; : : : ; n and k D 0; : : : ; C . The variables s.j; k/ indicate which of these two cases applies. So the algorithm enumerates all subsets S f1; : : : ; ng except those that are infeasible or those by others: P P that are dominated P P S is said to be dominated by S 0 if j 2S cj D j 2S 0 cj and j 2S wj j 2S 0 wj . In 4 the best feasible subset is chosen. P Of course it is desirable to have a better upper bound C than niD1 ci . For example, the 2-factor approximation algorithm of Proposition 17.6 can be run; multiplying the value of the returned solution by 2 yields an upper bound on the optimum value. We shall use this idea later. The O.nC /-bound is not polynomial in the size of the input, because the input size can only be bounded by O.n log C C n log W / (we may assume that wj W for all j ). But we have a pseudopolynomial algorithm which can be quite efficient if the numbers involved are not too large. If both the weights w1 ; : : : ; wn and the profits c1 ; : : : ; cn are small, the O.ncmax wmax /-algorithm of Pisinger [1999] is the fastest one (cmax WD maxfc1 ; : : : ; cn g, wmax WD maxfw1 ; : : : ; wn g).

17.3 A Fully Polynomial Approximation Scheme In this section we investigate approximation algorithms for the KNAPSACK PROBLEM. By Proposition 16.23, the KNAPSACK PROBLEM has no absolute approximation algorithm unless P D NP. However, we shall prove that the KNAPSACK PROBLEM has a fully polynomial approximation scheme. The first such algorithm was found by Ibarra and Kim [1975]. Since the running time of the DYNAMIC PROGRAMMING KNAPSACK ALGORITHM depends on C , it is a natural idea to divide all numbers c1 ; : : : ; cn by 2 and round them down. This will reduce the running time, but may lead to inaccurate solutions. More generally, setting jc k j cNj WD .j D 1; : : : ; n/ t will reduce the running time by a factor t. Trading accuracy for runningPtime is typical for approximation schemes. For S f1; : : : ; ng we write c.S / WD i 2S ci .

KNAPSACK APPROXIMATION SCHEME Input: Output:

1

Nonnegative integers n, c1 ; : : : ; cn , w1 ; : : : ; wn and W . A number > 0. P A subset S f1; : : : ; ng such that j 2S wj W and c.S / P 1 0 0 j 2S 0 wj W . 1C c.S / for all S f1; : : : ; ng with

Run the 2-factor approximation algorithm of Proposition 17.6. Let S1 be the solution obtained. If c.S1 / D 0 then set S WD S1 and stop.

17.3

n

2 3

4

A Fully Polynomial Approximation Scheme

465

o

1/ . Set t WD max 1; c.S n cj ˘ Set cNj WD t for j D 1; : : : ; n.

Apply the DYNAMIC PROGRAMMING KNAPSACK ALGORITHM to the 1/ . Let S2 be the instance .n; cN1 ; : : : ; cNn ; w1 ; : : : ; wn ; W /; set C WD 2c.S t solution obtained. If c.S1 / > c.S2 / then set S WD S1 , else set S WD S2 .

Theorem 17.9. (Ibarra and Kim [1975], Sahni [1976], Gens and Levner [1979]) The KNAPSACK APPROXIMATION SCHEME is a fully polynomial approximation scheme for the KNAPSACK PROBLEM; its running time is O n2 1 . Proof: If the algorithm stops in 1 then S1 is optimal by Proposition 17.6. So we now assume c.S1 / > 0. Let S be an optimum solution of the original instance. Since 2c.S1 / c.S / by Proposition 17.6, C in 3 is a correct upper bound on the value of the optimum solution of the rounded instance. So by Theorem 17.8, S2 is an optimum solution of the rounded instance. Hence we have: X X X X X X cj t cNj D t cNj t cNj D t cNj > .cj t/ j 2S2

j 2S2

j 2S2

j 2S

j 2S

j 2S

c.S / nt: If t D 1, then S2 is optimal by Theorem 17.8. Otherwise the above inequality implies c.S2 / c.S / c.S1 /, and we conclude that .1 C /c.S / c.S2 / C c.S1 / c.S /: So we have a .1 C /-factor approximation algorithm for any fixed > 0. By Theorem 17.8 the running time of 3 can be bounded by nc.S1 / 2 1 O.nC / D O D O n : t The other steps can easily be done in O.n/ time.

Lawler [1979] found a similar fully polynomial approximation scheme whose running time is O n log 1 C 14 . This was improved by Kellerer and Pferschy [2004]. Unfortunately there are not many problems that have a fully polynomial approximation scheme. To state this more precisely, we consider the MAXIMIZATION PROBLEM FOR I NDEPENDENCE SYSTEMS . What we have used in our construction of the DYNAMIC PROGRAMMING KNAPSACK ALGORITHM and the KNAPSACK APPROXIMATION SCHEME is a certain dominance relation. We generalize this concept as follows:

466

17 The Knapsack Problem

Definition 17.10. Given an independence system .E; F/, a cost function c W E ! ZC , subsets S1 ; S2 E, and > 0. S1 -dominates S2 if 1 c.S1 / c.S2 / .1 C / c.S1 / 1C and there is a basis B1 with S1 B1 such that for each basis B2 with S2 B2 we have .1 C / c.B1 / c.B2 /:

-DOMINANCE PROBLEM An independence system .E; F/, a cost function c W E ! ZC , a number > 0, and two subsets S1 ; S2 E. Question: Does S1 -dominate S2 ?

Instance:

Of course the independence system is given by some oracle, e.g. an independence oracle. The DYNAMIC PROGRAMMING KNAPSACK ALGORITHM made frequent use of 0-dominance. It turns out that the existence of an efficient algorithm for the -DOMINANCE PROBLEM is essential for a fully polynomial approximation scheme. Theorem 17.11. (Korte and Schrader [1981]) Let I be a family of independence systems. Let I 0 be the family of instances .E; F ; c/ of the MAXIMIZATION PROBLEM FOR I NDEPENDENCE SYSTEMS with .E; F / 2 I and c W E ! ZC , and let I 00 be the family of instances .E; F ; c; ; S1 ; S2 / of the -DOMINANCE PROBLEM with .E; F / 2 I. Then there exists a fully polynomial approximation scheme for the MAXIMIZATION PROBLEM FOR I NDEPENDENCE SYSTEMS restricted to I 0 if and only if there exists an algorithm for the -DOMINANCE PROBLEM restricted to I 00 whose running time is bounded by a polynomial in the length of the input and 1 . While the sufficiency is proved by generalizing the KNAPSACK APPROXIMASCHEME (Exercise 10), the proof of the necessity is rather involved and not presented here. The conclusion is that if a fully polynomial approximation scheme exists at all, then a modification of the KNAPSACK APPROXIMATION SCHEME does the job. See also Woeginger [2000] for a similar result. To prove that for a certain optimization problem there is no fully polynomial approximation scheme, the following theorem is often more useful: TION

Theorem 17.12. (Garey and Johnson [1978]) A strongly NP-hard optimization problem with integral objective function satisfying OPT.I / p .size.I /; largest.I // for some polynomial p and all instances I has a fully polynomial approximation scheme only if P D NP.

17.4

Multi-Dimensional Knapsack

467

Proof: Suppose it has a fully polynomial approximation scheme. Then we apply it with 1 D p.size.I /; largest.I // C 1 and obtain an exact pseudopolynomial algorithm. By Proposition 15.41 this is impossible unless P D NP. In the next section we consider a problem that has a pseudopolynomial algorithm but no fully polynomial approximation scheme.

17.4 Multi-Dimensional Knapsack Throughout this section let m 2 N be fixed. We consider the following problem.

m-DIMENSIONAL KNAPSACK PROBLEM Instance: Task:

A number n 2 N and nonnegative integers ci , wij , and Wj for i D 1; : : : ; n and j D 1; : : : ; m. P Find a subset S P f1; : : : ; ng such that i 2S wij Wj for all j D 1; : : : ; m and i 2S ci is maximum.

Even for this generalization of the KNAPSACK PROBLEM (which is the case m D 1) there is a pseudopolynomial algorithm; see Exercise 11. However, this does not lead to a fully polynomial approximation scheme: Proposition 17.13. (Korte and Schrader [1981]) The m-DIMENSIONAL KNAPSACK PROBLEM has no fully polynomial approximation scheme for any m 2, unless P D NP. Proof: It suffices to consider the case m D 2. Given an instance .P; Q; R; T / of 3DM, let T D ft1 ; : : : ; tn g P Q R, k WD jP j D jQj D jRj and w.l.o.g. P [Q [R D f1; : : : ; 3kg. We use a similar construction as in the proof of Corollary 15.27. For i D 1; : : : ; n let ti D .p; q; r/ 2 P Q R; then we set ci D 1, wi1 D .n C 1/p C .n C 1/q C .n C 1/r , and wi 2 D .n C 1/3kC1 wi1 . Moreover, P3k let W1 D pD1 .n C 1/p and W2 D k.n C 1/3kC1 W1 . This defines an instance of the 2-DIMENSIONAL KNAPSACK PROBLEM. If there is a 3-dimensional matching fti W i P 2 S g (where S f1; : : : ; ng), P then jS j D k and i 2S wi1 D W1 and hence i 2S wi 2 D W2 . On the other hand, any feasible solution S f1; : : : ; ng with P jS j D k of this instance of the 2-DIMENSIONAL KNAPSACK PROBLEM satisfies i 2S wi1 W1 and X X wi1 D k.n C 1/3kC1 wi 2 k.n C 1/3kC1 W2 D W1 : i 2S

i 2S

Therefore there is a feasible solution S with jS j D k if and only if the 3DM instance .U; V; W; T / is a yes-instance.

468

17 The Knapsack Problem

We conclude that the optimum value of this instance of the 2-DIMENSIONAL KNAPSACK PROBLEM is k if I is a yes-instance and at most k 1 otherwise. If we had a fully polynomial approximation scheme, we could get a .1C/-approximation for D k1 in polynomial time, and thus distinguish between the two cases. Thus we could solve 3DM in polynomial time. As 3DM is NP-complete (Theorem 15.26), this would imply P D NP. At least there is an approximation scheme: Theorem 17.14. (Frieze and Clarke [1984]) For any fixed m 2 N and > 0, there is a .1 C /-factor approximation algorithm for the m-DIMENSIONAL KNAPSACK PROBLEM. Proof: We set k WD d m e; note that k is a constant. We enumerate all subsets of f1; : : : ; ng with less than k elements. Moreover, for each S f1; : : : ; ng with jS j D k, we set S > WD fi 2 f1; : : : ; ng n S W ci > minfcj W j 2 S gg and solve the LP n n X max cx W wij xi Wj .j D 1; : : : ; m/; 0 x 1; i D1

o xi D 1 .i 2 S /; xi D 0 .i 2 S > / : Let x be an optimum basic solution. As x satisfies at least n constraints of the LP with equality, it has at most m fractional components. Let S 0 WD fi 2 f1; : : : ; ng W xi D 1g. Among all sets S and S 0 that we find, we output the best feasible solution. The running time is dominated by solving O.nk / linear programs with O.n/ variables and constraints. The optimum solution either has at most k 1 elements (then we find it) or corresponds to a feasible 0-1-solution ´ to one of these LPs, namely where S contains k of its elements with the largest profit. Then we find a solution S 0 (by rounding downPan optimumPbasic solution x) whichPis not much worse because n c´ cx D 0 ci C m maxfci W i 2 i D1 ci .xi bxi c/ i 2S 0 ci C i 2SP P m P > f1; : : : ; ngn.S [S /g 0 ci Cm minfci W i 2 S g i 2S i 2S 0 ci C k i 2S ci P P m i 2S 0 ci .1 C k / i 2S 0 ci .1 C /.

Exercises 1. Consider the fractional multi-knapsack problem defined as follows. An instance consists of nonnegative integers m and n, numbers wj , cijP and Wi (1 i m, m 1jP n). The task is to find numbers xij P 2 Œ0; 1 with i D1 xij D 1 for all n m Pn j and j D1 xij wj Wi for all i such that i D1 j D1 xij cij is minimum. Can one find a combinatorial polynomial-time algorithm for this problem (without using LINEAR PROGRAMMING)? Hint: Reduction to a MINIMUM COST FLOW PROBLEM.

References

469

2. Consider the following greedy algorithm for the KNAPSACK PROBLEM (similar to the one in Proposition 17.6). Sort the indices such that wc11 wcnn . Set P S WD ;. For i WD 1 to n do: If j 2S[fi g wj W then set S WD S [ fi g. Show that this is not a k-factor approximation algorithm for any k. 3. Find an exact O.nW /-algorithm for the KNAPSACK PROBLEM. 4. Consider the following problem: given nonnegative integers P n, c1 ; : : : ; cn , w ; : : : ; w and W , find a subset S f1; : : : ; ng such that 1 n j 2S wj W and P j 2S cj is minimum. How can this problem be solved by a pseudopolynomial algorithm? 5. Can one solve the integral multi-knapsack problem (see Exercise 1) in pseudopolynomial time if m is fixed? m 6. Let c 2 f0; :˚: : ; kgm and s 2 Œ0; 1

. How can one decide in O.mk/ time m whether max cx W x 2 ZC ; sx 1 k? 7. Consider the two Lagrangean relaxations of Exercise 21 of Chapter 5. Show that one of them can be solved in linear time while the other one reduces to m instances of the KNAPSACK PROBLEM. 8. Let m 2 N be a constant. Consider the following scheduling problem: given n jobs and m machines, costs cij 2 ZC (i D 1; : : : ; n, j D 1; : : : ; m), and capacities Tj 2 ZC (j D 1; : : : ; m), find an assignment f W f1; : : : ; ng ! f1; : : : ; mg such P that jfi 2 f1; : : : ; ng W f .i / D j gj Tj for j D 1; : : : ; m, and the total cost niD1 cif .i / is minimum. Show that this problem has a fully polynomial approximation scheme. 9. Give a polynomial-time algorithm for the -DOMINANCE PROBLEM restricted to matroids. 10. Prove the if-part of Theorem 17.11. 11. Find a pseudopolynomial algorithm for the m-DIMENSIONAL KNAPSACK PROBLEM for any fixed m 2 N. Note: This generalizes Exercise 3.

References General Literature: Garey, M.R., and Johnson, D.S. [1979]: Computers and Intractability; A Guide to the Theory of NP-Completeness. Freeman, San Francisco 1979, Chapter 4 Kellerer, H., Pferschy, U., and Pisinger, D. [2004]: Knapsack Problems. Springer, Berlin 2004 Martello, S., and Toth, P. [1990]: Knapsack Problems; Algorithms and Computer Implementations. Wiley, Chichester 1990 Papadimitriou, C.H., and Steiglitz, K. [1982]: Combinatorial Optimization; Algorithms and Complexity. Prentice-Hall, Englewood Cliffs 1982, Sections 16.2, 17.3, and 17.4

Cited References: Bellman, R. [1956]: Notes on the theory of dynamic programming IV – maximization over discrete sets. Naval Research Logistics Quarterly 3 (1956), 67–70

470

17 The Knapsack Problem

Bellman, R. [1957]: Comment on Dantzig’s paper on discrete variable extremum problems. Operations Research 5 (1957), 723–724 Blum, M., Floyd, R.W., Pratt, V., Rivest, R.L., and Tarjan, R.E. [1973]: Time bounds for selection. Journal of Computer and System Sciences 7 (1973), 448–461 Dantzig, G.B. [1957]: Discrete variable extremum problems. Operations Research 5 (1957), 266–277 Frieze, A.M. and Clarke, M.R.B. [1984]: Approximation algorithms for the m-dimensional 0-1 knapsack problem: worst case and probablistic analyses. European Journal of Operations Research 15 (1984), 100–109 Garey, M.R., and Johnson, D.S. [1978]: Strong NP-completeness results: motivation, examples, and implications. Journal of the ACM 25 (1978), 499–508 Gens, G.V., and Levner, E.V. [1979]: Computational complexity of approximation algorithms for combinatorial problems. In: Mathematical Foundations of Computer Science; LNCS 74 (J. Becvar, ed.), Springer, Berlin 1979, pp. 292–300 Ibarra, O.H., and Kim, C.E. [1975]: Fast approximation algorithms for the knapsack and sum of subset problem. Journal of the ACM 22 (1975), 463–468 Karp, R.M. [1972]: Reducibility among combinatorial problems. In: Complexity of Computer Computations (R.E. Miller, J.W. Thatcher, eds.), Plenum Press, New York 1972, pp. 85–103 Kellerer, H., and Pferschy, U. [2004]: Improved dynamic programming in connection with an FPTAS for the knapsack problem. Journal on Combinatorial Optimization 8 (2004), 5–11 Korte, B., and Schrader, R. [1981]: On the existence of fast approximation schemes. In: Nonlinear Programming; Vol. 4 (O. Mangaserian, R.R. Meyer, S.M. Robinson, eds.), Academic Press, New York 1981, pp. 415–437 Lawler, E.L. [1979]: Fast approximation algorithms for knapsack problems. Mathematics of Operations Research 4 (1979), 339–356 Pisinger, D. [1999]: Linear time algorithms for knapsack problems with bounded weights. Journal of Algorithms 33 (1999), 1–14 Sahni, S. [1976]: Algorithms for scheduling independent tasks. Journal of the ACM 23 (1976), 114–127 Vygen, J. [1997]: The two-dimensional weighted median problem. Zeitschrift für Angewandte Mathematik und Mechanik 77 (1997), Supplement, S433–S436 Woeginger, G.J. [2000]: When does a dynamic programming formulation guarantee the existence of a fully polynomial time approximation scheme (FPTAS)? INFORMS Journal on Computing 12 (2000), 57–74

18 Bin-Packing

Suppose we have n objects, each of a given size, and some bins of equal capacity. We want to assign the objects to the bins, using as few bins as possible. Of course the total size of the objects assigned to one bin should not exceed its capacity. Without loss of generality, the capacity of the bins is 1. Then the problem can be formulated as follows:

BIN-PACKING PROBLEM Instance:

A list of nonnegative numbers a1 ; : : : ; an 1.

Task:

Find P a k 2 N and an assignment f W f1; : : : ; ng ! f1; : : : ; kg with i Wf .i /Dj ai 1 for all j 2 f1; : : : ; kg such that k is minimum.

There are not many combinatorial optimization problems whose practical relevance is more obvious. For example, the simplest version of the cutting stock problem is equivalent: We are given many beams of equal length (say 1 meter) and numbers a1 ; : : : ; an . We want to cut as few of the beams as possible into pieces such that at the end we have beams of lengths a1 ; : : : ; an . Although an instance I is some ordered list where numbers may appear more than once, we write x 2 I for some element in the list I which is equal to x. By jI j we mean the number of elements in the list I . We shall also use the Pn abbreviation SUM.a1 ; : : : ; an / WD i D1 ai . This is an obvious lower bound: dSUM.I /e OPT.I / holds for any instance I . In Section 18.1 we prove that the BIN-PACKING PROBLEM is strongly NP-hard and discuss some simple approximation algorithms. We shall see that no algorithm can achieve a performance ratio better than 32 (unless P D NP). However, one can achieve an arbitrarily good performance ratio asymptotically: in Sections 18.2 and 18.3 we describe a fully polynomial asymptotic approximation scheme. This uses the ELLIPSOID METHOD and results of Chapter 17.

18.1 Greedy Heuristics In this section we shall analyse some greedy heuristics for the BIN-PACKING PROBLEM. There is no hope for an exact polynomial-time algorithm as the problem is NP-hard: B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__18, c Springer-Verlag Berlin Heidelberg 2012

471

472

18 Bin-Packing

Theorem 18.1. The following problem is NP-complete: given an instance I of the BIN-PACKING PROBLEM, decide whether I has a solution with two bins. Proof: Membership in NP is trivial. We transform the PARTITION problem (which is NP-complete by Corollary 15.28) to the above decision problem. Given an instance c1 ; : : : ; cn of PARTITION, consider the instance a1 ; : : : ; an of the BINPACKING PROBLEM, where 2ci ai D Pn : j D1 cj Obviously two P bins suffice if and only if there is a subset S f1; : : : ; ng such that P j 2S cj D j …S cj . Corollary 18.2. Unless P D NP, there is no -factor approximation algorithm for the BIN-PACKING PROBLEM for any < 32 . For any fixed k, there is a pseudopolynomial algorithm which decides for a given instance I whether k bins suffice (Exercise 1). However, in general this problem is strongly NP-complete: Theorem 18.3. (Garey and Johnson [1975]) The following problem is strongly NP-complete: given an instance I of the BIN-PACKING PROBLEM and a number B, decide whether I can be solved with B bins. Proof: Transformation from 3-DIMENSIONAL MATCHING (Theorem 15.26). Given an instance U; V; W; T of 3DM, we construct a bin-packing instance I with 4jT j items. Namely, the set of items is [ S WD ft; .u; t/; .v; t/; .w; t/g: t D.u;v;w/2T :

Let U Dfu1 ; : : : ; un g, V D fv1 ; : : : ; vn g and W D fw1 ; : : : ; wn g. For each x2U [ : V [ W we choose some tx 2 T such that .x; tx / 2 S . For each tD.ui ; vj ; wk / 2 T , the sizes of the items are now defined as follows: 1 .10N 4 C 8 iN jN 2 kN 3 / C ( 1 .10N 4 C iN C 1/ if t D tui .ui ; t/ has size C1 .11N 4 C iN C 1/ if t 6D tui C ( 1 .10N 4 C jN 2 C 2/ if t D tvj .vj ; t/ has size C1 4 2 if t 6D tvj C .11N C jN C 2/ ( 1 .10N 4 C kN 3 C 4/ if t D twk .wk ; t/ has size C1 4 3 if t 6D twk C .8N C kN C 4/ t has size

where N WD100n and C WD40N 4 C 15. This defines an instance I D .a1 ; : : : ; a4jT j / of the BIN-PACKING PROBLEM. We set B WD jT j and claim that I has a solution

18.1

Greedy Heuristics

473

with at most B bins if and only if the initial 3DM instance is a yes-instance, i.e. there is a subset M of T with jM j D n such that for distinct .u; v; w/; .u0 ; v 0 ; w 0 / 2 M one has u 6D u0 , v 6D v 0 and w 6D w 0 . First assume that there is such a solution M of the 3DM instance. Since the solvability of I with B bins is independent of the choice of the tx (x 2 U [ V [ W ), we may redefine them such that tx 2 M for all x. Now for each t D .u; v; w/ 2 T we pack t; .u; t/; .v; t/; .w; t/ into one bin. This yields a solution with jT j bins. Conversely, let f be a solution of I with B D jT j bins. Since SUM.I / D jT j, each bin must be completely full. Since all the item sizes are strictly between 15 and 1 , each bin must contain four items. 3 P Consider one bin k 2 f1; : : : ; Bg. Since C i Wf .i /Dk ai D C 15 .mod N /, the bin must contain one t D .u; v; w/ 2 T , P one .u0 ; t 0 / 2 U T , one .v 0 ; t 00 / 2 0 000 V T , and one .w ; t / 2 W T . Since C i Wf .i /Dk ai D C 15 .mod N 2 /, we have u D u0 . Similarly, by considering the sum modulo N 3 and modulo N 4 , we obtain v D v 0 and w D w 0 . Furthermore, either t 0 D tu and t 00 D tv and t 000 D tw (case 1) or t 0 6D tu and t 00 6D tv and t 000 6D tw (case 2). We define M to consist of those t 2 T for which t is assigned to a bin where case 1 holds. Obviously M is a solution to the 3DM instance. Note that all the numbers in the constructed bin-packing instance I are polynomially large, more precisely O.n4 /. Since 3DM is NP-complete (Theorem 15.26), the theorem is proved. This proof is due to Papadimitriou [1994]. Even with the assumption P 6D NP the above result does not exclude the possibility of an absolute approximation algorithm, for example one which needs at most one more bin than the optimum solution. Whether such an algorithm exists is an open question. The simplest heuristic for bin-packing may be the following:

NEXT-FIT ALGORITHM (NF) Input:

An instance a1 ; : : : ; an of the BIN-PACKING PROBLEM.

Output:

A solution .k; f /.

1

Set k WD 1 and S WD 0.

2

For i WD 1 to n do: If S C ai > 1 then set k WD k C 1 and S WD 0. Set f .i / WD k and S WD S C ai . Let us denote by NF .I / the number k of bins this algorithm uses for instance I .

Theorem 18.4. The NEXT-FIT ALGORITHM runs in O.n/ time. For any instance I D a1 ; : : : ; an we have NF .I / 2dSUM.I /e 1 2OPT.I / 1:

474

18 Bin-Packing

Proof: The time bound is obvious. Let k WD NF .I /,jandk let f be the assignment found by the NEXT-FIT ALGORITHM. For j D 1; : : : ; k2 we have X

ai > 1:

i Wf .i /2f2j 1;2j g

Adding these inequalities we get k < SUM.I /: 2 Since the left-hand side is an integer, we conclude that k1 k dSUM.I /e 1: 2 2 This proves k 2dSUM.I /e 1. The second inequality is trivial.

The instances 2; 1 ; 2; 1 ; : : : ; 2 for very small > 0 show that this bound is best possible. So the NEXT-FIT ALGORITHM is a 2-factor approximation algorithm. Naturally the performance ratio becomes better if the numbers involved are small: Proposition 18.5. Let 0 < < 1. For any instance I D a1 ; : : : ; an with ai for all i 2 f1; : : : ; ng we have SUM.I / : NF .I / 1 P Proof: We have i Wf .i /Dj ai > 1 for j D 1; : : : ; NF .I /1. By adding these inequalities we get .NF .I / 1/.1 / < SUM.I / and thus SUM.I / 1: NF .I / 1 1 A second approach in designing an efficient approximation algorithm could be the following:

FIRST-FIT ALGORITHM (FF) Input:

An instance a1 ; : : : ; an of the BIN-PACKING PROBLEM.

Output:

A solution .k; f /.

1

2

For i WD 1 to n do: 8 < Set f .i / WD min j 2 N W : Set k WD

max f .i /.

i 2f1;:::;ng

X h 12 , then each bin with smaller index did not have space for this item, thus has been assigned an item before. As the items are considered in nonincreasing order, there are at least j items of size > 12 . Thus OPT.I / j 23 k. Otherwise the j -th bin, and thus each bin with greater index, contains no item of size > 12 . Hence the bins j; j C 1; : : : ; k contain at least 2.k j / C 1 items, none of which fits into bins 1; : : : ; j 1. Note that 2.k j / C 1 2.k . 32 k C 23 // C 1 D 2 k 13 j 1. Thus OPT.I / SUM.I / > j 1, i.e. OPT.I / j 23 k. 3

476

18 Bin-Packing

By Corollary 18.2 this is best possible (for FFD, consider the instance 0.4, 0.4, 0.3, 0.3, 0.3, 0.3). However, the asymptotic performance guarantee is better: Johnson [1973] proved that FFD.I / 11 9 OPT.I / C 4 for all instances I (see also Johnson OPT.I / C 3. [1974]). Baker [1985] gave a simpler proof showing FFD.I / 11 9 Yue [1991] improved this to FFD.I / 11 OPT.I / C 1. The question was finally 9 settled by Dósa [2007], who proved the following: Theorem 18.8. (Dósa [2007]) For all instances I of the BIN-PACKING PROBLEM, 2 11 OPT.I / C ; FFD.I / 9 3 and this bound is tight. The proof is too involved to be presented here. However, we present a class of instances I with OPT.I / arbitrarily large and FFD.I / D 11 OPT.I /. (This 9 example is taken from Garey and Johnson [1979].) Namely, let > 0 be small enough and I D fa1 ; : : : ; a30m g with 81 if 1 i 6m, ˆ 2 C ˆ ˆ ˆ ˆ ˆ ˆ ˆ 1 ˆ ˆ < 4 C 2 if 6m < i 12m, ai D ˆ ˆ ˆ1 C if 12m < i 18m, ˆ 4 ˆ ˆ ˆ ˆ ˆ ˆ :1 2 if 18m < i 30m. 4 The optimum solution consists of 1 1 1 C ; C ; 2; 2 4 4 1 1 1 1 3m bins containing C 2; C 2; 2; 2: 4 4 4 4

6m bins containing

The FFD-solution consists of 1 1 C ; C 2; 2 4 1 1 1 2m bins containing C ; C ; C ; 4 4 4 1 1 1 1 3m bins containing 2; 2; 2; 2: 4 4 4 4

6m bins containing

So OPT.I / D 9m and FFD.I / D 11m. There are several other algorithms for the BIN-PACKING PROBLEM, some of them having a better asymptotic performance ratio than 11 . In the next section we 9 show that an asymptotic performance ratio arbitrarily close to 1 can be achieved.

18.2

An Asymptotic Approximation Scheme

477

In some applications one has to pack the items in the order they arrive without knowing the subsequent items. Algorithms that do not use any information about the subsequent items are called online algorithms. For example, N EXT-FIT and FIRSTFIT are online algorithms, but the FIRST-FIT-DECREASING ALGORITHM is not an online algorithm. The best known online algorithm for the BIN-PACKING PROBLEM has an asymptotic performance ratio of 1:59 (Seiden [2002]). On the other hand, van Vliet [1992] proved that there is no online asymptotic 1.54-factor approximation algorithm for the BIN-PACKING PROBLEM. A weaker lower bound is the subject of Exercise 6.

18.2 An Asymptotic Approximation Scheme In this section we show that for any > 0 there is a linear-time algorithm which guarantees to find a solution with at most .1 C /OPT.I / C 12 bins. We start by considering instances with not too many different numbers. We denote the different numbers in our instance I by s1 ; : : : ; sm . Let I contain exactly bi copies of si .i D 1; : : : ; m/. Let T1 ; : : : ; TN be all the possibilities of how a single bin can be packed: ( ) m X m ki si 1 fT1 ; : : : ; TN g WD .k1 ; : : : ; km / 2 ZC W i D1

We write Tj D .tj1 ; : : : ; tj m /. Then our BIN-PACKING PROBLEM is equivalent to the following integer programming formulation (due to Eisemann [1957]): min

N X

xj

j D1

s.t.

N X

(18.1) tj i xj bi

j D1

xj 2 ZC

.i D 1; : : : ; m/ .j D 1; : : : ; N /:

P We actually want jND1 tj i xj D bi , but relaxing this constraint makes no difference. The LP relaxation of (18.1) is: min

N X

xj

j D1

s.t.

N X

(18.2) tj i xj bi

.i D 1; : : : ; m/

j D1

xj 0

.j D 1; : : : ; N /:

478

18 Bin-Packing

The following theorem says that by rounding a solution of the LP relaxation (18.2) one obtains a solution of (18.1), i.e. of the BIN-PACKING PROBLEM, which is not much worse: Theorem 18.9. (Fernandez de la Vega and Lueker [1981]) Let I be an instance of the BIN-PACKING PROBLEM with only m different numbers. Let x be a feasible (not necessarily optimum) solution of (18.2) with at most m lnonzero components. m ˘ PN m1 Then a solution of the BIN-PACKING PROBLEM with at most j D1 xj C 2 bins can be found in O.jI j/ time. Proof: Consider bxc, which results from x by rounding down each component. bxc does not in general pack I completely (it might pack some numbers more often than necessary, but this does not matter). The remaining pieces form an instance I 0 . Observe that SUM.I 0 /

N m N N X X X X xj bxj c tj i si xj bxj c: j D1

i D1

j D1

j D1

m1 ˘

bins, because then So it is sufficient to pack I 0 into at most dSUM.I 0 /e C 2 the total number of bins used is no more than 2 3 N N X X ˙ m 1 7C m1 : 6 bxj c C SUM.I 0 / C x j 6 7 2 2 6j D1 7 j D1 We consider two packing methods for I 0 . Firstly, the vector dxe bxc certainly packs at least the elements of I 0 . The number of bins used is at most m since x has at most m nonzero components. Secondly, we can obtain a packing of I 0 using at most 2dSUM.I 0 /e 1 bins by applying the NEXT-FIT ALGORITHM (Theorem 18.4). Both packings can be obtained in linear time. The better of these two packings uses at most minfm; 2dSUM.I 0 /e 1g dSUM.I 0 /e C m1 bins. The theorem is proved. 2 Corollary 18.10. (Fernandez de la Vega and Lueker [1981]) Let m and > 0 be fixed constants. Let I be an instance of the BIN-PACKING PROBLEM with only m different numbers, none˘ of which is less than . Then we can find a solution with at most OPT.I / C m1 bins in O.jI j/ time. 2 Proof: By the SIMPLEX ALGORITHM (Theorem 3.14) we can find an optimum basic solution x of (18.2), i.e. a vertex of the polyhedron. Since any vertex satisfies N of the constraints with equality (Proposition 3.9), x has at most m nonzero components. The time needed to determine x depends on m and N only. Observe that N 1 .m C 1/ , because there can be at most 1 elements in each bin. So x can be found in constant time.

18.2

Since proof.

lP N

j D1 xj

An Asymptotic Approximation Scheme

479

m OPT.I /, an application of Theorem 18.9 completes the

Using the ELLIPSOID METHOD (Theorem 4.18) leads to the same result. This is not best possible: one can even determine the exact optimum in polynomial time for fixed m and , since INTEGER PROGRAMMING with a constant number of variables can be solved in polynomial time (Lenstra [1983]). A simpler exact algorithm for fixed m is discussed in Exercise 7. However, we do not need these stronger results here. We shall apply Theorem 18.9 again in the next section and obtain the same performance guarantee in polynomial time even if m and are not fixed (in the proof of Theorem 18.14). We are now able to formulate the algorithm of Fernandez de la Vega and Lueker [1981]. Roughly it proceeds as follows. First we partition the n numbers into m C 2 groups according to their size. We pack the group with the largest ones using one bin for each number. Then we pack the m middle groups by first rounding the size of each number to the largest number in its group and then applying Corollary 18.10. Finally we pack the group with the smallest numbers.

FERNANDEZ-DE-LA-VEGA-LUEKER ALGORITHM Input: Output:

An instance I D a1 ; : : : ; an of the BIN-PACKING PROBLEM. A number > 0. A solution .k; f / for I . C1

and h WD d SUM.I /e.

1

Set WD

2

Let I1 D L; M; R be a rearrangement of the list I , where M D K0 ; y1 ; K1 ; y2 ; : : : ; Km1 ; ym and L; K0 ; K1 ; : : : ; Km1 and R are again lists, such that the following properties hold: (a) For all x 2 L: x < . (b) For all x 2 K0 : x y1 . (c) For all x 2 Ki : yi x yi C1 (i D 1; : : : ; m 1). (d) For all x 2 R: ym x. (e) jK1 j D D jKm1 j D jRj D h 1 and jK0 j h 1. .k; f / is now determined by the following three packing steps: Find a packing SR of R using jRj bins.

3 4

5

Consider the instance Q consisting of the numbers y1 ; y2 ; : : : ; ym , each appearing h times. Find a packing SQ of Q using at most mC1 2 more bins than necessary (using Corollary 18.10). Transform SQ into a packing SM of M . As long as a bin of SR or SM has room amounting to at least , fill it with elements of L. Finally, find a packing of the rest of L using the NEXT-FIT ALGORITHM.

480

18 Bin-Packing

In 4 we used a slightly weaker bound than the one obtained in Corollary 18.10. This does not hurt here, and we shall need the above form in Section 18.3. The above algorithm is an asymptotic approximation scheme. More precisely: Theorem 18.11. (Fernandez de la Vega and Lueker [1981]) For each 0 < 1 and each instance I of the BIN-PACKING PROBLEM, the FERNANDEZ-DE-LA2 VEGA-LUEKER ALGORITHM returns a solution using at most .1 C /OPT.I / C 12 bins. The running time is O.n 12 / plus the time needed to solve (18.2). For fixed , the running time is O.n/. k j jI jjLj Proof: In , . 2 we first determine L in O.n/ time. Then we set m WD h Since .jI j jLj/ SUM.I /, we have m

jI j jLj 1 C1 jI j jLj D : h SUM.I / 2

We know that yi must be the .jI j C 1 .m i C 1/h/-th smallest element (i D 1; : : : ; m). So by Corollary 17.4 we can find each yi in O.n/ time. We finally determine K0 ; K1 ; : : : ; Km1 ; R, each in O.n/ time. So 2 can be done in O.mn/ time. Note that m D O. 12 /. Steps , 3 4 and 5 – except the solution of (18.2) – can easily be implemented to run in O.n/ time. For fixed , (18.2) can also be solved optimally in O.n/ time (Corollary 18.10). We now prove the performance guarantee. Let k be the number of bins that the algorithm uses. We write jSR j and jSM j for the number of bins used in the packing of R and M , respectively. We have jSR j jRj D h 1 < SUM.I / OPT.I /: Secondly, observe that OPT.Q/ OPT.I /: the i -th largest element of I is greater than or equal to the i -th largest element of Q for all i D 1; : : : ; hm. Hence by 4 (Corollary 18.10) we have jSM j D jSQ j OPT.Q/ C

mC1 mC1 OPT.I / C : 2 2

In 5 we can pack some elements of L into bins of SR and SM . Let L0 be the list of the remaining elements in L. Case 1: L0 is nonempty. Then the total size of the elements in each bin, except possibly for the last one, exceeds 1 , so we have .1 /.k 1/ < SUM.I / OPT.I /. We conclude that k Case 2:

1 OPT.I / C 1 D .1 C /OPT.I / C 1: 1

L0 is empty. Then

18.3

The Karmarkar-Karp Algorithm

481

k jSR j C jSM j mC1 2 C 1 C 2 .1 C /OPT.I / C 2 2 1 .1 C /OPT.I / C 2 ; < OPT.I / C OPT.I / C

because 12 .

Of course the running time grows exponentially in 1 . However, Karmarkar and Karp showed how to obtain a fully polynomial asymptotic approximation scheme. This is the subject of the next section.

18.3 The Karmarkar-Karp Algorithm The algorithm of Karmarkar and Karp [1982] works just as the algorithm in the preceding section, but instead of solving the LP relaxation (18.2) optimally as in Corollary 18.10, they solve it with a constant absolute error. The fact that the number of variables grows exponentially in 1 might not prevent us from solving the LP: Gilmore and Gomory [1961] developed the column generation technique and obtained a variant of the SIMPLEX ALGORITHM which solves (18.2) quite efficiently in practice. Similar ideas lead to a theoretically efficient algorithm if one uses the GRÖTSCHEL-LOVÁSZ-SCHRIJVER ALGORITHM instead. In both above-mentioned approaches the dual LP plays a major role. The dual of (18.2) is: max yb

s.t.

m X i D1

tj i yi 1

.j D 1; : : : ; N /

yi 0

.i D 1; : : : ; m/:

(18.3)

It has only m variables, but an exponential number of constraints. However, the number of constraints does not matter as long as we can solve the SEPARATION PROBLEM in polynomial time. It will turn out that the S EPARATION PROBLEM is equivalent to a KNAPSACK PROBLEM. Since we can solve KNAPSACK PROBLEMs with an arbitrarily small error, we can also solve the WEAK SEPARATION PROBLEM in polynomial time. This idea enables us to prove: Lemma 18.12. (Karmarkar and Karp [1982]) Let I be an instance of the BINPACKING PROBLEM with only m different numbers, none of which is less than .

482

18 Bin-Packing

Let ı > 0. Then a feasible solution y of the dual LP (18.3) differing from the m5 n mn optimum by at most ı can be found in O m6 log2 mn time. C log ı ı ı Proof: We may assume that ı D p1 for some natural number p. We apply the GRÖTSCHEL-LOVÁSZ-SCHRIJVER ALGORITHM (Theorem 4.19). Let D be the polyhedron of (18.3). We have

p B x0 ; Œ0; m D Œ0; 1m B.x0 ; m/; 2 where x0 is the vector all of whose components are 2 . We shall prove that we can solve the WEAK SEPARATION PROBLEM for (18.3), i.e. D and b, and 2ı in O nm time, independently of the size of the input vecı tor y. By Theorem 4.19, this implies that the WEAK OPTIMIZATION PROBLEM mjjbjj m5 n time, proving the lemma since can be solved in O m6 log2 mjjbjj C log ı ı ı jjbjjn. To show how to solve the WEAK SEPARATION PROBLEM, let y 2 Qm be given. We may assume 0 y 1 since otherwise the task is trivial. Now observe that y is feasible if and only if maxfyx W x 2 Zm C ; xs 1g 1;

(18.4)

where s D .s1 ; : : : ; sm / is the vector of the item sizes. (18.4) is a kind of KNAPSACK PROBLEM, so we cannot hope to solve it exactly. But this is not necessary, as the WEAK SEPARATION PROBLEM only calls for an approximate solution. Write y 0 WD b 2n yc (the rounding is done componentwise). The problem ı maxfy 0 x W x 2 Zm C ; xs 1g

(18.5)

can be solved optimally by dynamic programming, very similarly to the DYNAMIC PROGRAMMING KNAPSACK ALGORITHM in Section 17.2 (see Exercise 6 of Chapter 17): let F .0/ WD 0 and F .k/ WD minfF .k yi0 / C si W i 2 f1; : : : ; mg; yi0 kg . F .k/ is the minimum size of a set of items with total cost k for k D 1; : : : ; 4n ı (with respect to y 0 ). Now the maximum in (18.5) is less than or equal to 2n if and only if F .k/ > 1 ı 4n for all k 2 f 2n C 1; : : : ; g. The total time needed to decide this is O mn ı ı ı . There are two cases: ı 0 Case 1: The maximum in (18.5) is less than or equal to 2n . Then 2n y is a feaı ı 0 ı ı sible solution of (18.3). Furthermore, by b 2n y b 2n 1l D 2 . The task of the WEAK SEPARATION PROBLEM is done. Case 2: There exists an x 2 Zm 1 and y 0 x > 2n . Such an x can easily C with xs ı mn ı 0 be computed from the numbers F .k/ in O ı time. We have yx 2n y x > 1.

18.3

The Karmarkar-Karp Algorithm

483

Thus x corresponds to a bin configuration that proves that y is infeasible. Since we have ´x 1 for all ´ 2 D, this is a separating hyperplane, and thus we are done. Lemma 18.13. (Karmarkar and Karp [1982]) Let I be an instance of the BINPACKING PROBLEM with only m different numbers, none of which is less than . Let ı > 0. Then a feasible solution x of the primal LP (18.2) differing from the optimum by at most ı and having at most m nonzero components can be found in time polynomial in n, 1ı and 1 . Proof: We first solve the dual LP (18.3) approximately, using Lemma 18.12. We obtain a vector y with y b OPT.18.3/ ı. Now let Tk1 ; : : : ; TkN 0 be those bin configurations that appeared as a separating hyperplane in Case 2 of the previous proof, plus the unit vectors (the bin configurations containing just one element). Note that N 0 is bounded by the number of iterations in the GRÖTSCHEL -LOVÁSZ mn 0 2 SCHRIJVER ALGORITHM (Theorem 4.19), so N D O m log ı . Consider the LP max yb

s.t.

m X

tkj i yi 1

i D1

yi 0

.j D 1; : : : ; N 0 /

(18.6)

.i D 1; : : : ; m/:

Observe that the above procedure for (18.3) (in the proof of Lemma 18.12) is also a valid application of the G RÖTSCHEL-LOVÁSZ-SCHRIJVER ALGORITHM for (18.6): the oracle for the WEAK SEPARATION PROBLEM can always give the same answer as above. Therefore we have y b OPT.18.6/ ı. Consider 0

min

N X

xkj

j D1 0

s.t.

N X

(18.7) tkj i xkj bi

j D1

xkj 0

.i D 1; : : : ; m/ .j D 1; : : : ; N 0 /

which is the dual of (18.6). The LP (18.7) arises from (18.2) by eliminating the variables xj for j 2 f1; : : : ; N g n fk1 ; : : : ; kN 0 g (forcing them to be zero). In other words, only N 0 of the N bin configurations can be used. We have OPT.18.7/ ı D OPT.18.6/ ı y b OPT.18.3/ D OPT.18.2/: So it is sufficient to solve (18.7). But (18.7) is an LP of polynomial size: it has N 0 variables and m constraints; none of the entries of the matrix is larger than 1 ,

484

18 Bin-Packing

and none of the entries of the right-hand side is larger than n. So by Khachiyan’s Theorem 4.18, it can be solved in polynomial time. We obtain an optimum basic solution x (x is a vertex of the polyhedron, so x has at most m nonzero components). Now we apply the FERNANDEZ-DE-LA-VEGA-LUEKER ALGORITHM with just one modification: we replace the exact solution of (18.2) by an application of Lemma 18.13. We summarize: Theorem 18.14. (Karmarkar and Karp [1982]) There is a fully polynomial asymptotic approximation scheme for the BIN-PACKING PROBLEM. Proof: We apply Lemma 18.13 with ı D 1, obtaining an optimum solution x of (18.7) with at most m nonzero components. We have 1lx OPT.18.2/ C 1. An application of Theorem 18.9 yields an integral solution using at most dOPT.18.2/eC 1 C m1 4 of the FERNANDEZ - DE - LA-VEGA-L UEKER ALGO2 bins, as required in RITHM. So the statement of Theorem 18.11 remains valid. Since m 22 and 1 2 (we may assume 1), the running time for finding x is polynomial in n and 1 . The running time obtained in this way is worse than O 40 and completely out of the question for practical purposes. Karmarkar and Karp [1982] showed how to reduce the number of variables in (18.7) to m (while changing the optimum value only slightly) and thereby improve the running time (see Exercise 12). Plotkin, Shmoys and Tardos [1995] achieved a running time of O.n log 1 C 6 log 1 /. Many generalizations have been considered. The two-dimensional bin packing problem, asking for packing a given set of axis-parallel rectangles into a minimum number of unit squares without rotation, does not have an asymptotic approximation scheme unless P D NP (Bansal et al. [2006]). See Caprara [2008], Zhang [2005], Jansen, Prädel and Schwarz [2009], and the references therein, for related results.

Exercises 1. Let k be fixed. Describe a pseudopolynomial algorithm which – given an instance I of the BIN-PACKING PROBLEM – finds a solution for this instance using no more than k bins or decides that no such solution exists. 2. Consider the BIN-PACKING PROBLEM restricted to instances a1 ; : : : ; an with ai > 13 for i D 1; : : : ; n. (a) Reduce the problem to the CARDINALITY MATCHING PROBLEM. (b) Show how to solve the problem in O.n log n/ time. 3. Consider the QUADRATIC ASSIGNMENT PROBLEM Pn: given matrices A; B 2 Rnn , find a permutation on f1; : : : ; ng such that i;j D1 ai;j b.i /;.j / is minC imum. Show that this problem has no constant-factor approximation algorithm unless P D NP, even for the case that A is a 0-1-matrix and the entries of B

Exercises

4. 5. 6.

7.

8. 9.

10.

11.

485

define a metric. Hint: Use Theorem 18.3. (Queyranne [1986]) Find an instance I of the BIN-PACKING PROBLEM, where FF .I / D 17 while OPT.I / D 10. Implement the FIRST-FIT ALGORITHM and the FIRST-FIT-DECREASING ALGORITHM to run in O.n log n/ time. Show that there is no online algorithm for the BIN-PACKING PROBLEM with performance ratio less than 43 . Hint: Note that we do not assume P 6D NP. There is no such algorithm, regardless of the running time. Consider the list consisting of n elements of size 12 followed by n elements of size 12 C . Show that BIN PACKING with fixed number of different item sizes can be solved in polynomial time. Hint: Compute which subsets of items can be packed into i bins, for i D 1; 2 : : :, using dynamic programming. Show that 2 of the FERNANDEZ -DE-LA-VEGA-LUEKER ALGORITHM can be implemented to run in O n log 1 time. Consider the LP (18.3), which has a variable yi for each i D 1; : : : ; m (i.e., each item size). Assume s1 > > sm . Show that then there exists an optimum solution with y1 ym . (Caprara [2008]) Prove that for any > 0 there exists a polynomial-time algorithm which for any instance I D .a1 ; : : : ; an / of the BIN-PACKING PROBLEM finds a packing using the optimum number of bins but may violateP the capacity constraints by , i.e. an f W f1; : : : ; ng ! f1; : : : ; OPT.I /g with f .i /Dj ai 1 C for all j 2 f1; : : : ; OPT.I /g. Hint: Use ideas of Section 18.2. (Hochbaum and Shmoys [1987]) Consider the following MULTIPROCESSOR SCHEDULING PROBLEM. Given a finite set A of tasks, a positive number t.a/ for each a 2 A (the processing : : : time), and a number m of processors. Find a partition A D A1 [ A2 [ [ P Am of A into m pairwise disjoint sets such that maxm a2Ai t.a/ is minii D1 mum. (a) Show that this problem is strongly NP-hard. (b) Show that a greedy algorithm which successively assigns jobs (in arbitrary order) to the currently least used machine is a 2-factor approximation algorithm. (c) Show that for each fixed m the problem has a fully polynomial approximation scheme. (Horowitz and Sahni [1976]) (d) Use Exercise 10 to show that the MULTIPROCESSOR SCHEDULING PROBLEM has an approximation scheme. (Hochbaum and Shmoys [1987])

486

18 Bin-Packing

Note: This problem has been the subject of the first paper on approximation algorithms (Graham [1966]). Many variations of scheduling problems have been studied; see e.g. Graham et al. [1979] or Lawler et al. [1993].

12. Consider the LP (18.6) in the proof of Lemma 18.13. All but m constraints can be omitted without changing its optimum value. We are not able to find these m constraints in polynomial time, but we can find m constraints such that deleting all the others does not increase the optimum value too much (e.g., by at most one). How? Hint: Let D .0/ be the LP (18.6) and iteratively construct LPs D .1/ ; D .2/ ; : : : by deleting more and more constraints. At each iteration, a solution y .i / of D .i / is .i / .i / given with by OPT D ı. The set of constraints is partitioned into mC 1 sets of approximately equal size, and for each of the sets we test whether the set can be deleted. This test is performed by considering the LP after deletion, say D, and applying the GRÖTSCHEL-L -SCHRIJVER ALGORITHM. Let OVÁSZ y be a solution of D with by OPT D ı. If by by .i / C ı, the test is successful, and we set D .i C1/ WD D and y .i C1/ WD y. Choose ı appropriately. (Karmarkar and Karp [1982])

13. Find an appropriate choice of as a function of SUM.I /, such that the resulting modification of the KARMARKAR-KARP ALGORITHM is a polynomialtime

algorithm which guarantees to find a solution with at most OPT.I / C / log log OPT.I / O OPT.Ilog bins. OPT.I / (Johnson [1982])

References General Literature: Coffman, E.G., Garey, M.R., and Johnson, D.S. [1996]: Approximation algorithms for binpacking; a survey. In: Approximation Algorithms for NP-Hard Problems (D.S. Hochbaum, ed.), PWS, Boston, 1996

Cited References: Baker, B.S. [1985]: A new proof for the First-Fit Decreasing bin-packing algorithm. Journal of Algorithms 6 (1985), 49–70 Bansal, N., Correa, J.R., Kenyon, C., and Sviridenko, M. [2006]: Bin packing in multiple dimensions: inapproximability results and approximation schemes. Mathematics of Operations Research 31 (2006), 31–49 Caprara, A. [2008]: Packing d -dimensional bins in d stages. Mathematics of Operations Research 33 (2008), 203–215 Dósa, G. [2007]: The tight bound of first fit decreasing bin-packing algorithm is FFD.I / ˘ C âAL’6=9. ˘ 11=9OP T .I /âAL’ In: Combinatorics, Algorithms, Probabilistic and Experimental Methodologies; LNCS 4614 (Chen, B., Paterson, M., Zhang, G., eds.), Springer, Berlin 2007, pp. 1–11 Eisemann, K. [1957]: The trim problem. Management Science 3 (1957), 279–284

References

487

Fernandez de la Vega, W., and Lueker, G.S. [1981]: Bin packing can be solved within 1 C in linear time. Combinatorica 1 (1981), 349–355 Garey, M.R., Graham, R.L., Johnson, D.S., and Yao, A.C. [1976]: Resource constrained scheduling as generalized bin packing. Journal of Combinatorial Theory A 21 (1976), 257–298 Garey, M.R., and Johnson, D.S. [1975]: Complexity results for multiprocessor scheduling under resource constraints. SIAM Journal on Computing 4 (1975), 397–411 Garey, M.R., and Johnson, D.S. [1979]: Computers and Intractability; A Guide to the Theory of NP-Completeness. Freeman, San Francisco 1979, p. 127 Gilmore, P.C., and Gomory, R.E. [1961]: A linear programming approach to the cutting-stock problem. Operations Research 9 (1961), 849–859 Graham, R.L. [1966]: Bounds for certain multiprocessing anomalies. Bell Systems Technical Journal 45 (1966), 1563–1581 Graham, R.L., Lawler, E.L., Lenstra, J.K., and Rinnooy Kan, A.H.G. [1979]: Optimization and approximation in deterministic sequencing and scheduling: a survey. In: Discrete Optimization II; Annals of Discrete Mathematics 5 (P.L. Hammer, E.L. Johnson, B.H. Korte, eds.), North-Holland, Amsterdam 1979, pp. 287–326 Hochbaum, D.S., and Shmoys, D.B. [1987]: Using dual approximation algorithms for scheduling problems: theoretical and practical results. Journal of the ACM 34 (1987), 144–162 Horowitz, E., and Sahni, S.K. [1976]: Exact and approximate algorithms for scheduling nonidentical processors. Journal of the ACM 23 (1976), 317–327 Jansen, K., Prädel, L., and Schwarz, U.M. [2009]: Two for one: tight approximation of 2D bin packing. In: Algorithms and Data Structures – Proceedings of the 11th Algorithms and Data Structures Symposium; LNCS 5664 (F. Dehne, M. Gavrilova, J.-R. Sack, C.D. Tóth, eds.), Springer, Berlin 2009, pp. 399–410 Johnson, D.S. [1973]: Near-Optimal Bin Packing Algorithms. Doctoral Thesis, Dept. of Mathematics, MIT, Cambridge, MA, 1973 Johnson, D.S. [1974]: Fast algorithms for bin-packing. Journal of Computer and System Sciences 8 (1974), 272–314 Johnson, D.S. [1982]: The NP-completeness column; an ongoing guide. Journal of Algorithms 3 (1982), 288–300, Section 3 Johnson, D.S., Demers, A., Ullman, J.D., Garey, M.R., and Graham, R.L. [1974]: Worst-case performance bounds for simple one-dimensional packing algorithms. SIAM Journal on Computing 3 (1974), 299–325 Karmarkar, N., and Karp, R.M. [1982]: An efficient approximation scheme for the onedimensional bin-packing problem. Proceedings of the 23rd Annual IEEE Symposium on Foundations of Computer Science (1982), 312–320 Lawler, E.L., Lenstra, J.K., Rinnooy Kan, A.H.G., and Shmoys, D.B. [1993]: Sequencing and scheduling: algorithms and complexity. In: Handbooks in Operations Research and Management Science; Vol. 4 (S.C. Graves, A.H.G. Rinnooy Kan, P.H. Zipkin, eds.), Elsevier, Amsterdam 1993 Lenstra, H.W. [1983]: Integer Programming with a fixed number of variables. Mathematics of Operations Research 8 (1983), 538–548 Papadimitriou, C.H. [1994]: Computational Complexity. Addison-Wesley, Reading 1994, pp. 204–205 Plotkin, S.A., Shmoys, D.B., and Tardos, É. [1995]: Fast approximation algorithms for fractional packing and covering problems. Mathematics of Operations Research 20 (1995), 257–301

488

18 Bin-Packing

Queyranne, M. [1986]: Performance ratio of polynomial heuristics for triangle inequality quadratic assignment problems. Operations Research Letters 4 (1986), 231–234 Seiden, S.S. [2002]: On the online bin packing problem. Journal of the ACM 49 (2002), 640–671 Simchi-Levi, D. [1994]: New worst-case results for the bin-packing problem. Naval Research Logistics 41 (1994), 579–585 van Vliet, A. [1992]: An improved lower bound for on-line bin packing algorithms. Information Processing Letters 43 (1992), 277–284 Xia, B., and Tan, Z. [2010]: Tighter bounds of the First Fit algorithm for the bin-packing problem. Discrete Applied Mathematics 158 (2010), 1668–1675 Yue, M. [1991]: A simple proof of the inequality FFD.L/ 11 9 OPT.L/ C 1; 8L, for the FFD bin-packing algorithm. Acta Mathematicae Applicatae Sinica 7 (1991), 321–331 Zhang, G. [2005]: A 3-approximation algorithm for two-dimensional bin packing. Operations Research Letters 33 (2005), 121–126

19 Multicommodity Flows and Edge-Disjoint Paths

The MULTICOMMODITY FLOW PROBLEM is a generalization of the MAXIMUM FLOW PROBLEM. Given a digraph with edge capacities, we now ask for an s-tflow for several pairs .s; t/ (we speak of several commodities), such that the total flow through any edge does not exceed the capacity. We specify the pairs .s; t/ by a second digraph; for technical reasons we have an edge from t to s when we ask for an s-t-flow. Formally we have:

DIRECTED MULTICOMMODITY FLOW PROBLEM Instance:

A pair .G; H / of digraphs on the same vertices. Capacities u W E.G/ ! RC and demands b W E.H / ! RC .

Task:

Find a family .x f /f 2E.H / , where x f is an s-t-flow of value b.f / in G for each f D .t; s/ 2 E.H /, and X x f .e/ u.e/ for all e 2 E.G/: f 2E.H /

There is also an undirected version which we shall discuss later. The edges of G are called supply edges, the edges of H demand edges or commodities. Endpoints of demand edges are called terminals. If u 1, b 1 and x is forced to be integral, we have the E DGE-DISJOINT PATHS PROBLEM. Sometimes one also has edge weights and asks for a minimum cost multicommodity flow. But here we are only interested in feasible solutions. Of course, the problem can be solved in polynomial time by means of L INEAR PROGRAMMING (cf. Theorem 4.18). However the LP formulations are quite large, so it is also interesting that we have a combinatorial algorithm for solving the problem approximately; see Section 19.2. This algorithm uses an LP formulation as a motivation. Moreover, LP duality yields a useful good characterization of our problem as shown in Section 19.1. However, in contrast to single-commodity flows, the dual LP does not correspond to a minimum cut problem. We will study the max-flow min-cut ratio in Sections 19.3 and 19.4. In many applications one is interested in integral flows, or paths, and the E DGEDISJOINT PATHS PROBLEM is the proper formulation. We have considered a special case of this problem in Section 8.2, where we had a necessary and sufficient condition for the existence of k edge-disjoint (or internally disjoint) paths from s to t B. Korte and J. Vygen Combinatorial Optimization, Algorithms and Combinatorics 21, DOI 10.1007/978-3-642-24488-9__19, c Springer-Verlag Berlin Heidelberg 2012

489

490

19 Multicommodity Flows and Edge-Disjoint Paths

for two given vertices s and t (Menger’s Theorems 8.9 and 8.10). We shall prove that the general E DGE-DISJOINT PATHS PROBLEM is NP-hard, both in the directed and undirected case. Nevertheless there are some interesting special cases that can be solved in polynomial time, as we shall see in Sections 19.5 and 19.6.

19.1 Multicommodity Flows We concentrate on the DIRECTED MULTICOMMODITY FLOW PROBLEM but mention that all results of this section also hold for the undirected version:

UNDIRECTED MULTICOMMODITY FLOW PROBLEM Instance:

A pair .G; H / of undirected graphs on the same vertices. Capacities u W E.G/ ! RC and demands b W E.H / ! RC .

Task:

Find a family .x f /f 2E.H / , where x f is an s-t-flow of value b.f / in .V .G/; f.v; w/; .w; v/ W fv; wg 2 E.G/g/ for each f D ft; sg 2 E.H /, and X x f ..v; w// C x f ..w; v// u.e/ f 2E.H /

for all e D fv; wg 2 E.G/. Both versions of the MULTICOMMODITY FLOW PROBLEM have a natural formulation as an LP (cf. the LP formulation of the M AXIMUM FLOW PROBLEM in Section 8.1). Hence they can be solved in polynomial time (Theorem 4.18). Today exact polynomial-time algorithms which do not use LINEAR PROGRAMMING are known only for some special cases. We shall now mention a different LP formulation of the MULTICOMMODITY FLOW PROBLEM which will prove useful: Lemma 19.1. Let .G; H; u; b/ be an instance of the (DIRECTED or UNDIRECTED) MULTICOMMODITY FLOW PROBLEM. Let C be the set of circuits of G C H that contain exactly one demand edge. Let M be a 0-1-matrix whose columns correspond to the elements of C and whose rows correspond to the edges of G, where Me;C D 1 iff e 2 C . Similarly, let N be a 0-1-matrix whose columns correspond to the elements of C and whose rows correspond to the edges of H , where Nf;C D 1 iff f 2 C. Then each solution of the MULTICOMMODITY FLOW PROBLEM corresponds to at least one point in the polytope ˚ y 2 RC W y 0; My u; Ny D b ; (19.1) and each point in this polytope corresponds to a unique solution of the MULTICOMMODITY FLOW PROBLEM .

19.1

Multicommodity Flows

491

Proof: To simplify our notation we consider the directed case only; the undirected case follows by substituting each undirected edge by the subgraph shown in Figure 8.2. Let .x f /f 2E.H / be a solution of the MULTICOMMODITY FLOW PROBLEM. For each f D .t; s/ 2 E.H / the s-t-flow x f can be decomposed into a set P of s-tpaths and a set Q of circuits (Theorem 8.8): for each demand edge f we can write X x f .e/ D w.P / P 2P[QW e2E.P /

for e 2 E.G/, where w W P [ Q ! RC . We set yP Cf WD w.P / for P 2 P and yC WD 0 for f 2 C 2 C with C f 62 P. This obviously yields a vector y 0 with My u and Ny D b. Conversely, let y 0 with My u and Ny D b. Setting X x f .e/ WD yC C 2CW e;f 2E.C /

yields a solution of the MULTICOMMODITY FLOW PROBLEM.

With the help of LP duality we can now derive a necessary and sufficient condition for the solvability of the MULTICOMMODITY FLOW PROBLEM. We shall also mention the connection to the EDGE-DISJOINT PATHS PROBLEM. Definition 19.2. An instance .G; H / of the (DIRECTED or UNDIRECTED) EDGEDISJOINT PATHS PROBLEM satisfies the distance criterion if for each ´ W E.G/ ! RC X X dist.G;´/ .s; t/ ´.e/: (19.2) f D.t;s/2E.H /

e2E.G/

An instance .G; H; u; b/ of the MULTICOMMODITY FLOW PROBLEM satisfies the distance criterion if for each ´ W E.G/ ! RC X X b.f / dist.G;´/ .s; t/ u.e/´.e/: f D.t;s/2E.H /

e2E.G/

(In the undirected case, .t; s/ must be replaced by ft; sg.) The left-hand side of the distance criterion can be interpreted as a lower bound on the cost of a solution (with respect to edge costs ´), while the right-hand side is an upper bound on the maximum possible cost. Theorem 19.3. The distance criterion is necessary and sufficient for the solvability of the MULTICOMMODITY FLOW PROBLEM (in both the directed and the undirected case). Proof: We again consider only the directed case, the undirected case follows via the substitution of Figure 8.2. By Lemma 19.1, the MULTICOMMODITY FLOW

492

19 Multicommodity Flows and Edge-Disjoint Paths

˚ PROBLEM has a solution if and only if the polyhedron y 2 RCC W My u; Ny D b is nonempty. By Corollary 3.25, this polyhedron is empty if and only if there are vectors ´; w with ´ 0, ´M C wN 0 and ´u C wb < 0. (M and N are defined as above.) The inequality ´M C wN 0 implies X wf ´e e2P

for each demand edge f D .t; s/ and each s-t-path P in G, so wf dist.G;´/ .s; t/. Hence there exist vectors ´; w with ´ 0, ´M C wN 0 and ´u C wb < 0 if and only if there exists a vector ´ 0 with X ´u dist.G;´/ .s; t/ b.f / < 0: f D.t;s/2E.H /

This completes the proof.

In Section 19.2 we shall show how the LP description of Lemma 19.1 and its dual can be used to design an algorithm for the MULTICOMMODITY FLOW PROBLEM. Theorem 19.3 implies that the distance criterion is necessary for the solvability of the EDGE-DISJOINT PATHS PROBLEM, since this can be considered as a MULTICOMMODITY FLOW PROBLEM with b 1, u 1 and with integrality constraints. Another important necessary condition is the following: Definition 19.4. An instance .G; H / of the (DIRECTED or UNDIRECTED) EDGEDISJOINT PATHS PROBLEM satisfies the cut criterion if for each X V .G/ C jıG .X /j jıH .X /j jıG .X /j jıH .X /j

in the directed case, or in the undirected case.

An instance .G; H; u; b/ of the (DIRECTED or UNDIRECTED) MULTICOMMODITY FLOW PROBLEM satisfies the cut criterion if for each X V .G/ C u.ıG .X // b.ıH .X // u.ıG .X // b.ıH .X //

in the directed case, or in the undirected case.

Corollary 19.5. For an instance .G; H / of the (DIRECTED or UNDIRECTED) EDGE-DISJOINT PATHS PROBLEM, the following implications hold: .G; H / has a solution ) .G; H / satisfies the distance criterion ) .G; H / satisfies the cut criterion. Proof: The first implication follows from Theorem 19.3. For the second implication observe that the cut criterion is just a special case of the distance criterion, where weight functions of the type ( 1 if e 2 ı C .X / (directed case) or e 2 ı.X / (undirected case) ´.e/ WD 0 otherwise

19.1

a

1

2

2

1

b

Multicommodity Flows

1

2

2

1

493

Fig. 19.1.

for X V .G/ are considered.

None of the implications can be reversed in general. Figure 19.1 shows examples where there is no (integral) solution but there is a fractional solution, i.e. a solution of the multicommodity flow relaxation. So here the distance criterion is satisfied. In the figures of this section demand edges are indicated by equal numbers at their endpoints. In the directed case, one should orient the demand edges so that they are realizable. (A demand edge .t; s/ or ft; sg is called realizable if t is reachable from s in the supply graph.)

a

b

2,4

1,3

1

2 3

1

4

5

1 2

5

4

2,3

3,4

Fig. 19.2.

The two examples shown in Figure 19.2 satisfy the cut criterion (this is easily checked), but not the distance criterion: in the undirected example choose ´.e/ D 1 for all e 2 E.G/, in the directed example choose ´.e/ D 1 for the bold edges and ´.e/ D 0 otherwise. We remark that it is NP-hard to check whether a given instance of the UNDIRECTED E DGE -D ISJOINT PATHS PROBLEM satisfies the cut criterion (Exercise 2). This is in contrast to the distance criterion, which can be checked in polynomial time by linear programming. For some classes of instances of the E DGE-DISJOINT PATHS PROBLEM the cut criterion is sufficient for the existence of a solution. We will see some examples later

494

19 Multicommodity Flows and Edge-Disjoint Paths

in this chapter. A first example is Menger’s Theorem. To generalize this slightly, we use the following construction. Lemma 19.6. Let .G; H / be an instance of the (DIRECTED or UNDIRECTED) EDGE-DISJOINT PATHS PROBLEM and v 2 V .G/. Let .G 0 ; H 0 / result from .G; H / by adding a new vertex x and doing the following for each demand edge f incident to v: If f D fv; wg, then replace f by fv; xg and add a supply edge fw; xg. If f D .v; w/, then replace f by .v; x/ and add a supply edge .x; w/. If f D .w; v/, then replace f by .x; v/; and add a supply edge .w; x/. Then .G 0 ; H 0 / has a solution if and only if .G; H / has a solution. Moreover, 0 .G ; H 0 / satisfies the cut criterion if and only if .G; H / does. Proof: Any solution to .G 0 ; H 0 / yields a solution to .G; H / by omitting the new supply edges. Conversely, any solution to .G; H / can be transformed into a solution to .G 0 ; H 0 / by appending the new supply edges. For the cut criterion, we observe that for any set X V .G 0 / D V .G/ [ fxg we have C C jıG 0 .X /j jıH 0 .X /j jıG .X n fxg/j jıH .X n fxg/j or jıG 0 .X /j jıH 0 .X /j jıG .X n fxg/j jıH .X n fxg/j; respectively, with equality if jX \ fv; xgj D 1.

Theorem 19.7. Let .G; H / be an instance of the (DIRECTED or UNDIRECTED) EDGE-DISJOINT PATHS PROBLEM with a vertex v such that (a) f 2 ı C .v/ for all f 2 E.H /, or (b) f 2 ı .v/ for all f 2 E.H / in the directed case, or (c) f 2 ı.v/ for all f 2 E.H / in the undirected case. Then .G; H / has a solution if and only if the cut criterion holds. Proof: By Lemma 19.6 we can reduce this to the case where H contains only one set of parallel edges. In this case the sufficiency of the cut criterion is a reformulation of Menger’s Theorem 8.9.

19.2 Algorithms for Multicommodity Flows The definition of the MULTICOMMODITY FLOW PROBLEM directly gives rise to an LP formulation of polynomial size. Although this yields a polynomial-time algorithm it cannot be used for solving large instances: the number of variables is enormous. The LP description (19.1) given by Lemma 19.1 looks even worse since it has an exponential number of variables. Nevertheless this description proves much more useful in practice. We shall explain this now. Since we are interested in a feasible solution only, we consider the LP

19.2

Algorithms for Multicommodity Flows

495

maxf0y W y 0; My u; Ny D bg and its dual minf´u C wb W ´ 0; ´M C wN 0g which we can rewrite as minf´u C wb W ´ 0; dist.G;´/ .s; t/ w.f / for all f D .t; s/ 2 E.H /g: (In the undirected case replace .t; s/ by ft; sg.) This dual LP has only jE.G/j C jE.H /j variables but an exponential number of constraints. However, this is not important since the SEPARATION PROBLEM can be solved by jE.H /j shortest path computations; as only nonnegative vectors ´ have to be considered, we can use DIJKSTRA’S ALGORITHM here. If the dual LP is unbounded, then this proves infeasibility of the primal LP. Otherwise we can solve the dual LP, but this does not provide a primal solution in general. Ford and Fulkerson [1958] suggested to use the above consideration to solve the primal LP directly, in combination with the SIMPLEX ALGORITHM. Since most variables are zero at each iteration of the SIMPLEX ALGORITHM, one only keeps track of those variables for which the nonnegativity constraint yC 0 does not belong to the current set J of active rows. The other variables are not stored explicitly but “generated” when they are needed (when the nonnegativity constraint becomes inactive). The decision of which variable has to be generated in each step is equivalent to the SEPARATION PROBLEM for the dual LP, so in our case it reduces to a SHORTEST PATH PROBLEM. This column generation technique can be quite efficient in practice. Even with these techniques there are many practical instances that cannot be solved optimally. However, the above scheme also gives rise to an approximation algorithm. Let us first formulate our problem as an optimization problem:

MAXIMUM MULTICOMMODITY FLOW PROBLEM Instance:

A pair .G; H / of digraphs on the same vertices. Capacities u W E.G/ ! RC .

Task:

Find a family .x f /f 2E.H / , where x f is an s-t-flow in G for each P f D .t; s/ 2 E.H /, f 2E.H / x f .e/ u.e/ for all e 2 E.G/, and P the total flow value f 2E.H / value .x f / is maximum.

There are other interesting formulations. For example one can look for flows satisfying the greatest possible fraction of given demands (the CONCURRENT FLOW PROBLEM), or for flows satisfying given demands but violating capacities as slightly as possible. Moreover one can consider costs on edges. We consider only the MAXIMUM M ULTICOMMODITY FLOW PROBLEM ; other problems can be attacked with similar techniques. We again consider our LP formulation 8 9 <X = X max y.P / W y 0; y.P / u.e/ for all e 2 E.G/ ; : ; P 2P

P 2PWe2E.P /

496

19 Multicommodity Flows and Edge-Disjoint Paths

where P is the family of the s-t-paths in G for all .t; s/ 2 E.H /, and its dual 9 8 = < X ´.e/ 1 for all P 2 P : min ´u W ´ 0; ; : e2E.P /

We shall describe a primal-dual algorithm based on these formulations which turns out to be a fully polynomial approximation scheme. This algorithm always has a primal vector y 0 that is not necessarily a feasible primal solution since capacity constraints might be violated. Initially y D 0. At the end we shall multiply y by a constant in order to meet all constraints. To store y efficiently we keep track of the family P 0 P of those paths P with y.P / > 0; in contrast to P the cardinality of P 0 will be polynomially bounded. The algorithm also has a dual vector ´ 0. Initially, ´.e/ D ı for all e 2 E.G/, where ı depends on n and the error parameter . In each iteration, it finds a maximally violated dual constraint (corresponding to a shortest s-t-path for .t; s/ 2 E.H /, with respect to edge lengths ´) and increases ´ and y along this path:

MULTICOMMODITY FLOW APPROXIMATION SCHEME Input: Output: 1 2 3

4

A pair .G; H / of digraphs on the same vertices. Capacities u W E.G/ ! RC n f0g. A number with 0 < 12 . P Numbers y W P ! RC with P 2PWe2E.P / y.P / u.e/ for all e 2 E.G/.

Set y.P / WD 0 for all P 2 P. 5 Set ı WD .n.1 C //d e .1 C / and ´.e/ WD ı for all e 2 E.G/. Let P 2 P such that ´.E.P // is minimum. If ´.E.P // 1, then go to . 4 Let WD min u.e/. e2E.P /

Set y.P / WD y.P/ C . for all e 2 E.P /. Set ´.e/ WD ´.e/ 1 C u.e/ Go to . 2 X 1 y.P /. Let WD max e2E.G/ u.e/ Set y.P / WD

y.P /

P 2PWe2E.P /

for all P 2 P.

This algorithm is due to Young [1995] and Garg and Könemann [2007], based on earlier work of Shahrokhi and Matula [1990], Shmoys [1996], and others. Theorem 19.8. (Garg and Könemann [2007]) The MULTICOMMODITY FLOW APPROXIMATION SCHEME produces a feasible solution with total flow value at 1 least 1C OPT.G; H; u/. Its running time is O 12 km.m C n log n/ log n , where

19.2

Algorithms for Multicommodity Flows

497

k D jE.H /j, n D jV .G/j and m D jE.G/j, so it is a fully polynomial approximation scheme. Proof: In each iteration the value ´.e/ increases by a factor 1 C for at least one edge e (the bottleneck edge). Since an edge e with ´.e/ 1 is never used anymore in any path, the total number of iterations is t mdlog1C . 1ı /e. In each iteration we have to solve k instances of the SHORTEST PATH PROBLEM with nonnegative weights to determine P . Using DIJKSTRA’S ALGORITHM (Theorem 7.4) we get an overall running time of O.tk.m C n log n// D O km.m C n log n/ log1C . 1ı / . The stated running time now follows from observing that, for 0 < 1, ˙5 log. 1ı / log.2n/ 1 log n log1C D I D O ı log.1 C / 2 2 here we used log.1 C / 2 for 0 < 1. We also have to check that the maximum number of bits needed to store any number occurring in the computation is bounded by a polynomial in log n C size.u/ C size./ C 1 . This is clear for the y-variables. The number ı can be stored with O. 1 size.n.1 C // C size.// D O. 1 .log n C size./// bits. To deal with the ´-variables we assume that u is integral; otherwise we multiply all capacities by the product of the denominators in the beginning (cf. Proposition 4.1). Then the denominator of the ´-variables is bounded at any time by the product of all capacities and the denominator of ı. Since the numerator is at most twice the denominator we have shown that the size of all numbers is indeed polynomial in the input size and 1 . The feasibility of the solution is guaranteed by . 4 Note that every increase the weight time we add units of flow on edge e we ´.e/ by a factor 1 C u.e/ . This value is at least .1 C / u.e/ because 1 C a .1 C /a holds for 0 a 1 (both sides of this inequality are equal for a 2 f0; 1g, and the left-hand side is linear in a while the right-hand side is convex). Since e is not used once ´.e/ 1, we cannot add more than u.e/.1 C log1C . 1ı // units of flow on edge e. Hence 1 1C 1 C log1C D log1C : (19.3) ı ı Let ´.i / denote the vector ´ after iteration i , and let Pi and P i be the path P and the number in iteration i . We have ´.i / u D ´.i 1/ u C i e2E.Pi / ´.i 1/ .e/, P so .´.i / ´.0/ /u D ji D1 j ˛.´.j 1/ /, where ˛.´/ WD minP 2P ´.E.P //. Let us n o write ˇ WD min ´u W ´ 2 RE.G/ ; ˛.´/ 1 . Then .´.i / ´.0/ /u ˇ˛.´.i / ´.0/ / C and thus .˛.´.i / / ın/ˇ ˛.´.i / ´.0/ /ˇ .´.i / ´.0/ /u. We obtain ˛.´.i / / ın C

i X j ˛.´.j 1/ /: ˇ j D1

(19.4)

498

19 Multicommodity Flows and Edge-Disjoint Paths

We now prove ın C

P i i X j ˛.´.j 1/ / ıne ˇ j D1 j : ˇ

(19.5)

j D1

by induction on i (here e denotes the base of the natural logarithm). The case i D 0 is trivial. For i > 0 we have ın C

i i 1 X X j ˛.´.j 1/ / D ın C j ˛.´.j 1/ / C i ˛.´.i 1/ / ˇ ˇ ˇ j D1 j D1 P i 1 j D1 j ˇ 1 C i ıne ; ˇ

using (19.4) and the induction hypothesis. Using 1 C x < e x for all x > 0 the proof of (19.5) is complete. In particular we conclude from (19.4), (19.5) and the stopping criterion that .t /

ˇ

Pt

j D1 j

1 ˛.´ / ıne ; P 1 hence jt D1 j ˇ ln ın . Now observe that the total flow value that the algoP P rithm computes is P 2P y.P / D 1 jt D1 j . By the above and (19.3) this is at least 1 1 ˇ ln ın ˇ ln.1 C / ln ın D log1C . 1C ln. 1C ı / ı / D

ˇ ln.1 C / .d 5 e 1/ ln.n.1 C // d 5 e ln.n.1 C //

ˇ.1 5 / ln.1 C /

by the choice of ı. Recall that ˇ is the optimum value of the dual LP, and hence, by the LP Duality Theorem 3.20, the optimum value of a primal solution. Moreover, 2 ln.1 C / 2 (this inequality is trivial for D 0 and the derivative of the left-hand side is greater than that of the right-hand side for every > 0). Hence 1C .1 5 / ln.1 C / 1 1 D 5 2

3 10

6 2 10 C 1C

1 3 10

1 1C

for 12 . We conclude that the algorithm finds a solution whose total flow value is 1 at least 1C OPT.G; H; u/. A different algorithm which gives the same running time (by a more complicated analysis) was published before by Grigoriadis and Khachiyan [1996]. Fleischer [2000] improved the running time of the above algorithm by a factor of k. She

19.3

Sparsest Cut and Max-Flow Min-Cut Ratio

499

observed that it is sufficient to compute an approximate shortest path in , 2 and used this fact to show that it is not necessary to do a shortest path computation for each .t; s/ 2 E.H / in each iteration. See also Karakostas [2008], Müller, Radke and Vygen [2011], Bienstock and Iyengar [2006], and Chudak and Eleutério [2005].

19.3 Sparsest Cut and Max-Flow Min-Cut Ratio Consider the following problem:

GENERALIZED SPARSEST CUT PROBLEM Instance:

An instance .G; H; u; b/ of the UNDIRECTED MULTICOMMODITY FLOW PROBLEM.

Task:

Find a set X V .G/ with b.ıH .X // > 0 and

u.ıG .X// b.ıH .X//

minimum.

The special case where H is the complete undirected graph and b.f / D 1 for all f 2 E.H / is called the SPARSEST CUT PROBLEM: here we ask for a nonempty u.ıG .X// proper subset X of the vertex set such that jXjjV .G/nXj is minimum. The corresponding special case of the UNDIRECTED MULTICOMMODITY FLOW PROBLEM is called the UNIFORM MULTICOMMODITY FLOW PROBLEM. u.ıG .X// The minimum value of b.ı is clearly an upper bound on the optimum value H .X// of the instance .G; H; u; b/ of the CONCURRENT FLOW PROBLEM, which can be written as ( X max W y.P / 0 .P 2 P/; y.P / b.f / .f 2 E.H //; X

P 2Pf

)

(19.6)

y.P / u.e/ .e 2 E.G// ;

P 2PWe2E.P /

whereSPf denotes the family of the s-t-paths in G, for f D ft; sg 2 E.H /, and P D f 2E.H / Pf . If we introduce decision variables ´e 2 f0; 1g for e 2 E.G/, with the intended meaning that ´ is the incidence vector of ıG .X /, we can write the GENERALIZED SPARSEST CUT PROBLEM as an integer nonlinear program ( u> ´ min > W ´ 2 f0; 1gE.G/ ; w 2 f0; 1gE.H /; b > w > 0; b w ) (19.7) X ´.e/ w.f / .P 2 Pf ; f 2 E.H // : e2E.P /

Proposition 19.9. The GENERALIZED SPARSEST CUT PROBLEM is equivalent to (19.7): the optimum values are the same, and from a solution to the latter we can obtain in linear time an at least as good solution of the former (and vice versa).

500

19 Multicommodity Flows and Edge-Disjoint Paths

Proof: For a set X V .G/ vectors of ıG .X / and ıH .X /, > u.ıG .X// (19.7) and bu> w´ D b.ı . H .X// Conversely, if .´; w/ is a be the connected components P p

mini D1

u.ıG .Xi // b.ıH .Xi //

p

i D1 Pp

with b.ıH .X // > 0 let ´ and w be the incidence respectively. Then .´; w/ is a feasible solution of feasible solution of (19.7), then let X1 ; : : : ; Xp of .V .G/; fe 2 E.G/ W ´.e/ D 0g/. We have

u.ıG .Xi //

b.ıH .Xi // i D1

2u> ´ 2b > w

D

u> ´ . b>w

Any feasible solution to (19.7) can be scaled (by multiplying all variables with an appropriate positive constant) to a feasible solution of ( E.G/

min u> ´ W ´ 2 RC X

E.H /

; w 2 RC

; b > w D 1; )

(19.8)

´.e/ w.f / .P 2 Pf ; f 2 E.H // ;

e2E.P /

of course with the same objective function value. So (19.8) can be viewed as an LP relaxation. Lemma 19.10. The linear program (19.8) can be solved in polynomial time. Proof: If t is not reachable from s in G for some f D ft; sg 2 E.H / with b.f / > 0, the LP is easy to solve, and the optimum value is zero. Otherwise there is an optimum solution .´; w/ with w.f / D dist.G;´/ .s; t/ for all f D ft; sg 2 E.H P /. We add new variables d.fa; bg/ for a; b 2 V .G/ and replace the constraints e2E.P / ´.e/ w.f / for P 2 Pf and f 2 E.H / equivalently by d.e/ ´.e/ for e 2 E.G/, w.f / d.f / for f 2 E.H /, and d.fa; cg/ d.fa; bg/ C d.fb; cg/ for a; b; c 2 V .G/. We obtain an LP of polynomial size and can apply Theorem 4.18. But there is also a combinatorial fully polynomial approximation scheme similar to the one in Section 19.2, because (19.8) is the dual LP of (19.6), the CONCURRENT FLOW PROBLEM (cf. Exercise 5). The maximum ratio of the optimum values of (19.7) and (19.8) is called the max-flow min-cut ratio of the multicommodity flow instance. It can be as large as ‚.log n/, where n D jV .G/j, even in the uniform case (i.e., when H is the complete graph and b 1). This is demonstrated by an expander graph with unit capacities (cf. Exercise 6). In the next section we show that it is never worse.

19.4 The Leighton-Rao Theorem We will use a solution .´; w/ to the LP (19.8) in order to compute a sparse cut. If .´; w/ is an optimum solution, then W WD u> ´ is a lower bound on the sparsity u.ıG .X// minXV .G/ jXjjV .G/nXj . We will not need w in the following. Following Leighton and Rao [1999], we first partition our graph into low diameter sets such that the capacity of the multicut is rather small.

19.4

The Leighton-Rao Theorem

501

Lemma 19.11. (Leighton and Rao [1999]) Let G be an undirected graph with edge weights ´ W E.G/ ! RC and capacities u W E.G/ ! RC . The diameter of a nonempty set X V .G/ is defined as maxv;v0 2X dist.G;´/ .v; v 0 /. Let d > 0. Then V .G/ can be partitioned into sets V1 ; : : : ; Vk , each with diameter at most d , suchPthat the total capacity of edges in the multicut is at most 8W dlog n , where W WD e2E.G/ u.e/´.e/. Moreover, such a partition can be computed in O.m log n/ time, where n WD jV .G/j and m WD jE.G/j. Proof: We first deal with some trivial cases. Let U WD u.E.G//. If U D 0 or d 8WUlog n , the partition into singletons does the job. If W D 0, then we take the connected components of .V .G/; fe 2 E.G/ W ´.e/ D 0g/. log n Otherwise we have WP> 0 and WD 2WUd < 14 . Set ´0 .e/ WD dU ´.e/=W e 0 for e 2 E.G/. Note that e2E.G/ ´ .e/u.e/ < 2U . Then we apply the following procedure, starting P with i WD 1 and G1 WD G. x1 2U Choose vi 2 V .Gi /. For x 2 ZC let Uxi WD n1 C D0 u.ıGi .Bi //, where Bi denotes the set of vertices at distance at most from vi in .Gi ; ´0 /. Choose ri 0 smallest such that Urii C1 < 2 Urii . Set Vi WD Brii . Set Gi C1 WD Gi Vi , increment i , and iterate until no vertices are left. : : We get a partition V .G/ D V1 [ [ Vk . For each i we have Urii 2ri U0i D P 2U 2U 2U n 2ri n1 and hence 2ri n1 Urii n1 C e2E.G/ ´0 .e/u.e/ 2U n1 . Thus ri log n . For any two vertices v; v 0 2 Vi we have dist.G;´/ .v; v 0 / W dist.G;´0 / .v; v 0 / U 2W log n W .dist.G;´0 / .vi ; v/ C dist.G;´0 / .vi ; v 0 // W 2ri U D d . U U We have u.ıGi .Vi // D Urii C1 Urii < .2 1/Urii Urii for i D 1; : : : ; k. Summation yields u.ıG .V1 ; : : : ; Vk // D

k X

u.ıGi .Vi //

i D1

k X i D1

Urii

0

D @

2U k C n1

0 @2U C

k rX i 1 X i D1 D0

X

1 u.ıGi .Bi //A 1

´0 .e/u.e/A

e2E.G/

< 4U: This procedure can be implemented similarly to DIJKSTRA’S ALGORITHM. In each iteration we only need to consider x D 0 and the values x > 0 for which i ıGi .Bxi / 6D ıGi .Bx1 /. After each of these steps we check whether ri D x. Otherwise we compute the value x 0 D x C1 Cb1=.2 1/Uxi =u.ıGi .Bxi //c. If ıGi .Bi /

502

19 Multicommodity Flows and Edge-Disjoint Paths

remains constant for D x; x C 1; : : : ; x 0 , then x 0 is the smallest integer for which u.ıGi .Bxi 0 // D u.ıGi .Bxi // < .2 1/.Uxi C .x 0 x/u.ıGi .Bxi /// D .2 1/Uxi 0 , and thus the number ri P that we look for. Hence we have O. w2Bri .1 C jı.w/j// operations in iteration i , and O.m C i n log n/ total time with Fibonacci heaps. Now we can prove the main theorem of Leighton and Rao [1999]: Theorem 19.12. Let G be a graph with P edge weights ´ W E.G/ ! RC and capacities u W E.G/ ! RC . Suppose that fv;v0 g2.V .G// dist.G;´/ .v; v 0 / D 1. Let 2 n WD jV .G/j. Then we can find a nonempty proper subset X V .G/ with u.ı.X // 36 W log n; jX jjV .G/ n X j where again W WD

P e2E.G/

u.e/´.e/.

Proof: We first apply Lemma 19.11 with d D :

:

1 . n2

We get a partition V .G/ D

V1 [ [ Vk . If none of the sets V1 ; : : : ; Vk has more than 2n vertices, then we successively 3 unite the two smallest sets until o