[Oc-pm] graphviz

Bob Mathews bobmath11 at icloud.com
Tue Jun 30 11:12:34 PDT 2015


Graphviz is a lot of fun! Thanks for mentioning it, Ramana. This makes a map of the “squared mod 11” function (2*2=4, 4*4=16, 16%11=5). I tweaked the location of one of the nodes, because the default starting location came out ugly. You can change all the colors and shapes, too.

 -bob

use strict;
use warnings;
use GraphViz2;
my $n = 11;
my $g = GraphViz2->new(global => { directed => 1 });
$g->add_node(name => 6, pos => '100,100');
for my $i (0 .. $n-1) {
   my $j = ($i * $i) % $n;
   $g->add_edge(from => $i, to => $j);
}
$g->run(driver => 'neato', format => 'png', output_file => "$n.png");

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/oc-pm/attachments/20150630/868dc230/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eleven.png
Type: image/png
Size: 14278 bytes
Desc: not available
URL: <http://mail.pm.org/pipermail/oc-pm/attachments/20150630/868dc230/attachment.png>


More information about the Oc-pm mailing list