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

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

1 Scheduling Crossbar Switches Who do we chose to traverse the switch in the next time slot? N N 11.
Introduction To Algorithms CS 445 Discussion Session 8 Instructor: Dr Alon Efrat TA : Pooja Vaswani 04/04/2005.
MAXIMUM FLOW Max-Flow Min-Cut Theorem (Ford Fukerson’s Algorithm)
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2012 Lecture 19.
CSCI 256 Data Structures and Algorithm Analysis Lecture 18 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
Chapter 10: Iterative Improvement The Maximum Flow Problem The Design and Analysis of Algorithms.
1 Maximum Flow w s v u t z 3/33/3 1/91/9 1/11/1 3/33/3 4/74/7 4/64/6 3/53/5 1/11/1 3/53/5 2/22/2 
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.
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
Nick McKeown Spring 2012 Maximum Matching Algorithms EE384x Packet Switch Architectures.
Advanced Algorithms Piyush Kumar (Lecture 2: Max Flows) Welcome to COT5405 Slides based on Kevin Wayne’s slides.
048866: Packet Switch Architectures Dr. Isaac Keslassy Electrical Engineering, Technion MSM.
The max flow problem
Shortest Path With Negative Weights s 3 t
Lecture 11. Matching A set of edges which do not share a vertex is a matching. Application: Wireless Networks may consist of nodes with single radios,
Minimum Cost Flow Lecture 5: Jan 25. Problems Recap Bipartite matchings General matchings Maximum flows Stable matchings Shortest paths Minimum spanning.
Lecture 11. Matching A set of edges which do not share a vertex is a matching. Application: Wireless Networks may consist of nodes with single radios,
1 Scheduling Crossbar Switches Who do we chose to traverse the switch in the next time slot? N N 11.
Pipelined Two Step Iterative Matching Algorithms for CIOQ Crossbar Switches Deng Pan and Yuanyuan Yang State University of New York, Stony Brook.
Advanced Algorithms Piyush Kumar (Lecture 5: Weighted Matching) Welcome to COT5405 Based on Kevin Wayne’s slides.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 22.
Hungarian Algorithm Vida Movahedi Elderlab, York University June 2007.
WAN technologies and routing Packet switches and store and forward Hierarchical addresses, routing and routing tables Routing table computation Example.
Advanced Algorithms Piyush Kumar (Lecture 5: Weighted Matching) Welcome to COT5405 Based on Kevin Wayne’s slides.
Topic III The Simplex Method Setting up the Method Tabular Form Chapter(s): 4.
Single Source Shortest-Path: The General Case (with negative edges) Bellman-Ford algorithm. Iteratively relax all edges |V|-1 times Running time? O(VE).
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and.
Weikang Qian. Outline Intersection Pattern and the Problem Motivation Solution 2.
Maximum Flow. p2. Maximum Flow A flow network G=(V, E) is a DIRECTED graph where each has a nonnegative capacity u.
1 Network Models Transportation Problem (TP) Distributing any commodity from any group of supply centers, called sources, to any group of receiving.
CS223 Advanced Data Structures and Algorithms 1 Maximum Flow Neil Tang 3/30/2010.
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.
1 Chapter 5-2 Greedy Algorithms Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
CS38 Introduction to Algorithms Lecture 10 May 1, 2014.
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.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 23.
CSEP 521 Applied Algorithms Richard Anderson Lecture 8 Network Flow.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 10.
Prof. Swarat Chaudhuri COMP 382: Reasoning about Algorithms Fall 2015.
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
Markov Random Fields in Vision
Input buffered switches (1)
11/21/02CSE Max Flow CSE Algorithms Max Flow Problems.
CSE 421 Algorithms Richard Anderson Lecture 21 Shortest Paths and Network Flow.
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Chapter 5. Optimal Matchings
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Instructor: Shengyu Zhang
Edmonds-Karp Algorithm
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Packet Scheduling/Arbitration in Virtual Output Queues and Others
Network Flow and Connectivity in Wireless Sensor Networks
Analysis of Algorithms
Chapter 6 Dynamic Programming
Chapter 6 Dynamic Programming
Max Flow Min Cut, Bipartite Matching Yin Tat Lee
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
Scheduling Crossbar Switches
Data Structures and Algorithm Analysis Lecture 8
Presentation transcript:

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

* 7.13 Assignment Problem

3 Assignment Problem Assignment problem. n Input: weighted, complete bipartite graph G = (L  R, E) with |L| = |R|. n Goal: find a perfect matching of min weight '2'3'4'5' Min cost perfect matching M = { 1-2', 2-3', 3-5', 4-1', 5-4' } cost(M) = =

4 Applications Natural applications. n Match jobs to machines. n Match personnel to tasks. n Match PU students to writing seminars. Non-obvious applications. n Vehicle routing. n Signal processing. n Virtual output queueing. n Multiple object tracking. n Approximate string matching. n Enhance accuracy of solving linear systems of equations.

5 Bipartite matching. Can solve via reduction to max flow. Flow. During Ford-Fulkerson, all capacities and flows are 0/1. Flow corresponds to edges in a matching M. Residual graph G M simplifies to: n If (x, y)  M, then (x, y) is in G M. n If (x, y)  M, the (y, x) is in G M. Augmenting path simplifies to: n Edge from s to an unmatched node x  X. n Alternating sequence of unmatched and matched edges. n Edge from unmatched node y  Y to t. Bipartite Matching st YX

6 Alternating path. Alternating sequence of unmatched and matched edges, from unmatched node x  X to unmatched node y  Y. Alternating Path x y matching M x y alternating path x y matching M'

7 Cost of an alternating path. Pay c(x, y) to match x-y; receive c(x, y) to unmatch x-y. Shortest alternating path. Alternating path from any unmatched node x  X to any unmatched node y  Y with smallest cost. Successive shortest path algorithm. n Start with empty matching. n Repeatedly augment along a shortest alternating path. Assignment Problem: Successive Shortest Path Algorithm 1 2 1' 2' cost(2 - 1') = 7 cost(2 - 2' ') = = 6

8 Shortest alternating path. Corresponds to shortest s-t path in G M. Concern. Edge costs can be negative. Fact. If always choose shortest alternating path, then G M contains no negative cycles  compute using Bellman-Ford. Our plan. Use duality to avoid negative edge costs (and negative cost cycles)  compute using Dijkstra. Finding The Shortest Alternating Path 1 2 1' 2' st 0 0

9 Duality intuition. Adding (or subtracting) a constant to every entry in row x or column y does not change the min cost perfect matching(s). Equivalent Assignment Problem subtract 11 from column 4 11 c(x, y) c p (x, y)

10 Duality intuition. Adding p(x) to row x and subtracting p(y) from row y does not change the min cost perfect matching(s). Equivalent Assignment Problem c(x, y) c p (x, y)

11 Reduced costs. For x  X, y  Y, define c p (x, y) = p(x) + c(x, y) - p(y). Observation 1. Finding a min cost perfect matching with reduced costs is equivalent to finding a min cost perfect matching with original costs. Reduced Costs c(x, y) c p (x, y)

12 Compatible prices. For each node v, maintain prices p(v) such that: n (i) c p (x, y)  0 for for all (x, y)  M. n (ii) c p (x, y) = 0 for for all (x, y)  M. Observation 2. If p are compatible prices for a perfect matching M, then M is a min cost perfect matching. Compatible Prices c(x, y) c p (x, y) cost(M) =  (x, y)  M c(x, y) = ( ) = 44 cost(M) =  y  Y p(y)   x  X p(x) = ( ) - ( ) = 44

13 Successive shortest path. Successive Shortest Path Algorithm Successive-Shortest-Path(X, Y, c) { M   foreach x  X: p(x)  0 foreach y  Y: p(y)  min e into y c(e) while (M is not a perfect matching) { Compute shortest path distances d P  shortest alternating path using costs c p M  updated matching after augmenting along P foreach v  X  Y: p(v)  p(v) + d(v) } return M } p is compatible with M = 

14 Lemma 1. Let p be compatible prices for matching M. Let d be shortest path distances in G M with costs c p. All edges (x, y) on shortest path have c p+d (x, y) = 0. Pf. Let (x, y) be some edge on shortest path. n If (x, y)  M, then (y, x) on shortest path and d(x) = d(y) - c p (x, y). If (x, y)  M, then (x, y) on shortest path and d(y) = d(x) + c p (x, y). n In either case, d(x) + c p (x, y) - d(y) = 0. n By definition, c p (x, y) = p(x) + c(x, y) - p(y). n Substituting for c p (x, y) yields: (p(x) + d(x)) + c(x, y) - (p(y) + d(y)) = 0. n In other words, c p+d (x, y) = 0. ▪ Maintaining Compatible Prices Reduced costs: c p (x, y) = p(x) + c(x, y) - p(y). forward or reverse edges

15 Lemma 2. Let p be compatible prices for matching M. Let d be shortest path distances in G M with costs c p. Then p' = p + d are also compatible prices for M. Pf. (x, y)  M n (y, x) is the only edge entering x in G M. Thus, (y, x) on shortest path. n By Lemma 1, c p+d (x, y) = 0. Pf. (x, y)  M n (x, y) is an edge in G M  d(y)  d(x) + c p (x, y). n Substituting c p (x, y) = p(x) + c(x, y) - p(y)  0 yields (p(x) + d(x)) + c(x, y) - (p(y) + d(y))  0. n In other words, c p+d (x, y)  0. ▪ Maintaining Compatible Prices Compatible prices. For each node v: (i) c p (x, y)  0 for for all (x, y)  M. (ii) c p (x, y) = 0 for for all (x, y)  M.

16 Lemma 3. Let M' be matching obtained by augmenting along a min cost path with respect to c p+d. Then p' = p + d is compatible with M'. Pf. n By Lemma 2, the prices p + d are compatible for M. n Since we augment along a min cost path, the only edges (x, y) that swap into or out of the matching are on the shortest path. n By Lemma 1, these edges satisfy c p+d (x, y) = 0. n Thus, compatibility is maintained. ▪ Maintaining Compatible Prices Compatible prices. For each node v: (i) c p (x, y)  0 for for all (x, y)  M. (ii) c p (x, y) = 0 for for all (x, y)  M.

17 Invariant. The algorithm maintains a matching M and compatible prices p. Pf. Follows from Lemmas 2 and 3 and initial choice of prices. ▪ Theorem. The algorithm returns a min cost perfect matching. Pf. Upon termination M is a perfect matching, and p are compatible prices. Optimality follows from Observation 2. ▪ Theorem. The algorithm can be implemented in O(n 3 ) time. Pf. n Each iteration increases the cardinality of M by 1  n iterations. n Bottleneck operation is computing shortest path distances d. Since all costs are nonnegative, each iteration takes O(n 2 ) time using (dense) Dijkstra. ▪ Successive Shortest Path: Analysis

18 Weighted bipartite matching. Given weighted bipartite graph, find maximum cardinality matching of minimum weight. Successive shortest path algorithm. O(mn log n) time using heap-based version of Dijkstra's algorithm. Best known bounds. O(mn 1/2 ) deterministic; O(n ) randomized. Planar weighted bipartite matching. O(n 3/2 log 5 n). Weighted Bipartite Matching m edges, n nodes

Input Queued Switching

20 Input-Queued Switching Input-queued switch. n n inputs and n outputs in an n-by-n crossbar layout. n At most one cell can depart an input at a time. n At most one cell can arrive at an output at a time. n Cell arrives at input x and must be routed to output y. x3x3 x2x2 x1x1 y1y1 y2y2 y3y3 inputs outputs

21 Input-Queued Switching FIFO queueing. Each input x maintains one queue of cells to be routed. Head-of-line blocking (HOL). n A cell can be blocked by a cell queued ahead of it that is destined for a different output. n Can limit throughput to 58%, even when arrivals are uniform. FIFO outputs y2y2 y2y2 y1y1 y2y2 y1y1 y3y3 y3y3 x3x3 x2x2 x1x1 y1y1 y2y2 y3y3

22 Input-Queued Switching Virtual output queueing (VOQ). Each input x maintains n queue of cells, one for each output y. Maximum size matching. Find a max cardinality matching. n Achieves 100% when arrivals are uniform. n Can starve input-queues when arrivals are non-uniform. outputs y2y2 y2y2 y2y2 y3y3 y3y3 y1y1 y2y2 y2y2 y2y2 y3y3 y3y3 y3y3 y3y3 y2y2 y2y2 y2y2 y3y3 VOQ x3x3 x2x2 x1x1 y1y1 y2y2 y3y3

23 Input-Queued Switching Max weight matching. Find a min cost perfect matching between inputs x and outputs y, where c(x, y) equals: n [LQF] The number of cells waiting to go from input x to output y. n [OCF] The waiting time of the cell at the head of VOQ from x to y. Theorem. LQF and OCF achieve 100% throughput if arrivals are independent. Practice. n Too slow in practice for this application; difficult to implement in hardware. Provides theoretical framework. n Use maximal (weighted) matching  2-approximation. Reference: