Description
Hello,
Thanks for your work on this tool, I've been meaning to use it for a while and have started trying to do some things with graphs/subgraphs.
I have a general question about how subgraph positioning should work. I'm trying to set up simple layout like this (draw.io diagram):
Where you would have subgraphs in those positions.
I'm using invisible links to position subgraphs, and the only way I've been able to get the layout working is via the ordering of the subgraph definitions:
flowchart TB
subgraph host3
s3
end
subgraph host4
s4
end
subgraph host1
s1
end
subgraph host2
s2
end
host1 ~~~ host2
host3 ~~~ host4
the above will output the diagram:
flowchart TB
subgraph host3
s3
end
subgraph host4
s4
end
subgraph host1
s1
end
subgraph host2
s2
end
host1 ~~~ host2
host3 ~~~ host4
You can see I have to define host3 and host4 subgraphs above host1 and host2.
Seems like in general the way subgraphs work, you will always get subgraphs displayed from last to first defined, as opposed with nodes where you get first to last defined.
For example:
This subgraph layout
flowchart TB
subgraph one
1
end
subgraph two
2
end
subgraph three
3
end
subgraph four
4
end
outputs mermaid diagram (order 4,3,2,1):
flowchart TB
subgraph one
1
end
subgraph two
2
end
subgraph three
3
end
subgraph four
4
end
where this node layout:
flowchart TB
one
two
three
four
outputs this layout (order 1,2,3,4)
flowchart TB
one
two
three
four
I would prefer to have subgraph default positioning work more like node default positioning, for ease of writing and readability (makes more sense IMO).
My questions are:
- Is there any other straightforward way I can achieve this positioning with subgraphs aside from changing the order of their definitions?
- What's the reason that subgraphs should have this default positioning?