Welcome to yEd Q&A!
Here you can ask questions and receive answers from other members of the community and yEd developers. And you can tell us your most wanted feature requests.


Hierarchical Layout: Order system?

+2 votes
How does yEd determine the order in which way nodes are set when using the hierarchical layout?

I have one node which is linked to six other nodes. These six nodes have a certain order and several sub-trees of different size are attached to them. The diagramm looks like this:

... - 1 \

... - 2 \

... - 3 - A

... - 4 /

... - 5 /

... - 6 /

Whenever I use the hierarchical layout function (or the partial layout function) yEd does change the given order in a way I do not understand. The diagram then looks like this:

... - 1 \

... - 3 \

... - 4 - A

... - 2 /

... - 6 /

... - 5 /

How can I prevent yEd from doing this? I know, I can set the Partial Layout to "As Is", but then it does not sort the nodes (and the attached trees) at all.

Is there any way I can tell yEd: "When organizing the second layer, give 'node 1' first top-down-priority, then 'node 2' then 'node 3', etc."?
in Help by

1 Answer

+2 votes

Hierarchical layout tries to order the nodes in such a way that there are as few edge crossings as possible. To do so, the algorithm starts with a random ordering and subsequently tries to improve on that ordering. The randomization is a very important step to achieve good results in the general case.

To specify a ordering for the second layer, you can try to manually order the edge connection points at node A  according to your needs. Then select node A and go to "Tools -> Constraints -> Port Constraints". Choose "Configuration Method" "From Sketch", select "Fix Source Port" (but not "Fix Target Port")*, and choose "Act On" "Ports at Selected Nodes". Click ok then run the hierarchical layout. If you reordered the edges only sloppily, open "Port Constraints" once again, choose "Remove all Port Constraints", click ok, run hierarchical layout once again, but this time select "Use Drawing As Sketch" on the first tab.

* This assumes that A is the source node of all edges connecting to it. If it is the target node, select "Fix Target Port" instead of "Fix Source Port".

by [yWorks] (161k points)
How to order nodes per level in Hierarchical Layout
Legal Disclosure | Privacy Policy