Network flow problem [Adapted from M.Chandy].

Slides:



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

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.
Advanced Algorithm Design and Analysis (Lecture 8) SW5 fall 2004 Simonas Šaltenis E1-215b
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)
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
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.
1 Maximum Flow Maximum Flow Problem The Ford-Fulkerson method Maximum bipartite matching.
1 Optimization Spring 2007 (Third Quarter). 2 Some practical remarks Homepage: Exam: Written, 3 hours. There.
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
Chapter 27 Maximum Flow Maximum Flow Problem The Ford-Fulkerson method m bipartite matching.
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.
Maximum Flow Chapter 26.
Theory of Computing Lecture 13 MAS 714 Hartmut Klauck.
Single Source Shortest-Path: The General Case (with negative edges) Bellman-Ford algorithm. Iteratively relax all edges |V|-1 times Running time? O(VE).
Maximum Flow. p2. Maximum Flow A flow network G=(V, E) is a DIRECTED graph where each has a nonnegative capacity u.
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Flow Networks & Flows.
Maximum Flow Chapter 26. Flow Concepts Source vertex s – where material is produced Sink vertex t – where material is consumed For all other vertices.
Flow Networks Ching-Chen Huang Hsi-Yue Hsiao. CONTENTS Network flows on directed acyclic graphs Ford-fulkerson Algorithms -Residual networks.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
A directed graph G consists of a set V of vertices and a set E of arcs where each arc in E is associated with an ordered pair of vertices from V. V={0,
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)
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Network Flow What is a network? Flow network and flows
Maximum Flow Chapter 26.
The Maximum Network Flow Problem
Maximum Flow Chapter 26.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Graph Algorithms Minimum Spanning Tree (Chap 23)
Algorithms and Networks Hans Bodlaender
CSCI 3160 Design and Analysis of Algorithms Tutorial 8
ADVANCED ALGORITHMS GRAPH ALGORITHMS (UNIT-2).
Max Flow – Min Cut Problem
Network Flow 2016/04/12.
Instructor: Shengyu Zhang
Edmonds-Karp Algorithm
Network Flows and Matching (Supplementary)
Lecture 10 Network flow Max-flow and Min-cut Ford-Fulkerson method
7. Ford-Fulkerson Demo.
7. Ford-Fulkerson Demo.
Flow Networks Topics Flow Networks Residual networks
Richard Anderson Lecture 21 Network Flow
Lecture 5 Tuesday, 3/2/10 Graph Algorithms: Part 2
Network Flows and Matching (Supplementary)
Augmenting Path Algorithm
Flow Networks General Characteristics Applications
Flow Networks and Bipartite Matching
Algorithms (2IL15) – Lecture 7
EE5900 Advanced Embedded System For Smart Infrastructure
Text Book: Introduction to algorithms By C L R S
7. Ford-Fulkerson Demo.
Dinitz's algorithm for finding a maximum flow in a network.
MAXIMUM flow by Eric Wengert.
Augmenting Path Algorithm
7. Edmonds-Karp Algorithm
7. Edmonds-karp Demo.
7. Ford-Fulkerson Demo.
7. Ford-Fulkerson Demo.
7. Ford-Fulkerson Demo.
7. Ford-Fulkerson Demo.
7. Ford-Fulkerson Demo.
7. Ford-Fulkerson Demo.
Advanced Graph Homer Lee 2013/10/31.
Presentation transcript:

Network flow problem [Adapted from M.Chandy]

Maximum Flow - Example 12 a b 16 20 10 s 4 t 9 7 13 4 c d 14

Maximum Flow - Example 12/12 a b 11/16 15/20 0/10 s 1/4 t 4/9 7/7 8/13 4/4 c d 11/14

Maximum Flow - Example 12/12 a b 11/16 19/20 0/10 s 1/4 t 0/9 7/7 12/13 4/4 c d 11/14

Maximum Flow - Flow Network Flow network - directed graph G = (V,E) in which each edge (u,v)  E has a non-negative capacity c(u,v)  0. If (u,v)  E, we assume c(u,v) = 0.

Maximum Flow - Flow A Flow in G - a real valued function f : VV  R: for all u,v  V : f(u,v)  c(u,v) for all u,v  V : f(u,v) = – f(v,u) for all u  V – {s,t} : vV f(u,v) = 0

Maximum Flow - Flow The value of flow : | f | = vV f(s,v) Problem Given a flow network G with source s and sink t, find a flow f with a maximum possible value | f |.

Maximum Flow - Flow Properties X,Y - sets of vertices f(X,Y) = xX yY f(x,y)

Maximum Flow - Flow Properties Lemma Let G = (V,E) be a flow network and let f be a flow in G. Then: for X  V : f(X,X) = 0 for X,Y  V : f(X,Y) = – f(Y,X) for X,Y,Z  V, XY =  : f(XY,Z) = f(X,Z) + f(Y,Z) f(Z,XY) = f(Z,X) + f(Z,Y)

Maximum Flow - Ford-Fulkerson Method procedure FordFulkerson(graph G, source s, sink t) initialize flow f to 0 while there exists an augmenting path p do augment flow f along p return f

Maximum Flow - Residual Networks G = (V,E) - flow network s - source, t - sink f - flow in G Residual capacity of u,vV: cf(u,v) = c(u,v) – f(u,v)

Maximum Flow - Residual Networks G = (V,E) - flow network f - flow in G Residual network induced by f: Gf = (V,Ef), where Ef = {(u,v)  VV: cf(u,v) > 0}

Maximum Flow - Residual Networks - Example 12/12 a b 11/16 15/20 0/10 s 1/4 t 4/9 7/7 8/13 4/4 c d 11/14

Maximum Flow - Residual Networks - Example 12 a b 11 15 5 4 5 s 11 3 t 7 5 5 8 4 3 c d 11

Maximum Flow - Residual Networks - Example 12 a b 11 15 5 4 5 s 11 3 t 7 5 5 8 4 3 c d 11

Maximum Flow - Residual Networks - Example 12/12 a b 11/16 19/20 0/10 s 1/4 t 0/9 7/7 12/13 4/4 c d 11/14

Maximum Flow - Residual Networks - Example 12 a b 11 19 5 1 s 11 3 t 7 9 1 12 4 3 c d 11

Maximum Flow - Residual Networks Lemma Let G = (V,E) be a flow network with source s and sink t. Let f be a flow in G. Let Gf be a residual network induced by f and let f ’ be a flow in Gf. then the flow sum f + f ’ defined by (f + f ’) (u,v) = f(u,v) + f ’(u,v) is a flow in G with value | f + f ’| = | f | + | f ’ |

Maximum Flow - Augmenting Paths G = (V,E) - a flow network with source s and sink t. f - a flow in G. An augmenting path p is a simple path from s to t in Gf. Residual capacity of p : cf(p) = min{cf(u,v) : (u,v) is on p}

Maximum Flow - Augmenting Paths Lemma Let G = (V,E) be a flow network, let f be a flow in G, and let p be an augmenting path in Gf. Define fp : VV  R by cf(p), if (u,v) is on p –cf(p), if (v,u) is on p 0, otherwise fp (u,v) = Then fp is a flow in Gf with value | fp | = cf(p) > 0.

Maximum Flow - Augmenting Paths Corollary Let G = (V,E) be a flow network, let f be a flow in G, and let p be an augmenting path in Gf. Let fp be defined as above. Define f ’ : VV  R by f ’ = f + fp. Then f ’ is a flow in G with value | f ’ | = | f | + | fp | > | f |.

Maximum Flow - Cuts A cut (S,T) of a flow network G = (V,E) is a partition of V into S and T = V – S such that s  S and t  T. The net flow across the cut (S,T) is defined to be f(S,T). The capacity of the cut (S,T) is c(S,T).

Maximum Flow - Cuts - Example f(S,T) = 19 c(S,T) = 26 12/12 a b 11/16 15/20 0/10 s 1/4 t 4/9 7/7 8/13 4/4 c d 11/14 T S

Maximum Flow - Cuts - Lemmas Let f be a flow in flow network G with source s and sink t and let (S,T) be a cut of G. Then the flow across (S,T) is f(S,T) = | f |. Corollary The value of any flow f in a flow network G is bounded from above by the capacity of any cut in G.

Maximum Flow - Cuts - Lemmas [Adapted from R.Solis-Oba]

Maximum Flow - Cuts - Lemmas [Adapted from R.Solis-Oba]

Maximum Flow - Cuts - Lemmas [Adapted from R.Solis-Oba]

Maximum Flow - Cuts - Lemmas [Adapted from R.Solis-Oba]

Maximum Flow - Cuts - Lemmas [Adapted from R.Solis-Oba]

Maximum Flow - Cuts - Lemmas [Adapted from R.Solis-Oba]

Maximum Flow - Max-Flow Theorem If f is a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent: f is a maximum flow in G the residual network Gf contains no augmenting paths | f | = c(S,T) for some cut (S,T) in G [Adapted from R.Solis-Oba]

Maximum Flow - Max-Flow Theorem [Adapted from R.Solis-Oba]

Maximum Flow - Max-Flow Theorem [Adapted from R.Solis-Oba]

Maximum Flow - Ford-Fulkerson Method procedure FordFulkerson(graph G = (V,E), source s, sink t) for (u,v)  E do f[u,v]  0 f[v,u]  0 while there exists a path p from s to t in Gf do cf(p)  min{ cf(u,v): (u,v)  p } for (u,v)  p do f[u,v]  f[u,v] + cf(p) f[v,u]   f[u,v]

Maximum Flow - Ford-Fulkerson - Example 12 a b 16 20 10 s 4 t 9 7 13 4 c d 14

Maximum Flow - Ford-Fulkerson - Example 12 a b 16 20 10 s 4 t 9 7 13 4 c d 14

Maximum Flow - Ford-Fulkerson - Example 4/12 a b 4/16 20 10 s 4 t 4/9 7 13 4/4 c d 4/14

Maximum Flow - Ford-Fulkerson - Example 8 a b 4 4 20 12 4 s 10 4 t 7 5 13 4 10 c d 4

Maximum Flow - Ford-Fulkerson - Example 8 a b 4 4 20 12 4 s 10 4 t 7 5 13 4 10 c d 4

Maximum Flow - Ford-Fulkerson - Example 4/12 a b 11/16 7/20 7/10 s 4 t 4/9 7/7 13 4/4 c d 11/14

Maximum Flow - Ford-Fulkerson - Example 8 a b 4 7 11 5 4 13 s 3 11 t 7 5 13 4 3 c d 11

Maximum Flow - Ford-Fulkerson - Example 8 a b 4 7 11 5 4 13 s 3 11 t 7 5 13 4 3 c d 11

Maximum Flow - Ford-Fulkerson - Example 12/12 a b 11/16 15/20 10 s 1/4 t 4/9 7/7 8/13 4/4 c d 11/14

Maximum Flow - Ford-Fulkerson - Example b 12 15 11 5 4 5 s 11 3 t 7 5 5 4 8 3 c d 11

Maximum Flow - Ford-Fulkerson - Example b 12 15 11 5 4 5 s 11 3 t 7 5 5 4 8 3 c d 11

Maximum Flow - Ford-Fulkerson - Example 12/12 a b 11/16 19/20 10 s 1/4 t 9 7/7 12/13 4/4 c d 11/14

Maximum Flow - Ford-Fulkerson - Example b 12 19 11 5 1 s 11 3 t 7 9 1 4 12 3 c d 11

Maximum Flow - Ford-Fulkerson - Bad Example 1000000 1000000 s 1 t 1000000 1000000 b

Maximum Flow - Ford-Fulkerson - Bad Example 1000000 1000000 s 1 t 1000000 1000000 b

Maximum Flow - Ford-Fulkerson - Bad Example 999999 1000000 1 s 1 t 1 1000000 999999 b

Maximum Flow - Ford-Fulkerson - Bad Example 999999 1000000 1 s 1 t 1 1000000 999999 b

Maximum Flow - Ford-Fulkerson - Bad Example 999999 999999 1 1 s 1 t 1 1 999999 999999 b

Maximum Flow - Ford-Fulkerson - Bad Example 999999 999999 1 1 s 1 t 1 1 999999 999999 b

Maximum Flow - Ford-Fulkerson - Complexity procedure FordFulkerson(graph G = (V,E), source s, sink t) for (u,v)  E do f[u,v]  0 f[v,u]  0 while there exists a path p from s to t in Gf do cf(p)  min{ cf(u,v): (u,v)  p } for (u,v)  p do f[u,v]  f[u,v] + cf(p) f[v,u]   f[u,v] If all capacities are integers and f* is a maximum flow, then T(V,E,f*) = O(E | f* |)

Maximum Flow - Ford-Fulkerson - Complexity [Adapted from Z.Hu]

Maximum Flow - Edmonds-Karp Algorithm Apply Ford-Fulkerson method with using BFS for finding finding the shortest augmenting path in each residual network. [Adapted from Z.Hu]

Maximum Flow - Edmonds-Karp Algorithm - complexity Lemma If the Edmonds-Karp algorithm is run on a flow network G = (V,E) with source s and sink t, then for all vertices v  V – {s,t} the shortest path distance f(s,v) in the residual network Gf increases monotonically with each flow augmentation. Theorem If the Edmonds-Karp algorithm is run on a flow network G = (V,E) with source s and sink t, then the total number of flow augmentations performed by the algorithm is at most O(V E).

Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]

Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]

Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]

Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]

Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]

Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]

Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]

Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]

Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]

Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]

Maximum Flow - Edmonds-Karp Algorithm - complexity T(V,E) = O(V E2)

Maximum Flow - Best algorithms [Adapted from R.Solis-Oba]