Cs445 — Homework #5
All pairs shortest path, Network Flow, and
Due: 4/5/2005 during class meeting.
) be a graph, with weights assigned to the edges (positive and nega-
tive). Explain how to modify Johnson’s algorithm so the output of the algorithm
matrix that speciFes for every pairs of vertices
, the Frst
edge in the shortest path from
The running time of the algorithm is
The initialization of the matrix FirstEdgeWeight, will be done as
follows: For all
, FirstEdgeWeight[s,v] = w(s,v).
The remaining entries in the matirx will be initialized to
Instead of calling Relax(u,v,w), Dijkstra’s algorithm will make a call to Re-
lax(s,u,v,w), where the starting vertex s is also speci±ed.
The code of Relax(s,u,v,w) is as given below.
The edge (u,v) is added to the
shortest path from s to v, when the values of pi and d are updated inside
the relax procedure.
Thus, the correctness of the procedure follows from the
correctness of Dijkstra’s algorithm.
if( d[v] > d[u] + w(u,v) )
d[v] = d[u] + w(u,v);
pi[v] = u;
FirstEdgeWeight[s,v] = FirstEdgeWeight[s,u];
) is a graph where the weights of all edges are positive. You ran
Johnson algorithm on this graph. What is the values
) and ˆ
) given by
the algorithm ? Prove.