我想在顶部绘制两条平行的水平线。怎么做? 我的代码在这里。输出线的高度相同,因此不起作用。
digraph G {
graph [center, rankdir=TB, bgcolor=black];
edge [arrowsize=1, color=red, dir=none];
node [penwidth=1, color=white, fontcolor=white, labelloc=b];
BB1P1[shape=point, color=red, width=0.01];
BB1P[shape=point, color=white, width=0.1];
BB1PV[shape=point, color=red, width=0.01];
BB1P2[shape=point, color=red, width=0.01];
BB1P1 -> BB1P -> BB1PV -> BB1P2;
BB2P1[shape=point, color=red, width=0.01];
BB2PV[shape=point, color=red, width=0.01];
BB2P[shape=point, color=white, width=0.1];
BB2P2[shape=point, color=red, width=0.01];
BB2P1 -> BB2PV -> BB2P -> BB2P2;
{ rank=same; BB1P1; BB1P; BB1PV; BB1P2 };
{ rank=same; BB2P1; BB2PV; BB2P; BB2P2 };
}
答案 0 :(得分:2)
实际上有一个不可见的节点就足够了:
digraph G {
graph [center, rankdir=TB, bgcolor=black];
edge [arrowsize=1, color=red, dir=none];
node [penwidth=1, color=red, fontcolor=white, labelloc=b, shape=point, width=0.01];
{
rank=same;
BB1P1;
BB1P[color=white, width=0.1];
BB1PV;
BB1P2;
}
{
rank=same;
BB2P1;
BB2PV;
BB2P[color=white, width=0.1];
BB2P2;
}
BB1P1 -> BB1P -> BB1PV -> BB1P2;
BB2P1 -> BB2PV -> BB2P -> BB2P2;
BB1P1 -> BB2P1[style=invis];
}
或者,更简单,只需将rankdir
更改为LR
:
digraph G {
graph [center, rankdir=LR, bgcolor=black];
edge [arrowsize=1, color=red, dir=none];
node [penwidth=1, color=red, fontcolor=white, labelloc=b, shape=point, width=0.01];
BB1P[color=white, width=0.1];
BB2P[color=white, width=0.1];
BB1P1 -> BB1P -> BB1PV -> BB1P2;
BB2P1 -> BB2PV -> BB2P -> BB2P2;
}