0% found this document useful (0 votes)
75 views26 pages

Data Structures and Algorithms: Maximum Flows

The Ford-Fulkerson method finds the maximum flow in a flow network using a residual network and augmenting paths. It initializes the flow to 0 and repeatedly finds an augmenting path to incrementally increase the flow until no more augmenting paths exist. Each iteration increases the flow value and brings the algorithm closer to the maximum flow.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views26 pages

Data Structures and Algorithms: Maximum Flows

The Ford-Fulkerson method finds the maximum flow in a flow network using a residual network and augmenting paths. It initializes the flow to 0 and repeatedly finds an augmenting path to incrementally increase the flow until no more augmenting paths exist. Each iteration increases the flow value and brings the algorithm closer to the maximum flow.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 26

Data Structures and

Algorithms
Maximum flows
Maximum flows

We can interpret a directed graph as a "flow


network" and use it to answer questions about
material flows.

Imagine a material coursing through a system from a


source, where the material is produced, to a sink,
where it is consumed.
The source produces the material at some steady rate,
and
the sink consumes the material at the same rate.
The "flow" of the material at any point in the system is
intuitively the rate at which the material moves.
Flow networks

Flow networks can be used to


model liquids flowing through pipes,
parts through assembly lines,
current through electrical networks,
information through communication
networks, and so forth.
The maximum-flow problem

The maximum-flow problem asks:

What is the greatest rate at which


material can be shipped from the
source to the sink without violating
any capacity constraints?
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 :
source s and
sink t.
12
16 20

s 10 4 9 7 t

13 4
14
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, 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}, we require

f ( e ) f ( e)
e.in .v e.out .v
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 )
vV

The total flow from source to any other


vertices.
The same as the total flow from any vertices to
the sink.
Example

12/12

11/16 15/20

s 10 1/4 4/9 7/7 t

8/13 4/4

11/14
f 19

A flow f in G with value |f| = 19


Maximum-flow problem

Given a flow network G with source s and


sink t

Find a flow of maximum value from s to t.


The Ford-Fulkerson method

The Ford-Fulkerson method solves the


maximum-flow problem.

We call it a method rather than an


algorithm because it encompasses several
implementations with different running times.
Ideas

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.
FORD-FULKERSON-METHOD(G, s,
t)
FORD-FULKERSON-METHOD(G, s, t)
1 initialize flow f to 0
2 while there exists an augmenting
path p
3 do augment flow f along p
4 return f
The Ford-Fulkerson method is
iterative
We start with f(u, v) = 0 for all u,v V, giving
an initial flow of value 0.

At each iteration, we increase the flow value


by finding an "augmenting path," which we can
think of simply as a path from the source s to
the sink t along which we can push more flow,
and then augmenting the flow along this path.

We repeat this process until no augmenting


path can be found.
Residual networks

Given a flow network and a flow, the residual


network consists of edges that can admit more net
flow.

G=(V,E) is 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:
cf(u, v)=c(u, v) - f(u, v)
Example of residual network
12
v1 v3 A flow network G
16 20 and flow f.
The augmenting
s 10 4 9 7 t path p is shaded.

13 4
v2 v4
14
4/12 The flow in G that
4/16 v1 v3 20 results from
augmenting along
path p by its
s 10 4 7 t residual capacity
4/9 4.

13 4/4
v2 v4
4/14
Example of Residual network

8
12 v1 v3
20
4
4
s 10 4 4 7 t
5
13 10 4
v2 v4
4

The residual network induced by the flow.


A new augmenting path is shaded.
Lemma

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 is a flow in G with value
.

f f' f f'
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 Gf.

Residual capacity of p : the maximum amount of


net flow that we can ship along the edges of an
augmenting path p, i.e.,

cf(p)=min{cf(u, v) : (u, v) is on p}.


The basic Ford-Fulkerson
algorithm
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 Gf from line 4 with a shaded augmenting
path p.
The right side of each part shows the new flow f that
results from adding fp 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.
12 4/12
v1 v3 v1 v3
s 16 20 4/16 20
10 4 9 7 t s 10 4 7 t
4/9
13 4 13 4/4
v2 v4 v2 v4
14 4/14

(a)
8
12 v1 v3 4/12
20 v1 v3 7/20
4 11/16
4
s 10 4 4 7 t s 7/10 4 7/7 t
5 4/9
13 10 4 13 4/4
v2 v4 v2 v4
4 11/14

(b)
8 12/12
5 v1 v3 13 v1 v3
4 11/16 15/20
11 4
s 3 11 7 7 t s 7/7
10 1/4 4/9 t
5
13 3 8/13 4/4
v2 v4 4 v2 v4
11 11/14

(c)
12 12/12
5 v1 v3 5 v1 v3
11/16 19/20
11 4
s 11 3 7 15 t s 10 1/4 9 7/7 t
5 5
8 3 12/13 4/4
v2 v4 4 v2 v4
11 11/14

(d)
12
5 v1 v3 1
s
1 11 3 9 7 19 t

12 3 4
v2 v4
11

(e)
Running time

Running time depends on how the augmenting


path is determined. (It may not even terminate
for irrational capacities!)

If capacities are all integers, then each


augmenting path raises | f | by 1. If max flow is
f* , then need | f* | iterations.

O(E | f* | ).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy