gpt4 book ai didi

Graphviz:水平对齐不适用于向后箭头

转载 作者:行者123 更新时间:2023-12-03 09:12:58 25 4
gpt4 key购买 nike

我制作了以下图形:

enter image description here

我想添加一个额外的箭头,从“远程存储库”一直指向“工作副本”(标有“git pull”),并且我希望该箭头理想地首先稍微向下,然后向左,然后向上。

当我简单地在代码中添加一个箭头时,图形最终看起来像这样:

enter image description here

这是代码:

digraph G {
/* set direction of graph to be left-->right */
rankdir="LR";

/* make boxes instead of ellipses */
node [shape=box];

/* should enforce nodes to be horizontally aligned */
/* is not working, though... */
rank=same;

/* assign labels to nodes */
wc [label="working copy"];
id [label="index"];
lr [label="local repo"];
rr [label="remote repo"];

wc -> id [label="git add"];
id -> lr [label="git commit"];
lr -> rr [label="git push"];

rr -> wc [label="git pull"];
}

问题:为什么水平对齐被破坏以及如何解决这个问题?

后续问题:如何制作一个向下、向左、向上的箭头? (或者是使用某种不可见/假节点来做到这一点的唯一方法?)

最佳答案

您可以使用 constraint=false 属性修改有问题的边缘。然后您会收到下图。

enter image description here

如果您更喜欢更多角度的边缘,您还可以为图表使用 splines=ortho

enter image description here

请查看http://graphviz.it/#/mqNwRgzu与工作示例。下面我粘贴了源代码。

digraph G {
/* set direction of graph to be left-->right */
rankdir="LR";
splines=ortho;

/* make boxes instead of ellipses */
node [shape=box];

/* should enforce nodes to be horizontally aligned */
/* is not working, though... */
rank=same;

/* assign labels to nodes */
wc [label="working copy"];
id [label="index"];
lr [label="local repo"];
rr [label="remote repo"];

wc -> id [label="git add"];
id -> lr [label="git commit"];
lr -> rr [label="git push"];

rr -> wc [label="git pull", constraint=false];
}

关于Graphviz:水平对齐不适用于向后箭头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40271161/

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