You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Graphviz dot实现栈表居左、堆灰盒居右的指定布局

我使用graphviz想要生成如下目前用tikz手写实现的图表:
tikz手写实现的目标图表

目前我已经成功编写了dot文件得到了如下结果(顶部的栈表是单个使用HTML实现的节点,每个灰色框也都是用HTML实现的独立节点):
当前dot文件生成的结果

但遗憾的是我无法同时保留我想要的灰色框布局,又让灰色框显示在栈表的右侧。我尝试了rank、subgraphs、rankdir等配置都没有成功。
请问使用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;
}

内容的提问来源于stack exchange,提问作者Manuel Selva

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.26 05:24:03