Algorithm Design and Analysis

Similar documents
Algorithm Design and Analysis

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

Algorithm Design and Analysis

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

Algorithms and Theory of Computation. Lecture 11: Network Flow

Soviet Rail Network, 1955

7.5 Bipartite Matching

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

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

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

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

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

CSC 373: Algorithm Design and Analysis Lecture 12

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

Algorithms: COMP3121/3821/9101/9801

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

Algorithms: Lecture 12. Chalmers University of Technology

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

1 Matchings in Non-Bipartite Graphs

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

Two Applications of Maximum Flow

Maximum flow problem

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

CMPSCI 611: Advanced Algorithms

Algorithm Design and Analysis

6.046 Recitation 11 Handout

Bipartite Matchings and Stable Marriage

Mathematics for Decision Making: An Introduction. Lecture 13

Algorithm Design and Analysis

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

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

Exposition of the Dinitz algorithm

The min cost flow problem Course notes for Optimization Spring 2007

Lecture 2: Network Flows 1

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

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

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

Algorithm Design and Analysis

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

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

RECAP How to find a maximum matching?

Max Flow: Algorithms and Applications

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

Combinatorial Optimization

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)}

Data Structures and Algorithms CMPSC 465

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

Algorithm Design and Analysis

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

Breadth-First Search of Graphs

1 Review for Lecture 2 MaxFlow

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

Network Flows made simple

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

22 Max-Flow Algorithms

Algorithms. Algorithms 6.4 MAXIMUM FLOW

M-saturated M={ } M-unsaturated. Perfect Matching. Matchings

Algorithm Design and Analysis

Chapter 7. Network Flow. CS 350: Winter 2018

Lecture 21 November 11, 2014

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

Ma/CS 6b Class 3: Stable Matchings

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

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

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

Basics on the Graphcut Algorithm. Application for the Computation of the Mode of the Ising Model

Design and Analysis of Algorithms

LINEAR PROGRAMMING III

Topics in Approximation Algorithms Solution for Homework 3

Maximum Flow Problem (Ford and Fulkerson, 1956)

CSC2420: Algorithm Design, Analysis and Theory Fall 2017

Algorithms. Algorithms 6.4 MAXIMUM FLOW

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016)

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

The Budget-Constrained Maximum Flow Problem

CSE 202 Homework 4 Matthias Springer, A

Lecture 2: Divide and conquer and Dynamic programming

Algorithms and Theory of Computation. Lecture 22: NP-Completeness (2)

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

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: NP-Completeness I Date: 11/13/18

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

Algorithm Design and Analysis

Lecture 13 Spectral Graph Algorithms

Discrete Optimization 2010 Lecture 3 Maximum Flows

Mathematics for Decision Making: An Introduction. Lecture 8

Network Flow Problems Luis Goddyn, Math 408

Computing Maximum Flow with Augmenting Electrical Flows

Lecture 8 Network Optimization Algorithms

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

Midterm Exam 2 Solutions

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

Chapter 6. Dynamic Programming. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Topic: Balanced Cut, Sparsest Cut, and Metric Embeddings Date: 3/21/2007

Reductions. Reduction. Linear Time Reduction: Examples. Linear Time Reductions

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

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

Maximum Matchings via Algebraic Methods for Beginners

Algorithms. Algorithms 6.4 MIN CUT / MAX FLOW

CS 1501 Recitation. Xiang Xiao

Chapter 7 Matchings and r-factors

Transcription:

Algorithm Design and Analysis LETURE 2 Network Flow Finish bipartite matching apacity-scaling algorithm Adam Smith 0//0 A. Smith; based on slides by E. Demaine,. Leiserson, S. Raskhodnikova, K. Wayne

Marriage Theorem Marriage Theorem. [Frobenius 97, Hall 935] Let G = (L R, E) be a bipartite graph with L = R. Then, G has a perfect matching iff N(S) S for all subsets S L. Pf. This was the previous observation. ' 2 3 2' 3' No perfect matching: S = { 2, 4, 5 } N(S) = { 2', 5' }. 4 4' L 5 5' R

Proof of Marriage Theorem Pf. Suppose G does not have a perfect matching. Formulate as a max flow problem with constraints on edges from L to R and let (A, B) be min cut in G'. Key property # of this graph: min-cut cannot use edges. So cap(a, B) = L B + R A Key property #2: integral flow is still a matching By max-flow min-cut, cap(a, B) < L. hoose S = L A. Since min cut can't use edges: N(S) R A. N(S ) R A = cap(a, B) - L B < L - L B = S. s G' A 2 2' ' S = {2, 4, 5} L B = {, 3} 4 3 3' 4' t R A = {2', 5'} N(S) = {2', 5'} 5 5'

Bipartite Matching: Running Time Which max flow algorithm to use for bipartite matching? Generic augmenting path: O(m val(f*) ) = O(mn). apacity scaling: O(m 2 log ) = O(m 2 ). Shortest augmenting path (not covered in class): O(m n /2 ). Non-bipartite matching. Structure of non-bipartite graphs is more complicated, but well-understood. [Tutte-Berge, Edmonds-Galai] Blossom algorithm: O(n 4 ). [Edmonds 965] Best known: O(m n /2 ). [Micali-Vazirani 980] Recently: better algorithms for dense graphs, e.g. O(n 2.38 ) [Harvey, 2006]

Exercise A bipartite graph is k-regular if L = R and every vertex (regardless of which side it is on) has exactly k neighbors Prove or disprove: every k-regular bipartite graph has a perfect matching

Faster algorithms when capacities are large

Ford-Fulkerson: Exponential Number of Augmentations Q. Is generic Ford-Fulkerson algorithm polynomial in input size? m, n, and log A. No. If max capacity is, then algorithm can take iterations. X0 0 X0 X0 s X 0 t s X0 X 0 t 0 X0 X0 X0 2 2 Intuition: we re choosing the wrong paths!

hoosing Good Augmenting Paths Use care when selecting augmenting paths. Some choices lead to exponential algorithms. lever choices lead to polynomial algorithms. If capacities are irrational, algorithm not guaranteed to terminate! Goal: choose augmenting paths so that: an find augmenting paths efficiently. Few iterations. hoose augmenting paths with: [Edmonds-Karp 972, Dinitz 970] Max bottleneck capacity. Sufficiently large bottleneck capacity. Fewest number of edges.

apacity Scaling Intuition. hoosing path with highest bottleneck capacity increases flow by max possible amount. Don't worry about finding exact highest bottleneck path. Maintain scaling parameter. G f ( ) = subgraph of the residual graph with only arcs ofcapacity at least. 4 4 0 02 0 02 s t s t 22 70 22 70 2 2 G f G f (00)

apacity Scaling Scaling-Max-Flow(G, s, t, c) { foreach e E f(e) 0 smallest power of 2 greater than or equal to G f residual graph } while ( ) { G f ( ) -residual graph while (there exists augmenting path P in G f ( )) { f augment(f, c, P) // augment flow by update G f ( ) } / 2 } return f

apacity Scaling: orrectness Assumption. All edge capacities are integers between and. Integrality invariant. All flow and residual capacity values are integral. orrectness. If the algorithm terminates, then f is a max flow. Pf. By integrality invariant, when = G f ( ) = G f. Upon termination of = phase, there are no augmenting paths.

apacity Scaling: Running Time Lemma. The outer while loop repeats + log 2 times. Pf. Initially < 2. decreases by a factor of 2 each iteration. Lemma 2. Let f be the flow at the end of a -scaling phase. Then the value of the maximum flow f* is at most v(f) + m. proof on next slide (Sanity check: v(f*) v(f) m, and shrinks, so v(f) converges towards v(f*) ) Lemma 3. There are at most 2m augmentations per scaling phase. Let f be the flow at the end of the previous scaling phase. Lemma 2 v(f*) v(f) + m (2 ). Each augmentation in a -phase increases v(f) by at least. Theorem. The scaling max-flow algorithm finds a max flow in O(m log ) augmentations. It can be implemented to run in O(m 2 log ) time. (Why?)

apacity Scaling: Running Time Lemma 2. Let f be the flow at the end of a -scaling phase. Then value of the maximum flow is at most v(f) + m. Pf. (almost identical to proof of max-flow min-cut theorem) We show that at the end of a -phase, there exists a cut (A, B) such that cap(a, B) v(f) + m. hoose A to be the set of nodes reachable from s in G f ( ). By definition of A, s A. By definition of f, t A. A B t s So v(f*)-v(f) cap(a,b) v(f) m original network

Best Known Algorithms For Max Flow Reminder: The scaling max-flow algorithm runs in O(m 2 log ) time. urrently there are algorithms that run in time O(mn log n) O(n 3 ) O(min(n 2/3, m /2 ) m log n log ) Active topic of research: Flow algorithms for specific types of graphs Special cases (bipartite matching, etc) Multi-commodity flow

What you should know about max flow How Ford-Fulkerson works How to use it to find min cuts How to use it to solve other problems (more examples coming) max matching project selection edge-disjoint paths vertex-disjoint paths To study: Review lecture notes/ textbook Solved exercises in book Homework problems Homework exercises Solve lots of problems!