Skip to main content
. 2018 Oct 12;18(10):3437. doi: 10.3390/s18103437
Algorithm 1 DBSCAN: Density-based spatial clustering of applications with noise
Require:|HN×M|: amplitude of H; MinPts: minimum neighbor number requirement for a central point of a cluster; Eps: neighborhood radius;
Ensure: clustering result C
 1: VisitN×1=[0,0,,.0]T: mark all points in |H| as unvisited points, NoiseN×1=[0,0,,.0]T: mark all points in |H| as non-noise points, IDXN×1=[0,0,,.0]T: mark all points in |H| as the state of not adding any clusters, C=0: initial number of cluster;
 2: Normalize |H|
 3: for each point p in |H| do
 4:   if Visit(p)=0 then
 5:    Visit(p)=1;
 6:    Calculate the Euclidean distance between this point and the other points and get a set of neighbors N1 which have a distance of less than Eps;
 7:    if num(N1)<MinPts then
 8:     Noise(p)=1;
 9:    else
10:     C=C+1;
11:     k=1;
12:     repeat
13:      k=k+1; IDX(k)=C;
14:      if Visit(k)=0 then
15:       Visit(k)=1;
16:       Calculate the Euclidean distance between this point and the other points and get a set of neighbors N2 which have a distance of less than Eps;
17:       if num(N2)>=MinPts then
18:        N1=N1N2; ;
19:       end if
20:      end if
21:      if IDX(k)=0 then
22:       IDX(k)=C
23:      end if
24:     until k>num(N1)
25:    end if
26:   end if
27: end for