Graphviz 程序通常不喜欢故意将节点放置在其他节点之上,但在特殊情况下允许这样做——neato -n和neato -n2允许这样做(参见常见问题解答)。

我在这个输入文件中添加了一个新属性(dotme):
digraph G {
node [shape=circle penwidth=2 label=""]
n1 [ xlabel="P1" dotme=1]
n2 [ xlabel="P2" ]
n3 [ xlabel="P3" dotme=1]
n1 -> n2
n1 -> n3
n2 -> n3
}
然后通过这组 Graphviz 程序运行它:
dot -Tdot needsadot.gv |gvpr -c -fdotMe.gvpr |neato -n2 -Tpng >needsadot.png
gvpr 程序 dotMe.gvpr 在这里:
BEGIN {
int nxt=0;
}
N {
int i;
string str1, str2;
node_t n;
if (hasAttr($, "dotme")){
if (strcmp($.dotme,"1")==0){
// create a new node and position it on top of existing node
str1=sprintf("__dot_%d", ++nxt);
n=node($G, str1);
n.pos=$.pos;
n.shape="point";
}
}
}
dotMe.gvpr在 dotme==1 的每个节点上(相同的pos )添加一个新节点。
令人费解,但可重复使用。