GraphViz

时间:2017-10-31 17:29:43

标签: graph graphviz dot directed-graph

我正在尝试使用GraphViz将一些旧的文档迁移到我们的内部维基。

我不习惯Dot语言,需要一些帮助

参见以下示例:

Example of graph

我已经做了很多实验,但到目前为止我所做的最好的是: Resulting GraphViz

digraph CentralPmr {  
  fontname="Helvetica";
  shape=box;
  node[shape=box];
  graph [splines=ortho]

  sg  [label="TTD storage group for\nthe logged values"]
  vc  [label="Value catalogue"]
  tc1 [label="Time catalogoue (1)"]
  tc2 [label="Time catalogoue (2)"]
  sv_ [shape=point,width=0.01,height=0.01];
  sv  [label=""]
  ie  [shape=none, label="Initiating event"]
  c1  [shape=none, label="The set of values, defined\nby the value catalogue, which\nare freezed out of the TTD\nstorage group of the actual log."]
  c2  [shape=none, label="Time catalogue defining\nat what time around the\ninitiating event values\nshould be collected."]
  sgf [shape=record, label="{<f0> 1|2|3|4|..}|{ | | | | }"]

  sg  -> sv_ [penwidth=4, dir=none];
  sv_ -> sv -> tc2 [penwidth=4]
  sv  -> sgf:f0 [penwidth=4]
  {vc, tc1}  -> sg
  c1  -> sv [style=dashed, arrowhead="open"];

  {rank=min;  ie} 
  {rank=same; sg c1}
  {rank=same; vc sgf}
  {rank=max;  rc2}
}

它不必与源完全相同,但我希望它是可以理解的。

问题是:

  1. 如何在“价值目录”和“时间目录(1)”之间放置文字?
  2. [编辑] 如何从侧面强制箭头“TTD存储组获取PMR冻结值”,而不是从上面?它是内存区域的虚拟化,箭头指向特定的内存帖子。在其他图像中,它可以指向存储区域中的其他存储器柱(例如,2,3,4 ......)。
  3. 是否可以从“发起活动”创建之字形线?
  4. 如何将图例放在解释不同类型线条的底部?
  5. [edit] 如何在“TTD存储组的PMR冻结值”的右下方添加注释?
  6. [编辑] 如何让“PMR-freezed值的TTD存储组”更广泛?

2 个答案:

答案 0 :(得分:2)

这是我的第一个答案之一,编辑那个会产生太多混乱。我已经尝试将您的所有需求考虑在内,只有在您放弃splines=ortho要求时才会起作用(我相信)。请参考我的第一个答案下面的评论。我们走了:

digraph CentralPmr {  
    fontname="Helvetica";
    shape=box;
    node[shape=box];
    // graph [splines=ortho]

    sg  [label="TTD storage group for\nthe logged values", width = 2.5]
    sv[ label="", width = 2]
    ie [ shape=none, label="Initiating event", fontsize = 18 ]
    c1 [ shape=none, label="The set of values, defined\nby the value catalogue, which\nare freezed out of the TTD\nstorage group of the actual log." ]

    sgf[shape=box, margin=0, label=<
    <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
        <TR>
            <TD BORDER="0" COLSPAN="2">TTD storage group for<BR/>PMR freezed values</TD>
        </TR>
        <TR>
            <TD PORT="f1">1</TD>
            <TD BORDER="0" ROWSPAN="6">The set of<BR/>values is<BR/>stored in<BR/>the TTD<BR/>storage<BR/>group</TD>
        </TR>
        <TR>
            <TD>2</TD>
        </TR>
                <TR>
            <TD>3</TD>
        </TR>
                <TR>
            <TD>4</TD>
        </TR>
                <TR>
            <TD>-</TD>
        </TR>
        <TR>
            <TD>-</TD>
        </TR>
        <TR>
            <TD BORDER="0" COLSPAN="2">Up to nine freezing areas<BR/>for defined central PMR</TD>
        </TR>
    </TABLE>>]; 

    TTD [shape=none, margin=0, label=<
    <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="12">
        <TR>
            <TD PORT="f1">Value catalogue</TD>
        </TR>
        <TR>
            <TD BORDER="0"></TD>
        </TR>
        <TR>
            <TD PORT="f2">Time catalogue (1)</TD>
        </TR>
        <TR>
            <TD BORDER="0">Time catalogue defining<BR/>at what time around the<BR/>initiating event values<BR/>should be collected</TD>
        </TR>
        <TR>
            <TD PORT="f3">Time catalogue (2)</TD>
        </TR>
    </TABLE>>]; 


    connector_1[ shape = point height = 0 width = 0 margin = 0 ]
    ie -> connector_1[ style = dotted, arrowhead = none ];
    { rank = same; connector_1 c1 }
    connector_1 -> c1[ style = invis, minlen = 4 ];
    c1 -> sv[ style = dashed, arrowhead = open ];
    connector_2[ shape = point height = 0 width = 0 margin = 0 ]
    connector_1 -> connector_2[ style = dotted ];
    { rank = same; sg connector_2 sv }
    sg -> connector_2[ minlen = 3, penwidth = 4, arrowhead = none ];
    connector_2 -> sv[ minlen = 3, penwidth = 4 ];

    sg:sw -> TTD:f1:nw[ weight = 5 ];
    sg:w -> TTD:f2:w;
    sv:sw -> TTD:f3:e[ penwidth = 4 ];
    sv:sw -> sgf:f1:w[ penwidth = 4 ];

    node[ shape = plaintext ];
    leg2[ label = "Data flow" ];
    leg4[ label = "Reference" ];
    leg6[ label = "Comment" ];

    node [ shape = point height = 0 width = 0 margin = 0 ];
    leg1 leg3 leg5

    TTD:sw -> leg1[ style = invis ];

    { rank = same; leg1 leg2 leg3 leg4 leg5 leg6 }
    edge[ minlen = 2 ];
    leg1 -> leg2[ penwidth = 4 ];
    leg3 -> leg4[ style = dotted ];
    leg5 -> leg6[ style = dashed, arrowhead = open ];
}

产量

enter image description here

答案 1 :(得分:1)

不确定我是否完全理解你想要的东西,但不知道我对它的看法。这只是第一次尝试,可以做得更精细。我可能会使用类似HTML的节点,其中文本和“框”需要更接近,特别是原始图形中的“用于PMR冻结值的TTD存储组”。

我对你问题的回答是:

如何在“价值目录”和“时间目录(1)”之间放置文字?

---见下文。我把它放在原始图表中的两个时间目录之间,但很容易移动。

如何从侧面强制箭头到记录,而不是从上面?

---见下文。如果这是您的问题,您还可以使用rankdir = LR;更改方向。

是否可以从“发起活动”创建曲折线?

---有方法,但需要付出很多努力(比如创建自定义形状)。据我所知,没有“开箱即用”的东西。

如何将图例放在底部?

我真的不明白,但总的来说,当我们讨论节点时,答案就是类似HTML的标签。

她就是我所做的:

digraph CentralPmr 
{  
    fontname="Helvetica";
    shape=box;
    node[shape=box];
    graph [splines=ortho]

    sg  [label="TTD storage group for\nthe logged values"]
    vc  [label="Value catalogue"]
    tc1 [label="Time catalogoue (1)"]
    tc2 [label="Time catalogoue (2)"]
    sv_ [shape=point,width=0.01,height=0.01];
    sv  [label="", width = 2]
    ie  [shape=none, label="Initiating event"]
    c1  [shape=none, label="The set of values, defined\nby the value catalogue, which\nare freezed out of the TTD\nstorage group of the actual log."]
    c2  [shape=none, label="Time catalogue defining\nat what time around the\ninitiating event values\nshould be collected."]
    sgf [shape=record, label="{<f0> 1|2|3|4|..}|{ | | | | }"]

    connector_1[ shape = point height = 0 width = 0 margin = 0 ]
    ie -> connector_1[ style = dotted, arrowhead = none ];
    { rank = same; connector_1 c1 }
    connector_1 -> c1[ style = invis ];
    c1 -> sv[ style = dashed, arrowhead = open ];
    connector_2[ shape = point height = 0 width = 0 margin = 0 ]
    connector_1 -> connector_2[ style = dotted ];
    { rank = same; sg connector_2 sv }
    sg -> connector_2[ minlen = 3, penwidth = 4, arrowhead = none ];
    connector_2 -> sv[ minlen = 3, penwidth = 4 ];

    vc -> tc1 -> c2 -> tc2[ style = invis, weight = 10 ];
    sg -> vc;
    sg -> tc1;
    sv -> tc2[ penwidth = 4 ];
    sv -> sgf;
}

产量

enter image description here