# 关于DBSCAN算法的实现

#1

expandCluster(P, NeighborPts, C, eps, MinPts)里有一个步骤是在循环
“for each point P’ in NeighborPts”中，需要“NeighborPts = NeighborPts joined with NeighborPts”，这里循环的范围变了，怎么在程序里动态的实现这个啊

DBSCAN 需要两个参数：ε (eps) 和形成高密度区域所需要的最少点数 (minPts)，它由一个任意未被访问的点开始，然后探索这个点的 ε-邻域，如果 ε-邻域里有足够的点，则建立一个新的聚类，否则这个点被标签为杂音。注意这个点之后可能被发现在其它点的 ε-邻域里，而该 ε-邻域可能有足够的点，届时这个点会被加入该聚类中。

``````DBSCAN(D, eps, MinPts) {
C = 0
for each point P in dataset D {
if P is visited
continue next point
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) {
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
}
}

regionQuery(P, eps)
return all points within P's eps-neighborhood (including P)
``````

#2

#3