mirror of
https://github.com/tgorordo/smithy.git
synced 2026-06-13 02:42:14 -07:00
Update rcv.py to handle ties correctly
This commit is contained in:
parent
8a324243b3
commit
38c2845c3c
1 changed files with 6 additions and 0 deletions
|
|
@ -59,6 +59,9 @@ def pmg_from_rcv_bigslow(ballots: pl.DataFrame) -> rwx.PyDiGraph:
|
|||
pmg.add_edge(nodes[a], nodes[b], a_wins - b_wins)
|
||||
elif b_wins > a_wins:
|
||||
pmg.add_edge(nodes[b], nodes[a], b_wins - a_wins)
|
||||
else: # tie
|
||||
pmg.add_edge(nodes[a], nodes[b], 0)
|
||||
pmg.add_edge(nodes[b], nodes[a], 0)
|
||||
|
||||
return pmg
|
||||
|
||||
|
|
@ -105,6 +108,9 @@ def pmg_from_rcv_smallfast(ballots: pl.DataFrame) -> rwx.PyDiGraph:
|
|||
pmg.add_edge(nodes[a], nodes[b], int(a_wins - b_wins))
|
||||
elif b_wins > a_wins:
|
||||
pmg.add_edge(nodes[b], nodes[a], int(b_wins - a_wins))
|
||||
else: # tie
|
||||
pmg.add_edge(nodes[a], nodes[b], 0)
|
||||
pmg.add_edge(nodes[b], nodes[a], 0)
|
||||
|
||||
return pmg
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue