% matlab script to do small tests of $condorcet$ (your code and our code). % (you weren't asked to submit this.) election1 = [ 'A>D>E>C>B' 'C=B=E>D=A' 'A>E>C=D=B' 'A>B=E=D=C' 'D>C>E>B>A' 'D=A=C>B=E' 'A>C>E>B=D' 'A>D=C>E>B' 'A=C>E>B=D' 'B=C>E=D>A']; pwm1 = [ 0 7 5 6 7 3 0 0 2 1 3 6 0 4 6 2 4 2 0 4 3 6 2 4 0 ]; winner1 = 'A'; [winner1e, winner1es] = condorcet(election1); [winner1p, winner1ps] = condorcet(pwm1); winner1, winner1e, winner1es, winner1p, winner1ps election2 = [ 'B>C=A>E>D' 'A>E>C=B=D' 'D>E>B=C=A' 'C=E=A>B>D' 'A>B=D>C=E' 'D=C=B=A>E' 'A=D=C>B>E' 'A>B=C=D=E' 'B=A=D=E>C' 'C>A>E=D=B' 'E>C>B=A>D' 'D=E=A=C>B' 'C=A>E=D=B' 'C>B>D=E=A' 'B=A>E>C>D' 'D>E=B>A>C' 'D>B>A=C>E' 'A=D>C=B>E' 'D=C>E>B=A' 'C>D>A=B>E']; pwm2 = [ 0 9 7 9 12 4 0 6 5 9 5 9 0 8 10 5 8 6 0 9 4 6 6 5 0 ]; winner2 = 'A'; [winner2e, winner2es] = condorcet(election2); [winner2p, winner2ps] = condorcet(pwm2); winner2, winner2e, winner2es, winner2p, winner2ps election3 = [ 0 47 52 58 60 37 0 77 37 33 57 39 0 30 60 42 67 65 0 57 75 52 47 35 0]; winner3 = 'D'; [winner3p, winner3ps] = condorcet(election3); winner3, winner3p, winner3ps %123456789123456789123456789123456789 defeats = 'B/C (10) C/D (11) D/B (12) C/A (07) '; i = defeats(1:9:end); j = defeats(3:9:end); v = 10 * (defeats(6:9:end)-'0') + (defeats(7:9:end)-'0'); election4 = full(sparse(i-'A'+1,j-'A'+1,v)); [winner4p, winner4ps] = condorcet(election4); winner4 = 'plain is A, SSD is C', winner4p, winner4ps %1234123412341234123412341234123412341234123412341234123412341234 defeats = 'C/G G/H H/C F/K K/I I/M M/F C/B F/D B/E E/D D/B E/A A/J J/L L/A '; i = defeats(1:4:end); j = defeats(3:4:end); v = ceil(rand(1,length(i))*99); election5 = full(sparse(i-'A'+1,j-'A'+1,v)); [winner5p, winner5ps] = condorcet(election5); topmostSets = 'CGH and IKFM', winner5p, winner5ps