On Nov 19, 2007 8:37 PM, vijay <[EMAIL PROTECTED]> wrote: > Thanks for the help. I have another question. How do I compute the > depth of those trees. Do I need to first find the root of the tree and > then try of find the depth of the tree? Is there a more efficient > algorithm to find the depth? snip
If you are going to use the Graph module then you can simply say $g->longest_path. In scalar context it will return the depth (in list context it returns the actual path). snip > Is there a "Tree" module that I can use. > I could only find something called Tree::Nary which is not very useful > to me. Thank you. snip If you search CPAN* for tree you will find many implementations, but it is not common to use data structures directly. Unless you are doing something no one else has ever done, you are likely to find a module on CPAN that does what you want. What data structure it uses to do it is usually unimportant. Perhaps if you told us what you need a tree for (because you almost never need a tree for itself) we could suggest a good high level module. * http://search.cpan.org/search?q=tree -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/