#  problems 

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 allpairs shortest path problem on this type of graph. 
2  CLRS Exercise 25.21 on page 699
Run the FloydWarshall algorithm on the weighted, directed graph Show the matrix D^{(k)} that results for each iteration of the outer loop. 
3  CLRS Exercise 24.32 on page 663
Give a simple example of a directed graph with negativeweight edges for which Dijkstra's algorithm produces incorrect answers. 
#  hard problems  

4 
Given a weighted directed graph G=(V,E,p),
where p(e), the weight of edge e,
is the probability that an attempt to traverse that edge is successful.
Any unsuccessful attempt causes instant death.
Describe an efficient algorithm to find a path from the start vertex s to the goal vertex t that maximizes the probability of a successful journey. 

5  CLRS Exercise 24.24 on page 658
Give an efficient algorithm to count the total number of paths in a directed acyclic graph. Analyze your algorithm. 

6  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.


7  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
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. 