gpt4 book ai didi

graphviz - 如何调整点图中的边缘方向?

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

在提问之前,我试图搜索我的问题的答案,但我找不到。
我的问题是关于改变点图中的边缘方向。 Rankdir 是“LR”,但在图表的某些部分,我想使用“TB”。让我举个例子吧。

有向图 G {
等级目录=LR;
大小="7,5";
浏览器-> ui_thread;
浏览器-> db_thread;
浏览器-> webkit_thread;
浏览器->缓存线程;
浏览器->file_thread;
浏览器->io_thread;
io_thread[style=填充];
缓存线程[style=填充];
ui_thread->thread[label=inherit];
ui_thread->messageloop[style=dotted];
db_thread->messageloop[style=dotted];
webkit_thread->messageloop[style=dotted];
cache_thread->messageloop[style=dotted];
file_thread->messageloop[style=dotted];
io_thread->messageloop[style=dotted];
}

它给出这样的图表
output graph

但是,这不是我想要的。
我想要下图。 “线程”垂直高于“ui_thread”。
enter image description here
您可能认为使用“rankdir=same”和“thread”和“ui_thread”可以轻松解决这个问题。
我肯定已经试过了。但我失败了。 “线程”始终低于“ui_thread”。

谢谢,

最佳答案

不幸的是,图方向只能指定一次,并且整个图都停留在该方向上。在这种情况下,通常可以通过 constraint=false 的组合来获得想要的效果。和看不见的边缘来强制一些排序。

此代码将生成您的第二张图片:

digraph G {
rankdir=LR;
size="7,5";
browser->thread[style=invis];
browser->ui_thread;
browser->db_thread;
browser->webkit_thread;
browser->cache_thread;
browser->file_thread;
browser->io_thread;
io_thread[style=filled];
cache_thread[style=filled];
ui_thread->thread[label=inherit constraint=false];
ui_thread->messageloop[style=dotted];
db_thread->messageloop[style=dotted];
webkit_thread->messageloop[style=dotted];
cache_thread->messageloop[style=dotted];
file_thread->messageloop[style=dotted];
io_thread->messageloop[style=dotted];
}

关于graphviz - 如何调整点图中的边缘方向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6162841/

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