protected void merge ( int size , MatrixParadigm mat , double [ ] bestd , int [ ] besti , PointerHierarchyRepresentationBuilder builder , double mindist , int x , int y ) { // Avoid allocating memory, by reusing existing iterators: final DBIDArrayIter ix = mat . ix . seek ( x ) , iy = mat . iy . seek ( y ) ; if ( LOG . isDebuggingFine ( ) ) { LOG . debugFine ( "Merging: " + DBIDUtil . toString ( ix ) + " -> " + DBIDUtil . toString ( iy ) + " " + mindist ) ; } // Perform merge in data structure: x -> y assert ( y < x ) ; // Since y < x, prefer keeping y, dropping x. builder . add ( ix , linkage . restore ( mindist , getDistanceFunction ( ) . isSquared ( ) ) , iy ) ; // Update cluster size for y: final int sizex = builder . getSize ( ix ) , sizey = builder . getSize ( iy ) ; builder . setSize ( iy , sizex + sizey ) ; // Deactivate x in cache: besti [ x ] = - 1 ; // Note: this changes iy. updateMatrix ( size , mat . matrix , iy , bestd , besti , builder , mindist , x , y , sizex , sizey ) ; if ( besti [ y ] == x ) { findBest ( size , mat . matrix , bestd , besti , y ) ; } }
Execute the cluster merge .