Lecture Notes for IEOR 266: Graph Algorithms and Network Flows
Total Page:16
File Type:pdf, Size:1020Kb
Lecture Notes for IEOR 266: Graph Algorithms and Network Flows Professor Dorit S. Hochbaum Contents 1 Introduction 1 1.1 Assignment problem . 1 1.2 Basic graph definitions . 2 2 Totally unimodular matrices 4 3 Minimum cost network flow problem 5 3.1 Transportation problem . 7 3.2 The maximum flow problem . 8 3.3 The shortest path problem . 8 3.4 The single source shortest paths . 9 3.5 The bipartite matching problem . 9 3.6 Summary of classes of network flow problems . 11 3.7 Negative cost cycles in graphs . 11 4 Other network problems 12 4.1 Eulerian tour . 12 4.1.1 Eulerian walk . 14 4.2 Chinese postman problem . 14 4.2.1 Undirected chinese postman problem . 14 4.2.2 Directed chinese postman problem . 14 4.2.3 Mixed chinese postman problem . 14 4.3 Hamiltonian tour problem . 14 4.4 Traveling salesman problem (TSP) . 14 4.5 Vertex packing problems (Independent Set) . 15 4.6 Maximum clique problem . 15 4.7 Vertex cover problem . 15 4.8 Edge cover problem . 16 4.9 b-factor (b-matching) problem . 16 4.10 Graph colorability problem . 16 4.11 Minimum spanning tree problem . 17 5 Complexity analysis 17 5.1 Measuring quality of an algorithm . 17 5.1.1 Examples . 18 5.2 Growth of functions . 20 i IEOR266 notes: Updated 2014 ii 5.3 Definitions for asymptotic comparisons of functions . 21 5.4 Properties of asymptotic notation . 21 5.5 Caveats of complexity analysis . 21 5.6 A sketch of the ellipsoid method . 22 6 Graph representations 23 6.1 Node-arc adjacency matrix . 23 6.2 Node-node adjacency matrix . 23 6.3 Node-arc adjacency list . 24 6.4 Comparison of the graph representations . 25 6.4.1 Storage efficiency comparison . 25 6.4.2 Advantages and disadvantages comparison . 25 7 Graph search algorithms 25 7.1 Generic search algorithm . 25 7.2 Breadth first search (BFS) . 26 7.3 Depth first search (DFS) . 27 7.4 Applications of BFS and DFS . 27 7.4.1 Checking if a graph is strongly connected . 27 7.4.2 Checking if a graph is acyclic . 28 7.4.3 Checking of a graph is bipartite . 29 8 Shortest paths 29 8.1 Introduction . 29 8.2 Properties of DAGs . 29 8.2.1 Topological sort and directed acyclic graphs . 30 8.3 Properties of shortest paths . 31 8.4 Alternative formulation for SP from s to t ........................ 32 8.5 Shortest paths on a directed acyclic graph (DAG) . 32 8.6 Applications of the shortest/longest path problem on a DAG . 33 8.7 Dijkstra's algorithm . 36 8.8 Bellman-Ford algorithm for single source shortest paths . 39 8.9 Floyd-Warshall algorithm for all pairs shortest paths . 41 8.10 D.B. Johnson's algorithm for all pairs shortest paths . 42 8.11 Matrix multiplication algorithm for all pairs shortest paths . 43 8.12 Why finding shortest paths in the presence of negative cost cycles is difficult . 44 9 Maximum flow problem 45 9.1 Introduction . 45 9.2 Linear programming duality and max flow min cut . 46 9.3 Applications . 47 9.3.1 Hall's theorem . 47 9.3.2 The selection problem . 48 9.3.3 The maximum closure problem . 51 9.3.4 The open-pit mining problem . 54 9.3.5 Forest clearing . 54 9.3.6 Producing memory chips (VLSI layout) . 55 9.4 Flow Decomposition . 56 IEOR266 notes: Updated 2014 iii 9.5 Algorithms . 57 9.5.1 Ford-Fulkerson algorithm . 57 9.5.2 Maximum capacity augmenting path algorithm . 60 9.5.3 Capacity scaling algorithm . 61 9.5.4 Dinic's algorithm for maximum flow . 62 10 Goldberg's Algorithm - the Push/Relabel Algorithm 68 10.1 Overview . 68 10.2 The Generic Algorithm . 69 10.3 Variants of Push/Relabel Algorithm . 72 10.4 Wave Implementation of Goldberg's Algorithm (Lift-to-front) . 72 11 The pseudoflow algorithm 73 11.1 Initialization . 74 11.2 A labeling pseudoflow algorithm . 75 11.3 The monotone pseudoflow algorithm . 76 11.4 Complexity summary . 77 12 The minimum spanning tree problem (MST) 79 12.1 IP formulation . 79 12.2 Properties of MST . 80 12.2.1 Cut Optimality Condition . 80 12.2.2 Path Optimality Condition . 81 12.3 Algorithms of MST . 81 12.3.1 Prim's algorithm . 82 12.3.2 Kruskal's algorithm . 83 12.4 Maximum spanning tree . 83 13 Complexity classes and NP-completeness 84 13.1 Search vs. Decision . 85 13.2 The class NP ........................................ 86 13.2.1 Some Problems in NP ............................... 86 13.3 co-NP ............................................ 87 13.3.1 Some Problems in co-NP ............................. 87 13.4 NP and co-NP ....................................... 87 13.5 NP-completeness and reductions . 88 13.5.1 Reducibility . 88 13.5.2 NP-Completeness . 89 14 Approximation algorithms 93 14.1 Traveling salesperson problem (TSP) . 94 14.2 Vertex cover problem . 95 14.3 Integer programs with two variables per inequality . 98 15 Necessary and Sufficient Condition for Feasible Flow in a Network 99 15.1 For a network with zero lower bounds . 99 15.2 In the presence of positive lower bounds . 100 15.3 For a circulation problem . 100 15.4 For the transportation problem ..