private List < PROCLUSCluster > finalAssignment ( List < Pair < double [ ] , long [ ] > > dimensions , Relation < V > database ) { Map < Integer , ModifiableDBIDs > clusterIDs = new HashMap <> ( ) ; for ( int i = 0 ; i < dimensions . size ( ) ; i ++ ) { clusterIDs . put ( i , DBIDUtil . newHashSet ( ) ) ; } for ( DBIDIter it = database . iterDBIDs ( ) ; it . valid ( ) ; it . advance ( ) ) { V p = database . get ( it ) ; double minDist = Double . POSITIVE_INFINITY ; int best = - 1 ; for ( int i = 0 ; i < dimensions . size ( ) ; i ++ ) { Pair < double [ ] , long [ ] > pair_i = dimensions . get ( i ) ; double currentDist = manhattanSegmentalDistance ( p , pair_i . first , pair_i . second ) ; if ( best < 0 || currentDist < minDist ) { minDist = currentDist ; best = i ; } } // add p to cluster with mindist assert minDist >= 0. ; clusterIDs . get ( best ) . add ( it ) ; } List < PROCLUSCluster > clusters = new ArrayList <> ( ) ; for ( int i = 0 ; i < dimensions . size ( ) ; i ++ ) { ModifiableDBIDs objectIDs = clusterIDs . get ( i ) ; if ( ! objectIDs . isEmpty ( ) ) { long [ ] clusterDimensions = dimensions . get ( i ) . second ; double [ ] centroid = Centroid . make ( database , objectIDs ) . getArrayRef ( ) ; clusters . add ( new PROCLUSCluster ( objectIDs , clusterDimensions , centroid ) ) ; } } if ( LOG . isDebugging ( ) ) { LOG . debugFine ( new StringBuilder ( ) . append ( "clusters " ) . append ( clusters ) . toString ( ) ) ; } return clusters ; }
Refinement step to assign the objects to the final clusters .