From 8cbf7d89aa008879f4c415b7d0f6680bc08078cb Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 5 Sep 2008 14:00:40 +0000 Subject: [PATCH] Merge fix for infinite weights in Floyd-Warshall [SVN r48612] --- include/boost/graph/floyd_warshall_shortest.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/boost/graph/floyd_warshall_shortest.hpp b/include/boost/graph/floyd_warshall_shortest.hpp index 69c3e7ed..6204ca0e 100644 --- a/include/boost/graph/floyd_warshall_shortest.hpp +++ b/include/boost/graph/floyd_warshall_shortest.hpp @@ -59,15 +59,15 @@ namespace boost 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;