private void assign ( Relation < V > database , List < ORCLUSCluster > clusters ) { NumberVectorDistanceFunction < ? super V > distFunc = SquaredEuclideanDistanceFunction . STATIC ; // clear the current clusters for ( ORCLUSCluster cluster : clusters ) { cluster . objectIDs . clear ( ) ; } // projected centroids of the clusters List < NumberVector > projectedCentroids = new ArrayList <> ( clusters . size ( ) ) ; for ( ORCLUSCluster c : clusters ) { projectedCentroids . add ( DoubleVector . wrap ( project ( c , c . centroid ) ) ) ; } // for each data point o do for ( DBIDIter it = database . iterDBIDs ( ) ; it . valid ( ) ; it . advance ( ) ) { double [ ] o = database . get ( it ) . toArray ( ) ; double minDist = Double . POSITIVE_INFINITY ; ORCLUSCluster minCluster = null ; // determine projected distance between o and cluster for ( int i = 0 ; i < clusters . size ( ) ; i ++ ) { ORCLUSCluster c = clusters . get ( i ) ; NumberVector o_proj = DoubleVector . wrap ( project ( c , o ) ) ; double dist = distFunc . distance ( o_proj , projectedCentroids . get ( i ) ) ; if ( dist < minDist ) { minDist = dist ; minCluster = c ; } } // add p to the cluster with the least value of projected distance minCluster . objectIDs . add ( it ) ; } // recompute the seed in each clusters for ( ORCLUSCluster cluster : clusters ) { if ( cluster . objectIDs . size ( ) > 0 ) { cluster . centroid = Centroid . make ( database , cluster . objectIDs ) . toArray ( ) ; } } }
Creates a partitioning of the database by assigning each object to its closest seed .