1 Maximum Flow Maximum Flow Problem The Ford-Fulkerson method Maximum bipartite matching.

Slides:



Advertisements
Similar presentations
Bioinformatics III1 We will present an algorithm that originated by Ford and Fulkerson (1962). Idea: increase the flow in a network iteratively until it.
Advertisements

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.
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)
CS138A Maximum Bipartite Matching Peter Schröder.
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.
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
Yangjun Chen 1 Network Flow What is a network? Flow network and flows Ford-Fulkerson method - Residual networks - Augmenting paths - Cuts of flow networks.
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.
Chapter 27 Maximum Flow Maximum Flow Problem The Ford-Fulkerson method m bipartite matching.
Flows sourcesink s t Flows sourcesink edge-weights = capacities.
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 Maximum Flow Problem The Ford-Fulkerson method
1 The Min Cost Flow Problem. 2 The Min Cost Flow problem We want to talk about multi-source, multi-sink flows than just “flows from s to t”. We want to.
Maximum Flow Chapter 26.
CS774. Markov Random Field : Theory and Application Lecture 13 Kyomin Jung KAIST Oct
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.
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Finding Max Flow.
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.
Maximum Flow. p2. Maximum Flow A flow network G=(V, E) is a DIRECTED graph where each has a nonnegative capacity u.
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
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.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 25.
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.
Flow Networks Ching-Chen Huang Hsi-Yue Hsiao. CONTENTS Network flows on directed acyclic graphs Ford-fulkerson Algorithms -Residual networks.
CSEP 521 Applied Algorithms Richard Anderson Lecture 8 Network Flow.
1 Network Flow CSC401 – Analysis of Algorithms Chapter 8 Network Flow Objectives: Flow networks –Flow –Cut Maximum flow –Augmenting path –Maximum flow.
Fall 2003Maximum Flow1 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 
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
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)
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 Chapter 26.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Graph Algorithms Minimum Spanning Tree (Chap 23)
Network flow problem [Adapted from M.Chandy].
Richard Anderson Lecture 23 Network Flow
Lecture 22 Network Flow, Part 2
Instructor: Shengyu Zhang
Network Flows and Matching (Supplementary)
Lecture 10 Network flow Max-flow and Min-cut Ford-Fulkerson method
Flow Networks Topics Flow Networks Residual networks
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 21 Network Flow
Network Flows and Matching (Supplementary)
Flow Networks General Characteristics Applications
Flow Networks and Bipartite Matching
Algorithms (2IL15) – Lecture 7
Text Book: Introduction to algorithms By C L R S
Lecture 21 Network Flow, Part 1
Richard Anderson Lecture 22 Network Flow
Lecture 22 Network Flow, Part 2
Advanced Graph Homer Lee 2013/10/31.
Presentation transcript:

1 Maximum Flow Maximum Flow Problem The Ford-Fulkerson method Maximum bipartite matching

2 material coursing through a system from a source to a sink

3 Flow networks: A flow network G=(V,E): a directed graph, where each edge (u,v)  E has a nonnegative capacity c(u,v)>=0. If (u,v)  E, we assume that c(u,v)=0. two distinct vertices :a source s and a sink t. st

4 Flow: G=(V,E): a flow network with capacity function c. s-- the source and t-- the sink. A flow in G: a real-valued function f:V*V  R satisfying the following three properties: Capacity constraint: For all u,v  V, we require f(u,v)  c( u,v). Flow conservation: For all u  V-{s,t}, we require

5 Net flow and value of a flow f: The quantity f (u,v), which can be positive or negative, is called the net flow from vertex u to vertex v. The value of a flow is defined as –The total flow from source to any other vertices. –The same as the total flow from any vertices to the sink.

6 st 11/16 12/12 15/ /44/97/7 4/48/13 11/14 A flow f in G with value.

7 Maximum-flow problem: Given a flow network G with source s and sink t Find a flow of maximum value from s to t. How to solve it efficiently?

8 The Ford-Fulkerson method: This section presents the Ford-Fulkerson method for solving the maximum-flow problem.We call it a “method” rather than an “algorithm” because it encompasses several implementations with different running times.The Ford- Fulkerson method depends on three important ideas that transcend the method and are relevant to many flow algorithms and problems: residual networks,augmenting paths,and cuts. These ideas are essential to the important max-flow min-cut theorem,which characterizes the value of maximum flow in terms of cuts of the flow network.

9 Continue: FORD-FULKERSON-METHOD(G,s,t) initialize flow f to 0 while there exists an augmenting path p do augment flow f along p return f

10 Residual networks: Given a flow network and a flow, the residual network consists of edges that can admit more net flow. G=(V,E) --a flow network with source s and sink t f: a flow in G. The amount of additional net flow from u to v before exceeding the capacity c(u,v) is the residual capacity of (u,v), given by: c f (u,v)=c(u,v)-f(u,v)

11 s v2v2 v4v4 t v3v3 v1v /9 s v2v2 v4v4 t v3v3 v1v1 4/ / /4 7 4/14 (a) Example of residual network

12 5 s v2v2 v4v4 t v3v3 v1v (b) Example of Residual network (continued)

13 Fact 1: Let G=(V,E) be a flow network with source s and sink t, and let f be a flow in G. Let G f be the residual network of G induced by f,and let f’ be a flow in G f.Then, the flow sum f+f’ is a flow in G with value.

14 Augmenting paths: Given a flow network G=(V,E) and a flow f, an augmenting path is a simple path from s to t in the residual network G f. Residual capacity of p : the maximum amount of net flow that we can ship along the edges of an augmenting path p, i.e., c f (p)=min{c f (u,v):(u,v) is on p} The residual capacity is 1.

15 5 s v2v2 v4v4 t v3v3 v1v (b) Example of an augment path (bold edges)

16 The basic Ford-Fulkerson algorithm: FORD-FULKERSON(G,s,t) for each edge (u,v)  E[G] do f[u,v] 0 f[v,u] 0 while there exists a path p from s to t in the residual network G f do c f (p) min{c f (u,v): (u,v) is in p} for each edge (u,v) in p do f[u,v] f[u,v]+c f (p)

17 Example: The execution of the basic Ford-Fulkerson algorithm.(a)-(d) Successive iterations of the while loop. The left side of each part shows the residual network G f from line 4 with a shaded augmenting path p.The right side of each part shows the new flow f that results from adding f p to f.The residual network in (a) is the input network G.(e) The residual network at the last while loop test.It has no augmenting paths,and the flow f shown in (d) is therefore a maximum flow.

18 s v2v2 v4v4 t v3v3 v1v /9 s v2v2 v4v4 t v3v3 v1v1 4/ / /4 7 4/14 (a)

19 5 s v2v2 v4v4 t v3v3 v1v /9 s v2v2 v4v4 t v3v3 v1v1 11/ /12 7/10 4 7/20 4/4 7/7 11/14 (b)

20 5 s v2v2 v4v4 t v3v3 v1v /9 s v2v2 v4v4 t v3v3 v1v1 11/16 8/13 12/12 101/4 15/20 4/4 7/7 11/14 (c)

21 5 s v2v2 v4v4 t v3v3 v1v s v2v2 v4v4 t v3v3 v1v1 11/16 12/13 12/12 101/4 19/20 4/4 7/7 11/14 (d)

22 s v2v2 v4v4 t v3v3 v1v (e)

23 Time complexity: If each c(e) is an integer, then time complexity is O(|E|f*), where f* is the maximum flow. Reason: each time the flow is increased by at least one. This might not be a polynomial time algorithm since f* can be represented by log (f*) bits. So, the input size might be log(f*).

24 Cuts of flow networks: The proof of the correctness of the Ford-Fulkerson method depends on a concept “cut”. A cut (S,T) of flow network G=(V,E) is a partition of V into S and T=V-S such that s  S and t  T. If f is a flow, then the net flow across the cut (S,T) is F(S,T)=  u  S&v  T f(u, v). The capacity of the cut (S,T) is c(S, T)=  u  S&v  T c(u, v).

25 s v2 v1 t v4 v3 11/16 8/13 101/4 12/12 11/14 4/9 15/20 4/4 7/7 S T A cut (S,T), where S={s,v1,v2} and T={v3,v4,t}. The net flow across (S,T) is f(S,T)= =19,and the capacity is c(S,T)=12+14=26.

26 Continue: Lemma 27.5 Let f be a flow in a flow network G with source s and sink t,and let (S,T) be a cut of G.Then, the net flow across (S,T) is f(S,T)=. Proof: 1. f(S-s, V)=0 by flow conservation. 2. f(S, S)=0 since f(u, v)=-f(v, u). f(S, T)=f(S, V)-f(S, S)=f(S, V) =f(s, V)+f(S-s, V)=f(s, V)=|f|.

27 Continue: Corollary 27.6 The value of any flow f in a flow network G is bounded from above by the capacity of any cut of G. Proof: f(S, T)  c(S, T).

28 Theorem 27.7(Max-flow min-cut theorem) If f is a flow in a flow network G=(V,E) with source s and sink t,then the following conditions are equivalent: 1.f is a maximum flow in G; 2.The residual network G f contains no augmenting paths; 3.|f| =c(S,T) for some cut (S,T) of G. Proof: 1  2: Otherwise, if a aug. path exists, we can further increase the flow. 2  3. If no aug. path exists, then we construct S as the set of vertices that is reachable from s. T=V-S. By construction, there is no edge (u, v) in the residual graph such that u  S and v  T. Thus, |f|=f(S,T)=c(S, T). 3  1 |f|=f(S, T)=c(S,T). By 27.6,|f|= f(S, T)  c(S,T). Thus, |f| is maximum.

29 The Edmonds-Karp algorithm Find the augmenting path using breadth- first search. Breadth-first search gives the shortest path for graphs (Assuming the length of each edge is 1.) Time complexity of Edmonds-Karp algorithm is O(VE 2 ). The proof is not required.

30 Maximum bipartite matching: Bipartite graph: a graph (V, E), where V=L  R, L∩R=empty, and for every (u, v)  E, u  L and v  R. Given an undirected graph G=(V,E), a matching is a subset of edges M  E such that for all vertices v  V,at most one edge of M is incident on v.We say that a vertex v  V is matched by matching M if some edge in M is incident on v;otherwise, v is unmatched. A maximum matching is a matching of maximum cardinality,that is, a matching M such that for any matching M’, we have.

31 L R A bipartite graph G=(V,E) with vertex partition V=L  R.(a)A matching with cardinality 2.(b) A maximum matching with cardinality 3. (a) LR (b)

32 Finding a maximum bipartite matching: We define the corresponding flow network G’=(V’,E’) for the bipartite graph G as follows. Let the source s and sink t be new vertices not in V, and let V’=V  {s,t}.If the vertex partition of G is V=L  R, the directed edges of G’ are given by E’={(s,u):u  L}  {(u,v):u  L,v  R,and (u,v)  E}  {(v,t):v  R}.Finally, we assign unit capacity to each edge in E’. We will show that a matching in G corresponds directly to a flow in G’s corresponding flow network G’. We say that a flow f on a flow network G=(V,E) is integer-valued if f(u,v) is an integer for all (u,v)  V*V.

33 LR (a) LR (b) s t (a)The bipartite graph G=(V,E) with vertex partition V=L  R. A maximum matching is shown by shaded edges.(b) The corresponding flow network.Each edge has unit capacity.Shaded edges have a flow of 1,and all other edges carry no flow.

34 Continue: Lemma Let G=(V,E) be a bipartite graph with vertex partition V=L  R,and let G’=(V’,E’) be its corresponding flow network.If M is a matching in G, then there is an integer- valued flow f in G’ with value.Conversely, if f is an integer-valued flow in G’,then there is a matching M in G with cardinality. Reason: The edges incident to s and t ensures this.