Graphviz如何控制边缘

时间:2017-08-15 14:40:06

标签: graph graphviz dot digraphs

screenshot。我正在寻找右边的图表,但我得到的是左边的图表。我是Graphviz的新手。我还必须制作节点1和2,因为我无法模仿右侧的图像。我的终端形状也不完全相同。有人帮我这个。我的代码到现在为止:

digraph M
{
  style=filled;
  graph [splines = headport];

  START->1
  1->"Is COUNT\nan even\nnumber?"
  "Is COUNT\nan even\nnumber?"->"SUM = SUM +\nCOUNT" [label=TRUE]
  "SUM = SUM +\nCOUNT"->2
  "Is COUNT\nan even\nnumber?"->2 [label=FALSE]
  2->"COUNT = COUNT+1"
  "COUNT = COUNT+1"->"IS COUNT >\n20"
  "IS COUNT >\n20"->1 [label=FALSE]
  "IS COUNT >\n20"->STOP[label=TRUE]


  "Is COUNT\nan even\nnumber?"[shape=diamond]
  "SUM = SUM +\nCOUNT"[shape=rectangle]
  "IS COUNT >\n20"[shape=diamond]
  "COUNT = COUNT+1"[shape=rectangle]
  1[shape=circle]
  2[shape=circle]
  START[shape=record, style="rounded"]
  STOP[shape=record, style="rounded"]
}

1 个答案:

答案 0 :(得分:1)

我对您的图表进行了一些更改,以便让您更接近。样条线的折线,并将1和2节点的属性更改为更接近目标。显然并不完美,但希望能更好地帮助并提出其他方法,以便在不进行重大设计的情况下进一步改进。

digraph M
{
  style=filled;
  graph [splines = headport splines=polyline];

  START->1
  1->"Is COUNT\nan even\nnumber?"
  "Is COUNT\nan even\nnumber?"->"SUM = SUM +\nCOUNT" [label=TRUE]
  "SUM = SUM +\nCOUNT"->2
  "Is COUNT\nan even\nnumber?"->2 [label=FALSE]
  2->"COUNT = COUNT+1" 
  "COUNT = COUNT+1"->"IS COUNT >\n20"
  "IS COUNT >\n20"->1 [label=FALSE tailport=e]
  "IS COUNT >\n20"->STOP[label=TRUE ]


  "Is COUNT\nan even\nnumber?"[shape=diamond]
  "SUM = SUM +\nCOUNT"[shape=rectangle]
  "IS COUNT >\n20"[shape=diamond]
  "COUNT = COUNT+1"[shape=rectangle headport=n]
  1[shape=point size="0,0" label=""]
  2[shape=point size="0,0" label=""]
  START[shape=record, style="rounded"]
  STOP[shape=record, style="rounded"]
}