#include<stdio.h>
#include<math.h>
#define TOTALPOINT 12
#define AttSetSize 2
#define MinPts 4
bool Neighbor[TOTALPOINT][TOTALPOINT]; //保存点与点是否相邻的二维数组
int ClusterNo[TOTALPOINT]; //记录每个点属于哪个簇
int CurrentClusterNo=0; //记录当前的簇编号
struct ClusterList //用来存放直接密度可达的点
{
int data[10]; //元素值
int head; //队列头
int tail; //元素长度
};
double DIstance(double DataBase1[],double DataBase2[])
{
int i;
double distance=0;
for(i=0;i<AttSetSize;i++){
distance+=(DataBase1[i]-DataBase2[i])*(DataBase1[i]-DataBase2[i]);
}
distance=sqrt(distance);
return distance;
}
//判断是否为核心对象
bool isCenterObject(int ObjectNum)
{
int NeighborPointsNum=0; //记录邻近的点个数
int j;
//找出该点的邻近点的个数
for(j=0;j<TOTALPOINT;j++)
{
if(Neighbor[ObjectNum][j]==true)
{
NeighborPointsNum++;
}
}
if(NeighborPointsNum>=MinPts)
{
return true;
DBSCAN算法C实现
最新推荐文章于 2024-01-16 17:19:50 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)