Schulze method
The Schulze method, also known as the beatpath method, is a single winner ranked-choice voting rule developed by Markus Schulze. The Schulze method is a Condorcet completion method, which means it will elect a majority-preferred candidate if one exists. In other words, if most people rank A above B, A will defeat B. Schulze's method breaks cyclic ties by using indirect victories. The idea is that if Alice beats Bob, and Bob beats Charlie, then Alice beats Charlie; this kind of indirect win is called a "beatpath".
The Schulze method is used by several organizations including Debian, Ubuntu, Gentoo, Pirate Party political parties and many others. It was also used by Wikimedia prior to their adoption of score voting.
Description of the method
Schulze's method uses ranked ballots with equal ratings allowed. There are two common descriptions of Schulze's method.Beatpath explanation
The idea behind Schulze's method is that if Alice defeats Bob, and Bob beats Charlie, then Alice "indirectly" defeats Charlie. These chained sequences of "beats" are called 'beatpaths'.Every beatpath is assigned a particular strength. The strength of a single-step beatpath from Alice to Bob is just the number of voters who rank Alice over Bob. For a longer beatpath, consisting of multiple beats, a beatpath is as strong as its weakest link.
We say Alice has a "beatpath-win" over Bob if her strongest beatpath to Bob is stronger than Bob's strongest beatpath to Alice. The winner is any candidate who is not beaten by any other candidate via a beatpath-win.
This definition of a beatpath-win is transitive: in other words, if Alice has a beatpath-win over Bob, and Bob has a beatpath-win over Charlie, Alice has a beatpath-win over Charlie. As a result, the Schulze method is a Condorcet method, providing a full extension of the majority rule to any set of ballots.
Iterative description
The Schulze winner can also be constructed iteratively, using a defeat-dropping method:- Draw a directed graph with all the candidates as nodes; label the edges with the number of votes supporting the winner.
- If there is more than one candidate left:
- * Check if any candidates are tied.
- * Eliminate all candidates outside the majority-preferred set.
- * Delete the edge closest to being tied.
Example
In the following example 45 voters rank 5 candidates.| Number of voters | Order of preference |
| 5 | ACBED |
| 5 | ADECB |
| 8 | BEDAC |
| 3 | CABED |
| 7 | CAEBD |
| 2 | CBADE |
| 7 | DCEBA |
| 8 | EBADC |
The pairwise preferences have to be computed first. For example, when comparing ' and ' pairwise, there are voters who prefer ' to ', and voters who prefer ' to '. So and. The full set of pairwise preferences is:
File:Schulze_method_example1.svg|right|thumb|300x300px|Directed graph labeled with pairwise preferences d
| 20 | 26 | 30 | 22 | ||
| 25 | 16 | 33 | 18 | ||
| 19 | 29 | 17 | 24 | ||
| 15 | 12 | 28 | 14 | ||
| 23 | 27 | 21 | 31 |
The cells for d have a light green background if d > d, otherwise the background is light red. There is no undisputed winner by only looking at the pairwise differences here.
Now the strongest paths have to be identified. To help visualize the strongest paths, the set of pairwise preferences is depicted in the diagram on the right in the form of a directed graph. An arrow from the node representing a candidate X to the one representing a candidate Y is labelled with d. To avoid cluttering the diagram, an arrow has only been drawn from X to Y when d > d, omitting the one in the opposite direction.
One example of computing the strongest path strength is p = 33: the strongest path from B to D is the direct path which has strength 33. But when computing p, the strongest path from A to C is not the direct path of strength 26, rather the strongest path is the indirect path which has strength min = 28. The strength of a path is the strength of its weakest link.
For each pair of candidates X and Y, the following table shows the strongest path from candidate X to candidate Y in red, with the weakest link underlined.
| A | B | C | D | E | ||
| A | Image:Schulze method example1 AB.svg|border|none|150px A--D--C--B | Image:Schulze method example1 AC.svg|border|none|150px A--D--C | Image:Schulze method example1 AD.svg|border|none|150px A--D | Image:Schulze method example1 AE.svg|border|none|150px A--D--C--E | A | |
| B | Image:Schulze method example1 BA.svg|border|none|150px B--A | Image:Schulze method example1 BC.svg|border|none|150px B--D--C | Image:Schulze method example1 BD.svg|border|none|150px B--D | Image:Schulze method example1 BE.svg|border|none|150px B--D--C--E | B | |
| C | Image:Schulze method example1 CA.svg|border|none|150px C--B--A | Image:Schulze method example1 CB.svg|border|none|150px C--B | Image:Schulze method example1 CD.svg|border|none|150px C--B--D | Image:Schulze method example1 CE.svg|border|none|150px C--E | C | |
| D | Image:Schulze method example1 DA.svg|border|none|150px D--C--B--A | Image:Schulze method example1 DB.svg|border|none|150px D--C--B | Image:Schulze method example1 DC.svg|border|none|150px D--C | Image:Schulze method example1 DE.svg|border|none|150px D--C--E | D | |
| E | Image:Schulze method example1 EA.svg|border|none|150px E--D--C--B--A | Image:Schulze method example1 EB.svg|border|none|150px E--D--C--B | Image:Schulze method example1 EC.svg|border|none|150px E--D--C | Image:Schulze method example1 ED.svg|border|none|150px E--D | E | |
| A | B | C | D | E |
| 28 | 28 | 30 | 24 | ||
| 25 | 28 | 33 | 24 | ||
| 25 | 29 | 29 | 24 | ||
| 25 | 28 | 28 | 24 | ||
| 25 | 28 | 28 | 31 |
Now the output of the Schulze method can be determined. For example, when comparing ' and ', since, for the Schulze method candidate ' is better than candidate '. Another example is that, so candidate E is better than candidate D. Continuing in this way, the result is that the Schulze ranking is, and ' wins. In other words, ' wins since for every other candidate X.
Implementation
Computation of the strongest path strengths is the widest path problem. It is a variation of the all-pairs shortest path problem and it can be solved via a variant of the Floyd–Warshall algorithm. The following pseudocode illustrates the algorithm.- Input: d, the number of voters who prefer candidate i to candidate j.
- Output: p, the strength of the strongest path from candidate i to candidate j.
for j from 1 to C
if i ≠ j then
p := d - d
for k from 1 to C
for i from 1 to C
if i ≠ k then
for j from 1 to C
if j ≠ k and j ≠ i then
p := max
Ties and alternative implementations
When allowing users to have ties in their preferences, the outcome of the Schulze method naturally depends on how these ties are interpreted in defining d. Two natural choices are that d represents either the number of voters who strictly prefer A to B, or the margin of minus. But no matter how the ds are defined, the Schulze ranking has no cycles, and assuming the ds are unique it has no ties.Although ties in the Schulze ranking are unlikely, they are possible. Schulze's original paper recommended breaking ties by random ballot.
There is another alternative way to demonstrate the winner of the Schulze method. This method is equivalent to the others described here, but the presentation is optimized for the significance of steps being visually apparent as a human goes through it, not for computation.
- Make the results table, called the "matrix of pairwise preferences", such as used above in the example. Then, every positive number is a pairwise win for the candidate on that row, ties are zeroes, and losses are negative. Order the candidates by how long they last in elimination.
- If there is a candidate with no red on their line, they win.
- Otherwise, draw a square box around the Schwartz set in the upper left corner. It can be described as the minimal "winner's circle" of candidates who do not lose to anyone outside the circle. Note that to the right of the box there is no red, which means it is a winner's circle, and note that within the box there is no reordering possible that would produce a smaller winner's circle.
- Cut away every part of the table outside the box.
- If there is still no candidate with no red on their line, something needs to be compromised on; every candidate lost some race, and the loss we tolerate the best is the one where the loser obtained the most votes. So, take the red cell with the highest number, make it green—or any color other than red—and go back step 2.
| E | A | C | B | D | |
| E | 1 | −3 | 9 | 17 | |
| A | −1 | 7 | −5 | 15 | |
| C | 3 | −7 | 13 | −11 | |
| B | −9 | 5 | −13 | 21 | |
| D | −17 | −15 | 11 | −21 |
The first drop does not help shrink the Schwartz set.
| E | A | C | B | D | |
| E | 1 | −3 | 9 | 17 | |
| A | −1 | 7 | −5 | 15 | |
| C | 3 | −7 | 13 | −11 | |
| B | −9 | 5 | −13 | 21 | |
| D | −17 | −15 | 11 | −21 |
So we get straight to the second drop, and that shows us the winner, E, with its clear row.
| E | A | C | B | D | |
| E | 1 | −3 | 9 | 17 | |
| A | −1 | 7 | −5 | 15 | |
| C | 3 | −7 | 13 | −11 | |
| B | −9 | 5 | −13 | 21 | |
| D | −17 | −15 | 11 | −21 |
This method can also be used to calculate a result, if the table is remade in such a way that one can conveniently and reliably rearrange the order of the candidates on both the row and the column, with the same order used on both at all times.