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算法。DBSCAN算法(遞歸邏輯)
我想問一下這個確切的部分。
NeighborPts = NeighborPts joined with NeighborPts'
我的理解是,如果被訪問從核心點的鄰居的核心點,將被加入到當前檢查組,對不對?但是遞歸如何在這裏發生?因爲我們已經定義的循環:加盟,所以任何額外的NeighborPts點的過程之前
for each point P' in NeighborPts
不會被expandCluster功能檢查,如果新NeighborPts'實際上有一個點是另一個核心點指向同一個羣集,算法如何進行?
我有「expandCluster」方法在Java中實現代碼:
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);
修改後要重新審視?
非常感謝你,我不知道'addAll()'可以產生這種行爲,它讓我對遞歸感到困惑。 – neovee