Homework #8 -- due Monday Wk 10

# required problems topic
1 Suppose you are given a graph in which each vertex has a cost.  The cost of a path from v to w is the sum of the costs of the interior vertices along the path (the costs of v and w are not included in the sum).
Design an algorithm to solve the all-pairs shortest path problem on this type of graph.
shortest path alg
2 CLR Exercise 25.2-1 on page 634 Floyd-Warshall all-pair shortest path alg

# suggested problems topic
3 Baase Exercise 7.32 on page 381 articulation points
4 Baase Exercise 7.48 on pages 384 graph alg - bipartite
5 CLR Exercise 24.2-4 on page 595 graph alg - count paths on DAG
6 [Manber Exercise 10.23a on pp. 339-340]
The transitive closure A* of an n × n matrix A is defined as follows:
A* = I + A + A2 +...An-1, where I is the identity matrix.
Prove that, if A is a Boolean matrix corresponding to an adjacency matrix of a graph, then A* corresponds to the adjacency matrix of the transitive closure of the graph.
(Assume that multiplication is performed according to the Boolean rules.)
transitive closure
7 Consider a DAG with n vertices, labeled by the integers 1 through n.  Call this graph G.  There is an edge from vertex x to vertex y if and only if x > 2y.
  1. How many edges does graph G have as a function of n?
  2. Explain how thetransitive closure of G would be different from G, or why it would not be different.
transitive closure
8 We are given a directed graph G on n vertices.  Give an algorithm to fill in the entries of an n × n matrix M such that
M[i, j] =   the length of the longest path from vertex i to vertex j,
M[i, j] =   -1     if there is no path from i to j and
M[i, j] =   n + 1 if there are paths of unbounded length from i to j.
Analyze the time and space complexity of your algorithm.

Hint:  This problem can be solved by dynamic programming.  Let C[i, j, k] be the length of the longest path from i to j, using no intermediate vertex numbered higher than k.  Obtain a recurrence and boundary conditions for C[i, j, k].  Allow for the possibility that the graph may have some self loops, i.e., edges from a vertex to itself.

all pairs paths


Dan Hirschberg
Computer Science Department
University of California, Irvine, CA 92697-3435
dan at ics.uci.edu
Last modified: Jun 18, 2008