private List < Cluster < SubspaceModel > > sortClusters ( Relation < V > relation , Object2ObjectMap < long [ ] , List < ArrayModifiableDBIDs > > clustersMap ) { final int db_dim = RelationUtil . dimensionality ( relation ) ; // int num = 1; List < Cluster < SubspaceModel > > clusters = new ArrayList <> ( ) ; for ( long [ ] pv : clustersMap . keySet ( ) ) { List < ArrayModifiableDBIDs > parallelClusters = clustersMap . get ( pv ) ; for ( int i = 0 ; i < parallelClusters . size ( ) ; i ++ ) { ArrayModifiableDBIDs c = parallelClusters . get ( i ) ; Cluster < SubspaceModel > cluster = new Cluster <> ( c ) ; cluster . setModel ( new SubspaceModel ( new Subspace ( pv ) , Centroid . make ( relation , c ) . getArrayRef ( ) ) ) ; String subspace = BitsUtil . toStringLow ( cluster . getModel ( ) . getSubspace ( ) . getDimensions ( ) , db_dim ) ; cluster . setName ( parallelClusters . size ( ) > 1 ? ( "Cluster_" + subspace + "_" + i ) : ( "Cluster_" + subspace ) ) ; clusters . add ( cluster ) ; } } // sort the clusters w.r.t. lambda Comparator < Cluster < SubspaceModel > > comparator = new Comparator < Cluster < SubspaceModel > > ( ) { @ Override public int compare ( Cluster < SubspaceModel > c1 , Cluster < SubspaceModel > c2 ) { return c2 . getModel ( ) . getSubspace ( ) . dimensionality ( ) - c1 . getModel ( ) . getSubspace ( ) . dimensionality ( ) ; } } ; Collections . sort ( clusters , comparator ) ; return clusters ; }
Returns a sorted list of the clusters w . r . t . the subspace dimensionality in descending order .