29

How can edges and nodes be styled using graphviz dot with doubled lines as shown the in the "LEGAL" and "TAX DISC" nodes of the following diagram?

ER Diagram

Judge Maygarden
  • 25,264
  • 8
  • 76
  • 98

3 Answers3

45

Doubled shapes can be done by using [peripheries=2] on the node

Doubled edges can be done by specifying more than one colour for the edge, separated by a colon. In this case use the same colour twice: [color="black:black"] (or, to separate them slightly more, do [color="black:invis:black"])

I got there eventually! Sorry for the "evolutionary" nature of this answer :-)

So for example

graph G {
    Foo [peripheries=2]
    Foo -- Bar [color="black:white:black"]
}
Suzanne Soy
  • 2,522
  • 5
  • 32
  • 48
marnir
  • 1,077
  • 9
  • 12
  • 2
    Using the color `white` with a non-white background or objects can cause problems. See [my answer](http://stackoverflow.com/a/30759621/543738) for a better solution. – Mr. Lance E Sloan Jun 10 '15 at 14:43
15

The accepted answer is correct about using the peripheries attribute for multiple node outlines.

However, using the color white to draw widely-separated double edges between nodes is not ideal. If such an edge is drawn over a non-white background or crosses non-white objects, a white line will be visible. It is much better to use one of the colors none or invis. To update part of the example from the accepted answer:

graph G {
    Foo [peripheries = 2]
    Foo -- Bar [color = "black:invis:black"]
}

See the Graphviz color documentation for more information.

Community
  • 1
  • 1
Mr. Lance E Sloan
  • 2,724
  • 4
  • 28
  • 45
0

(See other answers about normal edges and nodes)

The three color solution does not work with directed edges with dir="back".

digraph A {
    foo -> bar [dir = "back", color = "black:invis:black"];
}

results in this output:

enter image description here

I tried wrapping it with invis layers outside. Looks a bit weird compared to normal arrows because of the increased edge width, but at least it is understandable to readers:

digraph A {
    foo -> bar [dir = "back", color = "invis:black:invis:black:invis"];
}

enter image description here

However this won't work with forward edges.

SOFe
  • 7,134
  • 4
  • 28
  • 57