digraph MyGraph { a [shape=box] b [shape=polygon,sides=6] c [shape=triangle] d [shape=invtriangle] e [shape=polygon,sides=4,skew=.5] f [shape=polygon,sides=4,distortion=.5] g [shape=diamond] h [shape=Mdiamond] i [shape=Msquare] a -> b a -> c a -> d a -> e a -> f a -> g a -> h a -> i }
digraph MyGraph { a [style=filled,color=green] b [peripheries=4,color=blue] c [fontcolor=crimson] d [style=filled,fillcolor=dodgerblue,color=coral4,penwidth=3] e [style=dotted] f [style=dashed] g [style=diagonals] h [style=filled,color="#333399"] i [style=filled,color="#ff000055"] j [shape=box,style=striped,fillcolor="red:green:blue"] k [style=wedged,fillcolor="green:white:red"] a -> b a -> c a -> d a -> e b -> f b -> g b -> h b -> i d -> j j -> k }
digraph MyGraph { a -> b [dir=both,arrowhead=open,arrowtail=inv] a -> c [dir=both,arrowhead=dot,arrowtail=invdot] a -> d [dir=both,arrowhead=odot,arrowtail=invodot] a -> e [dir=both,arrowhead=tee,arrowtail=empty] a -> f [dir=both,arrowhead=halfopen,arrowtail=crow] a -> g [dir=both,arrowhead=diamond,arrowtail=box] }
digraph MyGraph { a -> b [color="black:red:blue"] a -> c [color="black:red;0.5:blue"] a -> d [dir=none,color="green:red:blue"] a -> e [dir=none,color="green:red;.3:blue"] a -> f [dir=none,color="orange"] d -> g [arrowsize=2.5] d -> h [style=dashed] d -> i [style=dotted] d -> j [penwidth=5] }
digraph MyGraph { begin [label="This is the beginning"] end [label="It ends here"] begin -> end }
以及顶点:
1 2 3 4 5
digraph MyGraph { begin end begin -> end [label="Beginning to end"] }
我们可以设置标签样式:
1 2 3 4 5
digraph MyGraph { begin [label="This is the beginning",fontcolor=green,fontsize=10] end [label="It ends here",fontcolor=red,fontsize=10] begin -> end [label="Beginning to end",fontcolor=gray,fontsize=16] }
集群
聚类也称为子图。集群的名称必须以开头cluster_,否则将不会包含在框中。
1 2 3 4 5 6 7 8
digraph MyGraph { subgraph cluster_a { b c -> d } a -> b d -> e }
集群可以根据需要嵌套:
1 2 3 4 5 6 7 8 9 10 11 12 13
digraph MyGraph { subgraph cluster_a { subgraph cluster_b { subgraph cluster_c { d } c -> d } b -> c } a -> b d -> e }