graphviz 笔记

digraph test {
    ranksep=.75;
    {
        node [shape=plaintext, fontsize=16];
        2017 -> 2018 -> 2019;
    }
    node [shape=box];
    A  [label="开始"];
    { rank=same; 2017 -> A -> B;}
    { rank=same; 2018 C D}
    { rank=same; 2019 E F} 
    B -> C
    A -> C
    C -> D
    subgraph cluster0 {
        node [style=filled,color=white];
        style=filled;
        color=lightgrey;
        a0 -> a1 -> a2 -> a3;
        label = "process #1";
    }
    subgraph cluster1 {
        node [style=filled];
        b0 -> b1 -> b2 -> b3;
        label = "process #2";
        color=blue
    }
    node [shape=record];
    M [label="<a>a|b|<c>c"]
    M:a -> M:c
    N:n -> N:ne
    N:nw -> N:se [label="Y"]
    L [shape=cylinder]
    L -> K [color=red,arrowhead=diamond]
}
digraph g {
    //==========定义节点关系============
    a->b;
    b->c;
    c->a;
    c->d->e->f;
    d->g;
    e->h;
    //==========定义节点属性============
    //定义a节点为长方形, 样式为填充, 填充颜色为#ABACBA
    a[shape=box,label="Server1\nWebServer",fillcolor="#ABACBA",style=filled];
    //定义b为5边形, 标签为"bb", 样式为填充, 填充色为red
    b[shape=polygon,sides=5,label="bb",style=filled,fillcolor=red];
    //c, 默认为椭圆
    d[shape=circle]; //园
    e[shape=triangle]; //三角形
    f[shape=polygon, sides=4, skew=0.5]; //平行四边形
    g[shape=polygon, distortion=0.5]; //梯形, 上边长
    h[shape=polygon, distortion=-.5]; //梯形, 下边长
}

rank
same :让子图继承相同的排列
min :子图中所有结点至少比布局中其他结点的排列(rank)要小
source :强制子图所有结点严格基于某个排列,同时比其他结点排列要小(除非这些子图也指定了min或source)(?)
max 或 sink :做与最大排列接近的事情。

基本语法
字符串 都要加双引号, 可以加n换行符
注释 双斜杠// 或/ /
有向图 digraph, 节点关系: 指向->
无向图 graph, 节点关系: 连通 --
属性 node[attribute1=value1, attribute2=value2]
大小: size=”2,2”; 单位为英寸
标签: label=”显示在图上的内容”
边:edge [color=red,style=dotted]; 这句话之后生效
节点:node [color=navy]; 这句话之后生效
边方向:rankdir=参数值;LR(从左到右),RL,BT,TB
节点形状: a[shape=box]; 默认是椭圆
边框大小:a[width=.1,height=2.5]; 单位为英寸
边框颜色:a[color=red];
构造边

关系 有向图 无向图
一对一 a->b; a–b;
一对多 a->{b;c;d}; a–{b;c;d};
多对一 {b;c;d}->a; {b;c;d}–a;
多对多 {m,n,p,q}->{b;c;d}; {m,n,p,q}->{b;c;d};
详细资料:
官方文档:http://www.graphviz.org/documentation/
属性设置:https://graphviz.gitlab.io/_pages/doc/info/attrs.html
节点形状:https://graphviz.gitlab.io/_pages/doc/info/shapes.html
箭头形状:https://graphviz.gitlab.io/_pages/doc/info/arrows.html
颜色配置:https://graphviz.gitlab.io/_pages/doc/info/colors.html

https://blog.csdn.net/mouday/article/details/80902992

发表新评论