Skip to content

Conversation

@alesya-h
Copy link

@alesya-h alesya-h commented Aug 14, 2025

What is it

This introduces the keyword layout that can be used at any level (root and subgraphs) and allows to specify and pass layout options directly to the layout engine. Explicit user options override default/autogenerated ones. See examples below.

Help needed

While I have been coding for living for over 15 years, I never used go, so this was made with some AI help. Consequently, while it works, it might be not perfect and could benefit from a pair of human eyes reviewing and correcting it.

Potential improvements for later:

  • Make it so you don't have to pass --layout elk on the command line
  • Add support for dagre
  • Add more examples and test more variations
  • Update documentation

Examples

layout: {
  elk.algorithm: "stress"
}

A -> B
A -> C
B -> D
C -> D
D -> E
B -> F
C -> G
F -> H
G -> H
H -> I
E -> I
Screenshot 2025-08-15 at 03 13 52
layout: {
  elk.direction: "RIGHT"
}

Start -> Process1 -> Process2 -> End
Start -> AltProcess -> End
image
layout: {
  spacing.nodeNodeBetweenLayers: 200
  spacing.edgeNodeBetweenLayers: 100
}

A -> B -> C -> D
E -> F -> G -> H
I -> J -> K -> L

A -> E
B -> F
C -> G
D -> H
image

@i-am-the-slime
Copy link

Very cool!

@alesya-h alesya-h changed the title WIP: add support for specifying layout options and passing them to layout engines (starting with ELK) Add support for specifying layout options and passing them to layout engines (starting with ELK) Sep 7, 2025
@alesya-h
Copy link
Author

alesya-h commented Sep 7, 2025

I've rebased everything and updated commits to have my signature, so this presumably only needs maintainers' eyes at this point.

@rachidaitseddik
Copy link

Tested and confirmed working as described by @alesya-h. This is a very valuable contribution, thank you @alesya-h

@alesya-h
Copy link
Author

Can we have this reviewed and merged please? The actual change is fairly small, the diffstat only looks big because of a tiny update in tests that meant having to reaccept them (basically changing layout to _layout in a few places to not clash with the new keyword). It's been over 3 months and there's a risk it will get stale and gonna require rebasing. Pretty please? With a cherry on top? 🍒

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants