elk icon indicating copy to clipboard operation
elk copied to clipboard

How to get perfectly centered lines using layered, interactive strategy?

Open donutdan4114 opened this issue 1 year ago • 11 comments

This is a very real example of how our elk is setup. I have tried to fix the layout to achieve a perfect look. I have tried most options, but not sure how most of them work.

Two issues, may or may not be related:

  1. The nodes end up off-center.
  2. The weird bend is the big problem. Sometimes I can fix the bend by not using INTERACTIVE, but not sure of other consequences to switching from that strategy.

I am sure I am missing something obvious with how I should even be thinking about the node setup.

p.s. Thank you everyone for this amazingly powerful tool. Truly a work of wonder that it can do all that it does!

2 1

donutdan4114 avatar Apr 17 '24 02:04 donutdan4114

Try looking into nodePlacement.strategy. NETWORK_SIMPLEX as seen here might be what you want. But I think elk layered does currently not support the a node placement strategy that centers everything, maybe mrtree can do what you want.

soerendomroes avatar Apr 17 '24 15:04 soerendomroes

Thanks @soerendomroes , I'm working on this with @donutdan4114 . I updated the nodes so that, when multiple edges leave a node, theres an "source" port for each, and when they converge on a node, that node has a matching number of 'target' ports - seems to help with one of the edge problems. There is still the issue of the middle path not being aligned.

I have tried switching back and forth between NETWORK_SIMPLEX and BRANDES_KOEPF - its seems that when using NETWORK_SIMPLEX the alignment is better, however the balancing we are going for is gone. If we use BRANDES_KOEPF , the balancing is better, but the alignment is off.

Not sure how to achieve the center alignment of NETWORK_SIMPLES with the balancing of BRANDES_KOEPF

Updated Model

BCampbellDev avatar Apr 17 '24 18:04 BCampbellDev

Also ive found that when using BRANDES_KOEPF - if the farthest left node in the diagram, is made the width of the other nodes, 200, it solves the issue with the center line - not entirely sure why? lol maybe elk is working from left to right and thats the basis of the centering? so by making that node wider its pushing everything into a proper alignment?

BCampbellDev avatar Apr 17 '24 18:04 BCampbellDev

@BCampbellDev Sadly, there is currently no option for this. BRANDES_KOEPF even with bk.fixedAlignment: BALANCED will only balance based on the whole graph and not locally since this does usually cost more space and drawings get bigger. NETWORK_SIMPLEX cannot be combined with BRANDES_KOEPF. Implementing a simple centering strategy node placement strategy is however on our agenda.

soerendomroes avatar Apr 17 '24 18:04 soerendomroes

@BCampbellDev I will mark this as a bug and try to investigate this.

soerendomroes avatar Apr 17 '24 18:04 soerendomroes

thanks @soerendomroes

BCampbellDev avatar Apr 17 '24 18:04 BCampbellDev

@soerendomroes I was able to find some success by regrouping and using parent nodes, and I think this is the direction I will head in. I do have one question about this I'm wondering if you or anyone else could shed light on

Model

Is there a way to top align the three nodes, N3A, N3B, N3C ?

BCampbellDev avatar Apr 17 '24 21:04 BCampbellDev

@BCampbellDev Yes, by setting alignment for each node as documentated here and seen here.

soerendomroes avatar Apr 17 '24 21:04 soerendomroes

Ah thank you @soerendomroes I will try that!

BCampbellDev avatar Apr 17 '24 21:04 BCampbellDev

@soerendomroes perfect thank you so much

BCampbellDev avatar Apr 17 '24 21:04 BCampbellDev

@soerendomroes would you have any thought on this one ? its slightly different so I created a new question for it

What is the best strategy / approach for balancing and aligning the contents of a node with the graph

BCampbellDev avatar Apr 23 '24 16:04 BCampbellDev