Subject: | Graph::Easy::Group->add_group() always add child group to root graph instead of only current group |
Date: | Sun, 6 Jul 2014 05:39:11 -0700 |
To: | "bug-Graph-Easy [...] rt.cpan.org" <bug-Graph-Easy [...] rt.cpan.org> |
From: | Yubao Liu <liuyb [...] yahoo-inc.com> |
Without the two "del_group()", the node "world" will be added into sub group "xx.a".
I'm using Graph-Easy 0.75, I feel line 374 is buggy:
https://metacpan.org/source/SHLOMIF/Graph-Easy-0.75/lib/Graph/Easy/Group.pm#L372
# group with that name doesn't exist, so create new one 374: $group = $self->{graph}->add_group($name) unless ref $group; # index under the group name for easier lookup $self->{groups}->{ $group->{name} } = $group;
#!/usr/bin/perl
use Graph::Easy;
use strict;
use warnings;
my $graph = Graph::Easy->new;
my $xx = $graph->add_group("xx");
my $a1 = $xx->add_group("a");
#$graph->del_group($a1);
my $yy = $graph->add_group("yy");
my $a2 = $yy->add_group("a");
#$graph->del_group($a2);
$a1->add_node("hello");
$a2->add_node("world");
print $graph->as_graphviz;
Regards,
Yubao Liu