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

Similar documents
7. NETWORK FLOW III. assignment problem input-queued switching. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley

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

Single Source Shortest Path: The Bellman-Ford Algorithm. Slides based on Kevin Wayne / Pearson-Addison Wesley

CS261: Problem Set #2

Introduction. I Given a weighted, directed graph G =(V, E) with weight function

5.4 Shortest Paths. Jacobs University Visualization and Computer Graphics Lab. CH : Algorithms and Data Structures 456

Preflow-Push Algorithm

Single Source Shortest Path

Minimum Cost Edge Disjoint Paths

COT 6936: Topics in Algorithms! Giri Narasimhan. ECS 254A / EC 2443; Phone: x3748

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

1 Dijkstra s Algorithm

Network Design and Optimization course

Copyright 2007 Pearson Addison-Wesley. All rights reserved. A. Levitin Introduction to the Design & Analysis of Algorithms, 2 nd ed., Ch.

Network Flow. November 23, CMPE 250 Graphs- Network Flow November 23, / 31

Outline: Finish uncapacitated simplex method Negative cost cycle algorithm The max-flow problem Max-flow min-cut theorem

LECTURES 3 and 4: Flows and Matchings

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

Algorithms on Graphs: Part III. Shortest Path Problems. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar..

CSC 8301 Design & Analysis of Algorithms: Linear Programming

Introduction. I Given a weighted, directed graph G =(V, E) with weight function

Lecture 3: Graphs and flows

4/8/11. Single-Source Shortest Path. Shortest Paths. Shortest Paths. Chapter 24

COMP 251 Winter 2017 Online quizzes with answers

CSE 417 Network Flows (pt 4) Min Cost Flows

10. EXTENDING TRACTABILITY

and 6.855J March 6, Maximum Flows 2

Jessica Su (some parts copied from CLRS / last quarter s notes)

Maximum flow problem CE 377K. March 3, 2015

Shortest Path Algorithms

Outline. Computer Science 331. Definitions: Paths and Their Costs. Computation of Minimum Cost Paths

Copyright 2000, Kevin Wayne 1

1 Weighted matchings in bipartite graphs

11. APPROXIMATION ALGORITHMS

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Lecture 11: Analysis of Algorithms (CS ) 1

Graphs and Network Flows IE411. Lecture 13. Dr. Ted Ralphs

Crossbar - example. Crossbar. Crossbar. Combination: Time-space switching. Simple space-division switch Crosspoints can be turned on or off

Chapter 5 Graph Algorithms Algorithm Theory WS 2012/13 Fabian Kuhn

1 Linear programming relaxation

7. NETWORK FLOW II. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 2013 Kevin Wayne

Lecture 11: Maximum flow and minimum cut

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Graphs. Part II: SP and MST. Laura Toma Algorithms (csci2200), Bowdoin College

Reducing Directed Max Flow to Undirected Max Flow and Bipartite Matching

22 Elementary Graph Algorithms. There are two standard ways to represent a

CS261: Problem Set #1

Routing Algorithms : Fundamentals of Computer Networks Bill Nace

CSE 502 Class 23. Jeremy Buhler Steve Cole. April BFS solves unweighted shortest path problem. Every edge traversed adds one to path length

Design and Analysis of Algorithms

(Refer Slide Time: 00:18)

1 Bipartite maximum matching

CSE 521: Design and Analysis of Algorithms I

Graph Algorithms (part 3 of CSC 282),

Chapter 24. Shortest path problems. Chapter 24. Shortest path problems. 24. Various shortest path problems. Chapter 24. Shortest path problems

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Shortest Paths Date: 10/13/15

Introduction to Algorithms. Lecture 11

Lecture 18 Solving Shortest Path Problem: Dijkstra s Algorithm. October 23, 2009

CHAPTER 13 GRAPH ALGORITHMS

CS4800: Algorithms & Data Jonathan Ullman

Dijkstra s Algorithm Last time we saw two methods to solve the all-pairs shortest path problem: Min-plus matrix powering in O(n 3 log n) time and the

CS420/520 Algorithm Analysis Spring 2009 Lecture 14

Shortest path problems

COS 423 Lecture 22. Robert E. Tarjan 2011

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

Routing, Routers, Switching Fabrics

Algorithm Circle Extra Lecture: Solving the Assignment Problem with Network Flow

Minimum Spanning Tree

Maximum Flow. Flow Networks. Flow Networks Ford-Fulkerson Method Edmonds-Karp Algorithm Push-Relabel Algorithms. Example Flow Network

Outline. CS38 Introduction to Algorithms. Linear programming 5/21/2014. Linear programming. Lecture 15 May 20, 2014

11. APPROXIMATION ALGORITHMS

Problem set 2. Problem 1. Problem 2. Problem 3. CS261, Winter Instructor: Ashish Goel.

Single Source Shortest Paths

Reductions. Linear Time Reductions. Desiderata. Reduction. Desiderata. Classify problems according to their computational requirements.

Homework 3 Solutions

CS350: Data Structures Dijkstra s Shortest Path Alg.

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

Chapter 3. Graphs CLRS Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

PERFECT MATCHING THE CENTRALIZED DEPLOYMENT MOBILE SENSORS THE PROBLEM SECOND PART: WIRELESS NETWORKS 2.B. SENSOR NETWORKS OF MOBILE SENSORS

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Matching. Algorithms and Networks

Lecture 3: Totally Unimodularity and Network Flows

Network Flow. By: Daniel Pham, Anthony Huber, Shaazan Wirani

Today. Maximum flow. Maximum flow. Problem

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/27/17

CSE 417 Network Flows (pt 3) Modeling with Min Cuts

Network Flow and Matching

Mathematics for Decision Making: An Introduction. Lecture 18

Index. stack-based, 400 A* algorithm, 325

Algorithm Design and Analysis

10. EXTENDING TRACTABILITY

Lecture 8: Non-bipartite Matching. Non-partite matching

Problem Set 7 Solutions

Bipartite Matching & the Hungarian Method

CSE 417: Algorithms and Computational Complexity. 3.1 Basic Definitions and Applications. Goals. Chapter 3. Winter 2012 Graphs and Graph Algorithms

Source. Sink. Chapter 10: Iterative Programming Maximum Flow Problem. CmSc250 Intro to Algorithms

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Lecture 6: Shortest distance, Eulerian cycles, Maxflow

Algorithm Design and Analysis

Transcription:

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

* 7.13 Assignment Problem

Assignment Problem Assignment problem. Input: weighted, complete bipartite graph G = (L R, E) with L = R. Goal: find a perfect matching of min weight. 1' 2' 3' 4' 5' 1 2 3 3 8 9 15 10 4 10 7 16 14 9 13 11 19 10 Min cost perfect matching M = { 1-2', 2-3', 3-5', 4-1', 5-4' } cost(m) = 8 + 7 + 10 + 8 + 11 = 44 4 8 13 12 20 13 5 1 7 5 11 9 3

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

Bipartite Matching 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: If (x, y) M, then (x, y) is in G M. If (x, y) M, the (y, x) is in G M. s 1 1 1 t X Y Augmenting path simplifies to: Edge from s to an unmatched node x X. Alternating sequence of unmatched and matched edges. Edge from unmatched node y Y to t. 5

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

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

Finding The Shortest Alternating Path Shortest alternating path. Corresponds to shortest s-t path in G M. s 0 1 2 10-6 7 2 1' 2' 0 t 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. 8

Equivalent Assignment Problem 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). c(x, y) c p (x, y) 3 8 9 15 10 4 10 7 16 14 9 13 11 19 10 8 13 12 20 13 1 7 5 11 9 subtract 11 from column 4 3 8 9 4 10 4 10 7 2 14 9 13 11 8 10 8 13 12 9 13 1 7 5 0 9 11 9

Equivalent Assignment Problem Duality intuition. Adding p(x) to row x and subtracting p(y) from row y does not change the min cost perfect matching(s). c(x, y) c p (x, y) 3 8 9 15 10 4 10 7 16 14 9 13 11 19 10 8 13 12 20 13 1 7 5 11 9 5 4 3 0 8 0 0 3 1 2 0 1 0 1 5 4 3 3 3 0 0 0 1 1 0 1 2 2 0 4 8 13 11 19 13 9 + 8-13 10

Reduced Costs 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. c(x, y) c p (x, y) 3 8 9 15 10 4 10 7 16 14 9 13 11 19 10 8 13 12 20 13 1 7 5 11 9 5 4 3 0 8 0 0 3 1 2 0 1 0 1 5 4 3 3 3 0 0 0 1 1 0 1 2 2 0 4 8 13 11 19 13 9 + 8-13 11

Compatible Prices Compatible prices. For each node v, maintain prices p(v) such that: (i) c p (x, y) 0 for for all (x, y) M. (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. c(x, y) c p (x, y) 3 8 9 15 10 4 10 7 16 14 9 13 11 19 10 8 13 12 20 13 1 7 5 11 9 5 4 3 0 8 0 0 3 1 2 0 1 0 1 5 4 3 3 3 0 0 0 1 1 0 1 2 2 0 4 8 13 11 19 13 cost(m) = Σ (x, y) M c(x, y) = (8+7+10+8+11) = 44 cost(m) = Σ y Y p(y) Σ x X p(x) = (8+13+11+19+13) - (5+4+3+0+8) = 44 12

Successive Shortest Path Algorithm Successive shortest path. Successive-Shortest-Path(X, Y, c) { M φ foreach x X: p(x) 0 foreach y Y: p(y) min e into y c(e) p is compatible with M = φ } 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 13

Maintaining Compatible Prices 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. 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). In either case, d(x) + c p (x, y) - d(y) = 0. By definition, c p (x, y) = p(x) + c(x, y) - p(y). Substituting for c p (x, y) yields: (p(x) + d(x)) + c(x, y) - (p(y) + d(y)) = 0. In other words, c p+d (x, y) = 0. forward or reverse edges Reduced costs: c p (x, y) = p(x) + c(x, y) - p(y). 14

Maintaining Compatible Prices 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 (y, x) is the only edge entering x in G M. Thus, (y, x) on shortest path. By Lemma 1, c p+d (x, y) = 0. Pf. (x, y) M (x, y) is an edge in G M d(y) d(x) + c p (x, y). 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. In other words, c p+d (x, y) 0. 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. 15

Maintaining Compatible Prices 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. By Lemma 2, the prices p + d are compatible for M. 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. By Lemma 1, these edges satisfy c p+d (x, y) = 0. Thus, compatibility is maintained. 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

Successive Shortest Path: Analysis 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. Each iteration increases the cardinality of M by 1 n iterations. Bottleneck operation is computing shortest path distances d. Since all costs are nonnegative, each iteration takes O(n 2 ) time using (dense) Dijkstra. 17

Weighted Bipartite Matching Weighted bipartite matching. Given weighted bipartite graph, find maximum cardinality matching of minimum weight. m edges, n nodes 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 2.376 ) randomized. Planar weighted bipartite matching. O(n 3/2 log 5 n). 18

Input Queued Switching

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

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

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. Achieves 100% when arrivals are uniform. Can starve input-queues when arrivals are non-uniform. y 1 y 2 y 2 y 2 y 3 y3 x 1 VOQ y 2 y 2 y 2 y 3 y 3 y 3 y 3 x 2 y 2 y 2 y 2 y3 x 3 y 1 y 2 y 3 outputs 22

Input-Queued Switching Max weight matching. Find a min cost perfect matching between inputs x and outputs y, where c(x, y) equals: [LQF] The number of cells waiting to go from input x to output y. [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. Too slow in practice for this application; difficult to implement in hardware. Provides theoretical framework. Use maximal (weighted) matching 2-approximation. Reference: http://robotics.eecs.berkeley.edu/~wlr/papers/ammw.pdf 23