Algorithm Design
Algorithm Design
Algorithm Design
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
¯ 406<br />
Chapter 7 Network Flow<br />
Now we would like the resulting matching to have as small a cost as<br />
possible. To achieve this, we will search for a cheap augmenting path with<br />
respect to the fo!lowing natural costs. The edges leaving s and entering t will<br />
have cost 0; an edge e oriented from X to Y will have cost ce (as including this<br />
edge in the path means that we add the edge to M); and an edge e oriented<br />
from Y to X will have cost -ce (as including this edge in the path means that<br />
we delete the edge from M). We will use cost(P) to denote the cost of a path<br />
P in G M. The following statement summarizes this construction.<br />
(7.61) Let M be a matching and P be a path in GM from s to t. Let M’ be the<br />
matching obtained [tom M by augmenting along P. Then IM’I = IMI + 1 and<br />
cost(M’) = cost(M) + cost(P).<br />
Given this statement, it is natural to suggest an algorithm to find a<br />
minimum-cost perfect matching: We iterafively find minimum-cost paths in<br />
GM, and use the paths to augment the matchings. But how can we be sure<br />
that the perfect matching we find is of minimum cost?. Or even worse, is this<br />
algorithm even meaningful?. We can only find minimum-cost paths if we know<br />
that the graph GM has no negative cycles.<br />
Analyzing Negative Cycles In fact, understanding the role of negative cycles<br />
in GM is the key to analyzing the algorithm. First consider the case in which M<br />
is a perfect matching. Note that in this case the node s has no leaving edges,<br />
and t has no entering edges in GM (as our matching is perfect), and hence no<br />
cycle in G M contains s or t.<br />
(7.62) Let M be a perfect matching. I[ there is a negative-cost directed cycle<br />
C in G M, then M is not minimum cost.<br />
Proof. To see this, we use the cycle C for augmentation, iust the same way<br />
we used directed paths to obtain larger matchings. Augmenting M along C<br />
involves swapping edges along C in and out of M. The resulting new perfect<br />
matching M’ has cost cos~ (M’) = cost(M) + cost(C); but cost(C) < 0, and hence<br />
M is not of minimum cost. ¯<br />
More importantly, the converse of this statement is true as well; so in fact<br />
a perfect matching M has minimum cost precisely when there is no negative<br />
cycle in G M.<br />
(7.63) Let M be a perfect matching. I[ there are no negative-cost directed<br />
cycles C in G M, then M is a minimum-cost perfect matching.<br />
Proof. Suppose the statement is not true, and let M’ be a perfect matching of<br />
smaller cost. Consider the set of edges in one of M and M’ but not in both.<br />
7.13 A Further Direction: Adding Costs to the Matching Problem<br />
Observe that this set of edges corresponds to a set of node-disjoint directed<br />
cycles in G M. The cost of the set of directed cycles is exactly cost(M’) - cost(M).<br />
Assuming M’ has smaller cost than M, it must be that at least one of these<br />
cycles has negative cost..,<br />
Our plan is thus to iterate through matchings of larger and larger size,<br />
maintaining the property that the graph GM has no negative cycles in any<br />
iteration. In this way, our computation of a minimum-cost path will always<br />
be well defined; and when we terminate with a perfect matching, we can use<br />
(7.63) to conclude that it has minimum cost.<br />
Maintaining Prices on the Nodes It will help to think about a numericalprice<br />
p(v) associated with each node v. These prices will help both in understanding<br />
how the algorithm runs, and they will also help speed up the implementation.<br />
One issue we have to deal with is to maintain the property that the graph<br />
G M has no negative cycles in any iteration. How do we know that after an<br />
augmentation, the new residual graph still has no negative cycles?. The prices<br />
will turn out to serve as a compact proof to show this.<br />
To understand prices, it helps to keep in mind an economic interpretation<br />
of them. For this pm]~ose, consider the following scenario. Assume that the<br />
set X represents people who need to be assigned to do a set of iobs Y. For an<br />
edge e = (x, y), the cost c e is a cost associated with having person x doing job<br />
y. Now we will think of the price p(x) as an extra bonus we pay for person x to<br />
participate in this system, like a "signing bonus." With this in mind, the cost<br />
for assigning person x to do iob y will become p(x) + ce. On the other hand,<br />
we will think of the price p(y) for nodes y ~ Y as a reward, or value gained by<br />
taking care of iob y (no matter which person in X takes care of it). This way<br />
the "net cost" of assign~g person x to do job y becomes p(x) + ce -p(y): this<br />
is the cost of hiring x for a bonus ofp(x), having him do iob y for a cost of c e,<br />
and then cashing in on the reward p(y). We wil! call this the reduced cost of an<br />
edge e = (x, y) and denote it by ~ = p(x) + c e - p(y). However, it is important<br />
to keep in mind that only the costs c e are part of the problem description; the<br />
prices (bonuses and rewards) wi!l be a way to think about our solution.<br />
Specifically, we say that a set of numbers {p(v) : u ~ V} forms a set of<br />
compatible prices with respect to a matching M if<br />
(i) for all unmatched nodes x ~ X we havep(x) = 0 (that is, people not asked<br />
to do any job do not need to be paid);<br />
(if) for all edges e = (x, y) we have p(x) + Ce >_ P(Y) (that is, every edge has<br />
a nonnegative reduced cost); and<br />
(iii) for all edges e = (x, y) ~ M we have p(x) + c e = p(y) (every edge used in<br />
the assignment has a reduced cost of 0).<br />
407