code: function getNearestCluster(clusters, point) {
      var minDistance = Number.MAX_VALUE;
      var clusterIndex = 0;
      var minCluster = 0;
      for (var i = 0; i < clusters.length; i++) {
        var c = clusters[i];
        var d = distance(point, c.getCenter());
        if (d < minDistance) {
          minDistance = d;
          minCluster = clusterIndex;
        }
        clusterIndex++;
      }
      return minCluster;
    }
docs: /** * Get the point farthest to its cluster center * * @param clusters the {@link Cluster}s to search * @return point farthest to its cluster center * @throws ConvergenceException if clusters are all empty  function getFarthestPoint(clusters) {  var maxDistance = Number.NEGATIVE_INFINITY; var selectedCluster = null; var selectedPoint = -1; for (var clusterIndex = 0; clusterIndex < clusters.length; clusterIndex++) { var c = clusters[clusterIndex]; // get the farthest point var center = cluster.getCenter(); var points = cluster.getPoints(); for (var i = 0; i < points.length; ++i) { var d = distance(points[i], center); if (d > maxDistance) { maxDistance = d; selectedCluster = cluster; selectedPoint = i; } }  }  // did we find at least one non-empty cluster ? if (selectedCluster == null) { throw 'Empty cluster'; }  return selectedCluster.getPoints().splice(selectedPoint, 1);  } 
  Returns the nearest {@link Cluster} to the given point
  
  @param clusters the {@link Cluster}s to search
  @param point the point to find the nearest {@link Cluster} for
  @return the index of the nearest {@link Cluster} to the given point