Site Search:

dot language examples








Graph (colored and no duplicate edges)
strict graph {
  a[color=red];f[style=filled];
  a -- c
  d -- b
  b -- a [color=blue]
  a -- d
  d -- c
  d -- a

simple graph

graph {
    a -- b;
    b -- c;
    a -- c;
    d -- c;
    e -- c;
    e -- a;
}

simple digraph

digraph {
    a -> b;
    b -> c;
    c -> d;
    d -> a;
}

weighted graph

graph {
    a -- b[label="0.2",weight="0.2"];
    a -- c[label="0.4",weight="0.4"];
    c -- b[label="0.6",weight="0.6"];
    c -- e[label="0.6",weight="0.6"];
    e -- b[label="0.7",weight="0.7"];
}

weighted digraph

digraph {
    a -> b[label="0.2",weight="0.2"];
    a -> c[label="0.4",weight="0.4"];
    c -> b[label="0.6",weight="0.6"];
    c -> e[label="0.6",weight="0.6"];
    e -> e[label="0.1",weight="0.1"];
    e -> b[label="0.7",weight="0.7"];
}

highlight a path

graph {
    a -- b -- d -- c -- f[color=red,penwidth=3.0];
    b -- c;
    d -- e;
    e -- f;
    a -- d;
}

subgraph

digraph G {

subgraph cluster_0 {
style=filled;
color=lightgrey;
node [style=filled,color=white];
a0 -> a1 -> a2 -> a3;
label = "process #1";
}

subgraph cluster_1 {
node [style=filled];
b0 -> b1 -> b2 -> b3;
label = "process #2";
color=blue
}
start -> a0;
start -> b0;
a1 -> b3;
b2 -> a3;
a3 -> a0;
a3 -> end;
b3 -> end;

start [shape=Mdiamond];
end [shape=Msquare];
}

simple subgraph


digraph {
    subgraph cluster_0 {
        label="Subgraph A";
        a -> b;
        b -> c;
        c -> d;
    }

    subgraph cluster_1 {
        label="Subgraph B";
        a -> f;
        f -> c;
    }
}

graph -- adjacency-list data structure

graph {
    rankdir=LR; // Left to Right, instead of Top to Bottom
    a -- { b c d };
    b -- { c e };
    c -- { e f };
    d -- { f g };
    e -- h;
    f -- { h i j g };
    g -- k;
    h -- { o l };
    i -- { l m j };
    t -- z;
}

digraph -- adjacency list data structure

digraph {
    a -> {b, c};
    b -> {c, a};
    d -> a;
}

symbol graph

strict graph{
    "Tin Men" -- {"DeBoy", "BlumenFeld"};
    "Kevin" -- {"Animal House", "The Woodsman"};
    "Animal House" -- {"Kevin", "Donald"};
    "Donald" -- {"The Eagle Has landed","Cold Mountain"};
}

Highlight a directed cycle

digraph {
    a -> b -> d -> c -> a[color=red,penwidth=3.0];
    b -> c;
    d -> e;
    e -> f;
    a -> d;
}