You are on page 1of 19

Network Flow Problems

Max-Flow Algorithm. Also called


as Augmented Flow Algorithm
or Ford-Fulkerson Algorithm

1
Some of the applications

System of roads and highways


Maximize rate of flow of vehicles

System of pipelines that carries oil,


natural gas and water
Maximize the rate of flow of fluids

Telecommunication network
Routing data – best of use bandwidth 2
Frequently Used Algorithm

Maximal Flow Algorithm

Used for determining the greatest amount of flow that can be


transmitted through a system in which various branches, or
connections, have specified flow capacity limitations.

The algorithm to find maximum flow in a network is called


Max-Flow Algorithm or Augmented Flow Algorithm
or Ford-Fulkerson Algorithm

3
Maximal Flow Algorithm

• Before terminating, the network should also be scanned for reverse flow
augmenting paths and should be updated accordingly
4
Example 1

2
10 6

Flow 2
1 2 4
capacity

3 6
3

5
Example 1
Sent flow

2
6 0
10 0
2 0
2 0

1 4
Flow capacity

3 0
3 6 0

Consider an augmenting path 1-2-4. In this path, arc


1-2 has capacity of 10 and arc 2-4 has capacity of 6.
Hence maximum flow possible thro’ this path is 6.
Send this flow.

After sending this flow update the network “flow


capacity” and “sent flow”.

Updated network is given in the next slide. 6


1st revision of flow network
Sent flow

0 6
2
4 6 6 0
10 0
2 0
2 0

Residual 1 4
Capacity
available
3 0
3 6 0

Now we will go for next


augmenting path.

Consider the path 1-2-3-4.


Flow Augmenting Path Flow Sent Residual capacities available are
- for arc 1-2 it is 4, 2-3 it is 2 and
1-2-4 6 3-4 it is 6. Hence, max. flow
possible in this path is 2. Send
this flow.

After sending this flow update


the network “residual flow
capacity” and “sent flow”.

Updated network is given in the


7
next slide.
2nd revision of flow network
Sent flow

2 8 0 6
2
4 6 6 0
10 0
2 0
2 0
0 2

Residual 1 4
Capacity
available
3 0
3 6 0
4 2 Now flowing thro’ the arc 1-2 and
reaching 4 (sink) is not possible
because, in the arcs 2-4 and 2-3, the
residual capacities are zero.

Now consider another flow


Flow Augmenting Path Flow Sent augmenting path 1-3-4 (this path is
having residual capacities in all its
1-2-4 6 arcs). The residual capacity in arc 1-3
is 3 and arc 3-4 is 4. Hence, the flow
1-2-3-4 2 possible is 3. Send this flow.

After sending this flow update the


network “residual flow capacity” and
“sent flow”.

Updated network is given in the next


slide. 8
3rd revision of flow network
Sent flow

2 8 0 6
2
4 6 6 0
10 0
2 0
2 0
0 2

Residual 1 4
Capacity
available
3 0
3 6 0
0 3 Now, looking at the network, it is
4 2
observed that there is no forward
1 5
flow augmenting paths.

Hence, 4th revision of flow network is


not possible.
Flow Augmenting Path Flow Sent
Since, there is no “only forward flow
1-2-4 6 augmenting paths” and “reverse flow
augmenting paths”, the algorithm
1-2-3-4 2 stop.

1-3-4 3 Summation of flows thro’ various


augmenting paths is the total flow
possible thro’ this network.

Max. flow thro’ this network


calculated and it is given in the next
slide. 9
After 3rd revision
Sent flow

2 8 0 6
2
4 6 6 0
10 0
2 0
2 0
0 2

Residual 1 4
Capacity
available
3 0
3 6 0
0 3
4 2
1 5

Flow Augmenting Path Flow Sent


1-2-4 6
1-2-3-4 2
1-3-4 3

Maximum flow (Total) 11


10
Example 2 - demonstration of reverse flow

3 2 0
1 0

2 0 5

1 1 0
4
2 0
2 1 0

Consider path 1-3-5.

Max. flow possible is 1.


Send this flow.

Updated network is given in the


next slide.

11
1st revision of flow network

1 1
0 1 3 2 0
1 0

2 0 5

1 1 0
4
2 0
2 1 0

Now, consider path 1-2-4-5.

Max. flow possible is 1.


Send this flow.
Flow Augmenting Path Flow possible
1-3-5 1 Updated network is given in
the next slide.

12
2nd revision of flow network

1 1
0 1 3 2 0
1 0

2 0 5

1 1 0
4 0 1
2 0
Now, looking at the network
2 1 0
(after 2nd revision), it is
1 1
observed that there is no flow
0 1
augmenting path.

Hence, 3rd revision of flow


network is not possible.
Flow Augmenting Path Flow possible
Since, there is no “only forward
1-3-5 1 flow augmenting paths” and
“reverse flow augmenting
1-2-4-5 1 paths”, the algorithm stop.

Summation of flows thro’


Max. flow (total) 2 various augmenting paths is the
total flow possible thro’ this
network. 13
Some bad choice of “only forward arcs augmenting paths” will lead
to non-optimal solution. To overcome this issue, the network must
be scanned for reverse flow augmenting paths as well.

3 2 0
1 0

2 0 5

1 1 0
4
2 0
2 1 0

Consider this network, instead of


choosing the augmenting path 1-3-5, if
we choose 1-3-4-5 in the first instance,
we may end-up with non-optimal
solution.

We will get optimal solution after


considering reverse flow augmenting
path.

1st revision of this network is given in the


14
next slide
Now, looking at the network (after 1st
1st revision of flow network revision), it is observed that there is no flow
augmenting paths having only forward arcs.

Now the network must be scanned for


reverse flow augmenting paths.

0 1 3 2 0 Now consider, the reverse


1 0 flow augmenting path 1-2-4-
3-5
2 0 5
1 1
In this path, all the forward
1 1 0 arcs having residual capacity,
4 0 1 the arcs which we want to
2 0 reverse it (i.e. 4-3) is having
2 1 0 “sent flow” of 1.

After analyzing , we can send


flow of 1 unit thro’ the path.

Send this flow and update the


Flow Augmenting Path Flow sent network.

1-3-4-5 1 Updated network is given in


the next slide…

Reverse flow augmenting path is a path consisting of forward arcs Path


1 - 2 - 4 - 3 - 5
and a reversing arc, connecting source and sink. All forward arcs F F R F
should have some residual capacity and the arc which can be 2 1 1 2
reversed should have some “sent flow” Take the minimum of flow 15
2nd revision of flow network

1 1
0 1 3 2 0
1 0

2 0 5
1 1
1 2 0 1 0
4 0 1
2 0
Now there is no other
2 1 0
reverse flow augmenting
1 1
path is available.
0 1
Hence algorithm stops.

Flow Augmenting Path Flow sent Since there is no sent


flow in arc 3-4 (because
1-3-4-5 1 of reversal),
the path 1-3-4-5 will
1-2-4-3-5 1 become 1-3-5 and the
path 1-2-4-3-5 will
become 1-2-4-5.

Updated network is given


in the next slide. 16
After correcting paths…

1 1
0 1 3 2 0
1 0

2 0 5
1 1
1 2 0 1 0
4 0 1
2 0
1 1 2 1 0
Flow Augmenting Paths
0 1
after reversing
1-3-4-5
1-2-4-3-5
Flow Augmenting Path Flow sent
1-3-5 1
1-2-4-5 1

Total flow (total) 2


17
Example 3 - Exercise

10
2 5
30
40 10 20

1 4
10 7
40
10
15
20
3 6
20

18
Backup

19

You might also like