zhoupj / Thinking

0 stars 0 forks source link

graphviz #9

Open zhoupj opened 7 years ago

zhoupj commented 7 years ago

Graphviz

Example-1

digraph{
        //attributes
    label="byPass-Branch"
    node[color=red];
    //nodes
    headNode->node1;
    headNode->node2;
    node1->node3;

    node[shape=box,color=black];
    //distribute
    headNode->fromApp1[style=dotted];
    headNode->fromApp2[style=dotted];
    headNode->headApp[style=dotted,color=blue];

    node1->headApp[style=dotted];
    node1->fromApp3[style=dotted];
    node1->node1App[style=dotted,color=blue];

    node2->headApp[style=dotted];
    node2->node2App[style=dotted,color=blue];

    node3->node1App[style=dotted];
    node3->fromApp4[style=dotted];
    node3->node3App[style=dotted,color=blue];
}

1

Example-2

digraph G {
    size="200,200";
    center=true;
    rankdir=LR;
    //子图
    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;

        subgraph cluster_2 {
            node [style=filled];
            c1[shape=circle,peripheries=3,color=red];
            c0 -> c1 -> c2 -> c3[color=yellow];
            label = "process #3";
            color=blue
        }
    }
    //定义节点和边的属性
    start -> a0[style=bold,label="first",decorate=true];
    start -> b0;
    a1 -> b3[style=dotted,color=red,dir=both];
    b2 -> a3[style=dashed,dir=back];
    a3 -> a0[weight=20];
    a3 -> end;
    {b3,c3} -> end;

    a3[shape=ellipse,color=green];
    a1[color=red,style=diagonals];
    a2[shape=plaintext,color=orange];
    start [shape=Mdiamond];
    end [shape=Msquare,label="make a\n End"];
}

2

Example-3

digraph G {

    //多边形
    end->a->{e,c,d};
    a[shape=polygon,sides=5,peripheries=3,color=lightblue,style=filled];
    c[shape=polygon,sides=4,skew=.4,label="hello world"];
    d[shape=invtriangle];
    e[shape=polygon,sides=4,distortion=.7];

    node1[shape=record,label="left0|middile0|right0"];
    node2[shape=record,label="O1|{O2|{O3|04}|O5}|O6"];
    node1->node2;

    //record 记录
    node[shape=record];
    struct1[shape=record,label="<f0>left|<f1> mid\ dle|<f2> right"];
    struct2[shape=record,label="<f0> one|<f1> two"];
    struct3[shape=record,label="hello\nworld |{ b |{c|<here> d|e}| f}| g | h"];
    struct1->struct2;
    struct1->struct3;

}

3

Example-4

 digraph st2{

  fontname = "Verdana";
  fontsize = 10;
  rankdir=TB;
  node [fontname = "Verdana", fontsize = 10, color="skyblue", shape="record"];
  edge [fontname = "Verdana", fontsize = 10, color="crimson", style="solid"];

  st_hash_type [label="{<head>st_hash_type|(*compare)|(*hash)}"];
  st_table_entry [label="{<head>st_table_entry|hash|key|record|<next>next}"];
  st_table [label="{st_table|<type>type|num_bins|num_entries|<bins>bins}"];

  st_table:bins -> st_table_entry:head;
  st_table:type -> st_hash_type:head;
  st_table_entry:next -> st_table_entry:head [style="dashed", color="forestgreen"];
 }

4