looking for a "family tree" data type

Discussion in 'Java' started by Henry Townsend, Jan 19, 2008.

  1. Is there a standard Java tree structure which allows the programmer to
    attach nodes to parent nodes? Basically I need to represent something
    like a family tree (actually it's a process tree but the logic is the
    same). For each new node I will know, or have a way of determining,
    which pre-existing node is its parent and just need to attach it there,
    and subsequently have a means of traversing it.

    Everything tree-related I can find in java.* is either a GUI/display
    class(like JTree) or has a "natural ordering" like java.util.TreeSet
    which does not allow the user to pick the parent.

    Of course I could implement something myself by making each object hold
    a reference to its parent and a list of references to its children etc,
    but would prefer to use something built-in, documented, and stable. Does
    a class like this exist?

    Thanks,
    HT
     
    Henry Townsend, Jan 19, 2008
    #1
    1. Advertising

  2. Henry Townsend wrote:
    > Everything tree-related I can find in java.* is either a GUI/display
    > class(like JTree) or has a "natural ordering" like java.util.TreeSet
    > which does not allow the user to pick the parent.
    >

    The javax.tree package has the DefaultTreeModel. While it is meant as a
    model for display, you could very well just use that as a
    data-structure; no need for any GUI if you don't want to.

    My two humble cents.

    /W
     
    Wildemar Wildenburger, Jan 19, 2008
    #2
    1. Advertising

  3. Henry Townsend

    Lew Guest

    Wildemar Wildenburger wrote:
    > Henry Townsend wrote:
    >> Everything tree-related I can find in java.* is either a GUI/display
    >> class(like JTree) or has a "natural ordering" like java.util.TreeSet
    >> which does not allow the user to pick the parent.
    >>

    > The javax.tree package has the DefaultTreeModel. While it is meant as a
    > model for display, you could very well just use that as a
    > data-structure; no need for any GUI if you don't want to.
    >
    > My two humble cents.


    Better to roll your own.

    --
    Lew
     
    Lew, Jan 19, 2008
    #3
  4. Henry Townsend

    Roedy Green Guest

    On Sat, 19 Jan 2008 08:34:20 -0500, Henry Townsend
    <> wrote, quoted or indirectly quoted someone
    who said :

    >Is there a standard Java tree structure which allows the programmer to
    >attach nodes to parent nodes?


    see http://mindprod.com/jgloss/tree.html
    --
    Roedy Green, Canadian Mind Products
    The Java Glossary, http://mindprod.com
     
    Roedy Green, Jan 19, 2008
    #4
  5. Roedy Green wrote:
    > On Sat, 19 Jan 2008 08:34:20 -0500, Henry Townsend
    > <> wrote, quoted or indirectly quoted someone
    > who said :
    >
    >> Is there a standard Java tree structure which allows the programmer to
    >> attach nodes to parent nodes?

    >
    > see http://mindprod.com/jgloss/tree.html


    I had in fact done so previously and just checked back again but don't
    see anything that seems relevant. Have I missed something twice? Other
    than a passing reference to DefaultTreeModel which another poster has
    also mentioned, and which I'm now reading up on?

    Thanks,
    HT
     
    Henry Townsend, Jan 19, 2008
    #5
  6. Lew wrote:
    > Wildemar Wildenburger wrote:
    >> Henry Townsend wrote:
    >>> Everything tree-related I can find in java.* is either a GUI/display
    >>> class(like JTree) or has a "natural ordering" like java.util.TreeSet
    >>> which does not allow the user to pick the parent.
    >>>

    >> The javax.tree package has the DefaultTreeModel. While it is meant as
    >> a model for display, you could very well just use that as a
    >> data-structure; no need for any GUI if you don't want to.
    >>
    >> My two humble cents.

    >
    > Better to roll your own.
    >

    1. He said he'd like to use a tried and tested implementation.
    2. Why? :)

    /W
     
    Wildemar Wildenburger, Jan 19, 2008
    #6
  7. Henry Townsend

    Jeff Higgins Guest

    Henry Townsend wrote:
    > Is there a standard Java tree structure which allows the programmer to
    > attach nodes to parent nodes?
    > [snip]
    > but would prefer to use something built-in, documented, and stable. Does
    > a class like this exist?
    >


    How about documented, not built in, and not stable?
    <https://jsfcompounds.dev.java.net/>
    See the subproject treeutils.
     
    Jeff Higgins, Jan 19, 2008
    #7
  8. Henry Townsend

    Lew Guest

    Wildemar Wildenburger wrote:
    > 1. He said he'd like to use a tried and tested implementation.
    > 2. Why? :)


    All right, then, how about
    <http://myfaces.apache.org/tomahawk/apidocs/org/apache/myfaces/custom/tree2/TreeModelBase.html>
    and its related classes?

    --
    Lew
     
    Lew, Jan 19, 2008
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. luna
    Replies:
    1
    Views:
    6,828
  2. heyo
    Replies:
    3
    Views:
    924
    Dan Pop
    Apr 1, 2004
  3. pete
    Replies:
    4
    Views:
    802
    Dan Pop
    Apr 2, 2004
  4. family tree and

    , Dec 22, 2005, in forum: C Programming
    Replies:
    8
    Views:
    378
    Sven Hesse
    Dec 23, 2005
  5. Ata Jafari
    Replies:
    8
    Views:
    1,805
    rantingrick
    Jan 16, 2011
Loading...

Share This Page