elkjs icon indicating copy to clipboard operation
elkjs copied to clipboard

Encourage nodes to be in upper layers

Open mike-oakley opened this issue 3 years ago • 1 comments

Hi,

Is there any way to encourage ELK to place nodes in the upper layers of a graph? For example, in the below image, making the circled node move up a layer (where the arrow is pointing to) so the edge is shorter at the top and longer at the bottom?

image

My current layout options are:

defaultLayoutOptions: {
  "elk.algorithm": "layered",
  "elk.edgeRouting": "ORTHOGONAL",
  // Encourage ELK to layout in a symmetric way.
  "elk.layered.nodePlacement.favorStraightEdges": "false",
  "elk.layered.crossingMinimization.semiInteractive": "true",
  // Maintain the order that we specified in.
  "elk.layered.considerModelOrder": "NODES_AND_EDGES",
  // Layout downwards.
  "elk.direction": "DOWN",
  // Spacing of nodes and layers.
  "elk.spacing.nodeNode": "20",
  "elk.spacing.edgeNode": "20",
  "elk.layered.spacing.nodeNodeBetweenLayers": "0",
}

Thanks for your help!

mike-oakley avatar Sep 24 '21 09:09 mike-oakley

There's an option priority.shortness. It has to be set manually on the edges though. In other words, you'd have to know upfront, which edges you want to be shorter.

uruuru avatar Oct 31 '21 08:10 uruuru