chiark
/
gitweb
/
~ian
/
appendix-a6.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ec0d2da
)
graphviz: new output, with -g option
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Thu, 6 Feb 2014 00:54:19 +0000
(
00:54
+0000)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Thu, 6 Feb 2014 00:54:19 +0000
(
00:54
+0000)
compute
patch
|
blob
|
history
diff --git
a/compute
b/compute
index c544437bdb05468ed7f94076829c884d609a54f4..6b0e79d236fef4efcce2b9261be581715baa62d5 100755
(executable)
--- a/
compute
+++ b/
compute
@@
-55,6
+55,7
@@
use autodie;
use Data::Printer;
use Graph::Directed;
use Data::Printer;
use Graph::Directed;
+use Graph::Writer::GraphViz;
binmode STDIN, 'encoding(UTF-8)';
binmode STDOUT, 'encoding(UTF-8)';
binmode STDIN, 'encoding(UTF-8)';
binmode STDOUT, 'encoding(UTF-8)';
@@
-67,6
+68,19
@@
our @invotes_cc;
our $defcho;
our $quorum = 0;
our $defcho;
our $quorum = 0;
+our $gfile;
+
+while (@ARGV && $ARGV[0] =~ /^-/) {
+ local $_ = shift @ARGV;
+ if (m/^--?$/) {
+ last;
+ } elsif (s/^-g//) {
+ $gfile = $_;
+ } else {
+ die "bad usage\n";
+ }
+}
+
sub addchoice {
my $choname = shift @_;
my $cho = $choices{$choname} = {
sub addchoice {
my $choname = shift @_;
my $cho = $choices{$choname} = {
@@
-311,6
+325,8
@@
sub weaker ($$) {
return 0;
}
return 0;
}
+our $showg = $defeats->deep_copy();
+
our $schwartz;
for (;;) {
our $schwartz;
for (;;) {
@@
-391,6
+407,20
@@
if ($schwartz->vertices() == 1) {
printf " %-5s %s\n", $_, $choices{$_}{Desc}
foreach ($schwartz->vertices());
printf " %-5s %s\n", $_, $choices{$_}{Desc}
foreach ($schwartz->vertices());
+if (defined $gfile) {
+ foreach my $cho (values %choices) {
+ my $chn = $choices[$cho->{Index}];
+ my $label = "\\N\n$cho->{Desc}";
+ if ($cho->{Dropped}) {
+ $label .= "\nDropped: $cho->{Dropped}";
+ }
+ $showg->set_vertex_attribute($chn, 'label', $label);
+ }
+
+ my $gwriter = new Graph::Writer::GraphViz -format => 'ps';
+ $gwriter->write_graph($showg, $gfile);
+}
+
print ".\n";
#p %choices;
print ".\n";
#p %choices;