Differences between revisions 11 and 12
Revision 11 as of 2018-11-17 23:36:55
Size: 3258
Editor: risca
Comment:
Revision 12 as of 2018-11-17 23:39:21
Size: 3450
Editor: risca
Comment:
Deletions are marked like this. Additions are marked like this.
Line 92: Line 92:

label="{ {Level 0} | { First | Second | Third } | { 0 | 1 | 2} }" # those are the same
label="{ {Level 0} | { {First | 0} | {Second | 1} | {Third | 2} } }" # this is vertically aligned

Tools

  • xdot
  • viz.js: online editor-viewer

Examples

From about-Graphviz (and many more examples):

digraph D {

  A [shape=diamond]
  B [shape=box]
  C [shape=circle]

  A -> B [style=dashed, color=grey]
  A -> C [color="black:invis:black"]
  A -> D [penwidth=5, arrowhead=none]

}

Fake cell for better formatting:

digraph
{
    /* layout */
    // node width to create space for longer labels
    node [ width = 1.75 ];
    { rank=same; a; b; c }

    /* nodes */
    t [ label = "TOP", shape = doublecircle, width = 1];
    a [ label = "short" ];
    b [ label = "medium" ];
    c [ label = "rather  l o n g"]
    // invisible nodes to 're-route' the edges
    x [ style = invis, shape = point, width = 0 ];
    y [ style = invis, shape = point, width = 0 ];

    /* edges */
    t -> t;
    t -> { a b c }
    t -> { a b c } [dir = back ];      // added for reverse arrows
    a -> b -> c -> b -> a;
    a:nw -> a:sw;
    c:ne -> c:se;
    b:s -> b:s;
    // put the invisible nodes at the desired places with invisible edges
    b -> x -> y [ style = invis ];
    // edges to invisible nodes must not have heads
    c:sw -> x [ arrowhead = "none" ];
    x -> a:se;
    a:s ->  y [ arrowhead = "none" ];
    y -> c:s;
}

Commands

Everything starts with: digraph or graph (not directional).

Cluster

If a subgraph name starts with cluster then will be drawn with its own rectangle layout.

Attributes:

  • for label:
    • labelloc (label position)
    • labeljust (label justification)
    • color
    • style (default filled)
    • fillcolor

Node

Rank

Any of:

  • same
  • min/source (min will allow other subgraphs in the minimum rank. Source will not.)
  • max/sink

Shape

  • record: it's a positional table like
    • label="<f0> left|<f1> middle|<f2> right"
      label="hello\nworld |{ b |{c|<here> d|e}| f}| g | h"
      struct1:f1 -> struct2:f0
      struct1:f2 -> struct3:here
      
      label="{ {Level 0} | { First | Second | Third } | { 0 | 1 | 2} }"    # those are the same
      label="{ {Level 0} | { {First | 0} | {Second | 1} | {Third | 2} } }" # this is vertically aligned
  • or: Mdiamond, Msquare

Group

For forcing vertical alignment. See https://stackoverflow.com/questions/43599738/graphviz-alignment-of-subgraph https://stackoverflow.com/questions/1554635/graphviz-how-to-have-a-subgraph-be-left-to-right-when-main-graph-is-top-to-bot

Edge

  • constraint=false: avoid ranking dependency

  • splines=line|polyline|curved|ortho|spline

Label

label
taillabel
headlabel

Port

node:s -> node1:n
node -> node1 [tailport=n, headport=s]

Cluster end

To draw outside of cluster border:

c -> g [ltail=cluster0, lhead=cluster1]

Arrow shapes

See list

Documentation

MyWiki: graphviz (last edited 2018-11-17 23:39:21 by risca)