Algorithm Design
Algorithm Design
Algorithm Design
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
4O8<br />
Chapter 7 Network Flow<br />
Why are such prices useful? Intuitively, compatible prices suggest that the<br />
matching is cheap: Along the matched edges reward equals cost, while on<br />
all other edges the reward is no bigger than the cost. For a partial matching,<br />
this may not imply that the matching has the smallest possible cost for its<br />
size (it may be taking care of expensive jobs). However, we claim that if M<br />
is any matching for which there exists a set of compatible prices, then GM<br />
has no negative cycles. For a perfect matching M, this will imply that M is of<br />
minimum cost by (7.63).<br />
To see why G M can have no negative cycles, we extend the definition of<br />
reduced cost to edges in the residual graph by using the same expression<br />
~ =p(v)+ c e -p(w) for any edge e = (v, w). Observe that the definition<br />
of compatible prices implies that all edges in the residual graph GM have<br />
nonnegafive reduced costs. Now, note that for any cycle C, we have<br />
cost(c) = E = E<br />
eEC<br />
since all the terms on the right-hand side corresponding to prices cancel out.<br />
We know that each term on the right-hand side is nonnegafive, and so clearly<br />
cost(C) is nonnegafive.<br />
There is a second, algorithmic reason why it is usefnl to have prices on<br />
the nodes. When you have a graph with negative-cost edges but no negative<br />
cycles, you can compute shortest paths using the Bellman-Ford <strong>Algorithm</strong> in<br />
O(mn) time. But if the graph in fact has no negative-cost edges, then you can<br />
use Diikstra’s <strong>Algorithm</strong> instead, which only requires time O(m log n)--almost<br />
a full factor of n faster.<br />
In our case, having the prices around allows us to compute shortest paths<br />
with respect to the nonnegafive reduced costs ~, arriving at an equivalent<br />
answer. Indeed, suppose we use Diikstra’s <strong>Algorithm</strong> to find the minimum<br />
cost dp,M(U) of a directed path from s to every node u ~ X U Y subje.ct to the<br />
costs ~. Given the minimum costs dp,M(Y) for an unmatched node y ~ Y, the<br />
(nonreduced) cost of the path from s to t through y is dp,M(Y) + P(Y), and so<br />
we find the minimum cost in O(n) additional time. In summary, we have the<br />
following fact.<br />
(7.64) Let M be a matching, and p be compatible prices. We can use one<br />
run of Dijkstra’s <strong>Algorithm</strong> and O(n ) extra time to find the minimum-cost path<br />
from s to t.<br />
Updating the Node Prices We took advantage of the prices to improve one<br />
iteration of the algorithm. In order to be ready for the next iteration, we need<br />
not only the minimum-cost path (to get the next matching), but also a way to<br />
produce a set of compatible prices with respect to the new matching.<br />
7.13 A Further Direction: Adding Costs to the Matching Problem<br />
Figure 7.22 A matching M (the dark edges), and a residual graph used to increase the<br />
size of the matching.<br />
To get some intuition on how to do this, consider an unmatched node x<br />
with respect to a matching M, and an edge e = (x, y), as shown in Figure 7.22.<br />
If the new matching M’ includes edge e (that is, if e is on the augmenting<br />
path we use to update the matching), then we will want to have the reduced<br />
cost of this edge to be zero. However, the prices p we used with matching M<br />
may result in a reduced cost ~ > 0 -- that is, the assignment of person x to<br />
job y, in our economic interpretation, may not be viewed as cheap enough.<br />
We can arrange the zero reduced cost by either increasing the price p(y)<br />
reward) by ~, or by decreasing the price p(x) by the same amount. To keep<br />
prices nonnegative, we will increase the price p(y). However, node y may be<br />
matched in the matching M to some other node x’ via an edge e’ = (x’, y), as<br />
shown in Figure 7.22. Increasing the reward p(y) decreases the reduced cost<br />
of edge e’ to negative, and hence the prices are no longer compatible. To keep<br />
things compatible, we can increase p(x’) by the same amount. However, this<br />
change might cause problems on other edges. Can we update all prices and<br />
keep the matching and the prices compatible on all edges? Surprisingly, this<br />
can be done quite simply by using the distances from s to all other nodes<br />
computed by Dijkstra’s <strong>Algorithm</strong>.<br />
(7.6S) Let M be a matching, let p be compatible prices, and let M’ be a<br />
matching obtained by augmenting along the minimum-cost path from s to t.<br />
Then p’ (v) = dp,M(V ) + p(v) is a compatible set of prices for M’.<br />
Proof. To prove compatibility, consider first an edge e =,(x’, y) ~ M. The only<br />
edge entering x’ is the directed edge 0~, x’), and hence dp,M(x’) = dp,M(y) --<br />
~, where ~=p(y)+c e -p(x’), and thus we get the desired equation on<br />
such edges. Next consider edges (x, y) in M’-M. These edges are along the<br />
minimum-cost path from s to t, and hence they satisfy dp,M(y ) = dp,M(X ) + ~<br />
as desired. Finally, we get the required inequality for all other edges since all<br />
edges e = (x,y) ~M must satisfy dp,M(y ) < dp,M(X ) + ~. []<br />
409