Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subgraph positioning questions #6204

Open
keenanwells-tatari opened this issue Jan 19, 2025 · 0 comments
Open

Subgraph positioning questions #6204

keenanwells-tatari opened this issue Jan 19, 2025 · 0 comments
Labels
Status: Triage Needs to be verified, categorized, etc

Comments

@keenanwells-tatari
Copy link

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?
@github-actions github-actions bot added the Status: Triage Needs to be verified, categorized, etc label Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc
Projects
None yet
Development

No branches or pull requests

1 participant