Max Flow – Min Cut Problem

Slides:



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

Thursday, March 14 Introduction to Network Flows
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.
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.
Yangjun Chen 1 Network Flow What is a network? Flow network and flows Ford-Fulkerson method - Residual networks - Augmenting paths - Cuts of flow networks.
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Greed: Shortest Path s 3 t
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
Graph Theory Chapter 6 from Johnsonbaugh Article(6.1, 6.2)
Maximum Flow Chapter 26.
Introduction to Operations Research
Theory of Computing Lecture 13 MAS 714 Hartmut Klauck.
Yangjun Chen 1 Network Flow What is a network? Flow network and flows Ford-Fulkerson method - Residual networks - Augmenting paths - Cuts of flow networks.
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.
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
Maximum Flow Problem (Thanks to Jim Orlin & MIT OCW)
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.
15.082J & 6.855J & ESD.78J October 7, 2010 Introduction to Maximum Flows.
15.082J and 6.855J March 4, 2003 Introduction to Maximum Flows.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
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
Maximum Flow Chapter 26.
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
CS4234 Optimiz(s)ation Algorithms
Algorithms and Networks Hans Bodlaender
Network flow problem [Adapted from M.Chandy].
Richard Anderson Lecture 23 Network Flow
Algorithms and Networks
ADVANCED ALGORITHMS GRAPH ALGORITHMS (UNIT-2).
Instructor: Shengyu Zhang
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.
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
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Network Flow and Connectivity in Wireless Sensor Networks
Introduction to Maximum Flows
Flow Networks Topics Flow Networks Residual networks
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 21 Network Flow
Network Flows and Matching (Supplementary)
Max Flow Min Cut, Bipartite Matching Yin Tat Lee
Flow Networks General Characteristics Applications
Flow Networks and Bipartite Matching
Algorithms (2IL15) – Lecture 7
EE5900 Advanced Embedded System For Smart Infrastructure
Algorithms and Networks
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
Richard Anderson Lecture 22 Network Flow
Lecture 21 Network Flow, Part 1
Presentation transcript:

Max Flow – Min Cut Problem

Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material flow through conduit) Liquid flow through pipes Parts through assembly line Current through electrical network, etc

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 Networks Directed graph G = (V, E) Only one Source(s) and one Sink(t) Weight on each edge = Capacity of the edge if (u, v) Î E then Capacity is non-negative, i.e. c(u, v) ≥ 0 if (u, v)  E then Capacity is assumed zero, i.e. c(u, v) = 0

Flow Networks and Flows flow(f) in Flow Network(G) is a real-valued function f: V x V → R f(u, v) is flow from vertex u to vertex v. flow f(u, v) can be positive, negative or zero Constraints on flow : Capacity constraint : f(u, v) ≤ c(u, v), for all u, v Î V Skew symmetry constraint : f(u, v) = - f(v, u)

Flow Networks and Flows (Contd.) Flow conservation constraint : Total net flow at vertex must equal 0. ∑j f(i, j) - ∑k f(k, i) = 0 for all i Î V – {s, t} flow in equals flow out

Maximum Flow We refer a flow f(s,t) as maximum if it is feasible and maximizes ∑k f(s, k) OR ∑k f(k, t) Problem: Objective: To find a maximum flow f from s to t (flow/capacity) s t 2 1 (6/10) (7/8) (1/1) (5/6) (8/10)

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

Max Flow Current Flow, |f| = 13 Is it Max Flow? 2 1 (6/10) (7/8) (1/1) (5/6) (8/11) Current Flow, |f| = 13 Is it Max Flow? Can it be increased further? By how much? s t 2 1 (6/10) (7/8) (1/5) (5/6) (8/11) Current Flow, |f| = 13 Is it Max Flow? Can it be increased further? By how much?

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

Ford-Fulkerson method Contains several terms: Residual networks Augmenting paths Find a path p from s to t (augmenting path), such that there is some value (maximum 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} 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: Residual graph

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 Before After Flow Graph Residual Graph

Ford-Fulkerson Algorithm for Max Flow Key ingredients:- Residual Networks Augmenting Paths Cut Limitations :- Flow should be integral or rational On each iteration residual capacity should be integral

The Residual Network Flow Network Residual Network s 1 2 t (8/10) (7/8) (1/1) (6/10) (5/6) (flow / capacity) u v f (u, v) / c (u, v) Residual Network Residual capacity r (u ,v) s 1 2 t 4 8 5 6 7 u v c (u, f) – f (u, v) f (u, v)

Augmenting Paths An augmenting path is a path from s to t in the residual network. The Residual capacity of augmented path P is d(P) = min {r(i, j): (i, j)  P} Augmentation along P Add d(P) in each arc along P in flow network Modify residual capacities in residual network r(u, v) = r(u, v) - d(P) and r(v, u) = r(v, u) + d(P) for u, v  P s 1 2 t 4 8 5 6 7 s 1 2 t 4 8 6

Cut An (S,T)-cut in a flow network G = (V,E) is a partition of 1 2 t (9/10) (8/8) (1/1) (7/10) (6/6) An (S,T)-cut in a flow network G = (V,E) is a partition of vertices V into two disjoint subsets S and T such that s  S, t  T e.g., S = { s, 1 } and T = { 2, t }. The capacity of a cut (S,T) is CAP(S,T) = uSvT c(u,v)

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 cp = 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) Residual Graph Augmented Flow

Execution of Ford-Fulkerson (2) Residual Graph Augmented Flow

Multiple source – Multiple sink Network 10 3 12 5 15 8 14 20 6 7 11 13 18 2 Factories Warehouses Convert this problem to single source - single sink.

Conversion to flow Network Add a super – source with infinite weighted edges emanting out to original sources Add a super – sink with edges of infinite weight from original sinks s3 s4 s5 s2 s1 t3 t2 t1 10 3 12 5 15 8 14 20 6 7 11 13 18 2 Super-source Factories Warehouses Super-sink s t 

Another Example : Find a feasible match Assign persons to tasks such that each task is assigned to a person and each person is assigned to a task in feasible manner. 1 2 3 4 5 6 7 8 persons tasks

Transformation to maximum flow problem 1 2 3 4 5 6 7 8 persons tasks s t

The Ford Fulkerson Maximum Flow Method Begin x := 0; create the residual network G(x); while there is some directed path from s to t in G(x) do begin let P be a path from s to t in G(x);  := d(P); send  units of flow along P; update the residual capacities; end end {the flow x is now maximum}.

Proof of Correctness of the Algorithm Assume that all data are integral. Lemma: At each iteration all residual capacities are integral. Proof: By assumption it is true at beginning. Assume it is true after the first k-1 augmentations, and consider augmentation k along path P. The residual capacity D of P is the smallest residual capacity on P, which is integral. After updating, we modify residual capacities by 0, or D, and thus residual capacities stay integral.

Proof of finiteness of Algorithm The capacity of each augmenting path is at least 1. The augmentation reduces the residual capacity of some arc (s, j) and does not increase the residual capacity of (s, i) for any i. So, the sum of the residual capacities of arcs out of s keeps decreasing, and is bounded below by 0. Number of augmentations is O(nU), where U is the largest capacity in the network.

Indication of Optimum Flow s 1 2 t (9/10) (8/8) (1/1) (7/10) (6/6) There is no augmenting path in the residual network. s 1 2 t 3 9 6 7 8

Indication of Optimum Flow (Contd.) s 1 2 t (9/10) (8/8) (1/1) (7/10) (6/6) Flow across the network is equal to the capacity of some cut (Max Flow Min Cut Theorem)

Weak Duality Theorem for the Max Flow Problem If f is any feasible flow and if (S,T) is an (s,t)-cut, then the flow | f | from source to sink in the network is at most CAP(S,T). Proof: We define the flow across the cut (S,T) to be f(S,T) = iSjT f(i, j) - iSjT f(j, i) S T

Flows across different cuts  S/T cut s 1 2 t (9/10) (8/8) (1/1) (7/10) (6/6)  S If S = {s}, then the flow across (S, T) is 9 + 6 = 15  T s 1 2 t (9/10) (8/8) (1/1) (7/10) (6/6) If S = {s,1}, then the flow across (S, T) is 8 + 1 + 6 = 15 s 1 2 t (9/10) (8/8) (1/1) (7/10) (6/6) If S = {s,2}, then the flow across (S, T) is 9 + 7 – 1 = 15

More on Flows Across Cuts Claim: Let (S,T) be any s-t cut. Then f(S,T) = | f | = flow into t. Proof: Add the conservation of flow constraints for each node i Î S - {s} to the constraint that the flow leaving s is |f|. The resulting equality is f(S,T) = |f|. Sj f(i, j) - Sk f(k, i) = 0 for each i  {S} - s Sj f(s, j) = | f | S T

More on Flows Across Cuts Claim: The flow across (S,T) is at most the capacity of a cut. Proof: If i  S, and j  T, then f(i, j)  c(i, j). If i  T, and j  S, then f(i, j)  0. f(S,T) = iSjT f(i, j) - iSjT f(j, i) CAP(S,T) = iSjT c(i, j) - iSjT 0

Max Flow Min Cut Theorem Theorem: (Optimality conditions for max flows). The following are equivalent. 1. A flow x is maximum. 2. There is no augmenting path in G(x). 3. There is an s-t cutset (S, T) whose capacity is the flow value of x. Corollary: (Max-flow Min-Cut). The maximum flow value is the minimum value of a cut. Proof of Theorem: 1 Þ 2. (not 2 Þ not 1) Suppose that there is an augmenting path in G(x). Then x is not maximum.

Max Flow Min Cut Theorem Contd. 3 Þ 1. Let v = Fx(S, T) be the flow from s to t. By assumption, v = CAP(S, T). By weak duality, the maximum flow is at most CAP(S, T). Thus the flow is maximum. 2 Þ 3. Suppose there is no augmenting path in G(x). Claim: Let S be the set of nodes reachable from s in G(x). Let T = N\S. Then there is no arc in G(x) from S to T.

Max Flow Min Cut Theorem Contd. Thus i Î S and j Î T Þ f(i, j) = c(i, j) i Î T and j Î S Þ f(i, j) = 0. S T Saturated Reachable from s Not Reachable from s .s .t There is no arc from S to T in G(x) It follows that Fx(S,T) = iSjT f(i, j) - iSjT f(j, i) = iSjT c(i, j) - iSjT 0 = CAP(S,T)

Limitation of Algorithm : example 1 Termination even with integral flow and few nodes can take large no. of steps. Depends on path selection and capacity of flow network. s 1 2 t M Î Flow M >> 1 Flow Network 39

After 1st augmentation Residual Network s 1 2 t M-1 M 40

After 2nd augmentation s 1 2 t M-1 41

After 3rd augmentation s 1 2 t M-2 M-1 42

After 2M augmentations s 1 2 t M 43

Limitation of Algorithm (Non termination for irrational flow) Flow Network 1 m m r s 2 3 t 1 m m 1 m m 4 m >> 1 1/2 < r < 1 44

After 1st augmentation 1 S 2 3 t 2 3 4 r 1 1 1 1 1 Flow in Flow Network Residual Network 45 45

After 2nd augmentation 1 1 2 3 2 3 4 4 r r r 1-r 1-r r Residual Network Flow in Flow Network 46 46 46

After 3rd augmentation 1 1 2 3 2 3 4 r r 1 r 1-r r Residual Network Flow in Flow Network 47 47 47 47

After 4th augmentation 3 4 1 2 1 2 3 4 2r -1 r 1-r 1 - r 1 - r 1 - r Flow in Flow Network Residual Network 48 48 48 48 48

After 5th augmentation 3 4 1 2 2r -1 r 1-r 1 - r Flow in Flow Network Residual Network 49 49 49 49 49 49

Non termination in irrational flow 3 4 1 2 ai ai+1 ai - ai+1 = ai+2 ai+1 - (ai - ai+1) = ai+3 And this goes on ……………. 50

Summary and Extensions 1. Augmenting path theorem 2. Ford-Fulkerson Algorithm 3. Duality Theory. 4. Computational Speedups. 51