X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=appendix-a6.git;a=blobdiff_plain;f=parse;h=7ca1ed6aa70817165ca476ac6323a37f4404506e;hp=adb3d7df3ad1062d5759645458f61b9513087644;hb=708d36a1a95409c926ac4be1a343faa41cf09052;hpb=2eaee49e874572d17f6682d10abc737f00c38e1c diff --git a/parse b/parse index adb3d7d..7ca1ed6 100755 --- a/parse +++ b/parse @@ -57,6 +57,8 @@ our @vab; # Go through the voters and construct V(A,B) +print "\nDefeats matrix\n"; + foreach my $iv (@invotes) { my ($votestr,$voter) = @$iv; eval { @@ -122,7 +124,7 @@ sub drop ($$) { $ch[$i]{Dropped} = $why; } -print "# quorum A.6(2)\n"; +print "\nQuorum A.6(2) (quorum is $quorum)\n"; foreach my $i (0..$#choices) { next if $ch[$i]{Dropped}; @@ -132,7 +134,7 @@ foreach my $i (0..$#choices) { drop $i, "quorum ($v < $quorum)"; } -print "# maj. ratio A.6(3)\n"; +print "\nMajority ratio A.6(3)\n"; foreach my $i (0..$#choices) { next if $ch[$i]{Dropped}; @@ -173,20 +175,20 @@ sub weaker ($$) { return 0; } -print "defeats graph: $defeats\n"; - our $schwartz; for (;;) { # loop from A6(5) - print "# transitive closure A.6(5)\n"; + print "defeats graph: $defeats\n"; + + print "\nTransitive closure A.6(5)\n"; my $tdefeats = $defeats->transitive_closure(); print "closure graph: $tdefeats\n"; - print "# Schwartz set A.6(6)\n"; + print "\nSchwartz set A.6(6)\n"; $schwartz = $defeats->copy(); @@ -200,7 +202,7 @@ for (;;) { } } - print "# dropping weakest defeats A.6(7)\n"; + print "\nDropping weakest defeats A.6(7)\n"; our @weakest = (); @@ -230,11 +232,17 @@ for (;;) { $defeats->delete_edge($ia,$ib); } - print "# defeats within the Schwartz set, round again\n"; + print "defeats within the Schwartz set, round again\n"; } -print "# no defeats within the Schwartz set\n"; -print "FINAL SCHWARTZ SET:\n"; +print "no defeats within the Schwartz set\n"; +print "final schwartz set:\n\n"; + +if ($schwartz->vertices() == 1) { + print "WINNER IS:\n"; +} else { + print "WINNER IS ONE OF (CASTING VOTE DECIDES):\n"; +} printf " %-5s %s\n", $choices[$_], $ch[$_]{Desc} foreach ($schwartz->vertices());