public void updatePoint ( int p ) { neighbor [ p ] = p ; // flag for not yet found any distance [ p ] = Float . MAX_VALUE ; for ( int i = 0 ; i < npoints ; i ++ ) { int q = points [ i ] ; if ( q != p ) { float d = linkage . d ( p , q ) ; if ( d < distance [ p ] ) { distance [ p ] = d ; neighbor [ p ] = q ; } if ( neighbor [ q ] == p ) { if ( d > distance [ q ] ) { findNeighbor ( q ) ; } else { distance [ q ] = d ; } } } } }
All distances to point have changed check if our structures are ok Note that although we completely recompute the neighbors of p we don t explicitly call findNeighbor since that would double the number of distance computations made by this routine . Also like deletion we don t change any other point s neighbor to p .