graphviz:边缘的颜色方向

发布于 2024-10-03 20:18:10 字数 135 浏览 2 评论 0原文


我可以让 graphviz 以识别方向的方式对边缘进行着色吗?例如,靠近源节点的边部分可能是蓝色的,然后当它靠近目标节点时逐渐变为红色。或者有其他绘图工具(如 graphviz)可以做到这一点吗?

任何在这方面的帮助将不胜感激。

Hi
Can I get graphviz to color the edges in a way that identifies the direction? For example, the part of the edge near its source node might be blue and then it gradually shades away to red as it nears the target node. Or are there any other graphing tools (like graphviz) that can do this?

Any help in this regard would be much appreciated.

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

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

发布评论

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

评论(2

笑饮青盏花 2024-10-10 20:18:10

好吧,我对您当前的点文件一无所知,所以我必须做出一些假设。首先处理简单的情况,区分边的方向是箭头(指向)和箭头尾(指向)的工作。仅当您的图形类型是有向图形(您在点文件顶部设置)时,您的图形才会呈现这些图形,例如,

digraph G {
    node[style=filled, color=cornflowerblue, fontcolor=white, fontsize=10, 
          fontname='Helvetica']
    edge[arrowhead=vee, arrowtail=inv, arrowsize=.7, color=maroon, fontsize=10,
          fontcolor=navy]

    a1 -> a2;
    a2 -> a4 [taillabel="TL     "];
    a2 -> a5 [headlabel="       HL"];
    a4 -> a6 [label="  ordinary edge label"]
}

如果您已经装箱有向图,但由于某种原因您想要一个附加指示器来显示边缘方向,那么我能想到的唯一相关边缘属性是 headlabeltaillabel 属性,允许您指定标签放置在边缘的哪一端。上面的小点文件将呈现此图:

alt text

Well, i don't know anything about your current dot file, so i'll have to make a couple of assumptions. To deal with the easy case first, distinguishing the the direction of an edge is the job of the arrowhead (points to) and arrowtail (points from). Your graph is only going to render those if your graph type is a directed graph, which you set at the top of your dot file, e.g.,

digraph G {
    node[style=filled, color=cornflowerblue, fontcolor=white, fontsize=10, 
          fontname='Helvetica']
    edge[arrowhead=vee, arrowtail=inv, arrowsize=.7, color=maroon, fontsize=10,
          fontcolor=navy]

    a1 -> a2;
    a2 -> a4 [taillabel="TL     "];
    a2 -> a5 [headlabel="       HL"];
    a4 -> a6 [label="  ordinary edge label"]
}

If you've already crated a directed graph but for some reason you want an additional indicator to show edge direction, then the only relevant edge attributes i can think of are the headlabel and taillabel attributes, which allows you to specify which end of an edge a label is placed. The small dot file above will render this graph:

alt text

优雅的叶子 2024-10-10 20:18:10

自 2012 年和 2.30.0 起,Graphviz 支持多种边缘颜色:color="blue;0.5:red" 应该使一半更接近源蓝色,一半更接近目标红色。 更准确地说

如果 colorList 没有分数,则使用平行样条线或直线绘制边缘,按照给定的顺序对应列表中的每种颜色。

头箭头(如果有)使用列表中的第一种颜色绘制,尾箭头(如果有)使用第二种颜色绘制。这支持绘制相对边的常见情况,但使用平行样条线而不是单独布线的多重边。

如果使用任何分数,则颜色将按顺序绘制,每种颜色大致给出其指定的边缘分数。

Since 2012 and 2.30.0, Graphviz supports multiple colors for edges: color="blue;0.5:red" should make the half closer to the source blue and the half closer to the target red. More precisely:

if colorList has no fractions, the edge is drawn using parallel splines or lines, one for each color in the list, in the order given.

The head arrow, if any, is drawn using the first color in the list, and the tail arrow, if any, the second color. This supports the common case of drawing opposing edges, but using parallel splines instead of separately routed multiedges.

If any fraction is used, the colors are drawn in series, with each color being given roughly its specified fraction of the edge.

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