Created detail subdir.

Moved naive query function into its own header file in detail subdir.
Added header for Yuan Ming Chen's k_means algorithm implementation.



[SVN r45228]
This commit is contained in:
Jonathan Franklin
2008-05-08 20:36:49 +00:00
parent cdf58b4785
commit 64d219039e
3 changed files with 248 additions and 25 deletions

View File

@ -8,6 +8,7 @@
#include <boost/algorithm/cluster/cluster_data.hpp>
#include <boost/algorithm/cluster/concept.hpp>
#include <boost/algorithm/cluster/detail/naive_query.hpp>
#include <vector>
namespace boost
@ -23,29 +24,6 @@ namespace detail
int const UNCLASSIFIED = -1;
int const NOISE = 0;
// TODO: Replace this naive query function w/ R*-tree or fractional cascading.
// This query mechanism makes the runtime quadratic.
template<typename NTupleIterT, typename DistFunT>
static void query(
NTupleIterT const & query_pt,
NTupleIterT const & begin,
NTupleIterT const & end,
typename NTupleIterT::difference_type eps,
DistFunT const & d,
std::vector<NTupleIterT> & v)
{
for(NTupleIterT cur_pt = begin; cur_pt != end; ++cur_pt)
{
if (query_pt == cur_pt)
continue;
if (d(*query_pt->tuple, *cur_pt->tuple) > eps)
continue;
v.push_back(cur_pt);
}
}
// TODO: Replace this so we don't have to store the cluster info for each tuple?
template<typename NTupleIterT>
struct node
@ -107,7 +85,7 @@ dbscan(NTupleIterT const & begin,
// Expand cluster.
std::vector<ntuple_nodes::iterator> seeds;
detail::query(it, tuples.begin(), tuples.end(), eps, d, seeds);
detail::naive_query(it, tuples.begin(), tuples.end(), eps, d, seeds);
// If the neighborhood of this tuple is too small, then mark it as noise.
if (seeds.size() < min_points)
{
@ -137,7 +115,7 @@ dbscan(NTupleIterT const & begin,
seeds.pop_back();
std::vector<ntuple_nodes::iterator> results;
detail::query(cur, tuples.begin(), tuples.end(), eps, d, results);
detail::naive_query(cur, tuples.begin(), tuples.end(), eps, d, results);
if (results.size() >= min_points)
{