Skip to content

Subgraph positioning questions #6204

Open
@keenanwells-tatari

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):

Image

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
Loading

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    
Loading

where this node layout:

flowchart TB    
    one
    two
    three
    four

outputs this layout (order 1,2,3,4)

flowchart TB    
    one
    two
    three
    four
Loading

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:

  1. Is there any other straightforward way I can achieve this positioning with subgraphs aside from changing the order of their definitions?
  2. What's the reason that subgraphs should have this default positioning?

Metadata

Assignees

No one assigned

    Labels

    Status: TriageNeeds to be verified, categorized, etc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions