# (solution) An algorithm for solving the all-pairs Shortest Path Problem on a (arc- weighted) graph G ( V,E )

An algorithm for solving the all-pairs Shortest Path Problem on a (arc- weighted) graph G ( V,E ) with edge weights a ij for each arc in E computes the quantities and 1 D ij ¼ 8 a ij ; if ð i ; j Þ 2 E i ¼ j : þ1; else ( n k k o 2 k D ij ¼ min m D im þ D mj ; if i 6¼ j ; k ¼ 1; 2; .. .blogð N – 1Þc 0; if i ¼ j ; k ¼ 1; 2; .. .blogð N – 1Þc for all i ; j 2 V (and N = |V| is the total number of nodes in V ). Show that for i 6¼ j ; D k gives the shortest distance from node i to j using paths with 2 k – 1 arcs or fewer. ij