eclipse / elk

Eclipse Layout Kernel - Automatic layout for Java applications.
https://www.eclipse.org/elk/
Other
259 stars 86 forks source link

Layered NPE when not-partitioned node has specifically-partitioned neighbors #969

Open keyserj opened 1 year ago

keyserj commented 1 year ago

It seems that an exception is thrown if a layered, partitioned graph has a not-partitioned node with:

Is this expected? Here is an example configuration.

In my case, I have types of nodes and I'm blindly setting partitions based on those types, so ideally the solution would not be to set different partitions, and there is one node type that prefers no partition so that it can be placed anywhere that fits. My current easy workaround is to remove partitioning if the error is encountered 😅 since partitioning is more of a nice-to-have for me.

It would be ideal for me if source-target directions all point the same way, rather than preserving the partitioning here, like this, but I could also see prioritizing the partition order without matching source-target directions like this.

soerendomroes commented 12 months ago

This seems to be a bug in the port side calculation, as seen here, which causes an NPE. We currently do not have a partitioning strategy that only uses the partition as a tie-breaker. You can however use the GREEDY_MODEL_ORDER cycle breaking strategy to try to minimize the edges in the layout direction and use the order of nodes in the input model as a tie-breaker. Note that this does not really work together with partitioning.

soerendomroes commented 2 months ago

Maybe, this should be solved by setting a default partition of 0 or to throw an exception if one node has to partition.

The problem is that the iteration order may create problems since the transitive ordering is not respected. Hence when comparing a node with no partition to a node with a partition one may make an uninformed decision that creates a cycle if partitions are respected.