B
B
Bogdan2017-11-12 19:58:45
.NET
Bogdan, 2017-11-12 19:58:45

How to calculate coordinates for a tree?

There is a certain diagram for the elements of which you need to calculate the coordinates so that there are no overlaps and the tree looks normal. The coordinates of the root element are set manually. Accordingly, when moving the root or deleting an element, all elements can be recalculated.
The tree should look something
drawingtrees_fulltree.png
like this : Did not work out.
Tell me an algorithm or something to implement something like this

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2017-11-13
@Nipheris

In your picture, a certain non-leaf node is located in the middle of the interval (along the X axis) that its child nodes occupy.
So solve the problem of determining how much space child nodes should take, including all their children, and so on. This problem can be solved by the PVG tree traversal algorithm, manually managing the vertex stack or using recursive calls to the traversal procedure.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question