kieler / elkjs

ELK's layout algorithms for JavaScript
Other
1.81k stars 97 forks source link

Encourage nodes to be in upper layers #150

Open mike-oakley opened 3 years ago

mike-oakley commented 3 years ago

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!

uruuru commented 3 years ago

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.