From f16a1b114dc11c85ffbfb73f5d0d78ff2472c5da Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Sat, 22 Sep 2012 19:32:32 +0000 Subject: [PATCH] Fixed relax logic to not write predecessor map unless distance was actually changed in memory (although this case will never be hit unless registers have extra precision compared to memory); fixes #7226 [SVN r80639] --- include/boost/graph/relax.hpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/include/boost/graph/relax.hpp b/include/boost/graph/relax.hpp index 9c0d0260..e3866df4 100644 --- a/include/boost/graph/relax.hpp +++ b/include/boost/graph/relax.hpp @@ -53,17 +53,26 @@ namespace boost { const D d_v = get(d, v); const W& w_e = get(w, e); - // The redundant gets in the return statements are to ensure that extra - // floating-point precision in x87 registers does not lead to relax() - // returning true when the distance did not actually change. + // The seemingly redundant comparisons after the distance puts are to + // ensure that extra floating-point precision in x87 registers does not + // lead to relax() returning true when the distance did not actually + // change. if ( compare(combine(d_u, w_e), d_v) ) { put(d, v, combine(d_u, w_e)); - put(p, v, u); - return compare(get(d, v), d_v); + if (compare(get(d, v), d_v)) { + put(p, v, u); + return true; + } else { + return false; + } } else if (is_undirected && compare(combine(d_v, w_e), d_u)) { put(d, u, combine(d_v, w_e)); - put(p, u, v); - return compare(get(d, u), d_u); + if (compare(get(d, u), d_u)) { + put(p, u, v); + return true; + } else { + return false; + } } else return false; }