Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54044 - trunk/boost/graph
From: jewillco_at_[hidden]
Date: 2009-06-17 21:21:10


Author: jewillco
Date: 2009-06-17 21:21:10 EDT (Wed, 17 Jun 2009)
New Revision: 54044
URL: http://svn.boost.org/trac/boost/changeset/54044

Log:
Fixed relax() to avoid floating point precision issues
Text files modified:
   trunk/boost/graph/relax.hpp | 7 +++++--
   1 files changed, 5 insertions(+), 2 deletions(-)

Modified: trunk/boost/graph/relax.hpp
==============================================================================
--- trunk/boost/graph/relax.hpp (original)
+++ trunk/boost/graph/relax.hpp 2009-06-17 21:21:10 EDT (Wed, 17 Jun 2009)
@@ -48,14 +48,17 @@
       D d_u = get(d, u), d_v = get(d, v);
       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.
       if ( compare(combine(d_u, w_e), d_v) ) {
         put(d, v, combine(d_u, w_e));
         put(p, v, u);
- return true;
+ return compare(get(d, v), d_v);
       } 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 true;
+ return compare(get(d, u), d_u);
       } else
         return false;
     }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk