Jump to content
  • Advertisement
Sign in to follow this  

Help with calculating optimal display position for tree nodes?

This topic is 3630 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

For a project I'm working on I need to display a tree of nodes and leafs to the user. In general, this is a simple thing to achieve until I decided that I wanted to achieve a best fit render. Currently I'm using a bottom up approach to rendering the tree. Count the children, calculate total width, append it to the parent and use that to calculate centers as I go up. This gets a nice output but on large networks can result in very unusable renderings. My first thought was to use a similar approach and total the number of children "vertically" per row, then use this to calculate placement: R NN NNN NNNNN NNN ... But this doesn't work so well once you start rendering and centering by offset as it can set child nodes in out order and doesn't allow parents to push the children when necessary. So, my question is, any ideas on how to calculate optimal placement for displaying a tree where a parent (P) can have 0..n children (N)? Thanks, - Jeremy

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!