private static MultiMap < Integer , Integer > convertMergesToAssignments ( List < Merge > merges , int numOriginalClusters ) { MultiMap < Integer , Integer > clusterToElements = new HashMultiMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < numOriginalClusters ; ++ i ) clusterToElements . put ( i , i ) ; for ( Merge m : merges ) { clusterToElements . putMany ( m . remainingCluster ( ) , clusterToElements . remove ( m . mergedCluster ( ) ) ) ; } return clusterToElements ; }
Converts a series of merges to cluster assignments . Cluster assignments are assumed to start at 0 .