04.09.2013 Views

Algorithm Design

Algorithm Design

Algorithm Design

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

178<br />

Chapter 4 Greedy <strong>Algorithm</strong>s<br />

Figttre 4.18 A directed graph can have many different arborescences. Parts (b) and (c)<br />

depict two different aborescences, both rooted at node r, for the graph in part (a).<br />

(4.t4) A subgraph T = (V, F) of G is an arborescence with respect to root r if<br />

and only if T has no cycles, and for each node v ~ r, there is exactly one edge<br />

in F that enters v.<br />

Proof. If T is an arborescence with root r, then indeed every other node v<br />

has exactly one edge entering it: this is simply the last edge on the unique r-v<br />

path.<br />

Conversely, suppose T has no cycles, and each node v # r has exactly<br />

one entering edge. In order to establish that T is an arborescence, we need<br />

only show that there is a directed path from r to each other node v. Here is<br />

how to construct such a path. We start at v and repeatedly follow edges in<br />

the backward direction. Since T has no cycles, we can never return tO a node<br />

we’ve previously visited, and thus this process must terminate. But r is the<br />

only node without incoming edges, and so the process must in fact terminate<br />

by reaching r; the sequence of nodes thus visited yields a path (in the reverse<br />

direction) from r to v. m<br />

It is easy to see that, just as every connected graph has a spanning tree, a<br />

directed graph has an arborescence rooted at r provided that r can reach every<br />

node. Indeed, in this case, the edges in a breadth-first search tree rooted at r<br />

will form an arborescence.<br />

(4.t5) A directed graph G has an arborescence rooted at r if and only if the¢e<br />

_<br />

4.9 Minimum-Cost Arborescences: A Multi-Phase Greedy <strong>Algorithm</strong><br />

The basic problem we consider here is the following. We are given a<br />

directed graph G = (V, E), with a distinguished root node r and with a nonnegative<br />

cost ce >_ 0 on each edge, and we wish to compute an arborescence<br />

rooted at r of minimum total cost. (We will refer to this as an optimal arborescence.)<br />

We will assume throughout that G at least has an arborescence rooted<br />

at r; by (4.35), this can be easily checked at the outset.<br />

L4~ <strong>Design</strong>ing the <strong>Algorithm</strong><br />

Given the relationship between arborescences and trees, the minimum-cost<br />

arborescence problem certainlyhas a strong initial resemblance to the Minimum<br />

Spanning Tree Problem for undirected graphs. Thus it’s natural to start<br />

by asking whether the ideas we developed for that problem can be carried<br />

over directly to this setting. For example, must the minimum-cost arborescence<br />

contain the cheapest edge in the whole graph? Can we safely delete the<br />

most expensive edge on a cycle, confident that it cannot be in the optimal<br />

arborescence?<br />

Clearly the cheapest edge e in G will not belong to the optimal arborescence<br />

if e enters the root, since the arborescence we’re seeking is not supposed to<br />

have any edges entering the root. But even if the cheapest edge in G belongs<br />

to some arborescence rooted at r, it need not belong to the optimal one, as<br />

the example of Figure 4.19 shows. Indeed, including the edge of cost 1 in<br />

Figure 4.!9 would prevent us from including the edge of cost 2 out of the<br />

root r (since there can only be one entering edge per node); and this in turn<br />

would force us to incur an unacceptable cost of 10 when we included one of<br />

10 10<br />

(a)<br />

Figure 4.19 (a) A directed graph with costs onits edges, and (b) an optimal arborescence<br />

rooted at r for this graph.<br />

2<br />

4<br />

179

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!