我想画两个相互接触的圆形节点。我尝试使用
ranksep
来实现这一点,但这导致了两个问题:
ranksep
是全局设置,并且它会影响所有节点,因此我必须将 minlen
添加到图中的所有边。
这就是我所做的:digraph {
graph [rankdir=LR, nodesep="1", ranksep="0.1"];
a [shape=circle]
b [shape=circle]
a -> b [style=invis]
x [shape=rect]
x -> a [ minlen = 5]
y [shape=rect]
y -> a [ minlen = 5]
}
知道如何让它们接触吗?
没有简单的方法可以将两个节点对接在一起。
以下是两种不太简单的技巧:
graph ab {
// build by hand/eyeball
margin=0
pad=.01
node[shape=circle]
a [pos="72,72"]
b [pos="108,72"]
}
创建图像文件:
neato -Tpng -n2 mycircles.gv >mycircles.png
(参见https://graphviz.org/faq/#FaqDotWithCoords)
然后创建所需的(完整)图表:
digraph ab {
rankdir=LR
node[shape=circle]
b [label="" shape=rect image="mycircles.png" peripheries=0]
X->b:nw
Y->b:sw
}
或者: