Maximum Flow Chapter 26.

Slides:



Advertisements
Similar presentations
Maximum flow Main goals of the lecture:
Advertisements

Thursday, March 14 Introduction to Network Flows
1 Review of some graph algorithms Graph G(V,E) (Chapter 22) –Directed, undirected –Representation Adjacency-list, adjacency-matrix Breadth-first search.
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)
The Maximum Network Flow Problem. CSE Network Flows.
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 
Advanced Algorithm Design and Analysis (Lecture 8) SW5 fall 2004 Simonas Šaltenis E1-215b
Chapter 26 of CLSR Maximum Network Flow by me Dr. M. Sakalli Ch26 of CSLR and many other sources. Marmara Univ. Picture taken from without permission.
1 The Max Flow Problem. 2 Flow networks Flow networks are the problem instances of the max flow problem. A flow network is given by 1) a directed graph.
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.
Computational Methods for Management and Economics Carla Gomes Module 9a Network Models Terminology (Slides adapted from J.Orlin’s)
1 Maximum flow problems. 2 - Introduction of: network, max-flow problem capacity, flow - Ford-Fulkerson method pseudo code, residual networks, augmenting.
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Greed: Shortest Path s 3 t
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2004 Lecture 5 Wednesday, 10/6/04 Graph Algorithms: Part 2.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
Graph Theory Chapter 6 from Johnsonbaugh Article(6.1, 6.2)
MAX FLOW CS302, Spring 2013 David Kauchak. Admin.
Maximum Flow Chapter 26.
. 1 Transportation and Assignment Problems. . 2 Applications Physical analog of nodes Physical analog of arcs Flow Communication systems phone exchanges,
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
Overview of Graph Theory. Some applications of Graph Theory Models for communications and electrical networks Models for computer architectures Network.
Maximum Flow Chapter 26. Flow Concepts Source vertex s – where material is produced Sink vertex t – where material is consumed For all other vertices.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Flow Networks Ching-Chen Huang Hsi-Yue Hsiao. CONTENTS Network flows on directed acyclic graphs Ford-fulkerson Algorithms -Residual networks.
CSCE 3110 Data Structures & Algorithm Analysis Graphs (I) Reading: Chap.9, Weiss.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
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)
The Maximum Network Flow Problem
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Network Flow What is a network? Flow network and flows
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
Maximum Flow Chapter 26.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Graph Algorithms Minimum Spanning Tree (Chap 23)
CS4234 Optimiz(s)ation Algorithms
Algorithms and Networks Hans Bodlaender
Network flow problem [Adapted from M.Chandy].
Richard Anderson Lecture 23 Network Flow
Maximum Flow 9/13/2018 6:12 PM Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.
Lecture 22 Network Flow, Part 2
CSCI 3160 Design and Analysis of Algorithms Tutorial 8
ADVANCED ALGORITHMS GRAPH ALGORITHMS (UNIT-2).
Max Flow – Min Cut Problem
Algorithms and Networks
Edmonds-Karp Algorithm
Network Flows and Matching (Supplementary)
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.
Lecture 10 Network flow Max-flow and Min-cut Ford-Fulkerson method
Flow Networks Topics Flow Networks Residual networks
Lecture 5 Tuesday, 3/2/10 Graph Algorithms: Part 2
Network Flows and Matching (Supplementary)
Flow Networks General Characteristics Applications
Flow Networks and Bipartite Matching
Algorithms (2IL15) – Lecture 7
EE5900 Advanced Embedded System For Smart Infrastructure
Max Flow / Min Cut.
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
Text Book: Introduction to algorithms By C L R S
Network Flow.
Dinitz's algorithm for finding a maximum flow in a network.
MAXIMUM flow by Eric Wengert.
Lecture 22 Network Flow, Part 2
Network Flow.
Advanced Graph Homer Lee 2013/10/31.
Presentation transcript:

Maximum Flow Chapter 26

Flow Graph A common scenario is to use a graph to represent a “flow network” and use it to answer questions about material flows Flow is the rate that material moves through the network Each directed edge is a conduit for the material with some stated capacity Vertices are connection points but do not collect material Flow into a vertex must equal the flow leaving the vertex, flow conservation

Sample Networks Network Nodes Arcs Flow communication telephone exchanges, computers, satellites cables, fiber optics, microwave relays voice, video, packets circuits gates, registers, processors wires current mechanical joints rods, beams, springs heat, energy hydraulic reservoirs, pumping stations, lakes pipelines fluid, oil financial stocks, companies transactions money transportation airports, rail yards, street intersections highways, railbeds, airway routes freight, vehicles, passengers chemical sites bonds energy

Flow Concepts Source vertex s Sink vertex t where material is produced Sink vertex t where material is consumed For all other vertices – what goes in must go out Flow conservation Goal: determine maximum rate of material flow from source to sink

Formal Max Flow Problem Graph G=(V,E) – a flow network Directed, each edge has capacity c(u,v) ³ 0 Two special vertices: source s, and sink t For any other vertex v, there is a path s®…®v®…®t Flow – a function f : V ´ V ® R Capacity constraint: For all u, v Î V: f(u,v) £ c(u,v) Skew symmetry: For all u, v Î V: f(u,v) = –f(v,u) Flow conservation: For all u Î V – {s, t}: 2/15 a 4/19 s t 0/9 2/5 5/14 3/3 b

Cancellation of flows We would like to avoid two positive flows in opposite directions between the same pair of vertices Such flows cancel (maybe partially) each other due to skew symmetry 2/15 a 2/15 a 5/19 5/19 t s t s 2/9 5/5 0/9 3/5 2/3 5/14 2/3 5/14 b b

Max Flow We want to find a flow of maximum value from the source to the sink Denoted by |f| Max Flow, |f| = 19 Or is it? Best we can do? Lucky Puck Distribution Network

Ford-Fulkerson method Contains several algorithms: Residue networks Augmenting paths Find a path p from s to t (augmenting path), such that there is some value x > 0, and for each edge (u,v) in p we can add x units of flow f(u,v) + x  c(u,v) Augmenting Path? 8/13 a b 10/15 13/19 10 t s 2/4 9 5/5 6/14 8/11 3/3 c d

Residual Network To find augmenting path we can find any path in the residual network: Residual capacities: cf(u,v) = c(u,v) – f(u,v) i.e. the actual capacity minus the net flow from u to v Net flow may be negative Residual network: Gf =(V,Ef), where Ef = {(u,v) Î V ´ V : cf(u,v) > 0} Observation – edges in Ef are either edges in E or their reversals: |Ef| £ 2|E| 5/15 10 Sub-graph With c(u,v) and f(u,v) Residual Sub-Graph a b 5/6 a b 1 c c 0/14 19 5

Residual Graph Compute the residual graph of the graph with the following flow: 8/13 a b 10/15 13/19 10 t s 2/4 9 5/5 6/14 8/11 3/3 c d

Residual Capacity and Augmenting Path Finding an Augmenting Path Find a path from s to t in the residual graph The residual capacity of a path p in Gf: cf(p) = min{cf(u,v): (u,v) is in p} i.e. find the minimum capacity along p Doing augmentation: for all (u,v) in p, we just add this cf(p) to f(u,v) (and subtract it from f(v,u)) Resulting flow is a valid flow with a larger value.

Residual network and augmenting path

The Ford-Fulkerson method Ford-Fulkerson(G,s,t) 1 for each edge (u,v) in G.E do 2 f(u,v) ¬ f(v,u) ¬ 0 3 while there exists a path p from s to t in residual network Gf do 4 cf = min{cf(u,v): (u,v) is in p} 5 for each edge (u,v) in p do 6 f(u,v) ¬ f(u,v) + cf 7 f(v,u) ¬ -f(u,v) 8 return f The algorithms based on this method differ in how they choose p in step 3. If chosen poorly the algorithm might not terminate.

Execution of Ford-Fulkerson (1) Left Side = Residual Graph Right Side = Augmented Flow

Execution of Ford-Fulkerson (2) Left Side = Residual Graph Right Side = Augmented Flow

Cuts Does the method find the minimum flow? a b t s c d Yes, if we get to the point where the residual graph has no path from s to t A cut is a partition of V into S and T = V – S, such that s  S and t  T The net flow (f(S,T)) through the cut is the sum of flows f(u,v), where s  S and t  T Includes negative flows back from T to S The capacity (c(S,T)) of the cut is the sum of capacities c(u,v), where s  S and t  T The sum of positive capacities Minimum cut – a cut with the smallest capacity of all cuts. |f|= f(S,T) i.e. the value of a max flow is equal to the capacity of a min cut. 8/13 a b 10/15 13/19 10 t s 2/4 9 5/5 6/14 8/11 3/3 c d Cut capacity = 24 Min Cut capacity = 21

Max Flow / Min Cut Theorem Since |f|  c(S,T) for all cuts of (S,T) then if |f| = c(S,T) then c(S,T) must be the min cut of G This implies that f is a maximum flow of G This implies that the residual network Gf contains no augmenting paths. If there were augmenting paths this would contradict that we found the maximum flow of G 1231 … and from 23 we have that the Ford Fulkerson method finds the maximum flow if the residual graph has no augmenting paths.

Worst Case Running Time Assuming integer flow Each augmentation increases the value of the flow by some positive amount. Augmentation can be done in O(E). Total worst-case running time O(E|f*|), where f* is the max-flow found by the algorithm. Example of worst case: Augmenting path of 1 Resulting Residual Network Resulting Residual Network

Edmonds Karp Take shortest path (in terms of number of edges) as an augmenting path – Edmonds-Karp algorithm How do we find such a shortest path? Running time O(VE2), because the number of augmentations is O(VE) Skipping the proof here Even better method: push-relabel, O(V2E) runtime

Multiple Sources or Sinks What if you have a problem with more than one source and more than one sink? Modify the graph to create a single supersource and supersink 13 13 a b a b 15 13 15 13 10 k 10 t i 9 5 s 4 9 5 4   14 11 3 14 11 3 c d c d t s 4 4 13 13 e f e f 15 13 15 13   10 l 10 y j 9 5 x 9 5 4 4 14 11 3 14 11 3 g h g h

Application – Bipartite Matching Example – given a community with n men and m women Assume we have a way to determine which couples (man/woman) are compatible for marriage E.g. (Joe, Susan) or (Fred, Susan) but not (Frank, Susan) Problem: Maximize the number of marriages No polygamy allowed Can solve this problem by creating a flow network out of a bipartite graph

Bipartite Graph A bipartite graph is an undirected graph G=(V,E) in which V can be partitioned into two sets V1 and V2 such that (u,v)  E implies either u  V1 and v  V12 or vice versa. That is, all edges go between the two sets V1 and V2 and not within V1 and V2.

Model for Matching Problem Men on leftmost set, women on rightmost set, edges if they are compatible A A A X X X B B B Y Y Y C C C Z Z Z D D D Men Women A matching Optimal matching

Solution Using Max Flow Add a supersouce, supersink, make each undirected edge directed with a flow of 1 A A X X B B t Y s Y C C Z Z D D Since the input is 1, flow conservation prevents multiple matchings