Subject: | BalancedTree of height=1 |
Date: | Sat, 30 May 2015 18:59:29 +1000 |
To: | bug-Graph-Maker [...] rt.cpan.org |
From: | Kevin Ryde <user42_kevin [...] yahoo.com.au> |
With Graph::Maker 0.02, a program
use Graph::Maker::BalancedTree;
foreach my $height (1 .. 5) {
my $g = new Graph::Maker('balanced_tree', fan_out => 2, height => $height);
print "height=$height ",scalar($g->vertices),"\n";
}
prints
height=1 3
height=2 3
height=3 7
height=4 15
height=5 31
but for height=1 I expected the graph would be a single vertex (the
root), not 3 vertices.
Incidentally, in the code instead of an @newLeaves array you could
consider tracking just the vertex numbers of the first and last of the
preceding row, since the numbers are contiguous. (Initially start=1 and
end=1 for the single root node as first row.)