Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt

Slides:



Advertisements
Similar presentations
Maximum flow Main goals of the lecture:
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)
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.
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.
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 Maximum Flow Problem The Ford-Fulkerson method
Flow Networks Formalization Basic Results Ford-Fulkerson Edmunds-Karp Bipartite Matching Min-cut.
Maximum Flow Chapter 26.
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).
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Finding Max Flow.
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.
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.
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
Maximum Flow Chapter 26.
The Maximum Network Flow Problem
Maximum Flow Chapter 26.
Graph Algorithms Minimum Spanning Tree (Chap 23)
Algorithms and Networks Hans Bodlaender
Network flow problem [Adapted from M.Chandy].
Richard Anderson Lecture 23 Network Flow
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
Instructor: Shengyu Zhang
Edmonds-Karp Algorithm
Network Flows and Matching (Supplementary)
CSE Algorithms Max Flow Problems 11/21/02 CSE Max Flow.
Network Flow and Connectivity in Wireless Sensor Networks
Lecture 10 Network flow Max-flow and Min-cut Ford-Fulkerson method
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
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.
Text Book: Introduction to algorithms By C L R S
Dinitz's algorithm for finding a maximum flow in a network.
MAXIMUM flow by Eric Wengert.
Lecture 22 Network Flow, Part 2
Advanced Graph Homer Lee 2013/10/31.
Presentation transcript:

Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt Data Structures and Algorithms (AT70.02) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Prof. Sumanta Guha Slide Sources: CLRS “Intro. To Algorithms” book website (copyright McGraw Hill) adapted and supplemented

CLRS “Intro. To Algorithms” Ch. 26: Maximum Flow

vertex v lies on some path from s to t. A flow network G = (V, E) is a directed graph in which each edge (u,v)  E has a capacity c(u,v)  0. If (u,v)  E, set c(u,v) = 0. Moreover, there are two distinguished vertices, a source s and sink t, and we assume that every vertex v lies on some path from s to t. A flow in G is a real-valued function f : V x V  R satisfying: 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}, ∑vV f(u,v) = 0. The value of the flow f is defined to be |f| = ∑vV f(s,v). The maximum flow problem is to find the flow of maximum value. Only positive flows are shown in the flow graph

There may be a distinction between actual shipment and flows. E.g., if we ship 8 units from v1 to v2 (edge cap. 10) and 3 units from v2 to v1 (edge cap. 4), then it is wrong to say f(v1, v2) = 8 and f(v2, v1) = 3 as that would be a violation of skew-symmetry. We should consider the net flow, which is 5 from v1 to v2, and say f(v1, v2) = 5 and f(v2, v1) = -5. In other words, we should always take a net so that flow is positive in one direction and negative in the other. Practically, too, it’s a “waste” to ship 8 in one direction and 3 in the opposite!

Implicit summation notation: f(X, Y) = ∑xX∑yY f(x, y) Lemma 26.1: Let G = (V,E) be a flow network and f be a flow in G. Then the following equalities hold: For all X  V, we have f(X, X) = 0. For all X, Y  V, we have f(X, Y) = – f(Y, X). For all X, Y, Z  V with X  Y = , we have f(X  Y, Z) = f(X, Z) + f(Y, Z) and f(Z, XY) = f(Z, X) + f(Z, Y). Proof: Routine. Ex: Use the lemma to prove that the value of the flow |f| is equal to ∑vV f(v,t), i.e., the total flow out of the source is equal to the total flow into the sink. Equivalently, f(s, V) = f(V, t). Hint: |f| = f(s, V) = f(V, V) – f(V – s, V) = –f(V – s, V) = f(V, V – s) = …

Let f be a flow in a flow network G = (V, E) with source s and sink t Let f be a flow in a flow network G = (V, E) with source s and sink t. The amount of additional flow we can push from a vertex u to a vertex v before exceeding the capacity c(u,v) is the residual capacity of (u, v) given by cf(u, v) = c(u, v) – f(u, v) Given a flow f in flow network G = (V, E), the residual network of G induced by f is Gf = (V, Ef), where Ef = {(u, v)  V x V : cf(u, v) > 0} Each edge of the residual network is called a residual edge and its capacity is given by cf.

Lemma 26.2: Let G = (V, E) be a flow network with source s and sink t, and let f be a flow in G. Let Gf be the residual network of G 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’|. Proof: Routine.

Given a flow f in a flow network G = (V, E), an augmenting path p is a simple path from source s to sink t in the residual network Gf. The maximum amount by which we increase the flow on each edge in an augmenting path p is the residual capacity of p, given by cf(p) = min{cf(u, v) : (u, v) is on p}

Lemma 26.3: 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 a function fp : V x V  R by cf(p), if (u, v) is on p, fp(u, v) = –cf(p), if (v, u) is on p, 0, otherwise. Then fp is a flow in Gf with value |fp| = cf(p) > 0. Corollary 26.4: 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 a function f’ : V x V  R by f’ = f + fp. Then f’ is a flow in G with value |f’| = |f| + |fp| > |f|. Proofs: Routine.

Ford-Fulkerson

Input flow network Chosen path bold

Analysis of Ford-Fulkerson: Assume the capacities of all edges are integers. Then, a straightforward implementation of Ford-Fulkerson takes O(E|f*|) time, where f* is the maximum flow found by the algorithm: Lines 1-3 take Ө(E) time. The while loop of lines 4-8 is executed at most |f*| times since the value of the flow increases by at least 1 at each iteration. Moreover, each iteration of the while loop takes O(E) time if either depth-first or breadth-first search is used to find a path in the residual network. Therefore, total time = O(E + E|f*|) = O(E|f*|).

Edmonds-Karp Edmonds-Karp = Ford-Fulkerson using breadth-first search in line 4 to find an augmenting path, i.e., the augmenting path found is shortest in terms of the number of edges. Edmonds-Karp runs in O(VE2) time…

Analysis of Edmonds-Karp Lemma 26.8: 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 distance δf(s, v) in the residual network Gf increases monotonically with each flow augmentation. Theorem 26.9: 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 O(VE). Since, breadth-first search can be implemented in O(E) time, the running time of Edmonds-Karp is O(VE * E) = O(VE2).

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. If f is a flow then the net flow across the cut (S, T) is defined to be f(S, T). The capacity of the cut (S, T) is defined to be c(S, T). Of course, f(S, T) ≤ c(S, T). A minimum cut of a network is a cut whose capacity is minimum over all possible cuts of the network. Lemma 26.5: Let f be a flow in a 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) = |f|. Remark: In other words, the net flow across any cut is the same (= value of flow). Proof: Have to show that f(S, T) = f(s, V) (Hint: f(S, T) = f(S, V) – f(S, V-T) = f(S, V) – f(S, S) = f(S, V) = …) Corollary 26.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: …

Theorem 26.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: f is a maximum flow in G. The residual network Gf contains no augmenting paths. |f| = c(S, T) for some cut (S, T) of G. Proof: (1)  (2)  (3)  (1)…

Maximum Bipartite Matching A bipartite graph is a graph G = (V, E) s.t. the vertex set can be partitioned V = L  R where L and R are disjoint and every edge in E goes between L and R. A matching in an undirected graph G = (V, E) is a subset of edges M  E, such that for all vertices v  V, at most one edge of M is incident on v. Vertex v is matched by matching M if some edge of M is incident on v; otherwise, v is unmatched. A maximum matching is a matching with maximum number of edges, i.e., M is a maximum matching if |M|  |M’|, for any other matching M’.

Lemma 26.10: 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 |f| = |M|. Conversely, if f is an integer-valued flow in G’, then there is a matching M in G with cardinality |M| = |f|. Theorem 26.11 (Integrality Theorem): If the capacity function c takes on only integral values, then the maximum flow f produced by the Ford-Fulkerson method has the property that |f| is an integer. Moreover, for all vertices u and v, f(u, v) is an integer. Corollary 6.12: The cardinality of a maximum matching M in a bipartite graph G equals the value of a maximum flow in its corresponding flow network.

Converting a multiple-source multiple-sink max flow problem into a single-source single-sink problem by adding a supersource and a supersink.

Problems Ex. 26.1-2 Ex. 26.1-5 Ex. 26.1-6 Ex. 26.1-8 Ex. 26.2-1