47 namespace _DBSCAN_PRIVATE {
49 template<
typename VALUE_TYPE>
52 inline double operator()(VALUE_TYPE it)
const {
57 template<
typename INPUT_ITERATOR,
typename WEIGHT_FUNC>
58 inline double neighborhoodWeight(INPUT_ITERATOR first,
const INPUT_ITERATOR last, WEIGHT_FUNC &weight_func) {
60 for (; first != last; ++first)
61 result += weight_func(**first);
68 template<
typename INPUT_ITERATOR,
typename DISTANCE_FUNC,
typename OUTPUT_ITERATOR>
70 void region_query(INPUT_ITERATOR first,
const INPUT_ITERATOR last,
const INPUT_ITERATOR center,
71 DISTANCE_FUNC &distance_func, OUTPUT_ITERATOR result,
const double epsilon) {
73 for (; first != last; ++first) {
74 if (center == first)
continue;
75 if (distance_func(*center, *first) <= epsilon) {
82 template<
typename INPUT_ITERATOR,
typename DISTANCE_FUNC,
typename WEIGHT_FUNC>
84 void expand_cluster(INPUT_ITERATOR first,
const INPUT_ITERATOR last,
const INPUT_ITERATOR center,
85 DISTANCE_FUNC &distance_func,
const double epsilon,
const double n_min,
86 std::vector<int> &id_cache,
const int current_cluster_id, WEIGHT_FUNC &weight_func) {
89 std::queue<INPUT_ITERATOR> bfq;
92 id_cache[std::distance(first, center)] = current_cluster_id;
94 std::vector<INPUT_ITERATOR> neighborhood; neighborhood.reserve(std::distance(first, last));
96 while (!bfq.empty()) {
98 INPUT_ITERATOR current_element = bfq.front();
105 neighborhood.clear();
106 region_query(first, last, current_element, distance_func, std::back_inserter(neighborhood), epsilon);
112 if (neighborhoodWeight(neighborhood.begin(), neighborhood.end(), weight_func) < n_min)
118 for (
typename std::vector<INPUT_ITERATOR>::iterator it = neighborhood.begin(), it_end = neighborhood.end();
119 it != it_end; ++it) {
120 const size_t neighbor_idx = std::distance(first, *it);
124 if (id_cache[neighbor_idx] <= 0) {
128 id_cache[neighbor_idx] = current_cluster_id;
Namespace providing different geometric functions concerning angles.