def construct_comp_matrix(vec: np.ndarray, sorted_idx: np.ndarray) -> np.ndarray:
    """Construct the comparison matrix from a row-vector vec."""
    n = vec.shape[0]
    c = np.zeros(shape=(n, n), dtype=np.int32)

    # the elements of the b(0)-th row in C are all set to 1
    c[sorted_idx[0], :] = 1

    for i in range(1, n):
        if vec[sorted_idx[i]] == vec[sorted_idx[i - 1]]:
            # the rows in C corresponding to the same elements in w are identical
            c[sorted_idx[i]] = c[sorted_idx[i - 1]]
        else:
            c[sorted_idx[i], sorted_idx[i:]] = 1

    return c
Construct the comparison matrix from a row-vector vec.
pymoo/functions/standard/non_dominated_sorting.py