function meanDistanceToNearestGroup(which, labels, groupings, distances) {
    const label = labels[which];
    let result = Number.MAX_VALUE;
    for (let i = 0; i < groupings.length; i++) {
        if (i !== label) {
            const d = meanDistanceFromPointToGroup(
                which,
                groupings[i],
                distances
            );
            if (d < result) {
                result = d;
            }
        }
    }
    return result;
}
Calculate the mean distance between this point and all the points in the
nearest group (as determined by which point in another group is closest).

@private
@param {number} which The index of this point.
@param {Array<number>} labels Labels of points.
@param {Array<Array<number>>} groupings An array whose entries are arrays
containing the indices of the points in that group.
@param {Array<Array<number>>} distances A symmetric square array of inter-point
distances.
@return {number} The mean distance from this point to others in the nearest
group.