René Nyffenegger

VERSION

Version 0.02

SYNOPSIS

 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();

Methods

new()

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();

addNode($depth, $nodeValue)

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.

getTree()

After building, getTree() returns the created tree (as a Tree::Simple) object.

    $tree_simple = $tree_creator->getTree();

AUTHOR

René Nyffenegger, <rene.nyffenegger at adp-gmbh.ch>

LICENSE

According to the LICENSE file that comes with the package.

LINKS

The source code is in this Github repository