function createGroups(labels) {
    const numGroups = 1 + max(labels);
    const result = Array(numGroups);
    for (let i = 0; i < labels.length; i++) {
        const label = labels[i];
        if (result[label] === undefined) {
            result[label] = [];
        }
        result[label].push(i);
    }
    return result;
}
Create a lookup table mapping group IDs to point IDs.

@private
@param {Array<number>} labels Labels of points. This must be the same length as `points`,
and values must lie in [0..G-1], where G is the number of groups.
@return {Array<Array<number>>} An array of length G, each of whose entries is an array
containing the indices of the points in that group.