protected int findMerge ( int size , MatrixParadigm mat , double [ ] bestd , int [ ] besti , PointerHierarchyRepresentationBuilder builder ) { double mindist = Double . POSITIVE_INFINITY ; int x = - 1 , y = - 1 ; // Find minimum: for ( int cx = 0 ; cx < size ; cx ++ ) { // Skip if object has already joined a cluster: final int cy = besti [ cx ] ; if ( cy < 0 ) { continue ; } final double dist = bestd [ cx ] ; if ( dist <= mindist ) { // Prefer later on ==, to truncate more often. mindist = dist ; x = cx ; y = cy ; } } assert ( x >= 0 && y >= 0 ) ; assert ( y < x ) ; // We could swap otherwise, but this shouldn't arise. merge ( size , mat , bestd , besti , builder , mindist , x , y ) ; return x ; }
Perform the next merge step .