public static <T> int[] rank(
		final BaseSeq<? extends T> set,
		final Comparator<? super T> dominance
	) {
		// Pre-compute the dominance relations.
		final int[][] d = new int[set.length()][set.length()];
		for (int i = 0; i < set.length(); ++i) {
			for (int j = i + 1; j < set.length(); ++j) {
				d[i][j] = dominance.compare(set.get(i), set.get(j));
				d[j][i] = -d[i][j];
			}
		}

		// Compute for each element p the element q that it dominates, and the
		// number of times it is dominated. Using the names as defined in the
		// referenced paper.
		final int[] nq = new int[set.length()];
		final List<IntList> fronts = new ArrayList<>();
		IntList Fi = new IntList();

		for (int p = 0; p < set.length(); ++p) {
			final IntList Sp = new IntList();
			int np = 0;

			for (int q = 0; q < set.length(); ++q) {
				if (p != q) {
					// If p dominates q, add q to the set of solutions
					// dominated by p.
					if (d[p][q] > 0) {
						Sp.add(q);

					// Increment the domination counter of p.
					} else if (d[q][p] > 0) {
						np += 1;
					}
				}
			}

			// p belongs to the first front.
			if (np == 0) {
				Fi.add(p);
			}

			fronts.add(Sp);
			nq[p] = np;
		}

		// Initialize the front counter.
		int i = 0;
		final int[] ranks = new int[set.length()];
		while (!Fi.isEmpty()) {
			// Used to store the members of the next front.
			final IntList Q = new IntList();

			for (int p = 0; p < Fi.size(); ++p) {
				final int fi = Fi.get(p);
				ranks[fi] = i;

				// The updates dominated counts as compute next front.
				for (int k = 0, n = fronts.get(fi).size(); k < n; ++k) {
					final int q = fronts.get(fi).get(k);
					nq[q] -= 1;

					// q belongs to the next front.
					if (nq[q] == 0) {
						Q.add(q);
					}
				}
			}

			++i;
			Fi = Q;
		}

		return ranks;
	}
Calculates the <em>non-domination</em> rank of the given input {@code set},
using the given {@code dominance} comparator.

@apiNote
Calculating the rank has a time and space complexity of {@code O(n^2},
where {@code n} the {@code set} size.

<p>
 <b>Reference:</b><em>
     Kalyanmoy Deb, Associate Member, IEEE, Amrit Pratap,
     Sameer Agarwal, and T. Meyarivan.
     A Fast and Elitist Multiobjective Genetic Algorithm: NSGA-II,
     IEEE TRANSACTIONS ON EVOLUTIONARY COMPUTATION, VOL. 6, NO. 2,
     APRIL 2002.</em>

@param set the input set
@param dominance the dominance comparator used
@param <T> the element type
@return the <em>non-domination</em> rank of the given input {@code set}
jenetics.ext/src/main/java/io/jenetics/ext/moea/Pareto.java