CS321 Lecture: Network Flow Problems 11/12/97 revised 11/5/98
I. Introduction
- ------------
A. Thus far, we have used networks in which the edge weights represent
a COST, and we've solved problems where the goal is to MINIMIZE some
total of these costs.
B. Another class of problems arises when edge weights are CAPACITIES - and
our goal is to MAXIMIZE some measurement based on them.
1. A system of pipes in which the edge weight is a capacity in gallons
per hour. (Origin of the name "network flow" for this class of
problem.)
2. A highway network - weight = cars / hour.
3. A communications network - weight = bits / second.
C. Such networks give rise to the NETWORK FLOW PROBLEM.
1. We use a directed graph (pipes / roads / links are assumed to be
unidirectional)
2. One vertex - the SOURCE - has only outward edges; and one vertex -
the SINK - has only inward edges.
3. We associate two numbers with each edge:
a. Capacity
b. Actual flow
Where: 0 <= actual flow <= capacity
4. At each vertex - except source and sink - we require
sum(flows in) = sum(flows out)
5. We also require
sum(flows out of source) = sum(flows in to sink)
We call this value the overall flow.
6. Our goal is to maximize the overall flow. We assume some sort
of valves that allow us to reduce flow on edges below capacity if
needed.
D. Example: (Edges are labelled current flow / capacity )
2/6
--> B ---------> C
0/8 / ^ / \ 2/4
/ 2/3 \_______/ \
A < _____/\ > F
\ 0/2 / \ /
2/2 \ v \ / 0/5
--> D ---------> E
2/5
Sum of flows out of A = 2
Sum of flows into B = 2; out of B = 2
Sum of flows into C = 2; out of C = 2
Sum of flows into D = 2; out of D = 2
Sum of flows into E = 2; out of E = 2
Sum of flows into F = 2
Overall flow = 2
II. Ford and Fulkerson's Method
-- ---- --- ----------- ------
A. The following technique can be used to maximize flow for any given
network.
1. Start with any legal flow (say all 0)
2. Repeatedly perform flow-improving operations until no further
improvement is possible.
B. There are two ways to improve the overall flow in a network:
1. Consider any directed path from source to sink, such that all edges
have some unused capacity (capacity - current flow).
a. Determine the smallest such unused capacity along the path.
b. Increase all current flows along the path by this amount (which
will result in some edge(s) having current flow = capacity)
c. Example: Starting with above
Path ADEBCF - AD has unused capacity 0, so no improvement possible
using this path
Path ABCDEF - AB has unused capacity 8
BC has unused capacity 4
CD has unused capacity 2
DE has unused capacity 3
EF has unused capacity 5
Increase all current flows along this path by 2
4/6
--> B ---------> C
2/8 / ^ / \ 2/4
/ 2/3 \_______/ \
A < _____/\ > F
\ 2/2 / \ /
2/2 \ v \ / 2/5
--> D ---------> E
4/5
Path ABCF - AB has unused capacity 6
BC has unused capacity 2
CF has unused capacity @
Increase all current flows along this path by 2
6/6
--> B ---------> C
4/8 / ^ / \ 4/4
/ 2/3 \_______/ \
A < _____/\ > F
\ 2/2 / \ /
2/2 \ v \ / 2/5
--> D ---------> E
4/5
Path ADEF - AD has unused capacity 0, so no improvement possible
d. Once we have done this once for all possible directed paths, we can
make no further improvements this way.
2. A second way to make improvements is to consider arbitrary paths in
which we allow some edges to be followed the wrong way. We can make
an improvement along such a path if
a. All forward edges have unused capacity.
b. All backward edges have non-zero flow
c. We make improvements by taking the minimum (least unused capacity
over any forward edge along the path, least flow over any
backward edge along the path). We then increase the flow on all
forward edges on the path by this amount, and DECREASE the flow
on all backward edges along the path by this amount.
d. Example: Starting where we left off
Path ABEF - AB has unused capacity 4
BE has backward flow 2
EF has unused capacity 3
Increase forward flows by 2; decrease backward by 2
6/6
--> B ---------> C
6/8 / ^ / \ 4/4
/ 0/3 \_______/ \
A < _____/\ > F
\ 2/2 / \ /
2/2 \ v \ / 4/5
--> D ---------> E
4/5
We have maximized flow for this particular network!
C. Practical Considerations
1. Choice of order of considering paths for improvement is critical
Example:
1/1000 1/1000
----> B ---->
/ | \
A | 0/1 C
\ v /
----> D ---->
1/1000 1/1000
If we choose to improve along ABDC, we can get
1/1000 0/1000
----> B ---->
/ | \
A | 1/1 C
\ v /
----> D ---->
0/1000 1/1000
If we now use ADBC, we get
1/1000 1/1000
----> B ---->
/ | \
A | 0/1 C
\ v /
----> D ---->
1/1000 1/1000
Of course, we can repeat this cycle 999 more times before achieving
the optimal flow of 2000
However, if we considered paths in the order
ABC
ADC
we would get there in just two steps.
2. To arrive at maximum flow most quickly, it turns out that we should
consider the paths in the order they would be generated by a BFS
starting at the source.
a. Example: For our first network:
ABCF
ABEF (BE backwards)
ADCF (DC backwards)
ADEF
ABCDEF
ABEDCF (BE, ED, DC backward)
ADCBEF (DC, CB, BE backward)
ADEBCF
b. Example: For our second network:
ABC
ADC
ABDC
ADBC
Copyright ©1998 - Russell C. Bjork