#!/usr/bin/perl -w
use strict;
use utf8;
+use autodie;
use Data::Printer;
use Graph::Directed;
-binmode STDIN, 'encoding(UTF-8)' or die;
-binmode STDOUT, 'encoding(UTF-8)' or die;
-binmode STDERR, 'encoding(UTF-8)' or die;
+binmode STDIN, 'encoding(UTF-8)';
+binmode STDOUT, 'encoding(UTF-8)';
+binmode STDERR, 'encoding(UTF-8)';
our @choices;
our %choices;
foreach my $ix (-2..$#ch) {
if ($iy==-1) {
if ($ix==-1) {
- printf "+" or die;
+ printf "+";
} else {
- printf "------" or die;
+ printf "------";
}
} elsif ($ix==-1) {
- printf "|" or die;
+ printf "|";
} elsif ($ix==-2 && $iy==-2) {
- printf "V(Y,X)" or die;
+ printf "V(Y,X)";
} elsif ($iy==-2) {
- printf "%5s ", $choices[$ix] or die $!;
+ printf "%5s ", $choices[$ix];
} elsif ($ix==-2) {
- printf "%5s ", $choices[$iy] or die $!;
+ printf "%5s ", $choices[$iy];
} else {
my $v = \( $vab[$iy][$ix] );
$$v ||= [ ];
if (@$$v) {
- printf "%5d ", (scalar @$$v) or die $!;
+ printf "%5d ", (scalar @$$v);
} else {
- printf "%5s ", "" or die $!;
+ printf "%5s ", "";
}
}
}
- printf "\n" or die $!;
+ printf "\n";
}
sub drop ($$) {
$ch[$i]{Dropped} = $why;
}
-print "# quorum A.6(2)\n" or die $!;
+print "# quorum A.6(2)\n";
foreach my $i (0..$#choices) {
next if $ch[$i]{Dropped};
drop $i, "quorum ($v < $quorum)";
}
-print "# maj. ratio A.6(3)\n" or die $!;
+print "# maj. ratio A.6(3)\n";
foreach my $i (0..$#choices) {
next if $ch[$i]{Dropped};
my $vab = $vab[$ia][$ib];
my $vba = $vab[$ib][$ia];
next unless $vab > $vba;
- print "defeat: $choices[$ia] beats $choices[$ib] ($vab > $vba)\n"
- or die $!;
+ print "defeat: $choices[$ia] beats $choices[$ib] ($vab > $vba)\n";
$defeats->add_vertex($ia,$ib);
}
}
-print "# transitive closure A.6(5)\n" or die $!;
+print "# transitive closure A.6(5)\n";
my $tdefeats = $defeats->transitive_closure();
-print "# schwartz set A.6(6)\n" or die $!;
+print "# schwartz set A.6(6)\n";
my $schwartz = $defeats->copy();
foreach my $ib (0..$#ch) {
next if $tdefeats->has_edge($ia,$b);
next if !$tdefeats->has_edge($b,$ia);
- print "not in Schwartz set: $choices[$ia] because $choices[$ib]\n"
- or die $!;
+ print "not in Schwartz set: $choices[$ia] because $choices[$ib]\n";
$schwartz->delete_vertex($ia);
last;
}
}
-print "# dropping weakest defeats A.6(7)\n" or die $!;
+print "# dropping weakest defeats A.6(7)\n";
my @weakest = ();
push @weakest, $edge;
}
-#p %choices;
+b#p %choices;
#p @vab;