DBSCAN(D, eps, MinPts)
C = 0
for each unvisited point P in dataset D
mark P as visited
NeighborPts = regionQuery(P, eps)
if sizeof(NeighborPts) < MinPts
mark P as NOISE
else
C = next cluster
expandCluster(P, NeighborPts, C, eps, MinPts)
expandCluster(P, NeighborPts, C, eps, MinPts)
add P to cluster C
for each point P' in NeighborPts
if P' is not visited
mark P' as visited
NeighborPts' = regionQuery(P', eps)
if sizeof(NeighborPts') >= MinPts
NeighborPts = NeighborPts joined with NeighborPts'
if P' is not yet member of any cluster
add P' to cluster C
regionQuery(P, eps)
return all points within P's eps-neighborhood
以上是。如您所见,DBSCAN 的算法根据 Wikipedia。
我想问一下这个确切的部分。
NeighborPts = NeighborPts joined with NeighborPts'
我的理解是,如果访问核心点邻居的核心点,它将加入当前检查的集群,对吗?但是这里的递归是如何发生的呢?因为我们已经定义了循环:
for each point P' in NeighborPts
在加入过程之前,因此 expandCluster 函数不会检查来自 NeighborPts' 的任何附加点,如果新的 NeighborPts' 实际上有一个点是同一集群的另一个核心点,那么算法如何进行?
我有一个在 Java 中实现“expandCluster”方法的代码:
public void expand(Vector<Integer> region, Group c, double dist, int minPts){
for(int i = 0; i < region.size(); i++){
int idx = region.get(i);
if(labels[idx] == 0){ // check if point is visited
labels[idx] = 1; // mark as visited
Vector<Integer> v = region(idx, dist); // check for neighboring point
if (v.size() >= minPts){ // check if core point
region.addAll(v); // join the NeighborPts
}
}
if(clustered[idx] == 0){
c.elements.add(patterns.get(idx));
clustered[idx] = clusters.size()+1;
}
}
}
通过此代码修改数据收集region
后是否会重新访问数据收集region.addAll(v);
?