in reply to Re^3: how to construct tree from parent pointer list
in thread how to construct tree from parent pointer list
sub visit_preorder { my ($cb, node, $depth) = @_; $depth ||= 0; $cb->($node, $depth); visit_preorder($cb, $_, $depth+1) for $node->children(); }
For example, what is '$cb' ? What I am trying to do is output the tree in a flattened format once the tree is built. Something like : Fruit|Apple|Granny Smith.. Fruit being the parent of Apple, Apple being the parent of Granny Smith..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: how to construct tree from parent pointer list
by ikegami (Patriarch) on Jun 30, 2009 at 19:21 UTC |