pub struct Schulze<'a> { /* private fields */ }
Implementations§
source§impl<'a> Schulze<'a>
impl<'a> Schulze<'a>
A builder for the setup of Schulze method
See the module level documentation for more.
Default configuration can be generated with Schulze::new(&tally)
, where tally
is a
VoteMatrix
object.
Count is triggered by the run()
method, which returns a solitary winner, or an error.
sourcepub fn new(tally: &'a VoteMatrix) -> Self
pub fn new(tally: &'a VoteMatrix) -> Self
Acquire reference to a vote matrix tally and initiate default configuration, which can be altered with other builder methods. The default configuration involves using Winning pair scoring.
sourcepub fn pair_score(&mut self, pair_score: PairScore) -> &mut Self
pub fn pair_score(&mut self, pair_score: PairScore) -> &mut Self
Alters the random seed potentially used by the election algorithm to break ties.
sourcepub fn run(&self) -> Result<GenericOutcome<'a>, ElectionError>
pub fn run(&self) -> Result<GenericOutcome<'a>, ElectionError>
Performs a Schulze (beat-path) election
Errors
NotEnoughCandidates
, in case there is no candidates.DegeneratedElectionGraph
, in case when there is no winner in the final graph. Anyhow, such situation happens extremely rarely in practice, especially when indifferent votes are disallowed (this is what wybr does).
Notes
This is a basic version of the Schulze method, with no tie-breaking at all; there is also a more sophisticated version with forbidden links which fends off some ties, and even more complex one that uses a random ballot to break ties. Hence, it does not use pseudo-random generator at all.