Ford-Fulkerson Algorithm for Maximum Flow

Similar documents
Maximum Flow and Minimum Cut

Graphs III - Network Flow

6/3/2009. CS 244 Algorithm Design Instructor: t Artur Czumaj. Lecture 8 Network flows. Maximum Flow and Minimum Cut. Minimum Cut Problem.

Network Flows: Introduction & Maximum Flow

Flow Networks. Ma/CS 6a. Class 14: Flow Exercises

Reminder: Flow Networks

Soviet Rail Network, 1955

Problem Set If all directed edges in a network have distinct capacities, then there is a unique maximum flow.

Main Reference: Sections in CLRS.

Stationary Distribution. Design and Analysis of Algorithms Andrei Bulatov

Algorithm Design and Analysis

Soviet Rail Network, 1955

! Abstraction for material flowing through the edges. ! G = (V, E) = directed graph, no parallel edges.

MATH 5720: Gradient Methods Hung Phan, UMass Lowell October 4, 2018

Network Flow. Data Structures and Algorithms Andrei Bulatov

CS4445/9544 Analysis of Algorithms II Solution for Assignment 1

Hidden Markov Models. Adapted from. Dr Catherine Sweeney-Reed s slides

MEI Mechanics 1 General motion. Section 1: Using calculus

Greedy. I Divide and Conquer. I Dynamic Programming. I Network Flows. Network Flow. I Previous topics: design techniques

Matching. Slides designed by Kevin Wayne.

Network Flows UPCOPENCOURSEWARE number 34414

Algorithm Design and Analysis

Flow networks. Flow Networks. A flow on a network. Flow networks. The maximum-flow problem. Introduction to Algorithms, Lecture 22 December 5, 2001

CSC 364S Notes University of Toronto, Spring, The networks we will consider are directed graphs, where each edge has associated with it

MAXIMUM FLOW. introduction Ford-Fulkerson algorithm maxflow-mincut theorem

The Residual Graph. 12 Augmenting Path Algorithms. Augmenting Path Algorithm. Augmenting Path Algorithm

a 10.0 (m/s 2 ) 5.0 Name: Date: 1. The graph below describes the motion of a fly that starts out going right V(m/s)

Algorithmic Discrete Mathematics 6. Exercise Sheet

Section 3.5 Nonhomogeneous Equations; Method of Undetermined Coefficients

The Residual Graph. 11 Augmenting Path Algorithms. Augmenting Path Algorithm. Augmenting Path Algorithm

Random Walk with Anti-Correlated Steps

k-remainder Cordial Graphs

16 Max-Flow Algorithms

EXERCISES FOR SECTION 1.5

Chapter 7: Solving Trig Equations

Comments on Window-Constrained Scheduling

CHAPTER 12 DIRECT CURRENT CIRCUITS

Randomized Perfect Bipartite Matching

MA 366 Review - Test # 1

Math 333 Problem Set #2 Solution 14 February 2003

Topics in Combinatorial Optimization May 11, Lecture 22

t dt t SCLP Bellman (1953) CLP (Dantzig, Tyndall, Grinold, Perold, Anstreicher 60's-80's) Anderson (1978) SCLP

A Hop Constrained Min-Sum Arborescence with Outage Costs

Waveform Transmission Method, A New Waveform-relaxation Based Algorithm. to Solve Ordinary Differential Equations in Parallel

1 Motivation and Basic Definitions

1. VELOCITY AND ACCELERATION

4/12/12. Applications of the Maxflow Problem 7.5 Bipartite Matching. Bipartite Matching. Bipartite Matching. Bipartite matching: the flow network

Lecture 23: I. Data Dependence II. Dependence Testing: Formulation III. Dependence Testers IV. Loop Parallelization V.

Math Final Exam Solutions

Max Flow, Min Cut COS 521. Kevin Wayne Fall Soviet Rail Network, Cuts. Minimum Cut Problem. Flow network.

3.1.3 INTRODUCTION TO DYNAMIC OPTIMIZATION: DISCRETE TIME PROBLEMS. A. The Hamiltonian and First-Order Conditions in a Finite Time Horizon

WEEK-3 Recitation PHYS 131. of the projectile s velocity remains constant throughout the motion, since the acceleration a x

Appendix to Online l 1 -Dictionary Learning with Application to Novel Document Detection

Y. Xiang, Learning Bayesian Networks 1

Today: Max Flow Proofs

Hidden Markov Models

Differential Geometry: Numerical Integration and Surface Flow

Algorithms and Data Structures 2011/12 Week 9 Solutions (Tues 15th - Fri 18th Nov)

They were originally developed for network problem [Dantzig, Ford, Fulkerson 1956]

Admin MAX FLOW APPLICATIONS. Flow graph/networks. Flow constraints 4/30/13. CS lunch today Grading. in-flow = out-flow for every vertex (except s, t)

MA Study Guide #1

Lecture 9: September 25

dt = C exp (3 ln t 4 ). t 4 W = C exp ( ln(4 t) 3) = C(4 t) 3.

RL Lecture 7: Eligibility Traces. R. S. Sutton and A. G. Barto: Reinforcement Learning: An Introduction 1

Phys1112: DC and RC circuits

Maximum Flow. Contents. Max Flow Network. Maximum Flow and Minimum Cut

Particle Swarm Optimization Combining Diversification and Intensification for Nonlinear Integer Programming Problems

d = ½(v o + v f) t distance = ½ (initial velocity + final velocity) time

Ordinary Differential Equations

Computer-Aided Analysis of Electronic Circuits Course Notes 3

Today s topics. CSE 421 Algorithms. Problem Reduction Examples. Problem Reduction. Undirected Network Flow. Bipartite Matching. Problem Reductions

Chapter 3 Boundary Value Problem

Application of a Stochastic-Fuzzy Approach to Modeling Optimal Discrete Time Dynamical Systems by Using Large Scale Data Processing

Physics 221 Fall 2008 Homework #2 Solutions Ch. 2 Due Tues, Sept 9, 2008

Lecture 2-1 Kinematics in One Dimension Displacement, Velocity and Acceleration Everything in the world is moving. Nothing stays still.

Homogenization of random Hamilton Jacobi Bellman Equations

COMPUTING SZEGED AND SCHULTZ INDICES OF HAC C C [ p, q ] NANOTUBE BY GAP PROGRAM

Optimal Embedding of Functions for In-Network Computation: Complexity Analysis and Algorithms

x i v x t a dx dt t x

Machine Learning 4771

Flow networks, flow, maximum flow. Some definitions. Edmonton. Saskatoon Winnipeg. Vancouver Regina. Calgary. 12/12 a.

Solutions to Assignment 1

University of Cyprus Biomedical Imaging and Applied Optics. Appendix. DC Circuits Capacitors and Inductors AC Circuits Operational Amplifiers

Solutions for Assignment 2

Optima and Equilibria for Traffic Flow on a Network

Echocardiography Project and Finite Fourier Series

1. Kinematics I: Position and Velocity

Problem Set #1. i z. the complex propagation constant. For the characteristic impedance:

i L = VT L (16.34) 918a i D v OUT i L v C V - S 1 FIGURE A switched power supply circuit with diode and a switch.

Undetermined coefficients for local fractional differential equations

UST/DME: A Clock Tree Router for General Skew Constraints

An Introduction to Constraint Based Scheduling

Chapter 3 Kinematics in Two Dimensions

THE MATRIX-TREE THEOREM

Farr High School NATIONAL 5 PHYSICS. Unit 3 Dynamics and Space. Exam Questions

Hamilton- J acobi Equation: Explicit Formulas In this lecture we try to apply the method of characteristics to the Hamilton-Jacobi equation: u t

CS Lunch This Week. Special Talk This Week. Soviet Rail Network, Flow Networks. Slides20 - Network Flow Intro.key - December 5, 2016

Decentralized Stochastic Control with Partial History Sharing: A Common Information Approach

Basic Tools CMSC 641. Running Time. Problem. Problem. Algorithmic Design Paradigms. lg (n!) (lg n)! (lg n) lgn n.2

Giambattista, Ch 3 Problems: 9, 15, 21, 27, 35, 37, 42, 43, 47, 55, 63, 76

Transcription:

Ford-Fulkerson Algorihm for Maximum Flow 1. Assign an iniial flow f ij (for insance, f ij =0) for all edges.label s by Ø. Mark he oher verices "unlabeled.". Find a labeled verex i ha has no ye been scanned. Scan i as follows For every unlabeled adjacen verex j, (a or b or c) a) if C ij > f ij and f ij 0 compue Δ ij = C ij f ij and Δ j where Δij if i = 1 Δ j = min( Δi, Δij) if i > 1 Label j wih a forward label (i +, f ij ) b) if C ij > f ij and f ij <0 (opposie direcion) Δ j =min (Δ j, f ij ) Label j wih a backward label (i, Δ j ) c) if C ij = f ij No operaion. If no unlabeled j exiss STOP. ) Repea sep unil is reached. [This gives a flow augmening pah P: s > ] If i is impossible o reach hen STOP. ). Backrack he pah P, using he labels. )Using P, augmen he exising flow by Δ, Se f = f + Δ,. 7) Remove all labels from verices,, n. Go o Sep. Example: Find he maximum flow from s o in he following graph. 0,0 10,0 11,0,0 7,0 Soluion 1) C 1 =0, C =11, C =1, C =, C 1 =10, C =7, C =, C =, f 1 =f =f =f =f 1 =f =f =f =0,,0 1,0,0 ) verex 1 (s) is labeled Ø,,,,, are unlabeled ) Scan 1. i=1,adjacen labels and. [ j= and j=] C 1 =0. f 1 =0. (perform a) For verex j= Δ 1 = C 1 f 1 = 0 0=0 Δ = Δ 1 =0. L = {1 +, 0} For verex j= C 1 =0. f 1 =0. (perform a) Δ 1 = C 1 f 1 = 10 0=10 Δ = Δ 1 =10. L = {1 +, 10} Scan. i=,adjacen label, and. [ j= and j=] For verex j= C =11. f =0. Δ = C f = 11 0 = 11 Δ = min (Δ, Δ ) = min(0, 11) =11 L = { +, 11} For verex j=, f <0 (perform b) Δ = min( Δ f ) = min(0,0) =0 L = {, 0} Scan. i=,adjacen labels, and. [ j= ] (j= and j= are already labelled) C =1. f =0. Δ = C f = 1 0 = 1 Δ = min (Δ, Δ ) = min(11, 1) =11 L = { +, 11} Since verex is Δ =11 ---------------------------------- Now all verices are all labeled Find he pah L = { +, 11} L = { +, 11} L = {1 +, 0} L1 Thus one augmening pah i--- Add Δ =11 o his pah f 1(new) = f 1(old) + Δ f 1 = 0 + 11 f =0 +11=11 f =0 +11=11 Remove all he labels. Sar scanning

1) C 1 =0, C =11, C =1, C =, C 1 =10, C =7, C =, C =, f 1 =f =f =11, f =f 1 =f =f =f =0, ) verex 1 (s) is labeled Ø,,,,, are unlabeled ) Scan 1. i=1,adjacen labels and. [ j= and j=] C 1 =0. f 1 =11. (perform a) For verex j= Δ 1 = C 1 f 1 = 0 11=9 Δ = Δ 1 =9. L = {1 +, 9} For verex j= C 1 =10. f 1 =0. Δ 1 = C 1 f 1 = 10 0=10 Δ = Δ 1 =10. L = {1 +, 10} Scan. i=, Adjacen label, and. [ j= and j=] For verex j=, C =11. f =11. C = f No acion. For verex j=, f <0 (perform b) Δ = min( Δ f ) = min(9,0) =0 L = {, 0} Scan. 0,11 10,0,0 7,0 i= no labeled no acion. Scan. i= Adjacen label,. [ j=] C =7. f =0. Δ = C f = 7 0 = 7 Δ = min (Δ, Δ ) = min(10, 7) =10 L = { +, 10} Scan. i= Adjacen labels,,, [ j=, j=] (j= j= are already labelled) C =. f =0. Δ = C f = 0 = Δ = min (Δ, Δ ) = min(10, ) = L = { +, },0 1,11,0 Since verex is Δ = ---------------------------------- Now all verices are all labeled Find he pah L = { +, } L = { +, 10} L = {1 +, 0} L1 Thus one augmening pah i--- Add Δ = o his pah f 1(new) = f 1(old) + Δ f 1 = 0 + f =0 += f =0 += Remove all he labels. Sar scanning ) verex 1 (s) is labeled Ø,,,,, are unlabeled ) Scan 1. i=1,adjacen labels and. [ j= and j=] C 1 =0. f 1 =11. (perform a) For verex j= Δ 1 = C 1 f 1 = 0 11=9 Δ = Δ 1 =9. L = {1 +, 9} For verex j= C 1 =10. f 1 =. Δ 1 = C 1 f 1 = 10 =7 Δ = Δ 1 =7. L = {1 +, 7} Scan. i=, Adjacen label, and. [ j= and j=] For verex j=, C =11. f =11. C = f No acion. For verex j=, f <0 (perform b) Δ = min( Δ f ) = min(9,0) =0 L = {, 0} Scan. 0,11 10,,0 7, i= no labeled no acion. Scan. i= Adjacen label,. [ j=] C =7. f =0. Δ = C f = 7 0 = 7,0 1,11,

Δ = min (Δ, Δ ) = min(10, 7) =10 L = { +, 10} Scan. i= Adjacen labels,,, [ j=, j=] (j= j= are already labelled) C =. f =0. Δ = C f = 0 = Δ = min (Δ, Δ ) = min(10, ) = L = { +, } Soluion 1) C 1 =0, C =11, C =1, C =, C 1 =10, C Scan. i=,adjacen label, and. [ j= ] (j= and j= are already scanned) C =1. f =0. Δ = C f = 1 0 = 1 Δ = min (Δ, Δ ) = min(11, 1) =11 L = { +, 11} Since L is For verex j=, f <0 (perform b) Δ = min( Δ f ) = min(0,0) =0 L = {, 0} vv Δ = Δ 1 =10. L = {1 +, 10} Scan and. Second Number: given flow (f i,j ) S: source : arge Pah: sequence of edges in a diagraph Flow augmening pah: Pahs from S o. Examples: Pah 1=(1---) Pah =(1--- ) Pah =(1----) Forward edge:if he direcion of pah is he same as he direcion of edge i is called forward edge. Backward edge:if he direcion of pah is he opposie of he direcion of edge i is called forward edge. Pah 1: 1-, -, - all forward edges Pah : 1-, -, - forward edges, backward edge C ij =he capaciy of edge from i o j f ij =The value of curren flow from i o j. ij =possible addiional flow from edge i o j. ij = C ij - f ij 1 =0-=1, =11-8=, =1-=7, 1 =10-=, =7-=, =-=0, =- =. Maximum Flow: Maximum possible flow from s o Kirchof s rule: Incoming flow=ougoing flow Example: for verex,, incoming flow. 8:ougoing flow.. +=8 Possible addiional flow in pah 1 We can increase maximum flow by because he edge, allows only. No addiional flow is possible in pah, because =0, addiional flow is possible in pah. 0,8 10, Δ =11,,0 7, Ford-Fulkerson Algorihm for Maximum Flow ALGORفTHM FORD-FULKERSON [G = (V, E), verices l (= s),, n (= ), edges (;', j), Cy] This algorihm compues he maximum flow in a nework G wih source s, sink (, aý capaciies Cy > O of he edges (;', j). INPUT: n, s = l, = n, edges (;', j) of G, Cy OUTPUT: Maximum flow f in G 1. Assign an iniial flow f y (for insance, f y = O for ali edges), compue f.. Label s by 0. Mark he oher verices "unlabeled." J. l'lllu a laü^l^u v^/ha/a. ilul lýuo llü J^l Uüülý a^^mý^u. 0^0.11 For every unlabeled adjacen verex j, if Cy > f\p compue 1,11,

Ay = Cy - fy and A, and label7 wih a "fonvard label" (i" 1 ', A,); or if f^ > O, compue A, == min(a,, f,,) and label j by a "backward label" (;~, Aj). If no such j exiss hen OUTPUT f. Sop [^" ; r/îe ma xim um flo w.} Els e con in ue (h a is, go o Se p ).. Repea Sep unil is reached. A if ( = l ' ü im in (A,, A y) if ; > l [This gives a flow augmening pah P: s >.} If i is impossible o reach hen OUTPUT f. Sop [f is he ma xim um flo w.} Els e con in ue (h a is, go o Se p ).. Backrack he pah P, using he labels.. Using P, augmen he exising flow by a(. Se f = f + a(. 7. Remove ali labels from verices,, n. Go o Sep. End FORD-FULKERSON A Nework is a diagraph in which each edge has assigned o i a capaciy (maximum flow) 0, 10, 11,8, 7, Graphs and Combinaorial Opimizaion 1.7 Ford-Fulkerson Algorihm for Maximum Flow, 1,,

Flow augmening pahs, as discussed in he las secion, are used as he basic ool ini Ford-Fulkerson algorihm in Table 1.8 in which a given flow (for insance, zero flofl ali edges) is increased unil i is maximum. The algorihm accomplishes he increase a sepwise consrucion of flow augmening pahs, one a a ime, unil no furher sý pahs can be consruced, which happens precisely when he flow is maximum. Table 1.8 Ford-Fulkerson Algorihm for Maximum Flow ALGORفTHM FORD-FULKERSON [G = (V, E), verices l (= s),, n (= ), edges (;', j), Cy] This algorihm compues he maximum flow in a nework G wih source s, sink (, aý capaciies Cy > O of he edges (;', j). INPUT: n, s = l, = n, edges (;', j) of G, Cy OUTPUT: Maximum flow f in G 1. Assign an iniial flow f y (for insance, f y = O for ali edges), compue f.. Label s by 0. Mark he oher verices "unlabeled." J. l'lllu a laü^l^u v^/ha/a. ilul lýuo llü J^l Uüülý a^^mý^u. 0^0.11 For every unlabeled adjacen verex j, if Cy > f\p compue A if ( = l 'ü Ay = Cy - fy and A, imin (A,, Ay) if ; > l and label7 wih a "fonvard label" (i" 1 ', A,); or if f^ > O, compue A, == min(a,, f,,) and label j by a "backward label" (;~, Aj). If no such j exiss hen OUTPUT f. Sop [^" ; r/îe maximum flow.} Else coninue (ha is, go o Sep ).. Repea Sep unil is reached. [This gives a flow augmening pah P: s >.} If i is impossible o reach hen OUTPUT f. Sop [f is he maximum flow.} Else coninue (ha is, go o Sep ).. Backrack he pah P, using he labels.. Using P, augmen he exising flow by a(. Se f = f + a(. 7. Remove ali labels from verices,, n. Go o Sep. End FORD-FULKERSON Graphs and Combinaorial Opimizaion Chap. Table1.9