如果您确实必须使用 graphviz 执行此操作,您可以考虑使用类似 HTML 的标签。
我从维基百科重新创建了提到的示例:
rankdir = LR;
node [shape=none];
splines=false;
n1[label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
<TD CELLPADDING="2">2</TD>
<TD BORDER="0"></TD>
</TR>
<TR><TD COLSPAN="2" PORT="port00"> 00 </TD></TR>
<TR><TD COLSPAN="2" PORT="port01"> 01 </TD></TR>
<TR><TD COLSPAN="2" PORT="port10"> 10 </TD></TR>
<TR><TD COLSPAN="2" PORT="port11"> 11 </TD></TR>
</TABLE>>];
a[label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
<TD CELLPADDING="0" BORDER="0" COLSPAN="2">
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="2" FIXEDSIZE="TRUE" WIDTH="1" ALIGN="LEFT"><TR><TD>1</TD></TR></TABLE>
</TD>
</TR>
<TR>
<TD PORT="porta"> A </TD>
<TD>k2</TD>
</TR>
</TABLE>>];
b[label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
<TD CELLPADDING="2">2</TD>
<TD BORDER="0" COLSPAN="2"></TD>
</TR>
<TR>
<TD PORT="portb" COLSPAN="2"> B </TD>
<TD>k1</TD>
</TR>
</TABLE>>];
c[label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
<TD CELLPADDING="2">2</TD>
<TD BORDER="0" COLSPAN="2"></TD>
</TR>
<TR>
<TD PORT="portc" COLSPAN="2"> C </TD>
<TD>k3</TD>
</TR>
</TABLE>>];
n1:port00 -> a:porta;
n1:port01 -> a:porta;
n1:port10 -> b:portb;
n1:port11 -> c:portc;
如您所见,代码并不漂亮......但是,结果很接近:
http://graph.gafol.net/evEKgxwgj
请注意,出于演示目的,顶部标签有一个变体 - 节点a
使用嵌套表。