I am creating a family tree program. My question is how do I host nodes? Initially, I positioned the root in the center of my screen, and it works fine if it is a perfect binary tree, and the levels are much smaller. However, this is not most often. This is a sample of a tree: -
A BC DEFIJ KLNO
As you can see, the main problem is with the location of the nodes. If a node has many children, and next to it node also has many children, they tend to overlap . (MAIN PROBLEM) I am using absolute node positioning using Canvas in Silverlight. If you are not a Silverlight developer, you can not worry about the Silverlight and Canvas parts. I just need the logic of the location of the nodes.
The height of the tree can be easily calculated, knowing the total number of levels of the tree, but the width of the tree is what bothers me. How can I calculate the width of a tree (total canvas width)
Can someone give me some general recommendations on how to set the width of the canvas and what logic will work ideally for positioning nodes.
NOTE: - I do not ask for the whole algorithm, and this is not my homework. I already have an algorithm and a database. I just need a guide for the positional part of node.
Thank you in advance:)
source share