code: public List<Cluster> cluster(final Collection<Point2D> points) {
      	final List<Cluster> clusters = new ArrayList<Cluster>();
          final Map<Point2D, PointStatus> visited = new HashMap<Point2D, DBScan.PointStatus>();
  
          KDTree<Point2D> tree = new KDTree<Point2D>(2);
          
          // Populate the kdTree
          for (final Point2D point : points) {
          	double[] key = {point.x, point.y};
          	tree.insert(key, point);
          }
                  
          for (final Point2D point : points) {
              if (visited.get(point) != null) {
                  continue;
              }
              final List<Point2D> neighbors = getNeighbors(point, tree);
              if (neighbors.size() >= minPoints) {
                  // DBSCAN does not care about center points
                  final Cluster cluster = new Cluster(clusters.size());
                  clusters.add(expandCluster(cluster, point, neighbors, tree, visited));
              } else {
                  visited.put(point, PointStatus.NOISE);
              }
          }
  
          for (Cluster cluster : clusters) {
          	cluster.calculateCentroid();
          }
          
          return clusters;
      }
docs: Performs DBSCAN cluster analysis.
  
  @param points the points to cluster
  @return the list of clusters
  @throws NullArgumentException if the data points are null