jontingvold / pyrankvote

PyRankVote is a python library for different ranked-choice voting systems, like IRV, STV and PBV. Created in June 2019.
MIT License
52 stars 16 forks source link

Store inter-round data for sankey diagrams #20

Open chrisroat opened 2 years ago

chrisroat commented 2 years ago

Various analysis and visualizations (like Sankey diagrams) would benefit from having information stored on how many votes are transferred between candidates in each round.

If a single candidate is eliminated per-round, the ElectionResults object has enough data to reconstruct this information. However, sometimes multiple candidates are eliminated in a round, and I do not see how to recover how the vote shifts can be attributed back to each eliminated candidate. Of course, I may have missed something.

One approach would be to have the ElectionManager.transfer_votes be called prior to register results, and having it store the additional information. Care has to be taken that the transfer can shift excess votes for elected candidates. I will implement this and create a PR, but happy to hear ideas or constructive criticism.