0% found this document useful (0 votes)
14 views25 pages

NetworkFlow - Maxi Flow

Uploaded by

eshaasif005
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)
14 views25 pages

NetworkFlow - Maxi Flow

Uploaded by

eshaasif005
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/ 25

Network Flow

The Maximum Flow Problem


and
The Ford-Fulkerson Algorithm
Types of Networks
 Internet
 Telephone
 Cell
 Highways
 Rail
 Electrical Power
 Water
 Sewer
 Gas
 …
Maximum Flow Problem
 How can we maximize the flow in a network from a source or
set of sources to a destination of set of destinations?
 The problem reportedly rose to prominence in relation to the
rail networks of the Soviet Union, during the 1950's. The US
wanted to know how quickly the Soviet Union could get
supplies through its rail network to its satellite states in
Eastern Europe.
 In addition, the US wanted to know which rails it could destroy
most easily to cut off the satellite states from the rest of the
Soviet Union.
◦ It turned out that these two problems were closely related, and that
solving the max flow problem also solves the min cut problem of
figuring out the cheapest way to cut off the Soviet Union from its satellites.
 The first efficient algorithm for finding the maximum flow was
conceived by two Computer Scientists, named Ford and
Fulkerson. The algorithm was subsequently named the Ford-
Fulkerson algorithm, and is one of the more famous
algorithms in computer science.
lbackstrom, The Importance of Algorithms, at www.topcoder.com
Network Flow
•A Network is a directed graph G
•Edges represent pipes that carry flow
•Each edge <u,v> has a maximum capacity c<u,v>
•A source node s in which flow arrives
•A sink node t out which flow leaves

Goal:
Max Flow
Network Flow
 The network flow problem
is as follows: a 12
b
◦ Given a connected directed 16 20
graph G
 with non-negative integer 4 9
10 7
weights, s t
 (where each edge stands for
the capacity of that edge), 4
◦ 2 different vertices, s and t, c 14 d
called the source and the
sink,
 such that the source only has Each edge stands for the
out-edges and the sink only capacity of that edge.
has in-edges,
◦ Find the maximum amount
of some commodity that
can flow through the
network from source to
sink.
Network Flow
 One way to imagine the
situation is imagining a 12
b
each edge as a pipe that 16 20
allows a certain flow of a
liquid per second. 4 10
9
7
◦ The source is where the s t
liquid is pouring from, and
the sink is where it ends up. 4
◦ Each edge weight specifies c d
the maximal amount of 14
liquid that can flow through
that pipe per second.
Each edge stands for the
◦ Given that information, capacity of that edge.
what is the most liquid that
can flow from source to sink
per second, in the steady
state?
Network Flow
12
a b a
12/12
b
16 20
12/16 19/20

9 0/9
4 10 7
s t s
0/4 0/10
7/7 t
13 4
11/13 4/4
c 14 d c d
11/14

This graph contains the capacities Here is an example of a flow


of each edge in the graph. in the graph.

 The flow of the network is defined as the flow


from the source, or into the sink.
 For the situation above, the network flow is 23.
12 12/12
a b a b
16 20 12/16 19/20
0/9
4 9 0/4
10 7 0/10
s t s 7/7 t
13 4 11/13 4/4
c 14 d c 11/14 d

capacities flow
 The Conservation Rule:
◦ In order for the assignment of flows to be valid, we must have the
sum of flow coming into a vertex equal to the flow coming out of a
vertex, for each vertex in the graph except the source and the sink.
 The Capacity Rule:
◦ Also, each flow must be less than or equal to the capacity of the
edge.

 The flow of the network is defined as the flow from the


source, or into the sink.
◦ For the situation above, the network flow is 23.
Network Flow
 In
order to determine the maximum flow of a
network, we will use the following terms:
◦ Residual capacity – is simply an edge’s unused
capacity.
 Initially none of the capacities will have been used, so all
of the residual capacities will be just the original capacity.

0/12
a b
0/16 0/20
Using the notation: used / capacity.
0/9
0/4 0/10
s 0/7 t Residual Capacity: capacity - used.

0/13 0/4

c 0/14 d
Network Flow
◦ Residual capacity of a path – the minimum of the
residual capacities of the edges on that path, which
will end up being the max excess flow we can push
down that path.

◦ Augmenting path – defined as one where you have


a path from the source to the sink where every edge
has a non-zero residual capacity.

0/12
a b
0/16 0/20
Using the notation: used / unused.
0/9
0/4 0/10
s 0/7 t Residual Capacity: unused - used.

0/13 0/4

c 0/14 d
Ford-Fulkerson Algorithm
While there exists an augmenting path
Add the appropriate flow to that augmenting path

So we’re going to arbitrarily choose an the


augmenting path s,c,d,t in the graph
below:
◦ And add the flow to that path.
◦ Residual capacity of a
path – the minimum of the
0/12 residual capacities of the
a b edges on that path.
0/16 0/20
0/9
0/4 0/10 ◦ 4 in this case,
s 0/7 t which is the limiting
factor for this path’s
0/4
0/13
4/13 4/4 flow.
c 0/14 d
4/14
Ford-Fulkerson Algorithm
While there exists an augmenting path
Add the appropriate flow to that augmenting path

 Choose another augmenting path (one where


you have a path from the source to the sink where
every edge has a non-zero residual capacity.)
◦ s,a,b,t

◦ Residual capacity of a
12/12 path – the minimum of the
0/12
12/16 a b 12/20 residual capacities of the
0/16 0/20 edges on that path.
0/9
0/4 0/10 ◦ 12 in this case,
s 0/7 t which is the limiting
factor for this path’s
4/13 4/4 flow.
c 4/14 d
Ford-Fulkerson Algorithm
While there exists an augmenting path
Add the appropriate flow to that augmenting path

 Choose another augmenting path (one where


you have a path from the source to the sink where
every edge has a non-zero residual capacity.)
◦ s,c, d, b, t

◦ Residual capacity of a
12/12
path – the minimum of the
a b 19/20
residual capacities of the
12/16 12/20 edges on that path.
0/9
0/4 0/10 ◦ 7 in this case,
s 0/7 t which is the limiting
7/7
factor for this path’s
4/13 4/4 flow.
11/13 c 4/14 d
11/14
Ford-Fulkerson Algorithm
While there exists an augmenting path
Add the appropriate flow to that augmenting path

Are there any more augmenting paths?


◦ No! We’re done
◦ The maximum flow = 19 + 4 = 23

12/12
a b
12/16 19/20
0/9
0/4 0/10
s 7/7 t

11/13 4/4
c 11/14 d
Example
Basic Terms
Source
Sink
Bottleneck Capacity
Flow
Augmenting Path
Residual Capacity
Source and sink
Initially all flow is zero

You might also like