I have a program where I have a tree. I place the nodes and their edges in NodeList and EdgeList. Then put the lists in a DirectedGraph which I then run through DirectedGraphLayout.visit().
I now place the nodes and edges on the screen. The diagram is almost perfect but there are some inconsistencies with nodes being out of order.
The first one is shown in the following picture. As you can see it places a few children of parent1, then places some nodes from parent2. Then for some reason that I can't figure out it places the last child from parent1 to the right of parent2's children.
The next problem are the children of a parent being out of order. When the children should be placed in the order: 1 2 3 4, they are instead placed in different orders such as: 2 3 1 4.
I have tried adding the nodes to NodeList is different orders, trying post and pre order recursion to parse my tree. I end up getting the exact same positioning.
I'm at a loss on how to fix this. Any tips about how DirectedGraph works and why it's placing nodes like this is appreciated.
From the DirectedGraphLayout documentation,
[the layout algorithm will] assign x coordinates such that the graph is easily readable. The exact behavior is undefined
And further down
This class is not guaranteed to produce the same results for each invocation.
So I guess there is no way to "fix" this as the behavior is undefined.