Sign in to follow this  

Need Advice On Tree Data

This topic is 3626 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Everyone, I have some data that I want to put in a tree structure, but I need the following functionality: I need to be able to add and delete nodes and branches. To be able to replace a parent node with its child node. To be able get the next node up or down from any node in the tree. Each node should have an unlimited number of children. Instead of writing this myself, I thought I should first ask if there any tree libraries in C++ that have this kind of functionality? Or perhaps I don't need a tree and should use something else? Any suggestions would be greatly appreciated.

Share this post


Link to post
Share on other sites
Try searching some binary tree implementation and then customize it. Remember to test it before making your own changes, just in case if it is buggy. :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Davaris1
Each node should have an unlimited number of children.


Are you sure this is absolutely nessecary? If your only goal is fast access to stored data, a binary tree might be the better alternative. They are easy to write and also much simpler to maintain (see: AVL Tree). So unless you want to represents something else (like a bone hierarchy?) with it I recommend using one of these.

Share this post


Link to post
Share on other sites
Quote:
Original post by ChaosIII
Quote:
Original post by Davaris1
Each node should have an unlimited number of children.


Are you sure this is absolutely nessecary? If your only goal is fast access to stored data, a binary tree might be the better alternative. They are easy to write and also much simpler to maintain (see: AVL Tree). So unless you want to represents something else (like a bone hierarchy?) with it I recommend using one of these.


Perhaps he doesn't mean more than two direct children per node, but that all the nodes beneath a node and its children etc may be unlimited. Of course 'unlimited' in practice means limited by RAM, or at the very least hard disk.

Share this post


Link to post
Share on other sites
Thanks for the replies everyone. In case anyone is looking for the same thing in the future, here's a link to an n-tree implementation that fits the bill perfectly.

http://www.aei.mpg.de/~peekas/tree/#example

BTW I am using it store information in a game that has a branching story line. So sometimes I need nodes that have lots of children.

>Did you look at the Tree Container Library?

No not yet. Thanks! I'll check it out. :)

Share this post


Link to post
Share on other sites

This topic is 3626 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this