code: private static double findMax(DistanceQuery<?> dq, DBIDIter i, DBIDs cy, double maxDist, double minMaxDist) {
      for(DBIDIter j = cy.iter(); j.valid(); j.advance()) {
        double dist = dq.distance(i, j);
        if(dist > maxDist) {
          // Stop early, if we already know a better candidate.
          if(dist >= minMaxDist) {
            return dist;
          }
          maxDist = dist;
        }
      }
      return maxDist;
    }
docs: Find the maximum distance of one object to a set.
  
  @param dq Distance query
  @param i Current object
  @param cy Set of candidates
  @param maxDist Known maximum to others
  @param minMaxDist Early stopping threshold
  @return Maximum distance