[−][src]Function sp_phragmen::build_support_map
pub fn build_support_map<AccountId>(
winners: &[AccountId],
assignments: &[StakedAssignment<AccountId>]
) -> (SupportMap<AccountId>, u32) where
AccountId: Default + Ord + Clone,
Build the support map from the given phragmen result. It maps a flat structure like
assignments: vec![
voter1, vec![(candidate1, w11), (candidate2, w12)],
voter2, vec![(candidate1, w21), (candidate2, w22)]
]
into a mapping of candidates and their respective support:
SupportMap {
candidate1: Support {
own:0,
total: w11 + w21,
others: vec![(candidate1, w11), (candidate2, w21)]
},
candidate2: Support {
own:0,
total: w12 + w22,
others: vec![(candidate1, w12), (candidate2, w22)]
},
}
The second returned flag indicates the number of edges who didn't corresponded to an actual winner from the given winner set. A value in this place larger than 0 indicates a potentially faulty assignment.
O(E)
where E
is the total number of edges.