Problemadvanced
Kemeny rank aggregation
Also called Kemeny-Young method, Kemeny optimal aggregation.
Find the ranking that minimizes the total Kendall tau distance to the input rankings; NP-hard already for four input lists.
- Time
- O(2^n n^2 + n^2 k) worst
- Where
- k = the number of input rankings; n = the number of items
- Model
- Word RAM
Kemeny rank aggregation asks for the ranking of items whose total Kendall tau distance to given rankings is as small as possible. The Kendall tau distance counts the pairs of items that two rankings put in opposite orders, so a Kemeny ranking is one that disagrees with the voters on the fewest pairs in total. John Kemeny proposed it in 1959, and it is the reference objective of rank aggregation. It is NP-hard already for four input rankings. It is a weighted form of the feedback arc set problem on a tournament, so it can be solved exactly in time by a subset dynamic program, and it has a PTAS.
In plain words
Several judges each put the same items in order, and the orders do not agree. We want one order for all of them. Take any two items. Each judge puts one of them above the other. Our order also puts one above the other, and every judge who did it the other way disagrees with us on that pair. Count these disagreements over all pairs and all judges. A Kemeny order is an order with the smallest count. If most judges agree on every pair and these majorities fit together into one order, that order is the answer. Often they do not fit: most judges can prefer the first item to the second, the second to the third and the third to the first. Then some majorities must be broken, and the hard part is to choose which ones. No fast method is known that always finds the best choice.
Definition
Input. A set of items and rankings of , each a total order. A ranking may occur more than once.
Distance. For two rankings and , is the number of unordered pairs that one of them puts as above and the other as above . It is a metric on the rankings, with values from 0 to .
Output. A ranking of with the least Kemeny cost
A Kemeny ranking is a median of the input rankings in the metric . There can be several.
Decision form. Given the rankings and an integer , is there a with ? This is NP-complete; a ranking with its cost is a certificate that is checked in time.
Pairwise form. Let be the number of input rankings that put above , so . A ranking that puts above disagrees on this pair with the rankings that put first, so
The cost depends on the input only through the matrix , which is built in time. Every algorithm below starts from it.
Variants
- Partial lists. Each input ranks only some of the items, as the top results of a search engine do. A pair counts only for the lists that rank, or imply the order of, both items. Dwork, Kumar, Naor and Sivakumar studied this case for metasearch.
- Weighted voters. Ranking has weight , and becomes the total weight of the rankings that put above .
- Kemeny winner. Decide whether a given item is first in some Kemeny ranking. This is the form used in voting theory.
- Ties. Inputs or outputs may be weak orders, with a tie on a pair costing half a disagreement or a fixed amount. The definitions differ between papers.
- Footrule aggregation. Replace by the Spearman footrule , the sum of the absolute differences of positions. This version is polynomial, and its optimum is a 2-approximation of the Kemeny cost (see Known algorithms).
Examples
A Condorcet ranking. Five voters: three rank and two rank . Then , and , so a majority puts above , above and above . These majorities form the order , and its cost is : the two voters of disagree on and . The other orders cost more, for example 5 for and 6 for . The Borda count with points 3, 2 and 1 gives 11, 12 and 7, so it returns and does not rank the majority winner first.
A cycle. Three voters rank , then , then . Each pair has a majority of 2 to 1, but the majorities go round: above , above and above . Each of the three input rankings costs , and each of the three reversed rankings costs 5. So there are three Kemeny rankings, each with cost 4, and each breaks exactly one majority.
Two lists. On the toy collection, the BM25 run for "sorted array search" and the second run of the collection both hold documents 1, 2, 4 and 8. Restricted to these, the lists are and , at distance 1. Each list is a Kemeny ranking with cost 1. With two inputs this always holds: by the triangle inequality, with equality at .
Known algorithms
| algorithm | guarantee | time |
|---|---|---|
| try every ranking | exact | |
| subset dynamic programming | exact | |
| best input ranking (Pick-A-Perm) | ratio 2 | with , or directly |
| footrule optimal aggregation | ratio 2 | |
| order by Borda score | ratio 5 | |
| KwikSort on the majority relation | expected ratio 2 | expected comparisons with |
| better of KwikSort and Pick-A-Perm | expected ratio 11/7 | as the two parts |
| LP-based pivot and Pick-A-Perm | ratio 4/3 | polynomial, one linear program |
| Kenyon-Mathieu and Schudy (2007) | ratio | polynomial for fixed |
Subset dynamic programming. Let be the least cost of an order of the set , counting only pairs inside . The last item of the best order of is below every other item , so it pays , the number of voters that put above , for each of them. So and
The answer is . With the sums kept per set, this takes time and space, the same scheme as bitmask DP for the feedback arc set problem.
Best input ranking. Let be optimal. For each input , the triangle inequality gives . The average of over is , so the average of is at most , and the best input does at least as well as the average. Ailon, Charikar and Newman call the random choice Pick-A-Perm.
Footrule optimal aggregation. Minimizing is an assignment problem: put item at position at cost , and find a minimum cost perfect matching of items to positions. Diaconis and Graham proved . So for the footrule optimum , . Dwork, Kumar, Naor and Sivakumar used this for metasearch.
KwikSort. Pick a random pivot item, put each other item above or below it by the majority of , and recurse on the two sides, as in randomized quicksort. Ailon, Charikar and Newman proved that on rank aggregation inputs it has an expected ratio of 2, and that the better of KwikSort and Pick-A-Perm has an expected ratio of 11/7. Rounding a linear program over the pairs in place of the majority gives 4/3.
Local improvement. Local Kemenization, described on the page on Markov chain rank aggregation, swaps adjacent items while a majority prefers the swap. It never raises the cost and its result satisfies the extended Condorcet criterion, but it has no approximation guarantee of its own; it is used to clean up the output of a fast method.
Exact solvers in practice. Integer programs with one 0/1 variable per ordered pair and the transitivity constraints on each triple are the usual exact method. How large an instance they solve in a given time is a measured property of the inputs, not a proved bound.
Bounds
Lower bound on the cost. Each pair costs at least , so for every . Equality holds exactly when agrees with the strict majority on every pair that has one. So if the strict majorities are defined on every pair and form a total order, the Condorcet ranking, that order is the unique Kemeny ranking.
Hardness with many voters. Bartholdi, Tovey and Trick (1989) proved that it is NP-hard to decide whether an item is a Kemeny winner when the number of voters is part of the input. Hemaspaandra, Spakowski and Vogel (2005) proved that the winner problem is complete for , the class of problems solved by polynomial time with queries to an NP oracle.
Hardness with few voters. Dwork, Kumar, Naor and Sivakumar (2001) proved NP-hardness for and for every even . Bachmeier and coauthors (2019) proved it for every odd . The case stayed open until 2026, when a preprint by Dominik Peters and an independent preprint by Péter Madarasi gave NP-hardness for three rankings, and with the reduction that adds a ranking and its reverse, also for five. At the time of writing these are preprints, not reviewed papers. For and an input ranking is optimal, as the example shows.
Approximation. The PTAS of Kenyon-Mathieu and Schudy shows that the problem is not APX-hard. NP-hardness rules out an exact polynomial algorithm unless P = NP.
Reductions
To weighted feedback arc set. Write each pair's cost as plus if goes against the strict majority. Then
The first sum does not depend on . Draw the majority digraph, with an arc of weight whenever . The second sum is the weight of the arcs that points backwards. So a Kemeny ranking is exactly an order with a minimum weight set of backward arcs, a weighted feedback arc set of the majority digraph. With an odd number of voters every pair has a majority, and the digraph is a tournament.
Adding a ranking and its reverse. For every , , where is the reverse of , because each pair agrees with exactly one of the two. Adding both to the input adds the same amount to every cost and keeps the set of Kemeny rankings. So hardness for rankings gives hardness for , which is how the results for four and three rankings spread to all even and all odd .
From tournaments. The hardness proofs go the other way: they build input rankings whose majority digraph is a hard instance of feedback arc set on tournaments, or, in the preprint by Peters, encode an instance of maximum cut.
Maximum likelihood. In the Mallows model, a ranking is drawn with probability proportional to for a central ranking and some . The likelihood of independent draws is proportional to , so the maximum likelihood estimate of is a Kemeny ranking.
Applications
- Metasearch. Merge the result lists of several search engines. Dwork, Kumar, Naor and Sivakumar argued that the extended Condorcet criterion, which every Kemeny ranking satisfies, resists spam: if a majority of engines ranks each good page above each spam page, then all good pages come before all spam pages. Fast methods such as reciprocal rank fusion and CombMNZ are used in practice, and Kemeny serves as the objective to compare them with.
- Elections. The Kemeny rule elects the top of a Kemeny ranking. Young and Levenglick proved that it is the only rule that is neutral, consistent and Condorcet, so it is the natural extension of the majority principle to full rankings.
- Consensus of rankers. Combine the orders of several judges, sensors or learned models, for example in sports ranking or in the evaluation of systems on several metrics.
References
- John G. Kemeny, Mathematics without numbers, Daedalus 88(4) (1959), the distance between two rankings and the proposal to take as consensus the ranking with the least total distance to the given ones
- H. P. Young and A. Levenglick, A consistent extension of Condorcet's election principle, SIAM Journal on Applied Mathematics 35(2) (1978), 285-300, the characterization of the Kemeny rule as the only rule that is neutral, consistent and Condorcet
- John Bartholdi III, Craig A. Tovey and Michael A. Trick, Voting schemes for which it can be difficult to tell who won the election, Social Choice and Welfare 6(2) (1989), 157-165, the proof that deciding a Kemeny winner is NP-hard when the number of voters is part of the input
- Cynthia Dwork, Ravi Kumar, Moni Naor and D. Sivakumar, Rank aggregation methods for the Web, Proceedings of the 10th International World Wide Web Conference (WWW10), 613-622, NP-hardness of Kemeny optimal aggregation for four lists and every even number of lists from four on, the footrule optimal aggregation as a 2-approximation, and local Kemenization
- Edith Hemaspaandra, Holger Spakowski and Jörg Vogel, The complexity of Kemeny elections, Theoretical Computer Science 349(3) (2005), 382-391, the completeness of the Kemeny winner problem for the class Theta_2^p
- Nir Ailon, Moses Charikar and Alantha Newman, Aggregating inconsistent information, ranking and clustering, Journal of the ACM 55(5), Article 23 (2008), KwikSort and Pick-A-Perm, the expected ratio 11/7 for the better of the two (Theorem 8), and the ratio 4/3 with the LP-based pivot
- Claire Kenyon-Mathieu and Warren Schudy, How to rank with few errors, Proceedings of the 39th ACM Symposium on Theory of Computing (STOC), 95 to 103 (2007), the PTAS for weighted feedback arc set in tournaments and for Kemeny rank aggregation
- Georg Bachmeier et al., k-Majority digraphs and the hardness of voting with a constant number of voters, Journal of Computer and System Sciences 105 (2019), 130-157, NP-hardness of the Kemeny rule for every odd number of voters from seven on
- Don Coppersmith, Lisa K. Fleischer and Atri Rudra, Ordering by weighted number of wins gives a good ranking for weighted tournaments, ACM Transactions on Algorithms 6(3), Article 55 (2010), the 5-approximation by weighted number of wins, which for full rankings is the Borda order
- Persi Diaconis and R. L. Graham, Spearman's footrule as a measure of disarray, Journal of the Royal Statistical Society, Series B 39(2) (1977), 262-268, the inequality between the Kendall tau distance and the Spearman footrule, K at most F at most 2K
- Dominik Peters, Kemeny rank aggregation is NP-hard for three voters, arXiv:2607.25540 (2026), preprint, the reduction from maximum cut that shows NP-hardness for three input rankings
- Péter Madarasi, The complexity of Kemeny aggregation with three rankings, arXiv:2607.28588 (2026), preprint, the independent proof that the Kemeny score problem is NP-complete for three rankings
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag F4V2Z2 Edit this page History Report an error Markdown