Implementation
The only difficult step in implementing the Schulze method is computing the strongest path strengths. However, this is a well-known problem in graph theory sometimes called the widest path problem. One simple way to compute the strengths therefore is 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 i from 1 to C
- for j from 1 to C
- if (i ≠ j) then
- if (d > d) then
- p := d
- else
- p := 0
- for i from 1 to C
- for j from 1 to C
- if (i ≠ j) then
- for k from 1 to C
- if (i ≠ k and j ≠ k) then
- p := max ( p, min ( p, p ) )
This algorithm is efficient, and has running time proportional to C3 where C is the number of candidates. (This does not account for the running time of computing the d values, which if implemented in the most straightforward way, takes time proportional to C2 times the number of voters.)
Read more about this topic: Schulze Method
Related Phrases
Related Words