Hi Tels,
Thanks for creating Graph::Easy. It's a great module. I'm using it for
creating inheritance graphs:
http://search.cpan.org/dist/Class-Sniff/
(See the 'graph' method)
Unfortunately, I can't figure out any way of ensuring that Graph::Easy
respects the order in which I add parents. This is problematic because
if someone is using multiple inheritance (bad, I know, but that's a code
smell this module is designed to detect), the graph might show the wrong
order in which parents were inherited. I'm now trying to add proper
groups to graphs and being able to control the left-to-right ordering of
nodes would be useful. The following is my simple test case:
use Graph::Easy;
my $graph = Graph::Easy->new;
$graph->set_attribute( 'graph', 'flow', 'up' );
my $group = $graph->add_group;
$group->add_nodes(qw<AA BB CC DD>);
$graph->add_edge_once(qw<Foo AA>);
$graph->add_edge_once(qw<Foo BB>);
$graph->add_edge_once(qw<Foo CC>);
$graph->add_edge_once(qw<Foo DD>);
$graph->add_edge_once(qw<AA UNIVERSAL>);
$graph->add_edge_once(qw<BB UNIVERSAL>);
$graph->add_edge_once(qw<CC UNIVERSAL>);
$graph->add_edge_once(qw<DD UNIVERSAL>);
print $graph->as_ascii;
my $graphviz = $graph->as_graphviz();
open my $DOT, '|dot -Tpng -o groups.png'
or die("Cannot open pipe to dot: $!");
print $DOT $graphviz;
I've attached a png to let you see what's happening. The AA, BB, CC, DD
order is not preserved. I realize that this may not be useful for
graphs in general, but it would save me a lot of pain if I could figure
this out :)
Cheers,
Ovid