Version 0.02
use Tree::Create::DepthFirst; my $tree_creator = Tree::Create::DepthFirst->new(); $tree_creator -> addNode(0, 'child 1'); $tree_creator -> addNode(0, 'child 2'); $tree_creator -> addNode(1, 'grand chhild 1'); $tree_creator -> addNode(1, 'grand chhild 2'); $tree_creator -> addNode(2, 'grand-grand chhild 2'); my $tree_simple = $tree_creator->getTree();
Creates the tree creator.
my $tree_creator = Tree::Create::DepthFirst->new()
From now on, you will want to call
$tree_creator->addNode(…);
until the tree is finished. Then you get the created tree with
my $tree_simple = $tree_simple->getTree();
Add tree nodes and leaves in the same order as a depth first traversal would traverse the tree.
There are two restrictions on $depth: a) it must be greater or equal to 0. b) It must not be greater than the last added node's $depth+1.
After building, getTree() returns the created tree (as a Tree::Simple) object.
$tree_simple = $tree_creator->getTree();
René Nyffenegger, <rene.nyffenegger at adp-gmbh.ch>
<rene.nyffenegger at adp-gmbh.ch>
According to the LICENSE file that comes with the package.
LICENSE
The source code is in this Github repository
To install Tree::Create::DepthFirst, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tree::Create::DepthFirst
CPAN shell
perl -MCPAN -e shell install Tree::Create::DepthFirst
For more information on module installation, please visit the detailed CPAN module installation guide.