gpt4 book ai didi

dot - 将节点定位到 graphviz 中 DOT 中边的左侧和右侧

转载 作者:行者123 更新时间:2023-12-04 17:49:59 34 4
gpt4 key购买 nike

我写了下面的 DOT 来生成图表。除了定义和布置的节点外,我想在标记为 L 的边缘的左侧和右侧放置一个节点,它们应该靠近 L,并且在 NODE3 和 NODE6 之间。

我尝试了一些不可见的节点。新节点要么转到第一行,要么转到第二行,但我希望它们位于第一行和第二行之间的新行中。

digraph g {
ranksep=0.5
graph [rankdir = "TB"];
graph [splines=ortho];

node [fontsize = "8"];
edge [];

node0 [label = "{NODE0}" shape = "record" ];
node1 [label = "{NODE1}" shape = "record" ];
node2 [label = "{NODE2}" shape = "record" ];
node3 [label = "{NODE3}" shape = "record" ];
node4 [label = "{NODE4}" shape = "record" ];

node5 [label = "{NODE5}" shape = "record" ];
node6 [label = "{NODE6}" shape = "record" ];
node7 [label = "{NODE7}" shape = "record" ];
node8 [label = "{NODE8}" shape = "record" ];
node9 [label = "{NODE9}" shape = "record" ];

node10 [label = "{NODE10}" shape = "record" ];
node11 [label = "{NODE11}" shape = "record" ];
node12 [label = "{NODE12}" shape = "record" ];

{rank=same; node0 -> node1 -> node2 -> node3 -> node4};
{rank=same; node5 -> node6 -> node7 -> node8 -> node9};
{rank=same; node10 -> node11 -> node12};
node1 -> node5;
node5 -> node3;
node3 -> node6[label="L"];
node7 -> node10;
node11 -> node8;
node9 -> node12;

}

最佳答案

这样的事情怎么样?我为新节点创建了一个“点”节点,以便在他们的等级内连接。还摆弄了箭头,让您了解那里的可能性。

digraph g {
ranksep=0.5
graph [rankdir = "TB"];
graph [splines=ortho];

node [fontsize = "8"];
edge [];

node0 [label = "{NODE0}" shape = "record" ];
node1 [label = "{NODE1}" shape = "record" ];
node2 [label = "{NODE2}" shape = "record" ];
node3 [label = "{NODE3}" shape = "record" ];
node4 [label = "{NODE4}" shape = "record" ];

node5 [label = "{NODE5}" shape = "record" ];
node6 [label = "{NODE6}" shape = "record" ];
node7 [label = "{NODE7}" shape = "record" ];
node8 [label = "{NODE8}" shape = "record" ];
node9 [label = "{NODE9}" shape = "record" ];

node10 [label = "{NODE10}" shape = "record" ];
node11 [label = "{NODE11}" shape = "record" ];
node12 [label = "{NODE12}" shape = "record" ];

nodenew1 [label="new1" shape=record];
nodenew2 [label="new2" shape=record];

{rank=same; node0 -> node1 -> node2 -> node3 -> node4};
{rank=same; node5 -> node6 -> node7 -> node8 -> node9};
{rank=same; node10 -> node11 -> node12};
node1 -> node5;
node5 -> node3;

{
rank = same;
nodenew1 -> nodepoint -> nodenew2 [ arrowhead=none]
}

nodepoint [shape=point]
node3 -> nodepoint [label="L" arrowhead=none];
nodepoint -> node6[label="L"];

node7 -> node10;
node11 -> node8;
node9 -> node12;

}

enter image description here

关于dot - 将节点定位到 graphviz 中 DOT 中边的左侧和右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45762179/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com