Python code for Smith Set?

#1

Does anyone know of existing python code to find the Smith Set of candidates, given a pairwise array?

1 Like
#2

I don’t have time to write Python code right now, but here is the outline for an algorithm that should get you the Smith set:

  1. Start with an empty set (this will hold the solution) and empty queue.
  2. Find the Copelands winner. (If there is a tie, just add all tied candidates.) Add them to the set and queue.
  3. Loop until the queue is non-empty:
    a. Dequeue the first candidate in the queue. Call that candidate C.
    b. Find all the candidates that beat C. For each such candidate, if they have not already been added to the set, add them to the set and the queue.
  4. Once the queue is empty, the resulting set will be the Smith set.
2 Likes
#3

Thanks, that’s pretty straightforward. I can whip that out pretty quick.

#4

Correction: this should be beat or tie C.