Graphviz 如何在Dot中创建晶格结构

Graphviz 如何在Dot中创建晶格结构,graphviz,dot,Graphviz,Dot,我试图画一个图表,列出所有可能的项目集列表。应该是这样的: 但我现在得到的是: 我试着使用点语言,但结果与布局不一样。我的点号是 digraph item_set { // the first layer A [label = "abcd=>{}"]; // the second layer B1 [label = "bcd=>a"]; B2 [label = "acd=>b"]; B3 [label = "abd=>c"]; B4 [label = "abc=&g

我试图画一个图表,列出所有可能的项目集列表。应该是这样的:

但我现在得到的是:

我试着使用点语言,但结果与布局不一样。我的点号是

digraph item_set {
// the first layer
A [label = "abcd=>{}"];

// the second layer
B1 [label = "bcd=>a"];
B2 [label = "acd=>b"];
B3 [label = "abd=>c"];
B4 [label = "abc=>d"];

// the third layer
C1 [label = "cd=>ab"];
C2 [label = "bd=>ac"];
C3 [label = "bc=>ad"];
C4 [label = "ad=>bc"];
C5 [label = "ac=>bd"];
C6 [label = "ab=>cd"];

// the forth layer
D1 [label = "d=>abc"];
D2 [label = "c=>abd"];
D3 [label = "b=>acd"];
D4 [label = "a=>bcd"];

// draw line between the first layer and the second layer
A -> {B1, B2, B3, B4} [dir = none];

// draw line between the second layer and the third layer
{B1, B2} -> C1 [dir = none];
{B1, B3} -> C2 [dir = none];
{B1, B4} -> C3 [dir = none];
{B2, B3} -> C4 [dir = none];
{B2, B4} -> C5 [dir = none];
{B3, B4} -> C6 [dir = none];

// draw line between the second layer and the third layer
{C1, C2, C4} -> D1 [dir = none];
{C1, C3, C5} -> D2 [dir = none];
{C2, C3, C6} -> D3 [dir = none];
{C4, C5, C6} -> D4 [dir = none]; }
边缘 可以使用
tailport
控制边的尾部接触起始节点的位置。头部接触末端节点的位置可以通过
头部端口

digraph G {
  edge [dir=none]
  a -> b [color=red headport="n" tailport="s"]
  a -> c [headport="w" tailport="s"]
 }

填满 添加行:

 a [style=filled fillcolor="turquoise"]
在右大括号填充节点
a
之前

用子图分组节点 可以使用命名子图簇将一组节点放置在边界内。集群的边界可以设置样式。完整的代码是:

digraph G {
  edge [dir=none]
  a -> b [color=red headport="n" tailport="s"]
  a -> c [headport="w" tailport="s"]
  subgraph cluster_0 {
      style="dashed"
      label="Low-Confidence\nRule"
      a [style=filled fillcolor="turquoise"]
  }  
}
谢谢他的指导。我修改了我的代码,现在是

digraph item_set {

// set edge attribute
edge [dir = none tailport = "s" headport = "n"]
splines=false

// the first layer
A [label = "abcd=>{}"];

// the second layer
B1 [label = "bcd=>a"];
B2 [label = "acd=>b"];
B3 [label = "abd=>c"];
B4 [label = "abc=>d"];

// the third layer
C1 [label = "cd=>ab"];
C2 [label = "bd=>ac"];
C3 [label = "bc=>ad"];
C4 [label = "ad=>bc"];
C5 [label = "ac=>bd"];
C6 [label = "ab=>cd"];

// the forth layer
D1 [label = "d=>abc"];
D2 [label = "c=>abd"];
D3 [label = "b=>acd"];
D4 [label = "a=>bcd"];

// draw line between the first layer and the second layer
A -> {B1, B2, B3, B4} 

// draw line between the second layer and the third layer
{B1, B2} -> C1
{B1, B3} -> C2
{B1, B4} -> C3
{B2, B3} -> C4
{B2, B4} -> C5
{B3, B4} -> C6

// draw line between the second layer and the third layer
{C1, C2, C4} -> D1
{C1, C3, C5} -> D2
{C2, C3, C6} -> D3
{C4, C5, C6} -> D4

// subgraph
subgraph cluster_0 {
    style = "dashed"
    label = "Low-Confidence\n Rule"
    B1,C1,C2,C3,D1,D2,D3 [style = filled fillcolor = "grey"]
}
}
输出是


除了布局外,它还能工作。

非常感谢您帮助我编辑问题。谢谢。我试图修改我的代码,我回答了我的问题。