|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50808 - in trunk: boost/graph libs/graph/doc libs/graph/test
From: jewillco_at_[hidden]
Date: 2009-01-27 13:48:09
Author: jewillco
Date: 2009-01-27 13:48:09 EST (Tue, 27 Jan 2009)
New Revision: 50808
URL: http://svn.boost.org/trac/boost/changeset/50808
Log:
Changed closed_plus to match inf_plus from floyd_warshall_test, changed test to use closed_plus, fixed comments in documentation and replaced std::plus with closed_plus to match implementation, fixes #1164
Text files modified:
trunk/boost/graph/relax.hpp | 9 ++++-----
trunk/libs/graph/doc/floyd_warshall_shortest.html | 12 ++++++------
trunk/libs/graph/test/floyd_warshall_test.cpp | 29 ++++-------------------------
3 files changed, 14 insertions(+), 36 deletions(-)
Modified: trunk/boost/graph/relax.hpp
==============================================================================
--- trunk/boost/graph/relax.hpp (original)
+++ trunk/boost/graph/relax.hpp 2009-01-27 13:48:09 EST (Tue, 27 Jan 2009)
@@ -24,11 +24,10 @@
{
T operator()(const T& a, const T& b) const {
using namespace std;
- T zero(0);
- T result = a + b;
- if (result < zero && a >= zero && b >= zero)
- return (std::numeric_limits<T>::max)();
- return result;
+ const T inf = (std::numeric_limits<T>::max)();
+ if (a == inf) return inf;
+ if (b == inf) return inf;
+ return a + b;
}
};
Modified: trunk/libs/graph/doc/floyd_warshall_shortest.html
==============================================================================
--- trunk/libs/graph/doc/floyd_warshall_shortest.html (original)
+++ trunk/libs/graph/doc/floyd_warshall_shortest.html 2009-01-27 13:48:09 EST (Tue, 27 Jan 2009)
@@ -1,10 +1,10 @@
<HTML>
<!--
- -- Copyright (c) 2002 Rensselaer Polytechnic Institute
- --
- -- Distributed under the Boost Software License, Version 1.0.
- -- (See accompanying file LICENSE_1_0.txt or copy at
- -- http://www.boost.org/LICENSE_1_0.txt)
+ Copyright (c) 2002 Rensselaer Polytechnic Institute
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
-->
<Head>
<Title>Floyd-Warshall All Pairs Shortest Paths</Title>
@@ -127,7 +127,7 @@
The argument types must match the value type of the <code>WeightMap</code>.
The result type must be the same as the distance value type.<br>
-<b>Default:</b> <code>std::plus<WM></code> with <code>WM = typename property_traits<WeightMap>::value_type</code>
+<b>Default:</b> <code>boost::closed_plus<WM></code> with <code>WM = typename property_traits<WeightMap>::value_type</code>
</blockquote>
IN: <code>distance_inf(WM inf)</code>
Modified: trunk/libs/graph/test/floyd_warshall_test.cpp
==============================================================================
--- trunk/libs/graph/test/floyd_warshall_test.cpp (original)
+++ trunk/libs/graph/test/floyd_warshall_test.cpp 2009-01-27 13:48:09 EST (Tue, 27 Jan 2009)
@@ -21,17 +21,6 @@
#include <algorithm>
using namespace boost;
-template <typename T>
-struct inf_plus{
- T operator()(const T& a, const T& b) const {
- T inf = std::numeric_limits<T>::max BOOST_PREVENT_MACRO_SUBSTITUTION();
- if (a == inf || b == inf){
- return inf;
- }
- return a + b;
- }
-};
-
template<typename T>
inline const T& my_min(const T& x, const T& y)
{ return x < y? x : y; }
@@ -125,20 +114,16 @@
bool bellman, floyd1, floyd2, floyd3;
- std::less<int> compare;
- inf_plus<int> combine;
floyd1 =
boost::floyd_warshall_initialized_all_pairs_shortest_paths
(g,
matrix, weight_map(boost::get(boost::edge_weight, g)).
- distance_compare(compare). distance_combine(combine).
distance_inf(int_inf). distance_zero(0));
floyd2 =
boost::floyd_warshall_all_pairs_shortest_paths
(g, matrix3,
- weight_map(local_edge_map). distance_compare(compare).
- distance_combine(combine).
+ weight_map(local_edge_map).
distance_inf(int_inf). distance_zero(0));
floyd3 = boost::floyd_warshall_all_pairs_shortest_paths(g, matrix4);
@@ -153,8 +138,7 @@
(g, vec,
weight_map(boost::get(boost::edge_weight, g)).
distance_map(boost::get(boost::vertex_distance, g)).
- predecessor_map(dummy_map).distance_compare(compare).
- distance_combine(combine));
+ predecessor_map(dummy_map));
distance_row = boost::get(boost::vertex_distance, g);
for(boost::tie(firstv2, lastv2) = vertices(g); firstv2 != lastv2;
firstv2++){
@@ -302,20 +286,16 @@
bool bellman, floyd1, floyd2, floyd3;
- std::less<int> compare;
- inf_plus<int> combine;
floyd1 =
boost::floyd_warshall_initialized_all_pairs_shortest_paths
(g,
matrix, weight_map(boost::get(boost::edge_weight, g)).
- distance_compare(compare). distance_combine(combine).
distance_inf(int_inf). distance_zero(0));
floyd2 =
boost::floyd_warshall_all_pairs_shortest_paths
(g, matrix3,
- weight_map(local_edge_map). distance_compare(compare).
- distance_combine(combine).
+ weight_map(local_edge_map).
distance_inf(int_inf). distance_zero(0));
floyd3 = boost::floyd_warshall_all_pairs_shortest_paths(g, matrix4);
@@ -330,8 +310,7 @@
(g, vec,
weight_map(boost::get(boost::edge_weight, g)).
distance_map(boost::get(boost::vertex_distance, g)).
- predecessor_map(dummy_map).distance_compare(compare).
- distance_combine(combine));
+ predecessor_map(dummy_map));
distance_row = boost::get(boost::vertex_distance, g);
for(boost::tie(firstv2, lastv2) = vertices(g); firstv2 != lastv2;
firstv2++){
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