private void clusterData ( DBIDs ids , RangeQuery < O > rnnQuery , WritableDoubleDataStore radii , WritableDataStore < ModifiableDBIDs > labels ) { FiniteProgress clustProg = LOG . isVerbose ( ) ? new FiniteProgress ( "Density-Based Clustering" , ids . size ( ) , LOG ) : null ; // Iterate over all objects for ( DBIDIter iter = ids . iter ( ) ; iter . valid ( ) ; iter . advance ( ) ) { if ( labels . get ( iter ) != null ) { continue ; } ModifiableDBIDs newCluster = DBIDUtil . newArray ( ) ; newCluster . add ( iter ) ; labels . put ( iter , newCluster ) ; LOG . incrementProcessed ( clustProg ) ; // container of the points to be added and their radii neighbors to the // cluster ModifiableDBIDs nChain = DBIDUtil . newArray ( ) ; nChain . add ( iter ) ; // iterate over nChain for ( DBIDIter toGetNeighbors = nChain . iter ( ) ; toGetNeighbors . valid ( ) ; toGetNeighbors . advance ( ) ) { double range = radii . doubleValue ( toGetNeighbors ) ; DoubleDBIDList nNeighbors = rnnQuery . getRangeForDBID ( toGetNeighbors , range ) ; for ( DoubleDBIDListIter iter2 = nNeighbors . iter ( ) ; iter2 . valid ( ) ; iter2 . advance ( ) ) { if ( DBIDUtil . equal ( toGetNeighbors , iter2 ) ) { continue ; } if ( labels . get ( iter2 ) == null ) { newCluster . add ( iter2 ) ; labels . put ( iter2 , newCluster ) ; nChain . add ( iter2 ) ; LOG . incrementProcessed ( clustProg ) ; } else if ( labels . get ( iter2 ) != newCluster ) { ModifiableDBIDs toBeDeleted = labels . get ( iter2 ) ; newCluster . addDBIDs ( toBeDeleted ) ; for ( DBIDIter iter3 = toBeDeleted . iter ( ) ; iter3 . valid ( ) ; iter3 . advance ( ) ) { labels . put ( iter3 , newCluster ) ; } toBeDeleted . clear ( ) ; } } } } LOG . ensureCompleted ( clustProg ) ; }
This method applies a density based clustering algorithm .