CSE 589 Part III The computer is useless It can only answer questions. -- Pablo Picasso.

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

Introduction to Algorithms
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.
Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm.
1 Review of some graph algorithms Graph G(V,E) (Chapter 22) –Directed, undirected –Representation Adjacency-list, adjacency-matrix Breadth-first search.
MAX FLOW APPLICATIONS CS302, Spring 2013 David Kauchak.
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.
The Maximum Network Flow Problem. CSE Network Flows.
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.
Advanced Algorithm Design and Analysis (Lecture 8) SW5 fall 2004 Simonas Šaltenis E1-215b
Lectures on Network Flows
1 Maximum Flow Networks Suppose G = (V, E) is a directed network. Each edge (i,j) in E has an associated ‘capacity’ u ij. Goal: Determine the maximum amount.
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.
1 Efficient implementation of Dinic’s algorithm for maximum flow.
HW2 Solutions. Problem 1 Construct a bipartite graph where, every family represents a vertex in one partition, and table represents a vertex in another.
CS138A Network Flows Peter Schröder. CS138A Flow Networks Definitions a flow network G=(V,E) is a directed graph in which each edge (u,v)
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2001 Lecture 4 Tuesday, 2/19/02 Graph Algorithms: Part 2 Network.
1 Maximum flow problems. 2 - Introduction of: network, max-flow problem capacity, flow - Ford-Fulkerson method pseudo code, residual networks, augmenting.
A New Approach to the Maximum-Flow Problem Andrew V. Goldberg, Robert E. Tarjan Presented by Andrew Guillory.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 4 Tuesday, 10/2/01 Graph Algorithms: Part 2 Network.
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.
1 Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2006 Lecture 5 Wednesday, 10/4/06 Graph Algorithms: Part 2.
A New Approach to the Maximum-Flow Problem Andrew V. Goldberg, Robert E. Tarjan Presented by Andrew Guillory.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2004 Lecture 5 Wednesday, 10/6/04 Graph Algorithms: Part 2.
1 Ford-Fulkerson method Ford-Fulkerson(G) f = 0 while( 9 simple path p from s to t in G f ) f := f + f p output f Runs in time O(|f max | |E|) where f.
Maximum Flow Maximum Flow Problem The Ford-Fulkerson method
Assignment 4. (Due on Dec 2. 2:30 p.m.) This time, Prof. Yao and I can explain the questions, but we will NOT tell you how to solve the problems. Question.
Lecture 5: Network Flow Algorithms Single-Source Shortest-Path (SSSP) (Dijkstra's Algorithm) Max Flow - Min Cut (Ford-Fulkerson) Job Sequencing.
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.
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Finding Max Flow.
MAX FLOW APPLICATIONS CS302, Spring 2012 David Kauchak.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
10. Lecture WS 2006/07Bioinformatics III1 V10: Network Flows V10 follows closely chapter 12.1 in on „Flows and Cuts in Networks and Chapter 12.2 on “Solving.
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
1 WEEK 11 Graphs III Network Flow Problems A Simple Maximum-Flow Algorithm Izmir University of Economics.
Maximum Flow Problem (Thanks to Jim Orlin & MIT OCW)
Maximum Flow Chapter 26. Flow Concepts Source vertex s – where material is produced Sink vertex t – where material is consumed For all other vertices.
CS223 Advanced Data Structures and Algorithms 1 Maximum Flow Neil Tang 3/30/2010.
Chapter 7 April 28 Network Flow.
15.082J and 6.855J March 4, 2003 Introduction to Maximum Flows.
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.
Algorithm Design and Analysis (ADA)
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.
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
Maximum Flow Problem Definitions and notations The Ford-Fulkerson method.
Instructor Neelima Gupta Edited by Divya Gaur(39, MCS '09) Thanks to: Bhavya(9), Deepika(10), Deepika Bisht(11) (MCS '09)
1 Maximum Flows CONTENTS Introduction to Maximum Flows (Section 6.1) Introduction to Minimum Cuts (Section 6.1) Applications of Maximum Flows (Section.
The Maximum Network Flow Problem
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Maximum Flow Chapter 26.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
Instructor: Shengyu Zhang
Introduction to Maximum Flows
Algorithms (2IL15) – Lecture 7
EE5900 Advanced Embedded System For Smart Infrastructure
Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
Presentation transcript:

CSE 589 Part III The computer is useless It can only answer questions. -- Pablo Picasso

Dynamic Programming Summary 1. Formulate answer as recurrence relation or recursive algorithm 2. Show that number of values of recurrence bounded by poly 3. Specify order of evaluation for recurrence so have partial results when you need them. DP works particularly well for optimization problems with inherent left to right ordering among elements. Resulting global optimum often much better than solution found with heuristics. Once you understand it, usually easier to work out from scratch a DP solution than to look it up.

Readings Max Flow Skiena, Section CLR, chapter 27 Network Flows, Theory, Algorithms and Applications, by Ahuja, Magnanti and Orlin, chapter 6 ++

Maximum Flow Input description: a graph (network) G where each edge (v,w) has associated capacity c(v,w), and a specified source node s and sink node t Problem description: What is the maximum flow you can route from s to t while respecting the capacity constraint of each edge? st

Max-flow outline: properties of flow augmenting paths max-flow min-cut theorem Ford-Fulkerson method Edmonds-Karp method applications variants: min cost max flow

Properties of Flow: f(v,w) -- flow on edge (v,w) 0<= f(v,w) <= c(v,w) : the flow through an edge cannot exceed the capacity of an edge for all v except s,t  u f(u,v) =  w f(v,w): the total flow entering a vertex is equal to total flow exiting vertex total flow leaving s = total flow entering t. 4/5 st 3/7 5/5 4/6 2/3 3/4 2/4 1/1 3/4 2/6 3/3 7/7 Notation on edges f(v,w)/c(v,w) Not a maximum flow!

An augmenting path with respect to a given flow f is a Directed path from s to t which consists of edges from G, but not necessarily in same direction. Each edge on path is either: forward edge: (u,v) in same direction as G and f(u,v) has room for more flow. backward edge: (u,v) in opposite direction in G (i.e., (v,u) in E) and f(u,v) >0 => can borrow flow from such an edge. st 3/7 5/5 5/6 2/3 3/4 2/4 1/1 3/4 3/6 3/3 7/7 5/5 w v u s-w-u-v-t augmenting path

Using an augmenting path to increase flow If all edges are forward => move flow through all of them. amount of flow can push = minimum slack Otherwise, push flow forward on forward edges, deduct flow from backward edges. st 5/7 5/5 5/6 2/3 3/4 4/4 1/1 1/4 5/6 3/3 7/7 5/5 w v u

Augmenting Path Theorem: A flow f is maximum iff it admits no augmenting path Already saw that if flow admits an augmenting path, then it is not maximum. Suppose f admits no augmenting path. Need to show f maximum. Cut -- a set of edges that separate s from t. Capacity of a cut = sum of capacities of edges in cut. Prove theorem by showing that there is a cut whose capacity = f. A = vertices s.t. for each v in A, there is augmenting path from s to v. => defines a cut. Claim: for all edges in cut, f(v,w)=c(v,w) => value of flow = capacity of cut defined by A => maximum.

=> Celebrated Max-flow Min-Cut Theorem The value of a maximum flow in a network is equal to the minimum capacity of a cut. The Integral Flow Theorem If the capacities of all edges in the network are integers, then there is a maximum flow whose value is an integer.

Residual Graph w.r.t. flow f R=(V,E’) an edge (v,w) in E’ if either it is forward edge capacity = c(v,w)-f(v,w) or it is a backward edge capacity = f(v,w). (assuming edges in only one direction) An augmenting path = a regular directed path from s to t in the residual graph.

Ford-Fulkerson Method (G,s,t) Initialize flow on all edges to 0. While there is a path p from s to t in residual network R  = minimum capacity along p in R augment  units of flow along p and update R Running Time? s t M M M M 1

Edmonds-Karp If implement computation of augmenting path using breadth-first search, i.e., if augmenting path is a shortest path from s to t in residual network, then the number of augmentations O(|V||E|). The shortest-path distance from v to t in R is non-decreasing. The number of times an edge (u,v) can become critical, i.e., residual capacity of (u,v) = residual capacity of augmenting path, is O(|V|).

The shortest path distance from v to t in R f is non-decreasing. Proof by contradiction: Consider first time SP (in residual graph) to t decreases from some node v. Let v be the closest such node to t. SP in f’ from v to t begins with edge (v,w) vwt d’(v)=d’(w)+ 1. Claim: f(v,w)=c(v,w). If not (v,w) in R f d(v) <= d(w)+1 <= d’(w)+1 = d’(v). Contradiction.

Shortest paths non-decreasing, cont. Therefore (w,v) in R f, and in order for (v,w) in R f’, augmenting path must be: vwt s => d(v) = d(w)-1 <= d’(w)-1 = d’(v)-2 => d(v) <= d’(v). Contradiction.

Lemma: between any two consecutive saturations of (v,w), both d(v) and d(w) increase by at least 2. In first saturation, increasing flow along augmenting path, and d(v)= d(w)+1. vwt s vwt s Before edge can be saturated again, must send flow back from w to v. => d’(w)= d’(v)+1. In next saturation, again have d’’(v)=d’’(w)+ 1. => d’’(v)= d’’(w)+1 >= d’(w)+1 >= d’(v)+2 >= d(v)+2.

=> Running time of Edmonds-Karp is O(m 2 n) Corollary 1: An edge (v,w) can be saturated at most O(n) times. Corollary 2: The total # of flow augmentations performed is O(mn) Since each augmentation can be performed in O(m) time => O(m 2 n) time. O Can be improved to nearly O(mn) with super- fancy data structures.

Fastest max-flow algorithms: preflow-push Flood the network so that some nodes have excess or buildup of flow algorithms incrementally relieve flow from nodes with excess by sending flow towards sink or back towards source.

Some applications of max-flow and max-flow min-cut theorem Scheduling on uniform parallel machines Bipartite matching Network connectivity Video on demand

Scheduling on uniform parallel machines Have a set J of jobs, M uniform parallel machines. Each job j has processing requirement p j, release date r j and due date d j. d j >= r j + p j A machine can work on only one job at a time and each job can be processed by at most one machine at a time, but preemptions are allowed. Scheduling problem: determine a feasible schedule that completes all jobs before their due dates or show that no such schedule exists.

Bipartite Matching Input: a bipartite graph G=(V,E) Output: Largest-size set of edges M from E such that each vertex in V is incident to at most one edge of S

Network Connectivity What is the minimum number of links in the network such that if that many links go down, it is possible for nodes s and t to become disconnected? What is the minimum number of nodes in the network such that if that many nodes go down, it is possible for nodes s and t to become disconnected?

Video on Demand M storage devices (e.g., disks), each capable of supporting b simultaneous streams. k movies, one copy of each on 3 disks. Given set of R movie requests, how would you assign the requests to disks so that no disk is assigned more than b requests and the maximum number of requests is served?

Other network flow problems: 1. With lower bounds on flow. For each (v,w): 0 <= lb(v,w) <= f(v,w) <= c(v,w) Not always possible: svt (2,4)(5,10)

Other network flow problems: 2. Minimum flow Want to send minimum amount of flow from source to sink, while satisfying certain lower and upper bounds on flow on each edge.

Other network flow problems: 3. Min-cost max-flow Input description: a graph (network) G where each edge (v,w) has associated capacity c(v,w), and a cost cost(v,w). Problem description: What is the maximum flow of minimum cost you can route from s to t while respecting the capacity constraint of each edge? The cost of a flow :  f(v,w)>0 cost (v,w)f(v,w)

Classical application: Transportation Problem Firm has p plants with known supplies, q warehouses with known demands. Want to identify flow that satisfies the demands at warehouses from available supplies at plants and minimizes shipping costs. Min cost flow yields an optimal production and shipping schedule.

Example: Fiat makes Uno and Ferrari’s. t p1/Uno Plant 2 Plant 1 p1/F500 p2/F20 p2/Uno r1 r2/F20 r2/Uno r1/Uno r2/F500 s r2 cost cap 0 supply of plant production cost max production shipping cost capacity imposed by dist’n channelmodel demand 0 t Retailer demand 0

Disk head scheduling Have disk with 2 heads, and sequence of requests to read data on disk at locations l 1,….,l n. How to schedule movement of disk heads so as to minimize total head movement?