改变点的边缘方向

发布于 2024-10-26 12:22:51 字数 387 浏览 5 评论 0原文

我正在尝试用点画一个非常简单的图表。

digraph untitled
    {
    rankdir = LR;
    {rank=same; S; A}
    B -> A;
    B -> S;
    A -> A;
    S -> S;
    A -> S ;
    S -> A;
    A -> T;
    S -> T;
}

我得到的结果是

在此处输入图像描述

我真的必须从 S -> 更改边缘S,但我还想更改箭头的方向,以便它们从左到右循环。

I'm trying to draw a pretty simple diagram in dot.

digraph untitled
    {
    rankdir = LR;
    {rank=same; S; A}
    B -> A;
    B -> S;
    A -> A;
    S -> S;
    A -> S ;
    S -> A;
    A -> T;
    S -> T;
}

The results I get is

enter image description here

I really have to change the edge from S -> S, but I would also like to change the orientation of the arrows so they loop from left to right.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

腹黑女流氓 2024-11-02 12:22:51

要更改任何箭头的方向,您可以简单地使用 dir=back

S -> S [dir=back];

但在您的情况下,这似乎没有必要......(见下文)

由于边缘 < 之间的重叠代码>S-> S 和 A -> SS -> A 边,我建议仅使用 S 和 A 之间的一条边,两端都有箭头:

digraph g {
    rankdir = LR;
    {rank=same; S; A}
    B -> A -> T;
    B -> S -> T;
    A -> A;
    S -> S;
    A -> S[dir=both];
}

graphviz output

To change the orientation of any arrow, you may simply use dir=back:

S -> S [dir=back];

But in your case this doesn't seem to be necessary... (see below)

Because of the overlap between the edge S -> S and the A -> S and S -> A edges, I suggest to use only one edge between S and A with an arrowhead on both ends:

digraph g {
    rankdir = LR;
    {rank=same; S; A}
    B -> A -> T;
    B -> S -> T;
    A -> A;
    S -> S;
    A -> S[dir=both];
}

graphviz output

爱她像谁 2024-11-02 12:22:51

我不知道是否可以使箭头从左向右循环。您可以通过使用 dir 选项对箭头进行一定程度的控制,例如

S->S[dir=both];

此外,您可以通过将链接的长度从 S 更改为 S 来影响布局。您还可以控制(非自引用)的方向通过反转节点列出的顺序来改变箭头,例如:

S->T;
becomes
T->S;

我发现它几乎总是产生更好的图表,它受到的约束越少。我建议尝试删除rank=same 命令。

I don't know if it is possible to make the arrows loop from left to right. You can exercise a degree of control on the arrows by the use of the dir option eg

S->S[dir=both];

In addition you can influence the layout by changing the length of the link from S to S. You can also control the directions of (non-self referential) arrows by reversing the order the nodes are listed eg:

S->T;
becomes
T->S;

I have found that it nearly always produces better diagrams, the less it is constrained. I would suggest experimenting with removing the rank=same command.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文