95 template<
typename INPUT_ITERATOR,
typename DISTANCE_FUNC,
typename OUTPUT_ITERATOR,
typename WEIGHT_FUNC>
96 int DBSCAN(
const INPUT_ITERATOR first,
const INPUT_ITERATOR last, DISTANCE_FUNC distance_func,
97 OUTPUT_ITERATOR result,
const double epsilon,
const double n_min, WEIGHT_FUNC weight_func) {
99 const size_t input_size = std::distance(first, last);
101 std::vector<int> id_cache(input_size, -1);
104 int current_cluster_id = 0;
106 for (INPUT_ITERATOR it = first; it != last; ++it, ++idx) {
109 if (id_cache[idx] >= 0)
continue;
112 std::vector<INPUT_ITERATOR> neighborhood; neighborhood.reserve(input_size);
113 _DBSCAN_PRIVATE::region_query(first, last, it, distance_func, std::back_inserter(neighborhood), epsilon);
115 if (_DBSCAN_PRIVATE::neighborhoodWeight(neighborhood.begin(), neighborhood.end(), weight_func) < n_min) {
120 _DBSCAN_PRIVATE::expand_cluster(first, last, it, distance_func, epsilon, n_min, id_cache, ++current_cluster_id, weight_func);
124 std::copy(id_cache.begin(), id_cache.end(), result);
126 return current_cluster_id;
132 template<
typename INPUT_ITERATOR,
typename DISTANCE_FUNC,
typename OUTPUT_ITERATOR>
133 int DBSCAN(
const INPUT_ITERATOR first,
const INPUT_ITERATOR last, DISTANCE_FUNC distance_func,
134 OUTPUT_ITERATOR result,
const double epsilon,
const double n_min) {
135 return DBSCAN(first, last, distance_func, result, epsilon, n_min,
typename _DBSCAN_PRIVATE::constant_1<typename INPUT_ITERATOR::value_type>());
Namespace providing different geometric functions concerning angles.