4#ifndef TRIGTOOLS_TRIG_VSI_DBSCAN
5#define TRIGTOOLS_TRIG_VSI_DBSCAN
17#include <unordered_set>
18#include <unordered_map>
42template<
typename po
intType>
45 using RegionFunc = std::function<std::vector<pointType>(
const pointType&,
double)>;
82template<
typename po
intType>
87 for (
const auto& point :
set) {
96template<
typename po
intType>
106template<
typename po
intType>
111 tmp.insert( tmp.end(), tmp_noise.begin(), tmp_noise.end() );
127template<
typename po
intType>
141template<
typename po
intType>
147 const pointType& point =
pair.first;
149 if (
pair.second )
continue;
151 std::vector<pointType> neighbor_points =
m_regionQuery(point, eps);
152 if ( neighbor_points.size() < minN ) {
157 m_clusters.emplace_back( std::vector<pointType>{point} );
160 for (
size_t i = 0; i < neighbor_points.size(); i++) {
161 const auto& q = neighbor_points[i];
165 auto q_itr_noise =
m_noises.find(q);
166 if ( q_itr_noise !=
m_noises.end() ) {
168 cls.Points().emplace_back(q);
176 if ( q_itr->second )
continue;
177 q_itr->second =
true;
178 cls.Points().emplace_back(q);
180 std::vector<pointType> q_neighbor_points =
m_regionQuery(q, eps);
181 if ( q_neighbor_points.size() >= minN ) neighbor_points.insert( neighbor_points.end(), q_neighbor_points.begin(), q_neighbor_points.end() );
std::vector< T > & Points()
T getPoint(size_t ipt) const
std::vector< T > m_points
Cluster(std::vector< T > &&points)
const std::vector< T > & getPoints() const
Cluster(const std::vector< T > &points)
std::function< std::vector< pointType >(const pointType &, double)> RegionFunc
Function type for region query function.
const Cluster< pointType > & getCluster(size_t) const
Retrieve cluster.
std::vector< Cluster< pointType > > m_noisesCluster
std::unordered_set< pointType > m_noises
void clusterize(double, size_t)
Generate clusters with DBSCAN algorithim.
std::unordered_map< pointType, bool > m_pointsVisited
std::vector< Cluster< pointType > > m_clusters
DBScan & operator=(DBScan &&) noexcept=default
Move assignment operator.
DBScan(const std::unordered_set< pointType > &, RegionFunc)
Normal Constructor.
std::vector< Cluster< int > > getClusters() const
DBScan()
Default constructor.