--- /usr/include/boost/graph/floyd_warshall_shortest.hpp 2008-02-08 17:30:26.000000000 -0800 +++ floyd_warshall_shortest.hpp 2008-03-19 22:48:35.000000000 -0700 @@ -59,15 +59,15 @@ for (tie(k, lastk) = vertices(g); k != lastk; k++) for (tie(i, lasti) = vertices(g); i != lasti; i++) - for (tie(j, lastj) = vertices(g); j != lastj; j++) - { - d[*i][*j] = - detail::min_with_compare(d[*i][*j], - combine(d[*i][*k], d[*k][*j]), - compare); - } + if(d[*i][*k] != inf) + for (tie(j, lastj) = vertices(g); j != lastj; j++) + if(d[*k][*j] != inf) + d[*i][*j] = + detail::min_with_compare(d[*i][*j], + combine(d[*i][*k], d[*k][*j]), + compare); + - for (tie(i, lasti) = vertices(g); i != lasti; i++) if (compare(d[*i][*i], zero)) return false;