Function sp_npos_elections::phragmms::phragmms [−][src]
pub fn phragmms<AccountId: IdentifierT, P: PerThing128>(
to_elect: usize,
initial_candidates: Vec<AccountId>,
initial_voters: Vec<(AccountId, VoteWeight, Vec<AccountId>)>,
balancing_config: Option<(usize, ExtendedBalance)>
) -> Result<ElectionResult<AccountId, P>, &'static str>
Expand description
Execute the phragmms method.
This can be used interchangeably with [seq-phragmen
] and offers a similar API, namely:
- The resulting edge weight distribution is normalized (thus, safe to use for submission).
- The accuracy can be configured via the generic type
P
. - The algorithm is a best-effort to elect
to_elect
. If less candidates are provided, less winners are returned, without an error.
This can only fail of the normalization fails. This can happen if for any of the resulting
assignments, assignment.distribution.map(|p| p.deconstruct()).sum()
fails to fit inside
UpperOf<P>
. A user of this crate may statically assert that this can never happen and safely
expect
this to return Ok
.