Struct tallyman::condorcet::CondorcetTally
source · pub struct CondorcetTally<T, C = u64>where
T: Eq + Clone + Hash,
C: Copy + PartialOrd + AddAssign + Num + NumCast,{ /* private fields */ }
Implementations§
source§impl<T, C> CondorcetTally<T, C>where
T: Eq + Clone + Hash,
C: Copy + PartialOrd + AddAssign + Num + NumCast,
impl<T, C> CondorcetTally<T, C>where
T: Eq + Clone + Hash,
C: Copy + PartialOrd + AddAssign + Num + NumCast,
pub fn new(num_winners: u32) -> Self
pub fn with_capacity(num_winners: u32, expected_candidates: usize) -> Self
pub fn add(&mut self, selection: Vec<T>)
pub fn add_ref(&mut self, selection: &[T])
pub fn add_weighted(&mut self, selection: Vec<T>, weight: C)
pub fn add_weighted_ref(&mut self, selection: &[T], weight: C)
pub fn reset(&mut self)
pub fn winners(&mut self) -> RankedWinners<T>
sourcepub fn build_graph(&mut self) -> Graph<T, (C, C)>
pub fn build_graph(&mut self) -> Graph<T, (C, C)>
Build a graph representing all pairwise competitions between all candidates.
Each candidate is assigned a node, vertexes between nodes contain a tuple of counts. Vertexes are directional, leading from the more preferred candidate to the less prefered candidate. The first element of tuple is the number votes where the first candidate is prefered to the second. The second element of the tuple is the number of votes where the second candidate is prefered to the first. The first element in the tuple is always greater than or equal to the second element in the tuple.
If both candidates are equally prefered, two vertexes are created, one going in each direction.
![](https://raw.githubusercontent.com/phayes/tallyman/master/docs/pairwise-graph.png)