Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: How do "you" make a tree in perl

by cchampion (Curate)
on Sep 29, 2004 at 09:37 UTC ( [id://394896]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How do "you" make a tree in perl
in thread How do "you" make a tree in perl

Tree::DAG_Node may look like overshooting, but it does what it promises, i.e. a simple way of dealing with complex tree structures. I share your chagrin about lack of tests, but having seen that knowledgeable people like merlyn and perrin use it, I feel confident that it must not be as bad as you may think.

A simple example that makes me love this module:

#!/usr/bin/perl -w use strict; use Tree::DAG_Node; my $tree = [ [ 'Node1' ], [ [ 'GrandChild1' ], [ 'GrandChild2' ], 'Node2' ], 'Root' ]; my $dagnode= Tree::DAG_Node->lol_to_tree($tree); print map {"$_\n"} @{ $dagnode->draw_ascii_tree }; __END__ And the output is: | <Root> /-----------------\ | | <Node1> <Node2> /-------------\ | | <GrandChild1> <GrandChild2>

There is also a nice Introduction to Tree::DAG_Node in Tutorials.

Replies are listed 'Best First'.
Re^4: How do "you" make a tree in perl
by stvn (Monsignor) on Sep 29, 2004 at 15:12 UTC
    I share your chagrin about lack of tests, but having seen that knowledgeable people like merlyn and perrin use it, I feel confident that it must not be as bad as you may think.

    While I have the plenty of respect for merlyn and perrin and their collective experience, I don't take their choices on blind faith (that is not say that you are). I also know that Tree::DAG_Node seems to have been (for the most part) the only choice out there (the last version of Tree::DAG_Node was released in 2001 and the first version was released in 1998). Tree::DAG_Node does a lot too (IMO it tries to do too much), and I am sure people were reluctant to have to implement that themselves, so it was better to just use it, however that doesn't mean that it was always the best choice.

    And as for the lack of tests, for me this was the deal breaker. The application for which I originally developed Tree::Simple used tree structures as a fundemental component which was at the lowest levels of the application. I needed a n-ary tree which was well tested and that I was confident would work as I needed it to. Tree::DAG_Node just did not fit this description for me.

    A simple example that makes me love this module:

    I agree with you, I simultaniously like and dislike how much you can do with Tree::DAG_Node. It is all good functionality, but I think its too much packed into one module. My goal with Tree::Simple is to provide all the same functionality (and more) but with a more modular and flexible design. Tree::Simple::VisitorFactory is inteneded to be a means of adding functionality which really does not belong in Tree::Simple, while Tree::Simple::View is intended to help keep the display layer seperate (it has an HTML and DHTML version, and I am working on a Tk version too). I also working on a Tree::Visualize module, which currently draws Tree::Simple and Tree::Binary trees in ASCII and with GraphViz in a number of layout styles (top-down like DAG_Node does, as well as others).

    IMO all these things should be in seperate modules, not all squished into one.

    -stvn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://394896]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-03-19 04:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found