DBIx::Table::TestDataGenerator::TreeUtils - tree builder, used internally to handle self-references in the target table
This module has nothing to do with databases and could be used on its own. It handles ordered directed graphs, we call them trees here for lack of a better word, but in general they are trees with the root node cut off. The trees are represented as hashes where the keys are seen as parent identifiers and the values are references to arrays containing the child identifiers as elements. It provides a method add_child which adds a node in a place automatically determined and satisfying constraints defined by the parameters passed to add_child. Branches where no more children will be added are removed from the tree in the process.
Stack containing the currently handled node and its ancestors, internal use only.
Contains the handled nodes, i.e. those not getting any more child nodes, internal use only.
Removes the root node $base and all its descendants from the tree $tree_ref and returns a reference to the pruned tree, internal use only.
Reference to a tree (see above for what we mean by "tree").
Identifier of the current child node to be added.
For each handled parent node, this is the minimum number of child nodes to be added. The minimum number may not be reached if the parent node is the last one for which add_child is called.
Maximum depth at which nodes are added, must be at least 2 since all nodes other than root nodes are at least at level 2. The returned result is a pair ($tree_ref, $parent_id), where $tree_ref is a reference to a tree based on the old tree containing an additional child node with identifier $pkey, the tree may have been pruned, too. $parent_id is the identifier of the node at which the child note has been appended. The position of the appended node is determined in a depth-first manner.
Jose Diaz Seng,
<josediazseng at gmx.de>
Copyright 2012 Jose Diaz Seng.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.