0% found this document useful (0 votes)
33 views137 pages

Design and Analysis of Algos

Uploaded by

norac92034
The document describes how to use maximum flow algorithms to solve the bipartite matching problem. It constructs a flow network from the bipartite graph where edges have capacity 1. A maximum flow in this network corresponds to a maximum matching in the original graph. Specifically, edges that carry flow from the left node partition to the right correspond to the matching edges. This shows that computing maximum flow can be used to find maximum matchings in O(mn) time.

Copyright:

© All Rights Reserved

Available Formats

Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
33 views137 pages

Design and Analysis of Algos

Uploaded by

norac92034
The document describes how to use maximum flow algorithms to solve the bipartite matching problem. It constructs a flow network from the bipartite graph where edges have capacity 1. A maximum flow in this network corresponds to a maximum matching in the original graph. Specifically, edges that carry flow from the left node partition to the right correspond to the matching edges. This shows that computing maximum flow can be used to find maximum matchings in O(mn) time.

Copyright:

© All Rights Reserved

Available Formats

Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 137

7.

5 A First Application: The Bipartite Matching Problem 367

edge is not in the residual graph. In the first case, we clearly need to relabel v
before applying a push on this edge. In the latter case, one needs to apply push
to the reverse edge (w, v) to make (v, w) reenter the residual graph. However,
when we apply push to edge (w, v), then w is above v, and so v needs to be
relabeled before one can push flow from v to w again.

Since edges do not have to be considered again for push before relabeling,
we get the following.

(7.32) When the current(v) pointer reaches the end of the edge list for v,
the relabel operation can be applied to node v.

After relabeling node v, we reset current(v) to the first edge on the list and
start considering edges again in the order they appear on v’s list.

(7.33) The running time of the Preflow-Push Algorithm, implemented using


the above data structures, is O(mn) plus O(1) for each nonsaturating push
operation. In particular, the generic Preflow-Push Algorithm runs in O(n2m)
time, while the version where we always select the node at maximum height
runs in O(n3) time.

Proof. The initial flow and relabeling is set up in O(m) time. Both push and
relabel operations can be implemented in O(1) time, once the operation
has been selected. Consider a node v. We know that v can be relabeled at
most 2n times throughout the algorithm. We will consider the total time the
algorithm spends on finding the right edge on which to push flow out of node v,
between two times that node v gets relabeled. If node v has dv adjacent edges,
then by (7.32) we spend O(dv ) time on advancing the current(v) pointer
between consecutive relabelings of v. Thus the total time spent on advancing

the current pointers throughout the algorithm is O( v∈V ndv ) = O(mn), as
claimed.

7.5 A First Application: The Bipartite Matching


Problem
Having developed a set of powerful algorithms for the Maximum-Flow Prob-
lem, we now turn to the task of developing applications of maximum flows
and minimum cuts in graphs. We begin with two very basic applications. First,
in this section, we discuss the Bipartite Matching Problem mentioned at the
beginning of this chapter. In the next section, we discuss the more general
Disjoint Paths Problem.
368 Chapter 7 Network Flow

The Problem
One of our original goals in developing the Maximum-Flow Problem was to
be able to solve the Bipartite Matching Problem, and we now show how to
do this. Recall that a bipartite graph G = (V , E) is an undirected graph whose
node set can be partitioned as V = X ∪ Y, with the property that every edge
e ∈ E has one end in X and the other end in Y. A matching M in G is a subset
of the edges M ⊆ E such that each node appears in at most one edge in M.
The Bipartite Matching Problem is that of finding a matching in G of largest
possible size.

Designing the Algorithm


The graph defining a matching problem is undirected, while flow networks are
directed; but it is actually not difficult to use an algorithm for the Maximum-
Flow Problem to find a maximum matching.
Beginning with the graph G in an instance of the Bipartite Matching
Problem, we construct a flow network G  as shown in Figure 7.9. First we
direct all edges in G from X to Y. We then add a node s, and an edge (s, x)
from s to each node in X. We add a node t, and an edge (y, t) from each node
in Y to t. Finally, we give each edge in G  a capacity of 1.
We now compute a maximum s-t flow in this network G . We will discover
that the value of this maximum is equal to the size of the maximum matching
in G. Moreover, our analysis will show how one can use the flow itself to
recover the matching.

s t

(a) (b)

Figure 7.9 (a) A bipartite graph. (b) The corresponding flow network, with all capacities
equal to 1.
7.5 A First Application: The Bipartite Matching Problem 369

Analyzing the Algorithm


The analysis is based on showing that integer-valued flows in G  encode
matchings in G in a fairly transparent fashion. First, suppose there is a
matching in G consisting of k edges (xi1 , yi1), . . . , (xik , yik ). Then consider the
flow f that sends one unit along each path of the form s, xij , yij , t—that is,
f (e) = 1 for each edge on one of these paths. One can verify easily that the
capacity and conservation conditions are indeed met and that f is an s-t flow
of value k.
Conversely, suppose there is a flow f  in G  of value k. By the integrality
theorem for maximum flows (7.14), we know there is an integer-valued flow f
of value k; and since all capacities are 1, this means that f (e) is equal to either
0 or 1 for each edge e. Now, consider the set M  of edges of the form (x, y) on
which the flow value is 1.
Here are three simple facts about the set M .

(7.34) M  contains k edges.

Proof. To prove this, consider the cut (A, B) in G  with A = {s} ∪ X. The value
of the flow is the total flow leaving A, minus the total flow entering A. The
first of these terms is simply the cardinality of M , since these are the edges
leaving A that carry flow, and each carries exactly one unit of flow. The second
of these terms is 0, since there are no edges entering A. Thus, M  contains k
edges.

(7.35) Each node in X is the tail of at most one edge in M .

Proof. To prove this, suppose x ∈ X were the tail of at least two edges in M .
Since our flow is integer-valued, this means that at least two units of flow
leave from x. By conservation of flow, at least two units of flow would have
to come into x—but this is not possible, since only a single edge of capacity 1
enters x. Thus x is the tail of at most one edge in M .

By the same reasoning, we can show

(7.36) Each node in Y is the head of at most one edge in M .

Combining these facts, we see that if we view M  as a set of edges in the


original bipartite graph G, we get a matching of size k. In summary, we have
proved the following fact.

(7.37) The size of the maximum matching in G is equal to the value of the
maximum flow in G ; and the edges in such a matching in G are the edges that
carry flow from X to Y in G .
370 Chapter 7 Network Flow

Note the crucial way in which the integrality theorem (7.14) figured in
this construction: we needed to know if there is a maximum flow in G  that
takes only the values 0 and 1.

Bounding the Running Time Now let’s consider how quickly we can com-
pute a maximum matching in G. Let n = |X| = |Y|, and let m be the number
of edges of G. We’ll tacitly assume that there is at least one edge incident to
each node in the original problem, and hence m ≥ n/2. The time to compute
a maximum matching is dominated by the time to compute an integer-valued
maximum flow in G , since converting this to a matching in G is simple. For

this flow problem, we have that C = e out of s ce = |X| = n, as s has an edge
of capacity 1 to each node of X. Thus, by using the O(mC) bound in (7.5), we
get the following.

(7.38) The Ford-Fulkerson Algorithm can be used to find a maximum match-


ing in a bipartite graph in O(mn) time.

It’s interesting that if we were to use the “better” bounds of O(m2 log2 C) or
O(n3) that we developed in the previous sections, we’d get the inferior running
times of O(m2 log n) or O(n3) for this problem. There is nothing contradictory
in this. These bounds were designed to be good for all instances, even when C
is very large relative to m and n. But C = n for the Bipartite Matching Problem,
and so the cost of this extra sophistication is not needed.
It is worthwhile to consider what the augmenting paths mean in the
network G . Consider the matching M consisting of edges (x2 , y2), (x3, y3),
and (x5 , y5) in the bipartite graph in Figure 7.1; see also Figure 7.10. Let f
be the corresponding flow in G . This matching is not maximum, so f is not
a maximum s-t flow, and hence there is an augmenting path in the residual
graph Gf . One such augmenting path is marked in Figure 7.10(b). Note that
the edges (x2 , y2) and (x3, y3) are used backward, and all other edges are used
forward. All augmenting paths must alternate between edges used backward
and forward, as all edges of the graph G  go from X to Y. Augmenting paths
are therefore also called alternating paths in the context of finding a maximum
matching. The effect of this augmentation is to take the edges used backward
out of the matching, and replace them with the edges going forward. Because
the augmenting path goes from s to t, there is one more forward edge than
backward edge; thus the size of the matching increases by one.
7.5 A First Application: The Bipartite Matching Problem 371

x1 y1 x1 y1 x1 y1

x2 y2 x2 y2 x2 y2

x3 y3 x3 y3 x3 y3

x4 y4 x4 y4 x4 y4

x5 y5 x5 y5 x5 y5

(a) (b) (c)

Figure 7.10 (a) A bipartite graph, with a matching M. (b) The augmenting path in the
corresponding residual graph. (c) The matching obtained by the augmentation.

Extensions: The Structure of Bipartite Graphs with


No Perfect Matching
Algorithmically, we’ve seen how to find perfect matchings: We use the algo-
rithm above to find a maximum matching and then check to see if this matching
is perfect.
But let’s ask a slightly less algorithmic question. Not all bipartite graphs
have perfect matchings. What does a bipartite graph without a perfect match-
ing look like? Is there an easy way to see that a bipartite graph does not have a
perfect matching—or at least an easy way to convince someone the graph has
no perfect matching, after we run the algorithm? More concretely, it would be
nice if the algorithm, upon concluding that there is no perfect matching, could
produce a short “certificate” of this fact. The certificate could allow someone
to be quickly convinced that there is no perfect matching, without having to
look over a trace of the entire execution of the algorithm.
One way to understand the idea of such a certificate is as follows. We can
decide if the graph G has a perfect matching by checking if the maximum flow
in a related graph G  has value at least n. By the Max-Flow Min-Cut Theorem,
there will be an s-t cut of capacity less than n if the maximum-flow value in
G  has value less than n. So, in a way, a cut with capacity less than n provides
such a certificate. However, we want a certificate that has a natural meaning
in terms of the original graph G.
What might such a certificate look like? For example, if there are nodes
x1, x2 ∈ X that have only one incident edge each, and the other end of each
edge is the same node y, then clearly the graph has no perfect matching: both
x1 and x2 would need to get matched to the same node y. More generally,
consider a subset of nodes A ⊆ X, and let (A) ⊆ Y denote the set of all nodes
372 Chapter 7 Network Flow

that are adjacent to nodes in A. If the graph has a perfect matching, then each
node in A has to be matched to a different node in (A), so (A) has to be at
least as large as A. This gives us the following fact.

(7.39) If a bipartite graph G = (V , E) with two sides X and Y has a perfect


matching, then for all A ⊆ X we must have |(A)| ≥ |A|.

This statement suggests a type of certificate demonstrating that a graph


does not have a perfect matching: a set A ⊆ X such that |(A)| < |A|. But is the
converse of (7.39) also true? Is it the case that whenever there is no perfect
matching, there is a set A like this that proves it? The answer turns out to
be yes, provided we add the obvious condition that |X| = |Y| (without which
there could certainly not be a perfect matching). This statement is known
in the literature as Hall’s Theorem, though versions of it were discovered
independently by a number of different people—perhaps first by König—in
the early 1900s. The proof of the statement also provides a way to find such a
subset A in polynomial time.

(7.40) Assume that the bipartite graph G = (V , E) has two sides X and Y
such that |X| = |Y|. Then the graph G either has a perfect matching or there is
a subset A ⊆ X such that |(A)| < |A|. A perfect matching or an appropriate
subset A can be found in O(mn) time.

Proof. We will use the same graph G  as in (7.37). Assume that |X| = |Y| = n.
By (7.37) the graph G has a maximum matching if and only if the value of the
maximum flow in G  is n.
We need to show that if the value of the maximum flow is less than n,
then there is a subset A such that |(A)| < |A|, as claimed in the statement.
By the Max-Flow Min-Cut Theorem (7.12), if the maximum-flow value is less
than n, then there is a cut (A , B) with capacity less than n in G . Now the
set A contains s, and may contain nodes from both X and Y as shown in
Figure 7.11. We claim that the set A = X ∩ A has the claimed property. This
will prove both parts of the statement, as we’ve seen in (7.11) that a minimum
cut (A , B) can also be found by running the Ford-Fulkerson Algorithm.
First we claim that one can modify the minimum cut (A , B) so as to
ensure that (A) ⊆ A, where A = X ∩ A as before. To do this, consider a node
y ∈ (A) that belongs to B as shown in Figure 7.11(a). We claim that by moving
y from B to A, we do not increase the capacity of the cut. For what happens
when we move y from B to A? The edge (y, t) now crosses the cut, increasing
the capacity by one. But previously there was at least one edge (x, y) with
x ∈ A, since y ∈ (A); all edges from A and y used to cross the cut, and don’t
anymore. Thus, overall, the capacity of the cut cannot increase. (Note that we
7.6 Disjoint Paths in Directed and Undirected Graphs 373

Node y can be moved


to the s-side of the cut.

A
A� A�

s x y t s x y t

(a) (b)

Figure 7.11 (a) A minimum cut in proof of (7.40). (b) The same cut after moving node
y to the A side. The edges crossing the cut are dark.

don’t have to be concerned about nodes x ∈ X that are not in A. The two ends
of the edge (x, y) will be on different sides of the cut, but this edge does not
add to the capacity of the cut, as it goes from B to A.)
Next consider the capacity of this minimum cut (A , B) that has (A) ⊆ A
as shown in Figure 7.11(b). Since all neighbors of A belong to A, we see that
the only edges out of A are either edges that leave the source s or that enter
the sink t. Thus the capacity of the cut is exactly

c(A , B) = |X ∩ B| + |Y ∩ A|.

Notice that |X ∩ B| = n − |A|, and |Y ∩ A| ≥ |(A)|. Now the assumption that
c(A , B) < n implies that

n − |A| + |(A)| ≤ |X ∩ B| + |Y ∩ A| = c(A , B) < n.

Comparing the first and the last terms, we get the claimed inequality |A| >
|(A)|.

7.6 Disjoint Paths in Directed and


Undirected Graphs
In Section 7.1, we described a flow f as a kind of “traffic” in the network.
But our actual definition of a flow has a much more static feel to it: For each
edge e, we simply specify a number f (e) saying the amount of flow crossing e.
Let’s see if we can revive the more dynamic, traffic-oriented picture a bit, and
try formalizing the sense in which units of flow “travel” from the source to
7.6 Disjoint Paths in Directed and Undirected Graphs 373

Node y can be moved


to the s-side of the cut.

A
A� A�

s x y t s x y t

(a) (b)

Figure 7.11 (a) A minimum cut in proof of (7.40). (b) The same cut after moving node
y to the A side. The edges crossing the cut are dark.

don’t have to be concerned about nodes x ∈ X that are not in A. The two ends
of the edge (x, y) will be on different sides of the cut, but this edge does not
add to the capacity of the cut, as it goes from B to A.)
Next consider the capacity of this minimum cut (A , B) that has (A) ⊆ A
as shown in Figure 7.11(b). Since all neighbors of A belong to A, we see that
the only edges out of A are either edges that leave the source s or that enter
the sink t. Thus the capacity of the cut is exactly

c(A , B) = |X ∩ B| + |Y ∩ A|.

Notice that |X ∩ B| = n − |A|, and |Y ∩ A| ≥ |(A)|. Now the assumption that
c(A , B) < n implies that

n − |A| + |(A)| ≤ |X ∩ B| + |Y ∩ A| = c(A , B) < n.

Comparing the first and the last terms, we get the claimed inequality |A| >
|(A)|.

7.6 Disjoint Paths in Directed and


Undirected Graphs
In Section 7.1, we described a flow f as a kind of “traffic” in the network.
But our actual definition of a flow has a much more static feel to it: For each
edge e, we simply specify a number f (e) saying the amount of flow crossing e.
Let’s see if we can revive the more dynamic, traffic-oriented picture a bit, and
try formalizing the sense in which units of flow “travel” from the source to
374 Chapter 7 Network Flow

the sink. From this more dynamic view of flows, we will arrive at something
called the s-t Disjoint Paths Problem.

The Problem
In defining this problem precisely, we will deal with two issues. First, we will
make precise this intuitive correspondence between units of flow traveling
along paths, and the notion of flow we’ve studied so far. Second, we will
extend the Disjoint Paths Problem to undirected graphs. We’ll see that, despite
the fact that the Maximum-Flow Problem was defined for a directed graph, it
can naturally be used also to handle related problems on undirected graphs.
We say that a set of paths is edge-disjoint if their edge sets are disjoint, that
is, no two paths share an edge, though multiple paths may go through some
of the same nodes. Given a directed graph G = (V , E) with two distinguished
nodes s, t ∈ V, the Directed Edge-Disjoint Paths Problem is to find the maximum
number of edge-disjoint s-t paths in G. The Undirected Edge-Disjoint Paths
Problem is to find the maximum number of edge-disjoint s-t paths in an
undirected graph G. The related question of finding paths that are not only
edge-disjoint, but also node-disjoint (of course, other than at nodes s and t)
will be considered in the exercises to this chapter.

Designing the Algorithm


Both the directed and the undirected versions of the problem can be solved
very naturally using flows. Let’s start with the directed problem. Given the
graph G = (V , E), with its two distinguished nodes s and t, we define a flow
network in which s and t are the source and sink, respectively, and with a
capacity of 1 on each edge. Now suppose there are k edge-disjoint s-t paths.
We can make each of these paths carry one unit of flow: We set the flow to be
f (e) = 1 for each edge e on any of the paths, and f (e ) = 0 on all other edges,
and this defines a feasible flow of value k.
(7.41) If there are k edge-disjoint paths in a directed graph G from s to t, then
the value of the maximum s-t flow in G is at least k.
Suppose we could show the converse to (7.41) as well: If there is a flow
of value k, then there exist k edge-disjoint s-t paths. Then we could simply
compute a maximum s-t flow in G and declare (correctly) this to be the
maximum number of edge-disjoint s-t paths.
We now proceed to prove this converse statement, confirming that this
approach using flow indeed gives us the correct answer. Our analysis will
also provide a way to extract k edge-disjoint paths from an integer-valued
flow sending k units from s to t. Thus computing a maximum flow in G will
7.6 Disjoint Paths in Directed and Undirected Graphs 375

not only give us the maximum number of edge-disjoint paths, but the paths
as well.

Analyzing the Algorithm


Proving the converse direction of (7.41) is the heart of the analysis, since it
will immediately establish the optimality of the flow-based algorithm to find
disjoint paths.
To prove this, we will consider a flow of value at least k, and construct k
edge-disjoint paths. By (7.14), we know that there is a maximum flow f with
integer flow values. Since all edges have a capacity bound of 1, and the flow
is integer-valued, each edge that carries flow under f has exactly one unit of
flow on it. Thus we just need to show the following.

(7.42) If f is a 0-1 valued flow of value ν, then the set of edges with flow
value f (e) = 1 contains a set of ν edge-disjoint paths.

Proof. We prove this by induction on the number of edges in f that carry flow.
If ν = 0, there is nothing to prove. Otherwise, there must be an edge (s, u) that
carries one unit of flow. We now “trace out” a path of edges that must also
carry flow: Since (s, u) carries a unit of flow, it follows by conservation that
there is some edge (u, v) that carries one unit of flow, and then there must be
an edge (v, w) that carries one unit of flow, and so forth. If we continue in this
way, one of two things will eventually happen: Either we will reach t, or we
will reach a node v for the second time.
If the first case happens—we find a path P from s to t—then we’ll use this
path as one of our ν paths. Let f  be the flow obtained by decreasing the flow
values on the edges along P to 0. This new flow f  has value ν − 1, and it has
fewer edges that carry flow. Applying the induction hypothesis for f , we get
ν − 1 edge-disjoint paths, which, along with path P, form the ν paths claimed.
If P reaches a node v for the second time, then we have a situation like
the one pictured in Figure 7.12. (The edges in the figure all carry one unit of
flow, and the dashed edges indicate the path traversed so far, which has just
reached a node v for the second time.) In this case, we can make progress in
a different way.
Consider the cycle C of edges visited between the first and second appear-
ances of v. We obtain a new flow f  from f by decreasing the flow values on
the edges along C to 0. This new flow f  has value ν, but it has fewer edges that
carry flow. Applying the induction hypothesis for f , we get the ν edge-disjoint
paths as claimed.
376 Chapter 7 Network Flow

Flow around a cycle


can be zeroed out.

t
P
s

Figure 7.12 The edges in the figure all carry one unit of flow. The path P of dashed
edges is one possible path in the proof of (7.42).

We can summarize (7.41) and (7.42) in the following result.

(7.43) There are k edge-disjoint paths in a directed graph G from s to t if and


only if the value of the maximum value of an s-t flow in G is at least k.

Notice also how the proof of (7.42) provides an actual procedure for
constructing the k paths, given an integer-valued maximum flow in G. This
procedure is sometimes referred to as a path decomposition of the flow, since it
“decomposes” the flow into a constituent set of paths. Hence we have shown
that our flow-based algorithm finds the maximum number of edge-disjoint s-t
paths and also gives us a way to construct the actual paths.

Bounding the Running Time For this flow problem, C = e out of s ce ≤
|V| = n, as there are at most |V| edges out of s, each of which has capac-
ity 1. Thus, by using the O(mC) bound in (7.5), we get an integer maximum
flow in O(mn) time.
The path decomposition procedure in the proof of (7.42), which produces
the paths themselves, can also be made to run in O(mn) time. To see this, note
that this procedure, with a little care, can produce a single path from s to t
using at most constant work per edge in the graph, and hence in O(m) time.
Since there can be at most n − 1 edge-disjoint paths from s to t (each must
use a different edge out of s), it therefore takes time O(mn) to produce all the
paths.
In summary, we have shown

(7.44) The Ford-Fulkerson Algorithm can be used to find a maximum set of


edge-disjoint s-t paths in a directed graph G in O(mn) time.

A Version of the Max-Flow Min-Cut Theorem for Disjoint Paths The Max-
Flow Min-Cut Theorem (7.13) can be used to give the following characteri-
7.6 Disjoint Paths in Directed and Undirected Graphs 377

zation of the maximum number of edge-disjoint s-t paths. We say that a set
F ⊆ E of edges separates s from t if, after removing the edges F from the graph
G, no s-t paths remain in the graph.

(7.45) In every directed graph with nodes s and t, the maximum number of
edge-disjoint s-t paths is equal to the minimum number of edges whose removal
separates s from t.

Proof. If the removal of a set F ⊆ E of edges separates s from t, then each s-t
path must use at least one edge from F, and hence the number of edge-disjoint
s-t paths is at most |F|.
To prove the other direction, we will use the Max-Flow Min-Cut Theorem
(7.13). By (7.43) the maximum number of edge-disjoint paths is the value ν
of the maximum s-t flow. Now (7.13) states that there is an s-t cut (A, B) with
capacity ν. Let F be the set of edges that go from A to B. Each edge has capacity
1, so |F| = ν and, by the definition of an s-t cut, removing these ν edges from
G separates s from t.

This result, then, can be viewed as the natural special case of the Max-
Flow Min-Cut Theorem in which all edge capacities are equal to 1. In fact,
this special case was proved by Menger in 1927, much before the full Max-
Flow Min-Cut Theorem was formulated and proved; for this reason, (7.45)
is often called Menger’s Theorem. If we think about it, the proof of Hall’s
Theorem (7.40) for bipartite matchings involves a reduction to a graph with
unit-capacity edges, and so it can be proved using Menger’s Theorem rather
than the general Max-Flow Min-Cut Theorem. In other words, Hall’s Theorem
is really a special case of Menger’s Theorem, which in turn is a special case
of the Max-Flow Min-Cut Theorem. And the history follows this progression,
since they were discovered in this order, a few decades apart.2

Extensions: Disjoint Paths in Undirected Graphs


Finally, we consider the disjoint paths problem in an undirected graph G.
Despite the fact that our graph G is now undirected, we can use the maximum-
flow algorithm to obtain edge-disjoint paths in G. The idea is quite simple: We
replace each undirected edge (u, v) in G by two directed edges (u, v) and

2 In fact, in an interesting retrospective written in 1981, Menger relates his version of the story of how
he first explained his theorem to König, one of the independent discoverers of Hall’s Theorem. You
might think that König, having thought a lot about these problems, would have immediately grasped
why Menger’s generalization of his theorem was true, and perhaps even considered it obvious. But, in
fact, the opposite happened; König didn’t believe it could be right and stayed up all night searching
for a counterexample. The next day, exhausted, he sought out Menger and asked him for the proof.
378 Chapter 7 Network Flow

(v, u), and in this way create a directed version G  of G. (We may delete the
edges into s and out of t, since they are not useful.) Now we want to use the
Ford-Fulkerson Algorithm in the resulting directed graph. However, there is an
important issue we need to deal with first. Notice that two paths P1 and P2 may
be edge-disjoint in the directed graph and yet share an edge in the undirected
graph G: This happens if P1 uses directed edge (u, v) while P2 uses edge (v, u).
However, it is not hard to see that there always exists a maximum flow in any
network that uses at most one out of each pair of oppositely directed edges.

(7.46) In any flow network, there is a maximum flow f where for all opposite
directed edges e = (u, v) and e  = (v, u), either f (e) = 0 or f (e ) = 0. If the
capacities of the flow network are integral, then there also is such an integral
maximum flow.

Proof. We consider any maximum flow f , and we modify it to satisfy the


claimed condition. Assume e = (u, v) and e  = (v, u) are opposite directed
edges, and f (e)  = 0, f (e )  = 0. Let δ be the smaller of these values, and modify
f by decreasing the flow value on both e and e  by δ. The resulting flow f  is
feasible, has the same value as f , and its value on one of e and e  is 0.

Now we can use the Ford-Fulkerson Algorithm and the path decomposition
procedure from (7.42) to obtain edge-disjoint paths in the undirected graph G.

(7.47) There are k edge-disjoint paths in an undirected graph G from s to t


if and only if the maximum value of an s-t flow in the directed version G  of G
is at least k. Furthermore, the Ford-Fulkerson Algorithm can be used to find a
maximum set of disjoint s-t paths in an undirected graph G in O(mn) time.

The undirected analogue of (7.45) is also true, as in any s-t cut, at most
one of the two oppositely directed edges can cross from the s-side to the t-
side of the cut (for if one crosses, then the other must go from the t-side to
the s-side).

(7.48) In every undirected graph with nodes s and t, the maximum number of
edge-disjoint s-t paths is equal to the minimum number of edges whose removal
separates s from t.

7.7 Extensions to the Maximum-Flow Problem


Much of the power of the Maximum-Flow Problem has essentially nothing to
do with the fact that it models traffic in a network. Rather, it lies in the fact
that many problems with a nontrivial combinatorial search component can

You might also like