Boost logo

Boost-Commit :

From: franklin.jonathan_at_[hidden]
Date: 2008-05-21 18:50:22


Author: jfranklin
Date: 2008-05-21 18:50:22 EDT (Wed, 21 May 2008)
New Revision: 45631
URL: http://svn.boost.org/trac/boost/changeset/45631

Log:
Modified dbscan test program to use new generic euclid_dist function.

Text files modified:
   sandbox/cluster/libs/algorithm/cluster/src/dbscan.cpp | 16 +++++-----------
   1 files changed, 5 insertions(+), 11 deletions(-)

Modified: sandbox/cluster/libs/algorithm/cluster/src/dbscan.cpp
==============================================================================
--- sandbox/cluster/libs/algorithm/cluster/src/dbscan.cpp (original)
+++ sandbox/cluster/libs/algorithm/cluster/src/dbscan.cpp 2008-05-21 18:50:22 EDT (Wed, 21 May 2008)
@@ -1,4 +1,5 @@
 #include <boost/algorithm/cluster/dbscan.hpp>
+#include <boost/algorithm/cluster/dist_func.hpp>
 #include <boost/test/minimal.hpp>
 #include <vector>
 #include <cmath>
@@ -8,15 +9,6 @@
 
 typedef pair<float, float> two_tuple;
 
-static float norm2_dist(two_tuple const & p1, two_tuple const & p2)
-{
- float const d = ::sqrt(
- ::pow(static_cast<double>(p2.first - p1.first), 2.) +
- ::pow(static_cast<double>(p2.second - p1.second), 2.));
-
- return d;
-}
-
 int test_main(int, char *[])
 {
   typedef vector<two_tuple> tuple_data;
@@ -36,7 +28,8 @@
   float eps1 = 0.2f;
   size_t min_points = 3;
   clustering = dbscan<cluster>(
- tuples.begin(), tuples.end(), eps1, min_points, norm2_dist);
+ tuples.begin(), tuples.end(), eps1, min_points,
+ euclid_dist<two_tuple, two_tuple>);
 #if 0
   cerr << "clusters=" << clustering.size() << "\n";
   size_t c = 1;
@@ -59,7 +52,8 @@
 
   float eps2 = 1.01f;
   clustering = dbscan<cluster>(
- tuples.begin(), tuples.end(), eps2, min_points, norm2_dist);
+ tuples.begin(), tuples.end(), eps2, min_points,
+ euclid_dist<two_tuple, two_tuple>);
 
 #if 0
   cerr << "clusters=" << clustering.size() << "\n";


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