Algorithm Design and Analysis

Slides:



Advertisements
Similar presentations
Lecture 7. Network Flows We consider a network with directed edges. Every edge has a capacity. If there is an edge from i to j, there is an edge from.
Advertisements

15.082J & 6.855J & ESD.78J October 14, 2010 Maximum Flows 2.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
Piyush Kumar (Lecture 6: MaxFlow MinCut Applications)
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2012 Lecture 19.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Lectures on Network Flows
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
The max flow problem
Maximum Flows Lecture 4: Jan 19. Network transmission Given a directed graph G A source node s A sink node t Goal: To send as much information from s.
Applications of Network Flow Problem. 7.5 Bipartite Matching.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.
10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 22 Network.
1 Linear Programming & Flows Instructor: yedeshi
CSE 421 Algorithms Richard Anderson Lecture 24 Network Flow Applications.
Chapter 7 April 28 Network Flow.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 25.
and 6.855J March 6, 2003 Maximum Flows 2. 2 Network Reliability u Communication Network u What is the maximum number of arc disjoint paths from.
10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 21 Network.
Chapter 7 May 3 Ford-Fulkerson algorithm Step-by-step walk through of an example Worst-case number of augmentations Edmunds-Karp modification Time complexity.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
CSEP 521 Applied Algorithms Richard Anderson Lecture 8 Network Flow.
Introduction to Graph Theory
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
Prof. Swarat Chaudhuri COMP 382: Reasoning about Algorithms Fall 2015.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Lap Chi Lau we will only use slides 4 to 19
The Maximum Network Flow Problem
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
Bipartite Matching Lecture 8: Oct 7.
Topics in Algorithms Lap Chi Lau.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
V12: Network Flows V12 follows closely chapter 12.1 in
Algorithms and Networks
Lectures on Network Flows
Richard Anderson Lecture 23 Network Flow
Lecture 22 Network Flow, Part 2
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Chapter 5. Optimal Matchings
3.3 Applications of Maximum Flow and Minimum Cut
Network Flow 2016/04/12.
Instructor: Shengyu Zhang
Edmonds-Karp Algorithm
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
CSE Algorithms Max Flow Problems 11/21/02 CSE Max Flow.
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Network Flow and Connectivity in Wireless Sensor Networks
Analysis of Algorithms
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 21 Network Flow
Max Flow Min Cut, Bipartite Matching Yin Tat Lee
Flow Networks and Bipartite Matching
Piyush Kumar (Lecture 6: MaxFlow MinCut Applications)
Algorithms (2IL15) – Lecture 7
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
EE5900 Advanced Embedded System For Smart Infrastructure
and 6.855J March 6, 2003 Maximum Flows 2
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
Richard Anderson Lecture 22 Network Flow
Lecture 22 Network Flow, Part 2
Maximum Flow Problems in 2005.
Presentation transcript:

Algorithm Design and Analysis LECTURE 20 Network Flow Applications Bipartite matching Edge-disjoint paths CSE 565 Adam Smith 10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne

Last time: Ford-Fulkerson Find max s-t flow & min s-t cut in O(mnC) time All capacities are integers ≤ C (We will discuss how to remove this assumption) Duality: Max flow value = min cut capacity Integrality: if capacities are integers, then FF algorithm produces an integral max flow 10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne

Today: Applications when C=1 Maximum bipartite matching Reducing MBM to max-flow Hall’s theorem Edge-disjoint paths another reduction Coming up: faster algorithms for large C and applications 10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne

Matching Matching. Input: undirected graph G = (V, E). M  E is a matching if each node appears in at most 1 edge in M. Max matching: find a max cardinality matching.

Bipartite Matching Bipartite matching. Input: undirected, bipartite graph G = (L  R, E). M  E is a matching if each node appears in at most edge in M. Max matching: find a max cardinality matching. 1 1' 2 2' matching 1-2', 3-1', 4-5' 3 3' 4 4' L R 5 5'

Bipartite Matching Bipartite matching. Input: undirected, bipartite graph G = (L  R, E). M  E is a matching if each node appears in at most edge in M. Max matching: find a max cardinality matching. 1 1' 2 2' max matching 1-1', 2-2', 3-3' 4-4' 3 3' 4 4' L R 5 5'

Reductions Roughly: Problem A reduces to problem B if there is a simple algorithm for A that uses an algorithm for problem B as a subroutine. Usually: Given instance x of problem A we find a instance x’ of problem B Solve x’ Use the solution to build a solution to x Useful skill: quickly identifying problems where existing solutions may be applied. Good programmers do this all the time

Reducing Bipartite Matching to Maximum Flow Reduction to Max flow. Create digraph G' = (L  R  {s, t}, E' ). Direct all edges from L to R, and assign capacity 1. Add source s, and capacity 1 edges from s to each node in L. Add sink t, and capacity 1 edges from each node in R to t. G' 1 1 1' 1 1 2 2' s 3 3' t 4 4' L 5 5' R

Bipartite Matching: Proof of Correctness Theorem. Max cardinality matching in G = value of max flow in G’. Proof: We need two statements max. matching in G ≤ max flow in G’ max. matching in G ≥ max flow in G’

Bipartite Matching: Proof of Correctness Theorem. Max cardinality matching in G = value of max flow in G'. Pf.  Given max matching M of cardinality k. Consider flow f that sends 1 unit along each of k paths. f is a flow, and has cardinality k. ▪ 1 1' 1 1 1' 1 1 2 2' 2 2' 3 3' s 3 3' t 4 4' 4 4' G G' 5 5' 5 5'

Bipartite Matching: Proof of Correctness Theorem. Max cardinality matching in G = value of max flow in G'. Pf.  Let f be a max flow in G' of value k. Integrality theorem  f is integral; all capacities are 1  f is 0-1. Consider M = set of edges from L to R with f(e) = 1. each node in L and R participates in at most one edge in M |M| = k: consider cut (L  s, R  t) ▪ 1 1 1' 1 1' 1 1 2 2' 2 2' flow across cut (L  s, R  t) = flow entering t = k s 3 3' t 3 3' 4 4' 4 4' G' G 5 5' 5 5'

Exercises Give an example where the greedy algorithm for MBM fails. How bad can the greedy algorithm be, i.e. how far can the size of the maximum matching (global max) be from the size of the greedy matching (local max)? What do augmenting paths look like in this max-flow instance?

Perfect Matching Def. A matching M  E is perfect if each node appears in exactly one edge in M. Q. When does a bipartite graph have a perfect matching? Structure of bipartite graphs with perfect matchings. Clearly we must have |L| = |R|. What other conditions are necessary? What conditions are sufficient?

Perfect Matching Notation. Let S be a subset of nodes, and let N(S) be the set of nodes adjacent to nodes in S. Observation. If a bipartite graph G = (L  R, E), has a perfect matching, then |N(S)|  |S| for all subsets S  L. Pf. Each node in S has to be matched to a different node in N(S). 1 3 5 1' 3' 5' 2 4 2' 4' L R No perfect matching: S = { 2, 4, 5 } N(S) = { 2', 5' }.

Marriage Theorem Marriage Theorem. [Frobenius 1917, Hall 1935] 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. 1 3 5 1' 3' 5' 2 4 2' 4' L R No perfect matching: S = { 2, 4, 5 } N(S) = { 2', 5' }.

Proof of Marriage Theorem Pf.  Suppose G does not have a perfect matching. Formulate as a max flow problem with 1 constraints on edges from L to R and let (A, B) be min cut in G'. Key property #1 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 |. Choose 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|. ▪ 1 G'   1' A 1 2' S = {2, 4, 5} L  B = {1, 3} R  A = {2', 5'} N(S) = {2', 5'}  2 1 s 3' 1 3 4 4' t 5 1 5'

Bipartite Matching: Running Time Which max flow algorithm to use for bipartite matching? Generic augmenting path: O(m val(f*) ) = O(mn). Capacity scaling: O(m2 log C ) = O(m2). Shortest augmenting path (not covered in class): O(m n1/2). Non-bipartite matching. Structure of non-bipartite graphs is more complicated, but well-understood. [Tutte-Berge, Edmonds-Galai] Blossom algorithm: O(n4). [Edmonds 1965] Best known: O(m n1/2). [Micali-Vazirani 1980] Recently: better algorithms for dense graphs, e.g. O(n2.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

7.6 Disjoint Paths 10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne

Edge Disjoint Paths Disjoint path problem. Given a digraph G = (V, E) and two nodes s and t, find the max number of edge-disjoint s-t paths. Def. Two paths are edge-disjoint if they have no edge in common. Ex: communication networks. 2 5 s 3 6 t 4 7

Edge Disjoint Paths Disjoint path problem. Given a digraph G = (V, E) and two nodes s and t, find the max number of edge-disjoint s-t paths. Def. Two paths are edge-disjoint if they have no edge in common. Ex: communication networks. 2 5 s 3 6 t 4 7

Edge Disjoint Paths Max flow formulation: assign unit capacity to every edge. Theorem. Max number edge-disjoint s-t paths equals max flow value. s t 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Edge Disjoint Paths Max flow formulation: assign unit capacity to every edge. Theorem. Max number edge-disjoint s-t paths equals max flow value. Pf.  Suppose there are k edge-disjoint paths P1, . . . , Pk. Set f(e) = 1 if e participates in some path Pi ; else set f(e) = 0. Since paths are edge-disjoint, f is a flow of value k. ▪ s t 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Edge Disjoint Paths Max flow formulation: assign unit capacity to every edge. Theorem. Max number edge-disjoint s-t paths equals max flow value. Pf.  Suppose max flow value is k. Integrality theorem  there exists 0-1 flow f of value k. Consider edge (s, u) with f(s, u) = 1. by conservation, there exists an edge (u, v) with f(u, v) = 1 continue until reach t, always choosing a new edge Produces k (not necessarily simple) edge-disjoint paths. ▪ 1 1 1 1 1 1 s 1 1 t 1 1 1 1 1 1 can eliminate cycles to get simple paths if desired

Network Connectivity Network connectivity. Given a digraph G = (V, E) and two nodes s and t, find min number of edges whose removal disconnects t from s. Def. A set of edges F  E disconnects t from s if all s-t paths uses at least one edge in F. (That is, removing F would make t unreachable from s.) 2 5 s 3 6 t 4 7

Edge Disjoint Paths and Network Connectivity Theorem. [Menger 1927] The max number of edge-disjoint s-t paths is equal to the min number of edges whose removal disconnects t from s. Pf.  Suppose the removal of F  E disconnects t from s, and |F| = k. All s-t paths use at least one edge of F. Hence, the number of edge-disjoint paths is at most k. ▪ 2 5 2 5 s 3 6 t s 3 6 t 4 7 4 7

Disjoint Paths and Network Connectivity Theorem. [Menger 1927] The max number of edge-disjoint s-t paths is equal to the min number of edges whose removal disconnects t from s. Pf.  Suppose max number of edge-disjoint paths is k. Then max flow value is k. Max-flow min-cut  cut (A, B) of capacity k. Let F be set of edges going from A to B. |F| = k and disconnects t from s. ▪ A 2 5 2 5 s 3 6 t s 3 6 t 4 7 4 7