Agenda. Soviet Rail Network, We ve done Greedy Method Divide and Conquer Dynamic Programming

Similar documents
Algorithms and Theory of Computation. Lecture 11: Network Flow

Soviet Rail Network, 1955

Algorithm Design and Analysis

Algorithm Design and Analysis

7.5 Bipartite Matching

Running Time. Assumption. All capacities are integers between 1 and C.

Chapter 7. Network Flow. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Maximum flow problem

Algorithm Design and Analysis

directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time

CSC 373: Algorithm Design and Analysis Lecture 12

Chapter 7. Network Flow. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Algorithms: Lecture 12. Chalmers University of Technology

Undirected Graphs. V = { 1, 2, 3, 4, 5, 6, 7, 8 } E = { 1-2, 1-3, 2-3, 2-4, 2-5, 3-5, 3-7, 3-8, 4-5, 5-6 } n = 8 m = 11

10 Max-Flow Min-Cut Flows and Capacitated Graphs 10 MAX-FLOW MIN-CUT

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

The max flow problem. Ford-Fulkerson method. A cut. Lemma Corollary Max Flow Min Cut Theorem. Max Flow Min Cut Theorem

Maximum Flow. Jie Wang. University of Massachusetts Lowell Department of Computer Science. J. Wang (UMass Lowell) Maximum Flow 1 / 27

Chapter 7. Network Flow. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Two Applications of Maximum Flow

6.046 Recitation 11 Handout

CMPSCI 611: Advanced Algorithms

1 Matchings in Non-Bipartite Graphs

Max Flow: Algorithms and Applications

Mathematics for Decision Making: An Introduction. Lecture 13

Types of Networks. Internet Telephone Cell Highways Rail Electrical Power Water Sewer Gas

Algorithm Design and Analysis

Computer Science & Engineering 423/823 Design and Analysis of Algorithms

Algorithms: COMP3121/3821/9101/9801

7. NETWORK FLOW II. bipartite matching disjoint paths extensions to max flow 3D Memory Reliability survey design airline scheduling image segmentation

GRAPH ALGORITHMS Week 7 (13 Nov - 18 Nov 2017)

Flows and Cuts. 1 Concepts. CS 787: Advanced Algorithms. Instructor: Dieter van Melkebeek

Chapter 7. Network Flow. CS 350: Winter 2018

We say that a flow is feasible for G (or just feasible if the graph and capacity function in question are obvious) if

. CS711008Z Algorithm Design and Analysis. Lecture 10. Algorithm design technique: Network flow and its applications 1. Dongbo Bu

1 Review for Lecture 2 MaxFlow

- Well-characterized problems, min-max relations, approximate certificates. - LP problems in the standard form, primal and dual linear programs

Problem set 1. (c) Is the Ford-Fulkerson algorithm guaranteed to produce an acyclic maximum flow?

CSC2420: Algorithm Design, Analysis and Theory Spring (or Winter for pessimists) 2017

Flow Network. The following figure shows an example of a flow network:

Preliminaries. Graphs. E : set of edges (arcs) (Undirected) Graph : (i, j) = (j, i) (edges) V = {1, 2, 3, 4, 5}, E = {(1, 3), (3, 2), (2, 4)}

Part V. Matchings. Matching. 19 Augmenting Paths for Matchings. 18 Bipartite Matching via Flows

Recall: Matchings. Examples. K n,m, K n, Petersen graph, Q k ; graphs without perfect matching

Maximum Flow. Reading: CLRS Chapter 26. CSE 6331 Algorithms Steve Lai

Network Flows made simple

CSCE423/823. Introduction. Flow Networks. Ford-Fulkerson Method. Edmonds-Karp Algorithm. Maximum Bipartite Matching 2/35 CSCE423/823.

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

Today. Flow review. Augmenting paths. Ford-Fulkerson Algorithm. Intro to cuts (reason: prove correctness)

CS 138b Computer Algorithm Homework #14. Ling Li, February 23, Construct the level graph

CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs. Instructor: Shaddin Dughmi

Maximum flow problem (part I)

Combinatorial Optimization

CSC2420: Algorithm Design, Analysis and Theory Fall 2017

5 Flows and cuts in digraphs

Chapter 7. Network Flow. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Algorithms. Algorithms 6.4 MAXIMUM FLOW

Computing Maximum Flow with Augmenting Electrical Flows

22 Max-Flow Algorithms

Lecture 2: Network Flows 1

Introduction to Graph Theory

Lecture 1. 1 Overview. 2 Maximum Flow. COMPSCI 532: Design and Analysis of Algorithms August 26, 2015

Standard Diraphs the (unique) digraph with no vertices or edges. (modulo n) for every 1 i n A digraph whose underlying graph is a complete graph.

Lecture 2: Divide and conquer and Dynamic programming

The Simplest and Smallest Network on Which the Ford-Fulkerson Maximum Flow Procedure May Fail to Terminate

Algorithms. Algorithms 6.4 MAXIMUM FLOW

CSE 421 Introduction to Algorithms Final Exam Winter 2005

Internet Routing Example

Bipartite Matchings and Stable Marriage

Algorithm Design and Analysis

CS675: Convex and Combinatorial Optimization Fall 2016 Combinatorial Problems as Linear and Convex Programs. Instructor: Shaddin Dughmi

Lecture 21 November 11, 2014

Maximum flow problem CE 377K. February 26, 2015

CSE 202 Homework 4 Matthias Springer, A

Algorithms 6.4 MAXIMUM FLOW. overview Ford-Fulkerson algorithm analysis Java implementation applications

Network Flows. CTU FEE Department of control engineering. March 28, 2017

Graph Algorithms -2: Flow Networks. N. H. N. D. de Silva Dept. of Computer Science & Eng University of Moratuwa

Breadth-First Search of Graphs

Maximum skew-symmetric flows and matchings

Algorithms. Algorithms 6.4 MIN CUT / MAX FLOW

Midterm Exam 2 Solutions

CSE 326: Data Structures Network Flow. James Fogarty Autumn 2007

A New Characterization of König-Egervary Graphs

The min cost flow problem Course notes for Search and Optimization Spring 2004

Lecture 8 Network Optimization Algorithms

Duality of LPs and Applications

Lecture 3. 1 Polynomial-time algorithms for the maximum flow problem

CS 170 DISCUSSION 10 MAXIMUM FLOW. Raymond Chan raychan3.github.io/cs170/fa17.html UC Berkeley Fall 17

Parallel Graph Algorithms (con4nued)

The min cost flow problem Course notes for Optimization Spring 2007

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016)

An algorithm to increase the node-connectivity of a digraph by one

8. INTRACTABILITY I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 2/6/18 2:16 AM

Bipartite Matchings. Andreas Klappenecker

Exposition of the Dinitz algorithm

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2019

Design and Analysis of Algorithms

Mathematical Programs Linear Program (LP)

Observation 4.1 G has a proper separation of order 0 if and only if G is disconnected.

Parallel Graph Algorithms (con4nued)

Observation 4.1 G has a proper separation of order 0 if and only if G is disconnected.

Transcription:

Agenda We ve done Greedy Method Divide and Conquer Dynamic Programming Now Flow Networks, Max-flow Min-cut and Applications c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 1 / 52 Soviet Rail Network, 1955 c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 3 / 52

Maximum Flow and Minimum Cut Problems Cornerstone problems in combinatorial optimization Many non-trivial applications/reductions: airline scheduling, data mining, bipartite matching, image segmentation, network survivability, many many many more... Simple Example: on the Internet with error-free transmission, what is the maximum data rate that a router s can send to a router t (assuming no network coding is allowed), given that each link has limited capacity More examples and applications to come c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 4 / 52 Flow Networks A flow network is a directed graph G = (V, E) where each edge e has a capacity c(e) > 0 Also, there are two distinguished nodes: the source s and the sink t c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 6 / 52

Cuts An s, t-cut is a partition (A, B) of V where s A, t B Let [A, B] = set of edges (u, v) with u A, v B The capacity of the cut (A, B) is defined by cap(a, B) = c(e) e [A,B] c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 7 / 52 Cuts An s, t-cut is a partition (A, B) of V where s A, t B Let [A, B] = set of edges (u, v) with u A, v B The capacity of the cut (A, B) is defined by cap(a, B) = c(e) e [A,B] c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 8 / 52

Minimum Cut Problem Definition Given a flow network, find an s, t-cut with minimum capacity c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 9 / 52 Flows An s, t-flow is a function f : E R satisfying Capacity constraint: 0 f(e) c(e), e E Flow Conservation constraint: f(e) = The value of f: val(f) = e=(s,v) E e=(u,v) E f(e) e=(v,w) E f(e), v s, t c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 10 / 52

Flows An s, t-flow is a function f : E R satisfying Capacity constraint: 0 f(e) c(e), e E Flow Conservation constraint: f(e) = The value of f: val(f) = e=(s,v) E e=(u,v) E f(e) e=(v,w) E f(e), v s, t c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 11 / 52 Maximum Flow Problem Definition Given a flow network, find a flow f with maximum capacity c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 12 / 52

Flows and Cuts Lemma (Flow Value Lemma) For any flow f and any cut (A, B) f(e) f(e) = val(f) e out of A e into A c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 13 / 52 Flows and Cuts Lemma (Flow Value Lemma) For any flow f and any cut (A, B) f(e) f(e) = val(f) e out of A e into A c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 14 / 52

Flows and Cuts Lemma (Flow Value Lemma) For any flow f and any cut (A, B) f(e) f(e) = val(f) e out of A e into A c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 15 / 52 Weak Duality Lemma (Weak Duality) Given any s, t-flow f and any s, t-cut (A, B), the flow value is at most the cut capacity: val(f) cap(a, B) c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 16 / 52

Certificate of Optimality Corollary If val(f) = cap(a, B) for any flow f and any cut (A, B), then f is a maximum flow and (A, B) is a minimum cut c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 17 / 52 Computing Max Flow - First Attempt A greedy algorithm: start with f(e) = 0, e find a path P with f(e) < c(e) for all e on the path augment flow along P repeat until stuck c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 19 / 52

Computing Max Flow - First Attempt A greedy algorithm: start with f(e) = 0, e find a path P with f(e) < c(e) for all e on the path augment flow along P repeat until stuck c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 20 / 52 Computing Max Flow - First Attempt A greedy algorithm: start with f(e) = 0, e find a path P with f(e) < c(e) for all e on the path augment flow along P repeat until stuck (local opt global opt) c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 21 / 52

Residual Graph Define G f = (V, E f ) for each flow f, each edge in E f has a residual capacity c f (e) E f and c f are determined as follows Original edge e = (u, v) E, flow f(e), capacity c(e) If f(e) < c(e), then e E f and c f (e) = c(e) f(e) If f(e) > 0, e = (u, v), then e = (v, u) E f and c f (e ) = f(e) c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 22 / 52 Ford-Fulkerson (Augmenting Path) Algorithm Augment(f, c, P ) 1: b bottleneck(p ), i.e. min residual capacity on P 2: for each edge e = (u, v) on P do 3: if e is a forward edge then 4: Increase f(e) in G by b 5: else 6: Decrease f(e) in G by b 7: end if 8: end for Ford-Fulkerson(G, c) 1: Initially, set f(e) = 0 for all e E 2: while there is an s, t-path P in G f do 3: Choose a simple s, t-path P in G f (crucial for running time!) 4: f augment(f, c, P ) 5: end while c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 23 / 52

Max-Flow Min-Cut Theorem Theorem (Ford-Fulkerson, 1956) The value of a max-flow is equal to the capacity of a min-cut Proof. Let f be any feasible flow, the following are equivalent f is a maximum flow there s no augmenting path wrt f there s a cut (A, B) where val(f) = cap(a, B) c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 24 / 52 Termination and Running Time If 1 c(e) C N, and c(e) N for all e, then all flow values and residual capacities remain integers throughout Theorem Number of iterations is at most val(f ), which is at most nc Corollary If C = 1, i.e. c(e) = 1 for all e, then Ford-Fulkerson runs in time O(mn) Theorem (Ingegrality Theorem) If all capacities are integers, then there exists an integral maximum flow, i.e. a flow whose f(e) are all integers. c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 25 / 52

Generic Ford-Fulkerson: Exponential Running Time It could take C iterations. Recall: input size is a polynomial in m, n, log C c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 26 / 52 Choosing Good Augmenting Paths Augmenting path selection: Bad choices lead to exponential algorithms Good choices lead to polynomial-time algorithms If capacities are irrational, may not even terminate at all Some good choices [Edmonds-Karp 1972, Dinitz 1970] Max bottleneck capacity Sufficiently large bottleneck capacity Fewest number of edges c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 27 / 52

Some Strategies Choose augmenting path with no specific strategy O(mC) sufficiently large bottleneck capacity O(m 2 log C) maximum bottleneck capacity O(m log C) shortest length O(m 2 n) Note: there are also strategies not based on the augmenting path method. c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 29 / 52 The Edmonds-Karp Algorithm Lemma Choose shortest augmenting path Let d f (s, u) be the distance from s to u in G f, then d f (s, u) increases monotonically with each augmentation Theorem The Edmonds-Karp algorithm makes at most O(mn) augmentations, in particular its running time is O(m 2 n) c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 30 / 52

Proof of the Lemma Suppose augmenting f gives f for which some d f (s, v) > d f (s, v). Let v be such a vertex with smallest d f (s, v), and P = s u v is a path with length d f (s, v) Then, d f (s, u) = d f (s, v) 1 d f (s, u) d f (s, u) Thus, (u, v) / E f ; but (u, v) E f, hence (v, u) E f and Edmonds-Karp pushed some flow from v to u in f Since the flow is pushed along a shortest path, we have a contradiction d f (s, v) + 1 = d f (s, u) d f (s, u) = d f (s, v) 1 c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 31 / 52 Proof of the Theorem For each augmentation, some bottleneck edge (u, v) in G f will disappear in G f, where f is the next flow Suppose (u, v) is a bottleneck edge a few times, then there will be a time when (u, v) is a bottleneck for some f and later (v, u) is a bottleneck for some f. We have d f (u) = d f (v) 1 d f (v) = d f (u) 1 Thus, d f (u) = d f (v) 1 d f (v) 1 = d f (u) 2 Each time (u, v) becomes a bottleneck, d f (s, u) is increased by at least 2; thus, the number of times (u, v) is a bottleneck is at most (n 2)/2. c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 32 / 52

General Idea for Employing Max-Flow Min-Cut Set up a new problem as a network flow problem Use max-flow algorithm to solve new problem and/or Apply max-flow min-cut and integrality theorems to derive some combinatorial properties of the new problem c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 34 / 52 Maximum Matching in Graphs G = (V, E), a matching is a subset M E no two of which share an end point Maximum matching: find a maximum cardinality matching This is a fundamental problem in combinatorial optimization with numerous applications c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 36 / 52

Maximum Matching in Bipartite Graphs Given a bipartite graph G = (L R, E), find a max matching c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 37 / 52 Maximum Matching in Bipartite Graphs Given a bipartite graph G = (L R, E), find a max matching c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 38 / 52

Max-Flow Formulation for Bipartite Matching Create a new digraph G = (V {s, t}, E ) as follows Orient edges from left to right (L to R) with capacities (or any positive integer, doesn t matter which) Add a fake source s, fake sink t, and edges with capacities 1 as shown c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 39 / 52 Correctness of the Formulation Theorem The maximum matching cardinality of G is equal to the maximum flow value of G. Moreover, Ford-Fulkerson yields a maximum matching. c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 40 / 52

Running Times of Matching Algorithms Bipartite Matching Generic Ford-Fulkerson: O(mn) pretty good! Largest Bottleneck Path : O(m 2 ) Edmonds-Karp: O(m n)... Non-bipartite Matching More difficult, but very well studied Blossom algorithm (Edmonds, 1964): O(n 4 ) Best known (Micali-Vazirani, 1980): O(m n) c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 41 / 52 Marriage Theorem Given a bipartite G = (L R, E). A complete matching from L into R is a matching in which every vertex in L is matched. A perfect matching is a matching in which every vertex is matched Questions: When does G have a complete matching? When does it have a perfect matching? a perfect matching iff L = R and a complete matching Theorem (P. Hall 1935, Frobenius 1917, König 1916) Let Γ(X) denote the set of neighbors of X L, then G has a complete matching iff Γ(X) X, X L. c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 42 / 52

König-Egerváry Theorem Given G = (V, E), a vertex cover is a subset C V such that each edge in E has an end point in C Let τ(g) denote the size of a maximum vertex cover, ν(g) the size of a maximum matching Theorem (König 1931, Egerváry 1932) If G is bipartite, then τ(g) = ν(g) Proof. A direct consequence of max-flow min-cut. c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 43 / 52 Edge Disjoint Paths in Directed Graphs Given a directed graph G = (V, E), a source s and a target t, find the maximum number λ (s, t) of edge-disjoint s, t-paths c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 45 / 52

Edge Disjoint Paths in Directed Graphs Given a directed graph G = (V, E), a source s and a target t, find the maximum number λ (s, t) of edge-disjoint s, t-paths c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 46 / 52 Max-Flow Formulation Assign capacity 1 to each edge Theorem The max number of edge-disjoint s, t-paths is equal to the max flow value; moreover, Ford-Fulkerson can find a max set of paths Note: only need to eliminate cycles from output of max-flow algorithm c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 47 / 52

Disconnecting Sets Given digraph G and s, t, an s, t-disconnecting set is a set of edges whose removal separates s from t, i.e. no s, t-path remains Let κ (s, t) denote the minimum size of an s, t-disconnecting set Applications: network reliability, among many others c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 48 / 52 Menger s Theorem Theorem (Menger 1927) Given a digraph G and s, t, then λ (s, t) = κ (s, t) Proof: λ (s, t) κ (s, t) c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 49 / 52

Menger s Theorem Theorem (Menger 1927) Given a digraph G and s, t, then λ (s, t) = κ (s, t) Proof: λ (s, t) κ (s, t) c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 50 / 52 Vertex Disjoint Paths in Directed Graphs Given digraph G and s, t, an s, t-separating set is a set of vertices whose removal separates s from t Let κ(s, t) denote the minimum size of an s, t-separating set A set of paths from s to t is internally vertex disjoint if they only share vertices s and t; naturally let λ(s, t) denote the max number of internally vertex disjoint s, t-paths Theorem (Menger 1927) Given a digraph G and s, t, then λ(s, t) = κ(s, t) c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 51 / 52

Undirected Versions of Menger s Theorem There are also corresponding versions of Menger s Theorem for undirected graphs c Hung Q. Ngo (SUNY at Buffalo) CSE 531 Algorithm Analysis and Design 52 / 52