presentation overview maximum network flowlr/courses/alg/student/1/ford-fulkerson method.pdf ·...

3
1 Maximum Network Flow Maximum Network Flow Ford Ford-Fulkerson Method Fulkerson Method Dave Miller Dave Miller Presentation Overview Presentation Overview Introduction Introduction Basic Method Basic Method Things To Remember Things To Remember Key Concepts Key Concepts Basic Algorithm Basic Algorithm Example Example Analysis Analysis References References Introduction Introduction Maximum flow problem Maximum flow problem Given a flow network G = (V,E) determine the greatest Given a flow network G = (V,E) determine the greatest possible flow possible flow f(u,v f(u,v) ) from source ( from source (s) to sink ( ) to sink (t) without ) without violating capacity violating capacity c(u,v c(u,v) Ford Ford-Fulkerson is the classical method for solving Fulkerson is the classical method for solving the maximum flow problem the maximum flow problem v 1 v 3 v 2 v 4 t s 1 1/16 8/13 10 1/4 4 /9 11/14 12/12 15/ 20 4 /4 7 f ( u, v ) / c( u, v ) Flow network G=(V,E) with flow Flow network G=(V,E) with flow f(u,v f(u,v) and capacity ) and capacity c(u,v c(u,v) Introduction Introduction – Cont. Cont. Tidbits Tidbits Co Co-developed in 1956 by developed in 1956 by Mathematicians Lester Randolph Ford Mathematicians Lester Randolph Ford Sr. and Delbert Ray Fulkerson Sr. and Delbert Ray Fulkerson Referred to as a method because there Referred to as a method because there are several algorithm implementations are several algorithm implementations with differing running times with differing running times Basic Method Basic Method Iterative process with the flow Iterative process with the flow f f initial value set to 0 initial value set to 0 On each iteration, increase flow On each iteration, increase flow f by by finding an “augmenting path” and finding an “augmenting path” and augmenting the flow along this path augmenting the flow along this path Repeat process until no augmenting Repeat process until no augmenting path can be found, process path can be found, process terminates yielding maximum flow terminates yielding maximum flow Basic Method Basic Method – Cont. Cont. Pseudo code Pseudo code FORD-FULKERSON-METHOD(G, s, t) initialize f to 0 while there exists an augmenting path p do augment flow f along p return f where, G is the flow network G = (V,E) s is the source of the flow t is the sink f is the flow from s to t p is the path

Upload: others

Post on 14-Mar-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Presentation Overview Maximum Network Flowlr/courses/alg/student/1/Ford-Fulkerson Method.pdf · augmenting the flow along this path Repeat process until no augmenting path can be

11

Maximum Network FlowMaximum Network FlowFordFord--Fulkerson MethodFulkerson Method

Dave MillerDave Miller

Presentation Overview Presentation Overview IntroductionIntroductionBasic MethodBasic MethodThings To RememberThings To RememberKey ConceptsKey ConceptsBasic AlgorithmBasic AlgorithmExampleExampleAnalysisAnalysisReferencesReferences

IntroductionIntroduction

Maximum flow problemMaximum flow problem–– Given a flow network G = (V,E) determine the greatest Given a flow network G = (V,E) determine the greatest

possible flow possible flow f(u,vf(u,v) ) from source (from source (ss) to sink () to sink (tt) without ) without violating capacity violating capacity c(u,vc(u,v))

FordFord--Fulkerson is the classical method for solving Fulkerson is the classical method for solving the maximum flow problemthe maximum flow problem

v1 v3

v2 v4

ts

11/16

8/13

10 1/4

4/9

11/14

12/12

15/20

4/4

7

f(u,v) / c(u,v)

Flow network G=(V,E) with flow Flow network G=(V,E) with flow f(u,vf(u,v) and capacity ) and capacity c(u,vc(u,v))

Introduction Introduction –– Cont.Cont.TidbitsTidbits–– CoCo--developed in 1956 by developed in 1956 by

Mathematicians Lester Randolph Ford Mathematicians Lester Randolph Ford Sr. and Delbert Ray Fulkerson Sr. and Delbert Ray Fulkerson

–– Referred to as a method because there Referred to as a method because there are several algorithm implementations are several algorithm implementations with differing running timeswith differing running times

Basic MethodBasic MethodIterative process with the flow Iterative process with the flow f f initial value set to 0initial value set to 0On each iteration, increase flow On each iteration, increase flow ff by by finding an “augmenting path” and finding an “augmenting path” and augmenting the flow along this pathaugmenting the flow along this pathRepeat process until no augmenting Repeat process until no augmenting path can be found, process path can be found, process terminates yielding maximum flow terminates yielding maximum flow

Basic Method Basic Method –– Cont.Cont.Pseudo codePseudo code

FORD-FULKERSON-METHOD(G, s, t)

initialize f to 0

while there exists an augmenting path p

do augment flow f along p

return f

where,G is the flow network G = (V,E)s is the source of the flowt is the sinkf is the flow from s to tp is the path

Page 2: Presentation Overview Maximum Network Flowlr/courses/alg/student/1/Ford-Fulkerson Method.pdf · augmenting the flow along this path Repeat process until no augmenting path can be

22

Things To RememberThings To RememberProperties of flowsProperties of flows–– Capacity constraint: Capacity constraint:

A flow cannot be greater than the capacity of the A flow cannot be greater than the capacity of the edge that is edge that is f(u,vf(u,v) ≤ ) ≤ c(u,vc(u,v))

–– Skew symmetrySkew symmetryThe flow from vertex u to vertex v is the negative of The flow from vertex u to vertex v is the negative of the flow in the reverse direction that is the flow in the reverse direction that is f(u,vf(u,v) = ) = --f(v,uf(v,u))Notional convenienceNotional convenience

–– Flow conservationFlow conservationThe total flow entering a vertex must equal the total The total flow entering a vertex must equal the total flow leaving the vertex flow leaving the vertex More formally at a given vertex ∑ More formally at a given vertex ∑ f(u,vf(u,v) = 0) = 0

Key ConceptsKey ConceptsResidual NetworkResidual NetworkAugmenting PathAugmenting Path

Residual NetworkResidual NetworkConsists of edges that can admit Consists of edges that can admit more flowmore flowDef. Def. residual capacityresidual capacity ccff(u,v(u,v)) is the is the additional flow that can be pushed on additional flow that can be pushed on to an edge without exceeding the to an edge without exceeding the capacitycapacity, residual capacity is given , residual capacity is given by by ccff(u,v(u,v) = ) = c(u,vc(u,v) ) –– f(u,vf(u,v))Residual network Residual network GGff is a flow network is a flow network with capacities with capacities ccff

Residual Network Residual Network –– Cont.Cont.

v1 v3

v2 v4

ts

5

8

11 3 5

11

12

5

4

7

3

5

11 4

15

v1 v3

v2 v4

ts

11/16

8/13

10 1/4

4/9

11/14

12/12

15/20

4/47/

7

A flow network G with A flow network G with ff=19=19 A residual network A residual network GGff with with the augmenting path the augmenting path highlightedhighlighted

Augmenting PathAugmenting PathIs a path Is a path pp from from ss to to tt in the residual in the residual network network GGff

Max. amount the flow can be increased on Max. amount the flow can be increased on each edge in the augmenting path each edge in the augmenting path pp is is called the residual capacity of called the residual capacity of p, given byp, given by

} on is ),(:),(min{ pvuvucc ff =

AugmeningAugmening Path Path –– Cont.Cont.

v1 v3

v2 v4

ts

5

8

11 3 5

11

12

5

4

7

3

5

11 4

15

Augmenting path (highlighted in red) Augmenting path (highlighted in red) pp in in GGff with with the residual capacity the residual capacity ccff = 4= 4

residual capacity residual capacity ccff

Page 3: Presentation Overview Maximum Network Flowlr/courses/alg/student/1/Ford-Fulkerson Method.pdf · augmenting the flow along this path Repeat process until no augmenting path can be

33

Basic AlgorithmBasic AlgorithmPseudo codePseudo code

FordFord--Fulkerson(G,s,tFulkerson(G,s,t))1 for each edge (1 for each edge (u,vu,v) ) ЄЄ E[G]E[G]

2 2 do do f[u,vf[u,v] ] ←← 00

33 f[v,uf[v,u] ← 0] ← 0

4 while there exists a path p from s to t in the residual networ4 while there exists a path p from s to t in the residual network k GGff

55 do do ccff(p(p) ) ←← min{cmin{cff(u,v(u,v) : () : (u,vu,v) is in p}) is in p}

66 for each edge (for each edge (u,vu,v) in p) in p

77 do do f[u,vf[u,v] ] ←← f[u,vf[u,v] + ] + ccff(p(p))

88 f[v,uf[v,u] ← ] ← --f[u,vf[u,v]]

ExampleExamplev1 v3

v2 v4

ts

16

13

10 4 9

14

12

20

4

7

v1 v3

v2 v4

ts

4/16

13

10 4 4/9

4/14

4/12

20

4/4

7

v1 v3

v2 v4

ts

12

13

10 4 5

10

820

4

7

4

4

4

4

v1 v3

v2 v4

ts

11/16

13

7/10 4 4 /9

11/14

4/12

7/20

4/4

7/7

Example Example –– Cont.Cont.v1 v3

v2 v4

ts

5

13

3 11 5

3

8

13

4

7

11

4

4

11

7

v1 v3

v2 v4

ts

11/16

8/13

10 1/4

4 /9

11/14

12/1215/20

4/4

7/7

v1 v3

v2 v4

ts

5

8

11 3 5

11

12

5

4

7

3

5

11 4

15

v1 v3

v2 v4

ts

11/1612/13

10 1/4

9 /9

11/14

12/12

19/20

4/4

7/7

Example Example –– Cont.Cont.v1 v3

v2 v4

ts

5

12

11 3 9

11

12

1

4

7

3

1

11

19

No further augmenting paths are found, No further augmenting paths are found, algorithm exits with max. flow f=23algorithm exits with max. flow f=23

AnalysisAnalysisRunning time depends on how the Running time depends on how the augmenting path is chosen augmenting path is chosen If capacities are integral values and If capacities are integral values and using a breadthusing a breadth--first or depthfirst or depth--first first searchsearch O(E) to find the augmenting O(E) to find the augmenting path, the algorithm runs in O(E |f*|) path, the algorithm runs in O(E |f*|) where f* is the maximum flow where f* is the maximum flow

ReferencesReferencesThomas H. Thomas H. CornmenCornmen, Charles E. , Charles E. LeisersonLeiserson, , and Clifford Stein. and Clifford Stein. Introduction to Introduction to Algorithms.Algorithms. MIT Press, 2001MIT Press, 2001RavindraRavindra K. K. AhujaAhuja, Thomas L. , Thomas L. MagnantiMagnanti, , and James B. and James B. OrlinOrlin. . Network Flows: Network Flows: Theory, Algorithms, and Applications. Theory, Algorithms, and Applications. Prentice Hall, 1993Prentice Hall, 1993http://en.wikipedia.org/wiki/Fordhttp://en.wikipedia.org/wiki/Ford--Fulkerson_algorithmFulkerson_algorithm, 10 April, 2005, 10 April, 2005