STV Algorithm DetailTry ItDownload CodeContact

OverviewAdjusting VotesRelationshipsAllocationReductionFinal Thoughts


All candidates have one of these four statuses: Active, Deactivated, Excluded, Winner. The diagram below reflects the algorithm.

Overview Diagram


Adjusting votes is where most of the computation happens.

It alternates between voters allocating their votes and winners reducing their surplus. This happens as many times as necessary until both voters and candidates reach equilibrium.

Adjust Votes Diagram


In the following, please note that the term “Voter” designates the representation of the voter as an object in the algorithm, not the physical person.

The Voter is connected to each candidate on his ballot via something we call a “VoteLink”. The VoteLink has two important properties. Its “weight” meaning the percentage of the vote the voter is currently allocating to the candidate. The other important property is one of these five statuses:

  • Active: the candidate is active
  • Deactivated: the candidate is deactivated
  • Excluded: the candidate is excluded
  • Full: the candidate is a winner and is receiving full support from the voter
  • Partial: the candidate is a winner and is not receiving full support from the voter
Relationship Diagram

The difference between Partial and Full support will be explained below


To help us understand the Voter’s allocation function, it is best to process everything from his perspective. The Voter has his ballot (his list of VoteLinks), and knows how much weight he already allocated to each candidate and what is the status of his candidates (status of each of his VoteLinks).

Since the Voter is doing this allocation, it means he has been signaled to do so for one of the following reasons:

  • First Count of the whole election
  • One or more of his candidates has lost or was excluded
  • One or more of his candidates reduced a surplus and returned a portion of the vote that was already allocated. This happens every time one of the Voter’s candidates wins, and during the “Adjust Votes” phase if a candidate receives extra votes due to another Voter’s allocation.

There are two conditions to consider. First, weight allocated to winners is considered fixed, it cannot be lowered by the Voter himself. Second, weight can only be allocated to VoteLinks with Active or Partial status. Full status on the VoteLink is a signal from the candidate to the Voter informing the Voter that the candidate is not in need of any extra weight.

Voter's Allocation

Another way of visualizing the process is with the video below.

The video assumes we are in the middle of an election and showcases the Voter’s allocation after four events. The events are shown at the top and are in chronological order. However, for brevity, we only show the events related to this voter. The red bars represent the portions of the vote and where they are allocated.


To help us understand the Candidate’s reduction function, it is also best to process everything from the candidate’s perspective. The Candidate has his supporters (his list of VoteLinks), and knows how much weight he is receiving from each supporter. Ideally, the candidate wants to receive an equal amount of weight from each of his supporters. However, this cannot always be the case. Voters sometimes allocate weight below the ideal amount because they already have most of the weight allocated to other winners.

Reduction of surplus

Another way of visualizing the process is with the video below.

Let’s assume we have a quota of 6 and initially there’s 8 VoteLinks with full support (colored red) of weight 0.75 each. The candidate then receives 5 new partial votes (colored in yellow) of varying weights (0.25, 0.25, 0.5, 0.75, 1) bringing the total number of supporters to 13. The initial ideal full support amount is 6 / 13 = ~.46

The threshold for a VoteLink to be designated as Full is represented by the Green frame. It starts by considering all VoteLinks, then any VoteLink that does not pass the threshold remains as Partial (yellow) and increases the threshold for the next VoteLink as a compensation. Notice the green frame getting narrower and taller until it can find a VoteLink that is at least as high as itself. All subsequent VoteLink are designated as Full.


As we can see, the Voter’s allocation function may send surplus votes to winners thereby signaling a reduction function, which returns surplus votes to other voters, thus signaling a voter’s allocation function again. The algorithm is designed in a way that every iteration of the voter’s allocation and reduction functions makes the overall distribution of votes across candidates converge to a state of equilibrium. This state of equilibrium is then disrupted by a candidate’s win or loss.