CS 1501 Recitation. Xiang Xiao

Similar documents
Parallel Graph Algorithms (con4nued)

Types of Networks. Internet Telephone Cell Highways Rail Electrical Power Water Sewer Gas

Graph Algorithms -2: Flow Networks. N. H. N. D. de Silva Dept. of Computer Science & Eng University of Moratuwa

Parallel Graph Algorithms (con4nued)

Flow Network. The following figure shows an example of a flow network:

1 Review for Lecture 2 MaxFlow

Lecture 2: Network Flows 1

10 Max-Flow Min-Cut Flows and Capacitated Graphs 10 MAX-FLOW MIN-CUT

Max Flow: Algorithms and Applications

CMPSCI 611: Advanced Algorithms

Running Time. Assumption. All capacities are integers between 1 and C.

The max flow problem. Ford-Fulkerson method. A cut. Lemma Corollary Max Flow Min Cut Theorem. Max Flow Min Cut Theorem

directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time

Maximum Flow. Jie Wang. University of Massachusetts Lowell Department of Computer Science. J. Wang (UMass Lowell) Maximum Flow 1 / 27

Algorithms: Lecture 12. Chalmers University of Technology

Computer Science & Engineering 423/823 Design and Analysis of Algorithms

An example of LP problem: Political Elections

The min cost flow problem Course notes for Search and Optimization Spring 2004

Algorithms: COMP3121/3821/9101/9801

We say that a flow is feasible for G (or just feasible if the graph and capacity function in question are obvious) if

Maximum Flow. Reading: CLRS Chapter 26. CSE 6331 Algorithms Steve Lai

Algorithms and Theory of Computation. Lecture 11: Network Flow

Basics on the Graphcut Algorithm. Application for the Computation of the Mode of the Ising Model

CSE 326: Data Structures Network Flow. James Fogarty Autumn 2007

The min cost flow problem Course notes for Optimization Spring 2007

6.046 Recitation 11 Handout

Two Applications of Maximum Flow

Internet Routing Example

CS 170 DISCUSSION 10 MAXIMUM FLOW. Raymond Chan raychan3.github.io/cs170/fa17.html UC Berkeley Fall 17

Algorithm Design and Analysis

Problem set 1. (c) Is the Ford-Fulkerson algorithm guaranteed to produce an acyclic maximum flow?

Flows and Cuts. 1 Concepts. CS 787: Advanced Algorithms. Instructor: Dieter van Melkebeek

Agenda. Soviet Rail Network, We ve done Greedy Method Divide and Conquer Dynamic Programming

Maximum flow problem CE 377K. February 26, 2015

Lecture 1. 1 Overview. 2 Maximum Flow. COMPSCI 532: Design and Analysis of Algorithms August 26, 2015

Maximum flow problem

Algorithm Design and Analysis

The maximum flow problem

CSCE423/823. Introduction. Flow Networks. Ford-Fulkerson Method. Edmonds-Karp Algorithm. Maximum Bipartite Matching 2/35 CSCE423/823.

Preliminaries. Graphs. E : set of edges (arcs) (Undirected) Graph : (i, j) = (j, i) (edges) V = {1, 2, 3, 4, 5}, E = {(1, 3), (3, 2), (2, 4)}

22 Max-Flow Algorithms

Mathematics for Decision Making: An Introduction. Lecture 13

CSC2420: Algorithm Design, Analysis and Theory Spring (or Winter for pessimists) 2017

CSC2420: Algorithm Design, Analysis and Theory Fall 2017

Network Flows. CS124 Lecture 17

Lecture 8 Network Optimization Algorithms

CSC 373: Algorithm Design and Analysis Lecture 12

Exposition of the Dinitz algorithm

Algorithm Design and Analysis

Network Flow Problems Luis Goddyn, Math 408

The Simplest and Smallest Network on Which the Ford-Fulkerson Maximum Flow Procedure May Fail to Terminate

Review Questions, Final Exam

Lecture 21 November 11, 2014

Network Flows. CTU FEE Department of control engineering. March 28, 2017

Breadth-First Search of Graphs

Flows. Chapter Circulations

Multicommodity Flows and Column Generation

Energy minimization via graph-cuts

The Max Flow Problem

Discrete Optimization 2010 Lecture 3 Maximum Flows

2.13 Maximum flow with a strictly positive initial feasible flow

Maximum flow problem (part I)

Lecture 18: More NP-Complete Problems

CS599: Convex and Combinatorial Optimization Fall 2013 Lecture 17: Combinatorial Problems as Linear Programs III. Instructor: Shaddin Dughmi

p 3 p 2 p 4 q 2 q 7 q 1 q 3 q 6 q 5

Midterm Exam 2 Solutions

Advanced Algorithms Lecture Notes. Periklis A. Papakonstantinou

Algorithms - Exercise 1

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: NP-Completeness I Date: 11/13/18

Bulletin of the Transilvania University of Braşov Vol 8(57), No Series III: Mathematics, Informatics, Physics,

CS 170, Fall 1997 Second Midterm Professor Papadimitriou

CMPSCI 311: Introduction to Algorithms Second Midterm Exam

CSC Design and Analysis of Algorithms. LP Shader Electronics Example

Maximum Integer Flows in Directed Planar Graphs with Multiple Sources and Sinks and Vertex Capacities

Standard Diraphs the (unique) digraph with no vertices or edges. (modulo n) for every 1 i n A digraph whose underlying graph is a complete graph.

Chemical Reaction Optimization for Max Flow Problem

Algorithm Theory - Exercise Class

Steps towards Decentralized Deterministic Network Coding

GRAPH ALGORITHMS Week 7 (13 Nov - 18 Nov 2017)

Discrete Optimization Lecture 5. M. Pawan Kumar

Network Flows made simple

III. Linear Programming

Algorithms. Algorithms 6.4 MAXIMUM FLOW

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

Symmetric chain decompositions of partially ordered sets

University of Washington March 21, 2013 Department of Computer Science and Engineering CSEP 521, Winter Exam Solution, Monday, March 18, 2013

The partial inverse minimum cut problem with L 1 -norm is strongly NP-hard. Elisabeth Gassner

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016)

Maximum Skew-Symmetric Flows. September Abstract

CSE 421 Introduction to Algorithms Final Exam Winter 2005

(1,3) (3,4) (2,2) (1,2) (2,4) t

CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs. Instructor: Shaddin Dughmi

Generality of Languages

Bipartite Matchings and Stable Marriage

Maximum Flows & Minimum Cuts

conp = { L L NP } (1) This problem is essentially the same as SAT because a formula is not satisfiable if and only if its negation is a tautology.

Undirected Graphs. V = { 1, 2, 3, 4, 5, 6, 7, 8 } E = { 1-2, 1-3, 2-3, 2-4, 2-5, 3-5, 3-7, 3-8, 4-5, 5-6 } n = 8 m = 11

NP-Completeness. Algorithmique Fall semester 2011/12

Graph Theory and Optimization Computational Complexity (in brief)

Maximum skew-symmetric flows and matchings

Transcription:

CS 1501 Recitation Xiang Xiao

Network Flow 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. 16 12 20 s 10 9 7 t 13 1 2

Flow For each edge (u,v) in E, the flow f(u,v) is a real valued function that must satisfy following 3 conditions: Capacity constraint: f(u,v) c(u,v) Skew symmetry: f(u,v) = -f(v,u) Flow conservation: 0 f(u,v) u V {s,t} v V Skew symmetry condition implies that f(u,u)=0. f ( e) e. in. v e. out. v f ( e)

Net flow and value of a flow f: The quantity f (u,v) is called the net flow from vertex u to vertex v. The value of a flow is defined as f f ( s, v) v V The total flow from source to any other vertices. The same as the total flow from any vertices to the sink.

12/12 s 11/16 10 1/ /9 7/7 15/20 t 8/13 11/1 / A flow f in G with value f 19. 5

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? 6

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. 7

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 8

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) in the other direction: c f (v, u)=c(v, u)+f(u, v). 9

Example of residual network 16 v 1 12 v 3 20 /16 v 1 /12 v 3 20 s 13 10 7 9 v 2 v 1 t s 13 10 7 /9 v 2 v /1 / t (a) 10

Example of Residual network (continued) s 8 12 v 1 v 3 10 5 13 10 v 2 v 7 20 t (b) 11

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 f f ' f f. ' f+f : the flow in the same direction will be added. the flow in different directions will be cnacelled. 12

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}. 2 3 1 The residual capacity is 1. 13

Example of an augment path (bold edges) s 8 12 v 1 v 3 10 5 13 10 v 2 v 7 20 t (b) 1

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) 15

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 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. 16

16 v 1 12 v 3 20 /16 v 1 /12 v 3 20 s 13 10 7 9 v 2 v 1 t s 13 10 7 /9 v 2 v /1 / t (a) 17

s 8 12 v 1 v 3 10 5 13 10 v 2 v 7 20 t s /12 v 1 v 3 11/16 7/20 7/10 7/7 /9 13 / v 2 v 11/1 t (b) 18

s 8 5 v 1 v 3 11 3 11 7 5 13 3 v 2 v 11 13 7 t 11/16 12/12 v 1 v 3 15/20 s 10 1/ 7/7 /9 t 8/13 / v 2 v 11/1 (c) 19

s 12 12/12 5 v 1 v 3 5 11/16 v 1 v 3 19/20 11 11 3 7 15 5 t s 10 1/ 7/7 5 9 t 8 3 v 2 v 12/13 / v 2 v 11 11/1 (d) 20

5 v 1 12 v 3 1 s 1 11 3 9 7 19 t 12 3 v 2 v 11 (e) 21

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*). 22

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 very hard and is not required here. 23

Example of Edmonds-Karp algorithm 2

Step 1 25

Step 2 26

Step 3 27

Step 28