B2G/gecko/toolkit/components/places/ClusterLib.js
/**
   * Given the current state of the algorithm, return the keys of the two
   * clusters that are closest to each other so we know which ones to merge
   * next.
   *
   * @param clusters
   *        The array of all remaining clusters
   * @param distances
   *        Cached distances between pairs of clusters
   * @param neighbors
   *        Cached closest clusters
   *
   * @return An array of two keys of clusters to merge, or null if there are
   *         no more clusters close enough to merge
   */
Given the current state of the algorithm, return the keys of the two
clusters that are closest to each other so we know which ones to merge
next.

@param clusters
The array of all remaining clusters
@param distances
Cached distances between pairs of clusters
@param neighbors
Cached closest clusters

@return An array of two keys of clusters to merge, or null if there are
no more clusters close enough to merge
Given the current state of the algorithm return the keys of the two clusters that are closest to each other so we know which ones to merge next . @param clusters The array of all remaining clusters @param distances Cached distances between pairs of clusters @param neighbors Cached closest clusters @return An array of two keys of clusters to merge or null if there are no more clusters close enough to merge
function HC_closestClus(clusters, distances, neighbors) {
    let minKey = 0, minDist = Infinity;
    for (let i = 0; i < clusters.length; i++) {
      var key = clusters[i].key;
      if (distances[key][neighbors[key]] < minDist) {
        minKey = key;
        minDist = distances[key][neighbors[key]];
      }
    }
    if (minDist < this.threshold) {
      return [minKey, neighbors[minKey]];
    }
    return null;
  }
function HC_closestClus ( clusters , distances , neighbors ) { let minKey = 0 , minDist = Infinity ; for ( let i = 0 ; i < clusters . length ; i ++ ) { var key = clusters [ i ] . key ; if ( distances [ key ] [ neighbors [ key ] ] < minDist ) { minKey = key ; minDist = distances [ key ] [ neighbors [ key ] ] ; } } if ( minDist < this . threshold ) { return [ minKey , neighbors [ minKey ] ] ; } return null ; }
Given the current state of the algorithm, return the keys of the two
 clusters that are closest to each other so we know which ones to merge
 next.
Given the current state of the algorithm return the keys of the two clusters that are closest to each other so we know which ones to merge next .