(All pairs shortest path distances)

(1) Given directed network G=(N,A) with arc lengths c_ij. Let d_ij be the shortest path distances between the pair (i,j). If length of one arc (x,y) changes to c_xy ' < c_xy. Show algorithm finds modified all pairs shortest path distances.

1: if d_xy+c_xy ' <0 then network has a negative cycle

2: else

3: for each pair (i,j) do

4: d_ij=min[d_ij,d_ix+c_xy ' +d_yj]

(2) Given G=(N,A), suppose after solving all-pairs shortest path problem, you remember that you forgot 5 arcs from network. Show how by reducing the problem to (1) reoptimize network (with addition of arcs) in O(n^2) time.

(1) Given directed network G=(N,A) with arc lengths c_ij. Let d_ij be the shortest path distances between the pair (i,j). If length of one arc (x,y) changes to c_xy ' < c_xy. Show algorithm finds modified all pairs shortest path distances.

1: if d_xy+c_xy ' <0 then network has a negative cycle

2: else

3: for each pair (i,j) do

4: d_ij=min[d_ij,d_ix+c_xy ' +d_yj]

(2) Given G=(N,A), suppose after solving all-pairs shortest path problem, you remember that you forgot 5 arcs from network. Show how by reducing the problem to (1) reoptimize network (with addition of arcs) in O(n^2) time.