图和子图布局

Graphs and subgraphs layout

使用graphviz我想生成下面的图表(目前在tikz中手动编写):

我目前成功地编写了一个 dot 文件,得到了以下结果(有一个节点使用 html 作为顶部的 Pile table,还有一个节点也每个灰色框使用 html):

但不幸的是,我无法保留我喜欢的灰色框的布局,也无法将灰色框放在 Pile 的右侧 table。我仔细阅读 this related question 并尝试使用 ranksubgraphsrankdir,但没有成功。

dot有希望达到我的目标吗?

编辑:这是我目前

的完整dot文件
digraph structs {
node [shape=plaintext]
subgraph stack {
label = STACK;
stack [label=<
<TABLE BORDER="1" CELLBORDER="0" CELLSPACING="0" BGCOLOR="white">
<TR><TD><i>Nom</i></TD><TD><i>Type</i></TD><TD><i>Portée</i></TD><TD><i>Valeur</i></TD></TR>
<TR><TD BGCOLOR="chartreuse">list2</TD><TD BGCOLOR="chartreuse">référence</TD><TD BGCOLOR="chartreuse">main</TD><TD PORT="port_140407657518560" BGCOLOR="chartreuse">0x7f
b334a23ac0</TD></TR>
<TR><TD BGCOLOR="chartreuse">list1</TD><TD BGCOLOR="chartreuse">référence</TD><TD BGCOLOR="chartreuse">main</TD><TD PORT="port_140407657518032" BGCOLOR="chartreuse">0x7f
b334a23ac0</TD></TR>
</TABLE>
>
];
}
subgraph heap {
label = HEAP;
  struct_140407658920640 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" BGCOLOR="gray">
<TR><TD COLSPAN="6">0x7fb334a23ac0</TD></TR>
<TR><TD COLSPAN="6"><u>list</u></TD></TR>
<TR><TD PORT="port_child0">0x955e80</TD>
<TD PORT="port_child1">0x956360</TD>
<TD PORT="port_child2">0x956040</TD>
<TD PORT="port_child3">0x7fb3348cbbb0</TD>
<TD PORT="port_child4">0x7fb3348cbc30</TD>
<TD PORT="port_child5">0x7fb3348cbc70</TD>
</TR>
</TABLE>>];
  struct_9789056 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" BGCOLOR="gray">
<TR><TD>0x955e80</TD></TR>
<TR><TD><u>int</u></TD></TR>
<TR><TD>3</TD></TR>
</TABLE>>];
struct_140407658920640:port_child0 -> struct_9789056;
  struct_9790304 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" BGCOLOR="gray">
<TR><TD>0x956360</TD></TR>
<TR><TD><u>int</u></TD></TR>
<TR><TD>42</TD></TR>
</TABLE>>];
struct_140407658920640:port_child1 -> struct_9790304;
  struct_9789504 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" BGCOLOR="gray">
<TR><TD>0x956040</TD></TR>
<TR><TD><u>int</u></TD></TR>
<TR><TD>17</TD></TR>
</TABLE>>];
struct_140407658920640:port_child2 -> struct_9789504;
  struct_140407657511856 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" BGCOLOR="gray">
<TR><TD>0x7fb3348cbbb0</TD></TR>
<TR><TD><u>str</u></TD></TR>
<TR><TD>"go"</TD></TR>
</TABLE>>];
struct_140407658920640:port_child3 -> struct_140407657511856;
  struct_140407657511984 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" BGCOLOR="gray">
<TR><TD>0x7fb3348cbc30</TD></TR>
<TR><TD><u>str</u></TD></TR>
<TR><TD>"feu"</TD></TR>
</TABLE>>];
struct_140407658920640:port_child4 -> struct_140407657511984;
  struct_140407657512048 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" BGCOLOR="gray">
<TR><TD>0x7fb3348cbc70</TD></TR>
<TR><TD><u>str</u></TD></TR>
<TR><TD>"partez"</TD></TR>
</TABLE>>];
struct_140407658920640:port_child5 -> struct_140407657512048;
}
stack:port_140407657518560 -> struct_140407658920640;
stack:port_140407657518032 -> struct_140407658920640;
}

小改动

digraph structs {
node [shape=plaintext]
subgraph cluster_stack {  // changed to cluster
graph [peripheries=0]     // no box around this cluster
label = STACK;
stack [label=<
<TABLE BORDER="1" CELLBORDER="0" CELLSPACING="0" BGCOLOR="white">
<TR><TD><i>Nom</i></TD><TD><i>Type</i></TD><TD><i>Porté?e</i></TD><TD><i>Valeur</i></TD></TR>
<TR><TD BGCOLOR="chartreuse">list2</TD><TD BGCOLOR="chartreuse">ré?fé?rence</TD><TD BGCOLOR="chartreuse">main</TD><TD PORT="port_140407657518560" BGCOLOR="chartreuse">0x7f
b334a23ac0</TD></TR>
<TR><TD BGCOLOR="chartreuse">list1</TD><TD BGCOLOR="chartreuse">ré?fé?rence</TD><TD BGCOLOR="chartreuse">main</TD><TD PORT="port_140407657518032" BGCOLOR="chartreuse">0x7f
b334a23ac0</TD></TR>
</TABLE>
>
];
}
subgraph cluster_heap {  // changed to cluster
label = HEAP;
  struct_140407658920640 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" BGCOLOR="gray">
<TR><TD COLSPAN="6">0x7fb334a23ac0</TD></TR>
<TR><TD COLSPAN="6" port="myport"><u>list</u></TD></TR>
<TR><TD PORT="port_child0">0x955e80</TD>
<TD PORT="port_child1">0x956360</TD>
<TD PORT="port_child2">0x956040</TD>
<TD PORT="port_child3">0x7fb3348cbbb0</TD>
<TD PORT="port_child4">0x7fb3348cbc30</TD>
<TD PORT="port_child5">0x7fb3348cbc70</TD>
</TR>
</TABLE>>];
  struct_9789056 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" BGCOLOR="gray">
<TR><TD>0x955e80</TD></TR>
<TR><TD><u>int</u></TD></TR>
<TR><TD>3</TD></TR>
</TABLE>>];
struct_140407658920640:port_child0 -> struct_9789056;
  struct_9790304 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" BGCOLOR="gray">
<TR><TD>0x956360</TD></TR>
<TR><TD><u>int</u></TD></TR>
<TR><TD>42</TD></TR>
</TABLE>>];
struct_140407658920640:port_child1 -> struct_9790304;
  struct_9789504 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" BGCOLOR="gray">
<TR><TD>0x956040</TD></TR>
<TR><TD><u>int</u></TD></TR>
<TR><TD>17</TD></TR>
</TABLE>>];
struct_140407658920640:port_child2 -> struct_9789504;
  struct_140407657511856 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" BGCOLOR="gray">
<TR><TD>0x7fb3348cbbb0</TD></TR>
<TR><TD><u>str</u></TD></TR>
<TR><TD>"go"</TD></TR>
</TABLE>>];
struct_140407658920640:port_child3 -> struct_140407657511856;
  struct_140407657511984 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" BGCOLOR="gray">
<TR><TD>0x7fb3348cbc30</TD></TR>
<TR><TD><u>str</u></TD></TR>
<TR><TD>"feu"</TD></TR>
</TABLE>>];
struct_140407658920640:port_child4 -> struct_140407657511984;
  struct_140407657512048 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" BGCOLOR="gray">
<TR><TD>0x7fb3348cbc70</TD></TR>
<TR><TD><u>str</u></TD></TR>
<TR><TD>"partez"</TD></TR>
</TABLE>>];
struct_140407658920640:port_child5 -> struct_140407657512048;
}
edge [constraint=false]  // do not use next two edges to position nodes/clusters
stack:port_140407657518560 -> struct_140407658920640:myport
stack:port_140407657518032 -> struct_140407658920640
// add invisible edge & use to position nodes/clusters
edge [constraint=true style=invis]  
stack:port_140407657518032 -> struct_9789056
}

给予: