如何在 Graphviz 中用大点装饰边缘?
How to make edges decorated with big dot in Graphviz?
我想在某些边缘的中心有一个大点(或类似的东西)。
以下代码是我能够生成的最好的代码。
digraph BDD {
ordering = out;
splines = true;
edge [arrowhead="none"];
node [shape = none, label = "SUM"] 0;
node [shape = circle, label = "x"] 1;
node [shape = circle, label = "y"] 2;
node [shape = circle, label = "w"] 3;
node [shape = none, label = "1"] 4;
node [shape = circle, label = "z"] 5;
node [shape = none, label = "1"] 6;
node [shape = circle, label = "y"] 7;
node [shape = circle, label = "w"] 8;
node [shape = none, label = "1"] 9;
0 -> 1;
1 -> 2;
1 -> 7 [arrowhead="dot"];
2 -> 3;
2 -> 5 [arrowhead="dot"];
3 -> 4 [arrowhead="dot"];
3 -> 4;
5 -> 6 [arrowhead="dot"];
5 -> 6;
7 -> 5;
7 -> 8;
8 -> 9;
8 -> 5;
}
这将产生以下图像,但不太正确,因为点在边缘的末端。
任何人都可以建议我一个解决方案来产生这个:
编辑 1:使用额外的节点作为点会产生不可接受的输出。
digraph BDD {
ordering = out;
splines = true;
edge [arrowhead="none"];
node [shape = none, label = "SUM"] 0;
node [shape = circle, label = "x"] 1;
node [shape = circle, label = "y"] 2;
node [shape = circle, label = "w"] 3;
node [shape = none, label = "1"] 4;
node [shape = circle, label = "z"] 5;
node [shape = none, label = "1"] 6;
node [shape = circle, label = "y"] 7;
node [shape = circle, label = "w"] 8;
node [shape = none, label = "1"] 9;
0 -> 1;
1 -> 2;
node [shape = point width=0.1] p1p7;
1 -> p1p7 -> 7;
2 -> 3;
node [shape = point width=0.1] p2p5;
2 -> p2p5 -> 5;
node [shape = point width=0.1] p3p4;
3 -> p3p4 -> 4;
3 -> 4;
node [shape = point width=0.1] p5p6;
5 -> p5p6 -> 6;
5 -> 6;
7 -> 5;
7 -> 8;
8 -> 9;
8 -> 5;
}
编辑 2:我也可以接受点不完全位于中心的图形。他们只是不能接触节点,也就是说,如果我能 set/make 箭头和节点之间的距离可能就可以了。
你可以创建一个额外的节点(和一个额外的边)来实现它。
digraph {
node [shape = circle]
A
C
node [shape = point width=0.2]
B
edge [arrowhead=none]
A -> B -> C
}
产生
编辑:
您可以将图表布局到放置所有节点和边的 *.dot 文件中。然后您可以使用您最喜欢的编程语言来读取和修改该文件。还有一些 built-in 脚本语言我还没有尝试过。最后,您使用 nop2 引擎将修改后的 DOT-file 转换为您选择的图像格式。您必须了解如何在贝塞尔样条曲线上放置点。根据文档
splineType
spline ( ';' spline )*
where spline = (endp)? (startp)? point (triple)+
and triple = point point point
and endp = "e,%f,%f"
and startp = "s,%f,%f"
我们每条边总是有 4+3n (0 <= n) 个点。这些是三次样条的 4 元组,其中一个样条的端点是下一个样条的起点。由于 start-/endpoints 被直接触摸,如果至少有两条样条线(7 点),则它们是放置点的候选对象。一般来说,每个点 [4+3n] 都是候选点。如果我们只有一条样条曲线,这种方法就会失败。我们必须在样条曲线上放置一个点。有效的四元组从 0+3n 开始到 3+3n 结束。
您可以使用任何有效的 x/y 坐标四元组来计算样条曲线上的一个点
x = (x1 + 3*x2 + 3*x3 + x4)/8
这是除法器 2 的简单公式。您可以为 y-coordinate.
做类似的事情
示例:
digraph { rankdir = LR ranksep=1 nodesep=1 pad=0.5
node [shape = circle]
edge [arrowhead=none]
{ rank=same
A -> B
B -> C
A -> C
}
}
给予
digraph {
graph [bb="0,0,74.575,252",
nodesep=1,
pad=0.5,
rankdir=LR,
ranksep=1
];
node [label="\N",
shape=circle
];
edge [arrowhead=none];
{
graph [rank=same];
A [height=0.5,
pos="56.575,234",
width=0.5];
B [height=0.5,
pos="56.575,126",
width=0.5];
A -> B [pos="56.575,215.75 56.575,191.88 56.575,168.01 56.575,144.14"];
C [height=0.5,
pos="56.575,18",
width=0.5];
A -> C [pos="44.02,220.46 24.619,197.84 -9.2417,150.66 2.5745,108 10.795,78.323 31.695,48.606 44.952,31.836"];
B -> C [pos="56.575,107.75 56.575,83.878 56.575,60.01 56.575,36.141"];
}
}
线的边缘
A -> C [pos="44.02,220.46 24.619,197.84 -9.2417,150.66 2.5745,108 10.795,78.323 31.695,48.606 44.952,31.836"];
由 2 个样条组成。我们有一个可以直接使用的重叠 start/endpoint
U1 [shape=point width=0.2 color=red pos="2.5745,108"]
从上面的所选边有 2 个有效的 4 元组可供选择,从而在样条曲线上产生 2 个点(对于 divider2)
X1 [shape=point width=0.2 pos="11.59,171.75"]
X2 [shape=point width=0.2 pos="21.87,65.08"]
合并文件
digraph {
graph [bb="0,0,74.575,252",
nodesep=1,
pad=0.5,
rankdir=LR,
ranksep=1
];
node [label="\N",
shape=circle
];
edge [arrowhead=none];
{
graph [rank=same];
A [height=0.5,
pos="56.575,234",
width=0.5];
B [height=0.5,
pos="56.575,126",
width=0.5];
A -> B [pos="56.575,215.75 56.575,191.88 56.575,168.01 56.575,144.14"];
C [height=0.5,
pos="56.575,18",
width=0.5];
A -> C [pos="44.02,220.46 24.619,197.84 -9.2417,150.66 2.5745,108 10.795,78.323 31.695,48.606 44.952,31.836"];
B -> C [pos="56.575,107.75 56.575,83.878 56.575,60.01 56.575,36.141"];
U1 [shape=point width=0.2 color=red pos="2.5745,108"]
X1 [shape=point width=0.2 pos="11.59,171.75"]
X2 [shape=point width=0.2 pos="21.87,65.08"]
}
}
给予
我想在某些边缘的中心有一个大点(或类似的东西)。 以下代码是我能够生成的最好的代码。
digraph BDD {
ordering = out;
splines = true;
edge [arrowhead="none"];
node [shape = none, label = "SUM"] 0;
node [shape = circle, label = "x"] 1;
node [shape = circle, label = "y"] 2;
node [shape = circle, label = "w"] 3;
node [shape = none, label = "1"] 4;
node [shape = circle, label = "z"] 5;
node [shape = none, label = "1"] 6;
node [shape = circle, label = "y"] 7;
node [shape = circle, label = "w"] 8;
node [shape = none, label = "1"] 9;
0 -> 1;
1 -> 2;
1 -> 7 [arrowhead="dot"];
2 -> 3;
2 -> 5 [arrowhead="dot"];
3 -> 4 [arrowhead="dot"];
3 -> 4;
5 -> 6 [arrowhead="dot"];
5 -> 6;
7 -> 5;
7 -> 8;
8 -> 9;
8 -> 5;
}
这将产生以下图像,但不太正确,因为点在边缘的末端。
任何人都可以建议我一个解决方案来产生这个:
编辑 1:使用额外的节点作为点会产生不可接受的输出。
digraph BDD {
ordering = out;
splines = true;
edge [arrowhead="none"];
node [shape = none, label = "SUM"] 0;
node [shape = circle, label = "x"] 1;
node [shape = circle, label = "y"] 2;
node [shape = circle, label = "w"] 3;
node [shape = none, label = "1"] 4;
node [shape = circle, label = "z"] 5;
node [shape = none, label = "1"] 6;
node [shape = circle, label = "y"] 7;
node [shape = circle, label = "w"] 8;
node [shape = none, label = "1"] 9;
0 -> 1;
1 -> 2;
node [shape = point width=0.1] p1p7;
1 -> p1p7 -> 7;
2 -> 3;
node [shape = point width=0.1] p2p5;
2 -> p2p5 -> 5;
node [shape = point width=0.1] p3p4;
3 -> p3p4 -> 4;
3 -> 4;
node [shape = point width=0.1] p5p6;
5 -> p5p6 -> 6;
5 -> 6;
7 -> 5;
7 -> 8;
8 -> 9;
8 -> 5;
}
编辑 2:我也可以接受点不完全位于中心的图形。他们只是不能接触节点,也就是说,如果我能 set/make 箭头和节点之间的距离可能就可以了。
你可以创建一个额外的节点(和一个额外的边)来实现它。
digraph {
node [shape = circle]
A
C
node [shape = point width=0.2]
B
edge [arrowhead=none]
A -> B -> C
}
产生
编辑:
您可以将图表布局到放置所有节点和边的 *.dot 文件中。然后您可以使用您最喜欢的编程语言来读取和修改该文件。还有一些 built-in 脚本语言我还没有尝试过。最后,您使用 nop2 引擎将修改后的 DOT-file 转换为您选择的图像格式。您必须了解如何在贝塞尔样条曲线上放置点。根据文档
splineType
spline ( ';' spline )*
where spline = (endp)? (startp)? point (triple)+
and triple = point point point
and endp = "e,%f,%f"
and startp = "s,%f,%f"
我们每条边总是有 4+3n (0 <= n) 个点。这些是三次样条的 4 元组,其中一个样条的端点是下一个样条的起点。由于 start-/endpoints 被直接触摸,如果至少有两条样条线(7 点),则它们是放置点的候选对象。一般来说,每个点 [4+3n] 都是候选点。如果我们只有一条样条曲线,这种方法就会失败。我们必须在样条曲线上放置一个点。有效的四元组从 0+3n 开始到 3+3n 结束。
您可以使用任何有效的 x/y 坐标四元组来计算样条曲线上的一个点
x = (x1 + 3*x2 + 3*x3 + x4)/8
这是除法器 2 的简单公式。您可以为 y-coordinate.
做类似的事情示例:
digraph { rankdir = LR ranksep=1 nodesep=1 pad=0.5
node [shape = circle]
edge [arrowhead=none]
{ rank=same
A -> B
B -> C
A -> C
}
}
给予
digraph {
graph [bb="0,0,74.575,252",
nodesep=1,
pad=0.5,
rankdir=LR,
ranksep=1
];
node [label="\N",
shape=circle
];
edge [arrowhead=none];
{
graph [rank=same];
A [height=0.5,
pos="56.575,234",
width=0.5];
B [height=0.5,
pos="56.575,126",
width=0.5];
A -> B [pos="56.575,215.75 56.575,191.88 56.575,168.01 56.575,144.14"];
C [height=0.5,
pos="56.575,18",
width=0.5];
A -> C [pos="44.02,220.46 24.619,197.84 -9.2417,150.66 2.5745,108 10.795,78.323 31.695,48.606 44.952,31.836"];
B -> C [pos="56.575,107.75 56.575,83.878 56.575,60.01 56.575,36.141"];
}
}
线的边缘
A -> C [pos="44.02,220.46 24.619,197.84 -9.2417,150.66 2.5745,108 10.795,78.323 31.695,48.606 44.952,31.836"];
由 2 个样条组成。我们有一个可以直接使用的重叠 start/endpoint
U1 [shape=point width=0.2 color=red pos="2.5745,108"]
从上面的所选边有 2 个有效的 4 元组可供选择,从而在样条曲线上产生 2 个点(对于 divider2)
X1 [shape=point width=0.2 pos="11.59,171.75"]
X2 [shape=point width=0.2 pos="21.87,65.08"]
合并文件
digraph {
graph [bb="0,0,74.575,252",
nodesep=1,
pad=0.5,
rankdir=LR,
ranksep=1
];
node [label="\N",
shape=circle
];
edge [arrowhead=none];
{
graph [rank=same];
A [height=0.5,
pos="56.575,234",
width=0.5];
B [height=0.5,
pos="56.575,126",
width=0.5];
A -> B [pos="56.575,215.75 56.575,191.88 56.575,168.01 56.575,144.14"];
C [height=0.5,
pos="56.575,18",
width=0.5];
A -> C [pos="44.02,220.46 24.619,197.84 -9.2417,150.66 2.5745,108 10.795,78.323 31.695,48.606 44.952,31.836"];
B -> C [pos="56.575,107.75 56.575,83.878 56.575,60.01 56.575,36.141"];
U1 [shape=point width=0.2 color=red pos="2.5745,108"]
X1 [shape=point width=0.2 pos="11.59,171.75"]
X2 [shape=point width=0.2 pos="21.87,65.08"]
}
}
给予