private Cluster expandCluster ( final Cluster cluster , final Point2D point , final List < Point2D > neighbors , final KDTree < Point2D > points , final Map < Point2D , PointStatus > visited ) { cluster . addPoint ( point ) ; visited . put ( point , PointStatus . PART_OF_CLUSTER ) ; List < Point2D > seeds = new ArrayList < Point2D > ( neighbors ) ; int index = 0 ; while ( index < seeds . size ( ) ) { Point2D current = seeds . get ( index ) ; PointStatus pStatus = visited . get ( current ) ; // only check non-visited points if ( pStatus == null ) { final List < Point2D > currentNeighbors = getNeighbors ( current , points ) ; if ( currentNeighbors . size ( ) >= minPoints ) { seeds = merge ( seeds , currentNeighbors ) ; } } if ( pStatus != PointStatus . PART_OF_CLUSTER ) { visited . put ( current , PointStatus . PART_OF_CLUSTER ) ; cluster . addPoint ( current ) ; } index ++ ; } return cluster ; }
Expands the cluster to include density - reachable items .