Professional Documents
Culture Documents
4, 4
1 5
4, 6 0, 4 1, 4 3, 6
4, 8
4, 8 2 6 6, 7
1, 5
s 0, 2 t
2, 5 2, 2 1, 4
3 7
1, 3
2, 2 1, 5 2, 5 2, 2
0, 4
4 8
The figures at the arcs denote respectively the flow xa (a ∈ A) and the capacity ua (a ∈ A).
One can check that in the example above the flow indeed satisfies the capacity constraints and
maintains the flow balance on all nodes except s and t. The net outflow of s equals the net
inflow of t, and this is named the flow value. In Figure 1 we can see that the flow value is 12.
Often we are interested in finding a flow of maximum value: the max flow problem.
1
Graph Theory 2
One could easily denote this problem as a linear program. The decisions to be made in this
problem are how much flow to put through each arc.
Variables: ∀a∈A xa = the amount of flow through arc a.
This gives the following LP-formulation, in which the objective is to maximize the net outflow
from the source s.
X X
maximize xs,j − xi,s
j:(s,j)∈A i:(i,s)∈A
X X
subject to xi,j = xj,i ∀i∈V \{s,t}
j:(i,j)∈A j:(j,i)∈A
0 ≤ xa ≤ ua ∀a∈A
For convenience, we sometimes add an arc (t, s) to the network to redirect the flow from t back
to s, so that the flow balance in these two nodes is also maintained. The flow is then called a
circulation.
There are numerous extensions of the maximum flow problem. In one of these we add costs on
units of flows through the arcs and try to minimize find a flow that minimizes the total cost
for a given flow value. This min-cost flow problem will be the subject of a later section. Many
problems can be modelled as a maximum flow problem or as one of its extensions. Among them
are the shortest path problem and the bipartite matching problem (also called the assignment
problem).
1 1
1 2
+2
s 3 t s +2 t
+2
2 1
2 2
The leftover capacities of the example network are given in the following picture.
1
1 0
s 1 t
0 1
2
It looks like the augmenting path algorithm can not find a better flow, although there is
one. What is wrong? The mistake is found in the interpretation of augmenting paths. An
augmenting path may consist of arcs which have the ”wrong” direction. The ”path” s−1−2−t
consists of the non-existent arc (1, 2). However, we CAN increase the flow along this path by
increasing the flow on the arcs (s, 1) and (2, t), and DECREASING the flow on the arc (2, 1),
by one unit. Note that this DOES maintain the flow conservation constraints at the nodes 1
and 2.
1 1
+1 1 2
s −1 t s 1 t
+1 2 1
2 2
A path from s to t that contains arcs in the ”right” direction and arcs in the ”wrong” direction
is an augmenting path if the flow along ”right” arcs can be increased and the flow along ”wrong”
arcs can be decreased. This idea is implemented such that the ordinary reaching algorithm
can find augmenting paths by introducing the so-called residual network G(x) which depends
on the flow x. For each arc (i, j) with capacity uij and flow xij , in the original network, we
introduce at most two new arcs in G(x). If xij < uij then the arc (i, j) is defined with capacity
Graph Theory 4
uij − xij . If xij > 0 then the arc (j, i) is defined with capacity xij .
uij − xij
0 < xij < uij
i j i j
xij
Figure 5:
The residual network of the example after one flow augmentation is depicted in Figure 6 below.
1
1 2
s 1 2 t
2 1
2
Finding an augmenting path in the residual network can be done by any variant of the reaching
algorithm. Note that the amount with which we can increase the flow depends on the capacities
of the arcs on the augmenting path. It equals the minimum capacity of an arc on the path.
Theorem 2.1. (Optimality Condition) A flow in a network is maximum if and only if there
is no augmenting path with respect to that flow in the corresponding residual graph.
Proof. If a flow x is maximum, then certainly there is no augmenting path. Otherwise, the
flow could have been augmented to a better one.
If a flow x is not maximum, then let xmax be a better flow. Observe that xmax − x is a feasible
flow in the residual network G(x). Moreover, the net outflow from s of xmax − x is positive.
Since all vertices except s and t satisfy the flow balance constraints with respect to xmax − x,
it follows that t must be reachable by a path P from s on which each arc carries positive flow.
Clearly P is a flow augmenting path in G(x).
This theorem does not imply that the augmenting path algorithm finishes, or even converges
to the right value. However, with integral capacities, or with special choices of augmenting
paths, we are able to prove that the problem is solvable, even in polynomial time. A final, but
very important, property of flows in case the capacities are integral, is the following:
Theorem 2.2. Consider a network (G, u) with integral capacity function u : A → N+ with
Graph Theory 5
source s and sink t. There is a maximum flow x : A → N+ from s to t in (G, u), i.e., there is
an integral maximum flow.
This theorem is an immediate consequence of the application of the augmenting path algorithm.
All residual capacities are integral at the start, and remain integral during the updates with
an integral number of units of flow on augmenting paths.
Some definitions. A cut [S, S] is a partition of the vertex set V into two subsets S and S.
A cut [S, S] is an s − t cut if s ∈ S and t ∈
/ S. We define the forward arcs of [S, S] as the set of
arcs with their tail in S and their head in S. These arcs are denoted by (S, S). The arcs with
their tail in S and their head in S are called backward arcs. These arcs are denoted by (S, S).
The capacity of a cut, i.e., u(S, S) is the cumulative capacity of the forward arcs, i.e.,
X
u[S, S] = ua .
a∈(S,S)
Theorem 3.1. (Weak Duality) The value of a feasible flow v is less than or equal to the
capacity of any s − t cut.
Graph Theory 6
Proof.
X X
v = xs,j − xj,s (1)
j:(s,j)∈A j:(j,s)∈A
X X X X X
= xs,j − xj,s + xi,j − xj,i (2)
j:(s,j)∈A j:(j,s)∈A i∈S−s j:(i,j)∈A j:(j,i)∈A
X X X
= xi,j − xj,i (3)
i∈S j:(i,j)∈A j:(j,i)∈A
X X
= xi,j − xj,i (4)
(i,j)∈(S,S) (j,i)∈(S,S)
X
≤ xi,j (5)
(i,j)∈(S,S)
X
≤ ui,j (6)
(i,j)∈(S,S)
= u[S, S] (7)
Theorem 3.2. (Strong Duality) The maximum value of a feasible flow equals the minimum
capacity among all s − t cuts.
Proof. Consider a maximum flow xmax and its residual network G(xmax ). By theorem 2.1
there is no path in G(xmax ) from s to t. Now label the vertices that are reachable in G(xmax )
from s and define S as the set of labeled vertices. Clearly, S defines an s − t cut. We claim
that the forward arcs (S, S) in the original network contain a flow equal to their capacity, and
the backward arcs (S, S) contain no flow. Otherwise the residual network G(xmax ) would have
contained an arc from a node i in S to a node j in S implying that j should have been labeled.
Thus, the flow through the cut [S, S] is equal to its capacity. With the previous theorem this
implies optimality of both the flow xmax and the cut [S, S].
3.1 Exercises
Exercise 1. (Khan and Lewis [1987]). To provide adequate medical service to its con-
stituents at a reasonable cost, hospital administrators must constantly seek ways to hold staff
levels as low as possible while maintaining sufficient staffing to provide satisfactory levels of
health care. An urban hospital has three departments: the emergency room (department 1),
the neonatal intensive care nursery (department 2), and the orthopaedics (department 3). The
hospital has three work shifts, each with different levels of necessary staffing for nurses. The
hospital would like to identify the minimum number of nurses required to meet the following
Graph Theory 7
three constraints: (1) the hospital must allocate at least 13, 32 and 22 nurses to the three
departments (over all shifts); (2) the hospital must assign at least 26,24 and 19 nurses to the
three shifts (over all departments); and (3) the minimum and maximum number of nurses
allocated to each department in a specific shift must satisfy the following limits:
The problem is to find a feasible schedule that minimizes the total number of shifts. Formulate
this problem as a max flow problem.
Exercise 3. Consider the network and the feasible flow x shown in Figure 7.
a) Specify four s − t cuts in the network, each containing four forward arcs. List the capacity,
residual capacity, and the flow across each cut.
b) Draw the residual network for the network and flow given in Figure 7 and list fours aug-
menting paths from node s to node t.
5, 8
1 4
5, 10 5, 5 0, 10
0, 4
10, 20
s 2 10, 25 0, 5 t
7, 9
2, 4
5, 15 20, 30
3, 6
3 5
times, which need to be scheduled on identical different machines. In this exercise we aim to
schedule four jobs on two identical machines. The jobs have a processing time, a release time
and a due date all described in Figure 8.
Jobs can be preempted, which means that one can stop processing a job and resume it on a
later time.
a) Formulate the example in Figure 8 of the scheduling problem on uniform parallel machines
as a max flow algorithm. Hint: you need to create a node for each job and for each possible
time interval {[0, 1], [1, 2], [2, 3], [3, 5], [5, 6], [6, 7]} and a source s and sink t. Carefully think
about the edges and their capacities.
b) Solve the problem from a and give a feasible schedule.
c) What happens with the optimal value of the max flow if there is no feasible schedule?
Exercise 5. An airline has p flight legs that it wishes to service by the fewest possible
planes. To do so, it must determine the most efficient way to combine these legs into flight
schedules. The starting time for flight i is ai and the finishing time is bi . The plane requires rij
hours to return from the point of destination of flight i to the origin point of flight j. Suggest
a method for solving this problem.
1 2 3 4 5 6 7 8
A 1 0 1 1 0 0 1 0
B 0 1 0 0 1 1 0 0
C 0 0 1 1 0 0 1 0
D 0 1 0 0 0 1 0 1
E 1 0 1 0 0 0 1 0
F 1 0 0 1 0 0 1 0
G 0 1 0 0 1 1 0 1
H 1 0 1 1 0 0 1 0
d) Give a compact proof on why there is no assignment in which each teacher is matched to
exactly one timeslot.
Exercise 8. Write down the dual program of the LP-formulation of the max flow problem
on page 2 and explain what kind of solution this dual program will return.
The numbers at the arcs denote respectively the arc costs ca (a ∈ A) and the capacity ua (a ∈
A). A LP-formulation of the problem is given below.
X
minimize ci,j xi,j
(i,j)∈A
X X
subject to xi,j = xj,i ∀i∈V \{s,t}
j:(i,j)∈A j:(j,i)∈A
X X
xs,j − xj,s = v
j:(s,j)∈A j:(j,s)∈A
X X
xt,j − xj,s = −v
j:(t,j)∈A j:(j,t)∈A
0 ≤ xa ≤ ua ∀a∈A
We make some assumptions for instances of minimum cost flows: (1) all input (capacities and
costs) are integral; (2) there is a single supply node s and a single demand node t; (3) there
Graph Theory 10
4, 4
1 5
4, 6 0, 4 1, 4 3, 6
4, 8
4, 8 2 6 6, 7
1, 5
s 0, 2 t
2, 5 2, 2 1, 4
3 7
1, 3
2, 2 1, 5 2, 5 2, 2
0, 4
4 8
(−cij , xij )
Figure 10:
If a given feasible (value v) flow x∗ , has a residual graph G(x∗ ) that contains a negative cost
cycle, then clearly we can improve upon it by augmenting flow over the cycle. The converse is
also true.
Theorem 4.1. A feasible flow x∗ is optimum if and only if there is no cycle of negative costs
in the residual graph G(x∗ ).
Proof. Let x∗ be a given flow. If there is a negative cost cycle in G(x∗ ), then the flow can be
Graph Theory 11
Note that we did not treat the subject of finding negative cost cycles in graphs in this course.
Though, one could easily adapt Dijkstra’s algorithm in order to do so. In the exercises we
consider the examples are small enough to do it by hand.
Graph Theory 12
4.2 Exercises
1 4 -
HH HH 2,8
H HH 1,9
2,3
HH
? 1,1 j
H
* 2,1 HH 3,4 HH
H
*
HY
H HH
20,7 3,3 30,1
H
H
s - 2 - 5 - t
H H
H H
HH HH
j
H H ? 2,2
H
6,7 HH 3,2 HH 6,4
jH
H
*
5,3
HH
*
40,5 H H
3
-
6
Exercise 10. Determine in the following network a maximum s − t flow of minimum cost.
1 -
4
HH 5,1 HH
HH HH 9,8
8,7
7,3 ? H ? 1,3 j
H
*
2,2 H H
j
H 7,4 HH
HH HH
*
H H
6,3 6,2 2,4
s - 2 - 5 - t
H H
HH HH
HH HH
j 1,3 1,1
6 2,1 8,1
H H *
1,4 HH H
jH
H 6 8,8
HH *
1,5 HH
3 -
6
Exercise 11. Entrepreneur’s problem (Prager [1957]). An entrepreneur faces the fol-
lowing problem. In each of T periods, he can buy, sell, or hold for later sale some commodity,
subject to the following constraints. In each period i he can buy at most αi units of the
commodity, an holdover at most βi units of the commodity for the next period, and must
sell at least γi units (perhaps due some prior agreements). The entrepreneur cannot sell the
commodity in the same period in which he buys it. Assuming that pi , wi and si denote the
purchase costs, inventory carrying cost, and the selling price per unit in period i, what buy-sell
Graph Theory 13
policy should the entrepreneur adopt to maximize total profit in the T periods. Formulate this
problem as a minimum cost flow problem for T = 4.
Exercise 12. The Millersburg Supply Company uses a large fleet of vehicles which it
leases from the manufacturers. The company has forecast the following pattern of vehicle
requirements for the next six months:
Millersburg can lease vehicles from several manufacturers at verious costs and for various
lengths of time. Three of the plans appear to be the best available: a 3-month lease for $1700;
a 4-month lease for $2200; and a 5-month lease for $2600. The company can undertake a lease
beginning in any month. On January 1 the company has 200 cars on lease, all of which go
off lease at the end of February. Formulate the problem of determining the most economical
leasing policy as a minimum cost flow problem.
Exercise 13. Terminal assignment problem (Esau and Wiliams [1966]). Centralized
teleprocessing networks often contain many (as many as tens of thousands) relatively unsophis-
ticated geographically dispersed terminals. These terminals need to be connected to a central
processor unit (CPU) either by direct lines or through concentrators. Each concentrator is
connected to the CPU through a high-speed, cost-effective line that is capable of merging data
flow streams from different terminals and sending them to the CPU. Suppose that the con-
centrators are in place and that each concentrator can handle at most K terminals. For each
terminal j, let coj denote the cost of laying down a direct line from the CPU to the terminal
and let cij denote the line construction cost for connecting concentrator i to terminal j. The
decision problem is to construct a minimum cost network for connecting the terminals to the
CPU. Formulate this Problem as a minimum cost flow problem.
Exercise 14. Formulate the following linear program as a min cost flow problem. All
variables are non-negative.
Min 6x1 + 3x2 + 2x3 + 8x4
x1 + x3 − x4 = 0
x2 − x3 + x5 = 0
x4 + x5 ≥ 20
x3 ≤ 5
x5 ≤ 8