54 namespace _DBSCAN_PRIVATE {
56 template<
typename VALUE_TYPE>
59 inline double operator()(VALUE_TYPE it)
const {
64 template<
typename INPUT_ITERATOR,
typename WEIGHT_FUNC>
65 inline double neighborhoodWeight(INPUT_ITERATOR first,
const INPUT_ITERATOR last, WEIGHT_FUNC &weight_func) {
67 for (; first != last; ++first)
68 result += weight_func(**first);
75 template<
typename INPUT_ITERATOR,
typename DISTANCE_FUNC,
typename OUTPUT_ITERATOR>
77 void region_query(INPUT_ITERATOR first,
const INPUT_ITERATOR last,
const INPUT_ITERATOR center,
78 DISTANCE_FUNC &distance_func, OUTPUT_ITERATOR result,
const double epsilon) {
80 for (; first != last; ++first) {
81 if (center == first)
continue;
82 if (distance_func(*center, *first) <= epsilon) {
89 template<
typename INPUT_ITERATOR,
typename DISTANCE_FUNC,
typename WEIGHT_FUNC>
91 void expand_cluster(INPUT_ITERATOR first,
const INPUT_ITERATOR last,
const INPUT_ITERATOR center,
92 DISTANCE_FUNC &distance_func,
const double epsilon,
const double n_min,
93 std::vector<int> &id_cache,
const int current_cluster_id, WEIGHT_FUNC &weight_func) {
96 std::queue<INPUT_ITERATOR> bfq;
99 id_cache[std::distance(first, center)] = current_cluster_id;
101 std::vector<INPUT_ITERATOR> neighborhood; neighborhood.reserve(std::distance(first, last));
103 while (!bfq.empty()) {
105 INPUT_ITERATOR current_element = bfq.front();
112 neighborhood.clear();
113 region_query(first, last, current_element, distance_func, std::back_inserter(neighborhood), epsilon);
119 if (neighborhoodWeight(neighborhood.begin(), neighborhood.end(), weight_func) < n_min)
125 for (
typename std::vector<INPUT_ITERATOR>::iterator it = neighborhood.begin(), it_end = neighborhood.end();
126 it != it_end; ++it) {
127 const size_t neighbor_idx = std::distance(first, *it);
131 if (id_cache[neighbor_idx] <= 0) {
135 id_cache[neighbor_idx] = current_cluster_id;
Namespace providing different geometric functions concerning angles.