程序流程图:
DBSCAN核心功能函数,计算每个point的eps范围内的point数量pts;
对于所有pts >Minpts的point,记为Core point;
对于所有的corepoint,将其eps范围内的core point下标添加到vector<int>::corepts中;
对于所有的corepoint,采用深度优先的方式遍历core point的所有cluster,使得相互连接的core point具有相同的cluster编号;
计算所有pts < Minpts且在Core point范围内的,记为Borderpoint;
将所有Borderpoint加入到任意一个关联的core point;
剩余的point的为Noise point,文件写写入时忽略;
将point信息写入clustering文件,程序结束。/*
DBSCAN Algorithm
15S103182
Ethan
*/
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <ctime>
#include <cstdlib>
#include <limits>
#include <cmath>
#include <stack>
using namespace std;
class point{
public:
float x;
float y;
int cluster=0;
int pointType=1;//1 noise 2 border 3 core
int pts=0;//points in MinPts
vector<int> corepts;
int visited = 0;
point (