Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to join edges to same point on node?

I want two edges to connect to the same point on a node, like in this screenshot:

graph with nodes converging on central point

I tried the following simple code but the edges aren’t connecting as I want them. I want them to connect to a central point under the node, not inside the node. So if the shape were a box instead plaintext the edges should be connecting underneath the box to the middle of its lower perimeter.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

strict graph {

    node [
        shape=plaintext,
    ]

    A
    B
    C

    A -- B
    A -- C
}

graph with nodes converging on peripheral point

I also tried several things using ports but I couldn’t get the desired result. What I want is a binary tree of plain text nodes that always follow the shown pattern – so ideally I wouldn’t have to set the attribute on each node/edge but could specify the necessary attributes at top level for the whole graph.

>Solution :

If I understand the request, adding ports does the trick. Also added splines=false to guarantee straight lines.

strict graph {
  splines=false  // for straight lines
    node [
        shape=plaintext,
    ]

    A
    B
    C

    A:s -- B  // added port
    A:s -- C  // added port
}

Giving:
enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading