Here is the code for decode.pl, which parsed the output
of the Nauty program
geng to produce this xhtml file:
#!/usr/bin/perl
$ROW_LENGTH = 12;
$SPACING = 60;
$OFFSET = 75;
$SIZE = 20;
$CIRCSIZE = 3;
$TOTAL_WIDTH = $SPACING * $ROW_LENGTH + $OFFSET;
sub line {
my ($x1, $y1, $x2, $y2) = @_;
qq(<line x1="$x1" x2="$x2" y1="$y1" y2="$y2"/>\n);
}
sub circle {
my ($x, $y, $r) = @_;
qq(<circle cx="$x" cy="$y" r="$r"/>\n);
}
$svg = qq(<svg width="$TOTAL_WIDTH" height="$SPACING" version="1.1"
xmlns="http://www.w3.org/2000/svg">);
$header = <<EOF;
<html xmlns="http://www.w3.org/1999/xhtml">
<head><style>
pre { margin: 20px 100px; padding: 0px 50px; }
pre, tt { background-color: rgb(200,200,200); }
line { stroke: rgb(30,80,110); }
circle { fill:rgb(185,120,80); }
</style></head>
<body>
Here is every graph on no more than 6 vertices.<br/>
$svg
EOF
open IN, $0 or die $!;
{local $/; $self = <IN>;}
$self =~ s/&/&/g;
$self =~ s/</</g;
$self_ad = <<EOF;
Here is the code for <tt>decode.pl</tt>, which parsed the output
of the <a href="http://cs.anu.edu.au/~bdm/nauty/">Nauty</a> program
<tt>geng</tt> to produce this xhtml file:
<pre>$self</pre>
In particular, I did the following:
<pre>bash\$ ./geng 1 > g
bash\$ ./geng 2 >> g
bash\$ ./geng 3 >> g
bash\$ ./geng 4 >> g
bash\$ ./geng 5 >> g
bash\$ ./geng 6 >> g
bash\$ ./decode.pl g > graphs.xhtml</pre>
EOF
$footer = <<EOF;
</svg><br/><br/>$self_ad</body></html>
EOF
print $header;
sub xc { cos ($_[0] * 2 * 3.1415926535) }
sub yc { sin ($_[0] * 2 * 3.1415926535) }
sub render {
my ($x, $y, $n, $g) = @_;
my $buf = "";
for my $i ((0..$n-2)) {
for my $j (($i+1..$n-1)) {
$g->[($j * ($j-1)) / 2 + $i] and
$buf .= line($x + $SIZE * xc($i/$n), $y + $SIZE * yc($i/$n),
$x + $SIZE * xc($j/$n), $y + $SIZE * yc($j/$n));
}
}
for (0..$n-1) {
$buf .= circle($x + $SIZE * xc($_/$n), $y + $SIZE * yc($_/$n), $CIRCSIZE);
}
return $buf;
}
my $t = 0;
while (<>) {
my ($esize, $egraph) = /^(.)(.*)/;
my $size = (ord $esize) - 63;
my $bits = join ("", map {sprintf("%06b", ord($_) - 63);} (split //, $egraph));
if ($t % $ROW_LENGTH == 0 && $t != 0) { print "</svg><br/>$svg\n" }
print render($OFFSET + ($t % $ROW_LENGTH) * $SPACING,
$OFFSET / 2,
$size, [split //, $bits]);
$t++;
}
print $footer;
In particular, I did the following:
bash$ ./geng 1 > g
bash$ ./geng 2 >> g
bash$ ./geng 3 >> g
bash$ ./geng 4 >> g
bash$ ./geng 5 >> g
bash$ ./geng 6 >> g
bash$ ./decode.pl g > graphs.xhtml