### Midterm Exam. (Special topics on graph algorithms)

### Instructor: Kun-Mao Chao

### April 15, 2004

*Unless specified explicitly, a graph G is assumed to be simple and undirected, and the edge weights are*
nonnegative.

*1. (10%) Assume the vertex set V = {1, 2, 3, 4, 5, 6, 7}. Decode the following Pr¨*ufer sequences: (a)

*P = (1, 2, 3, 4, 5), and (b) P = (1, 1, 3, 5, 7).*

*2. (10%) Let F*1*, F*2*, . . . , Fk* *be a spanning forest of G, and let (u, v) be the smallest of all edges with only*

*one endpoint u ∈ V (F*1*). Prove that there is a minimum spanning tree containing (u, v) among all*

*spanning trees containing all edges in ∪k*

*i=1E(Fi*).

3. (10%) Apply the Bellman-Ford algorithm to Figure 1, and show how it detects the negative cycle in the graph.

Figure 1: A directed graph with a negative-weight cycle.

4. (15%) (a) What is a minimum routing cost spanning tree of a complete graph with unit length on each
*edge? Prove your answer. (b) What is a maximum routing cost spanning tree of a complete graph*
with unit length on each edge? Prove your answer.

5. (10%) (a) Give a tree with two centroids. (b) Show that any tree can have at most two centroids.
*6. (10%) Construct an example where its minimum spanning tree has a routing cost Θ(n) times that of*

a minimum routing cost spanning tree.

7. (15%) Prove that a shortest-paths tree rooted at the median of a graph is a 2-approximation of a minimum routing cost spanning tree of the graph.

*8. (10%) Let P = (p*1*, p*2*, ..., pk*) be a path separator of b*T . It is easy to see that a centroid must be in*

*V (P ). Let pq* be a centroid of b*T . Construct R = SPG(p*1*, pq) ∪ SPG(pq, pk*). In class, we show that

X
*v∈V*
*dG(v, R) ≤*
X
*v∈V*
*dbT(v, P ) + (n/12)w(P ).*

*Explain why we could have the coefficient n/12 instead of n/6 as in the case using only two end vertices*

*p*1 *and pk*.

*9. (10%) We are given a tree T with positive edge weights. Suppose that P = SPT(v*1*, v*2) is a diameter.

*Starting at v*1 *and traveling along the path P , we compute the distance dT(u, v*1*) for each vertex u*

*on the path. Let u*1 *be the last encountered vertex such that dT(v*1*, u*1*) ≤* 12*w(P ) and u*2 be the next

*vertex to u*1*. Prove that u*1 *or u*2is a center of the tree.