public static int globalCentroid ( Centroid overallCentroid , Relation < ? extends NumberVector > rel , List < ? extends Cluster < ? > > clusters , NumberVector [ ] centroids , NoiseHandling noiseOption ) { int clustercount = 0 ; Iterator < ? extends Cluster < ? > > ci = clusters . iterator ( ) ; for ( int i = 0 ; ci . hasNext ( ) ; i ++ ) { Cluster < ? > cluster = ci . next ( ) ; if ( cluster . size ( ) <= 1 || cluster . isNoise ( ) ) { switch ( noiseOption ) { case IGNORE_NOISE : continue ; // Ignore completely case TREAT_NOISE_AS_SINGLETONS : clustercount += cluster . size ( ) ; // Update global centroid: for ( DBIDIter it = cluster . getIDs ( ) . iter ( ) ; it . valid ( ) ; it . advance ( ) ) { overallCentroid . put ( rel . get ( it ) ) ; } continue ; // With NEXT cluster. case MERGE_NOISE : break ; // Treat as cluster below: } } // Update centroid: assert ( centroids [ i ] != null ) ; overallCentroid . put ( centroids [ i ] , cluster . size ( ) ) ; ++ clustercount ; } return clustercount ; }
Update the global centroid .