【问题标题】:How to make this graph with graphviz?如何用graphviz制作这个图表?
【发布时间】:2022-01-25 22:48:12
【问题描述】:

我想使用 graphviz 生成这样的图表:

我怎样才能写出这样的图表?

到目前为止,我已经尝试过:

digraph
{
  rankdir = "LR";
  subgraph cluster0
  {
    rank = same { indices array }
    color = white;
    indices [ shape = record, color = white, label = "{ 1 | 2 | 3 | 4 | 5 | 6 }" ];
    array [ shape = record, label = "{ 1 | 2 | 4 | 5 | 6 | 3 }" ];
  }
  nodesep = .0;
}

制作:

【问题讨论】:

标签: graphviz


【解决方案1】:

没有内置方法可以更改单个记录的样式或轻松地将边缘链接到它们。为此,您需要切换到使用类似 HTML 的语法:

digraph records {
  edge [color="gray" arrowhead="vee"]

  node1 [
    label = <<table border="0" cellspacing="0">
          <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
          <td>4</td>
          <td>5</td>
          <td>6</td>
          <td>6</td>
          </tr>
          <tr>
            <td port="p1" width="20" border="1" bgcolor="white">1</td>
            <td port="p2" width="20" border="1" bgcolor="gray">2</td>
            <td port="p3" width="20" border="1" bgcolor="gray">4</td>
            <td port="p4" width="20" border="1" bgcolor="gray">5</td>
            <td port="p5" width="20" border="1" bgcolor="gray">6</td>
            <td port="p6" width="20" border="1" bgcolor="black"><font color="white">3</font></td>
          </tr>
          </table>>
  ]

  # :s = attach arrow at the south compass point
  node1:p3:s -> node1:p4:s
  node1:p4:s -> node1:p5:s
  node1:p5:s -> node1:p6:s
  node1:p6:s -> node1:p3:s [color="black"]

}

您需要稍微调整一下以使边缘的长度合适,以免重叠等。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 2020-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多