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

Bidirectional arrows should not force nodes into different levels #4745

Open
e-pet opened this issue Aug 18, 2023 · 1 comment
Open

Bidirectional arrows should not force nodes into different levels #4745

e-pet opened this issue Aug 18, 2023 · 1 comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@e-pet
Copy link

e-pet commented Aug 18, 2023

Description

Bidirectional arrows (A <--> B) force the involved nodes to be on different levels, with the first-mentioned one being placed higher up even if the nodes would be on the same level without the addition of the bidirectional link. This seems unnecessary and often yields undesirable results. Adding a bidirectional link should not change the relative ranking of the nodes.

Steps to reproduce

Example 1: without bidirectional link - A and B are on the same level.

flowchart TD
    C --> A & B

image

Example 2: with bidirectional link - now B is forced down one level. The diagram would look much nicer if everything stayed as in the previous example, just with the extra arrow.

flowchart TD
    C --> A & B
    A <--> B

image

Example 3: without bidirectional link - A and B are on the same level.

flowchart TD
    C --> A & B
    A --> D
    B --> E

image

Example 4: with bidirectional link - now B is forced down one level. The diagram would look much nicer if everything stayed as in the previous example, just with the extra arrow.

flowchart TD
    C --> A & B
    A --> D
    B --> E
    A <--> B

image

Screenshots

No response

Code Sample

No response

Setup

  • Mermaid version: 10.3.1
  • Browser and Version: Edge

Suggested Solutions

I know too little about the placement algorithm to make a useful suggestion. Could it be possible to just ignore bidirectional links for the purposes of determining the level on which to place a node? (Is the placement algorithm described / documented somewhere?)

Additional Context

Note that this is different from #4317 which is about keeping nodes on the same level even if they are connected by unidirectional links. While that issue would clearly require special treatment / syntax, I would hope that the issue described here could give a general improvement of the default placement behavior.

@e-pet e-pet added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Aug 18, 2023
@e-pet e-pet changed the title Bidirectional arrows should not force nodes on different levels in Flowcharts Bidirectional arrows should not force nodes into different levels Aug 18, 2023
@e-pet
Copy link
Author

e-pet commented Aug 18, 2023

Maybe this has to wait until after the planned Dagre/cytoscape migration? https://github.com/orgs/mermaid-js/discussions/3811

@jgreywolf jgreywolf added roadmap items to add to roadmap for auto workflow and removed roadmap items to add to roadmap for auto workflow labels Nov 16, 2023
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 Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

No branches or pull requests

2 participants