title: DBSCAN algorithm (recursion logic)
body: <pre><code>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) &lt; 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') &gt;= 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
  </code></pre>
  
  <p>Above is. as you can see, the algorithm  of DBSCAN according to Wikipedia.</p>
  
  <p>I want to ask about this exact part.</p>
  
  <pre><code>      NeighborPts = NeighborPts joined with NeighborPts'
  </code></pre>
  
  <p>My understanding was that if a core point from a neighbor of core point is visited, it will be joined to the currently examined cluster, right? But how does the recursion happen here? Because we has defined the loop of:</p>
  
  <pre><code>   for each point P' in NeighborPts 
  </code></pre>
  
  <p>before the process of the joining, so any additional point from NeighborPts' won't be examined by the expandCluster function and if the new NeighborPts' actually has a point that is an another core point to the same cluster, how does the algorithm proceed? </p>
  
  <p>I have a code with the implementation of 'expandCluster' method in Java:</p>
  
  <pre><code>public void expand(Vector&lt;Integer&gt; region, Group c, double dist, int minPts){
      for(int i = 0; i &lt; region.size(); i++){
          int idx = region.get(i);
          if(labels[idx] == 0){                         // check if point is visited
              labels[idx] = 1;                          // mark as visited
              Vector&lt;Integer&gt; v = region(idx, dist);    // check for neighboring point
              if (v.size() &gt;= 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;
          }
      }
  }
  </code></pre>
  
  <p>Will the data collection <code>region</code> going to be revisited after the modification of the data collection through this code <code>region.addAll(v);</code>? </p>