Struct wybr::methods::schulze::Schulze

source ·
pub struct Schulze<'a> { /* private fields */ }

Implementations§

source§

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.

source

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.

source

pub fn pair_score(&mut self, pair_score: PairScore) -> &mut Self

Alters the random seed potentially used by the election algorithm to break ties.

source

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.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Schulze<'a>

§

impl<'a> Send for Schulze<'a>

§

impl<'a> Sync for Schulze<'a>

§

impl<'a> Unpin for Schulze<'a>

§

impl<'a> UnwindSafe for Schulze<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.