sub tree_dag_node { my($tree) = Tree::DAG_Node -> new({name => 'Root'});
$tree -> attributes({uid => 0}); my($count) = 0; my(%node); for (qw/H I J K L M N O P Q/) { $node{$_} = Tree::DAG_Node -> new({name => $_}); $node{$_} -> attributes({uid => ++$count}); } $tree -> add_daughter($node{H}); $node{H} -> add_daughter($node{I}); $node{I} -> add_daughter($node{J}); $node{H} -> add_daughter($node{K}); $node{H} -> add_daughter($node{L}); $tree -> add_daughter($node{M}); $tree -> add_daughter($node{N}); $node{N} -> add_daughter($node{O}); $node{O} -> add_daughter($node{P}); $node{P} -> add_daughter($node{Q}); print map("$_\n", @{$tree -> tree2string}); print map("$_\n", @{$tree -> tree2string({no_attributes => 1})});
} # End of tree_dag_node.
To install Tree, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tree
CPAN shell
perl -MCPAN -e shell install Tree
For more information on module installation, please visit the detailed CPAN module installation guide.