Ooker
Ooker

Reputation: 3032

How to have split arrow in GraphViz?

I want to have branching arrows like this graph:

enter image description here

Here is my current code:

digraph {
    splines=curved
    a -> b -> c -> d -> e 
    e -> a [ label=1 ]
    e -> f [ label=2 ]
}

Using neato you can see that the arrows don't come from one root:

enter image description here

There is a trick to use an invisible joint node

digraph {
    splines=curved
    a -> b -> c -> d -> e 
    e -> joint [ dir=none ]
    joint [shape="none", label="", width=0, height=0]
    joint -> a [ label=1 ]
    joint -> f [ label=2 ]
}

But then the e -> a arrow is too long. And the arrow 2 is still not tangent with arrow 1.

enter image description here

Is there a way to achieve this effect?

Upvotes: 2

Views: 623

Answers (2)

Duo Tao
Duo Tao

Reputation: 56

I figured out an answer that makes it look a bit more perfect.

digraph {
    a -> b -> c -> d -> e 
    e -> joint [ dir=none ]
    joint [shape="point", style="filled", label="", width=0, height=0]
    a -> joint [ dir=none, label=1 ]
    joint -> f [ label=2 ]
}

Upvotes: 0

peter.cyc
peter.cyc

Reputation: 1813

Here's a tip:

digraph {
    splines=curved
    a -> b -> c -> d -> e 
    e -> joint [ dir=none ]
    joint [shape="none", label="", width=0, height=0]
    joint -> a [ label=1 ]
    joint -> f [ label=2 ]
    a -> f [style=invis]  //pull a and f together ~ "tangent" effect
}

I doubt if there is a better solution, Graphviz being what it is.

enter image description here

Upvotes: 3

Related Questions