Graphviz 中的节点分层

发布于 2024-08-12 04:50:49 字数 495 浏览 2 评论 0原文

我正在使用 Graphviz (用 neato 编译)创建一个图表。该图包含许多重叠的节点,这非常好。然而,有一组大节点我更喜欢始终位于其他小节点之上 - 尽管我更喜欢首先在图中定义大节点(这使得它们被绘制在最底部)。

有什么办法可以强制我这样做吗?

编辑:
这是一个小例子,只是为了澄清我的意思:

graph G {
    node [style=filled,fillcolor=black];
    BigNode [fillcolor=skyblue,shape=Msquare];

    node [style=filled,fillcolor=red,shape=circle];
    edge [style=invis]
    1 -- BigNode[len=0.5];
    2 -- BigNode[len=1];
}

我希望在节点 1 上绘制 BigNode

I'm creating a graph using Graphviz (compiled with neato). This graph contains many overlapping nodes which is perfectly fine. However, there is a group of large nodes which I prefer to always be on top of other small nodes - even-though I prefer to define the large nodes first in the graph (which makes them get painted at the very bottom).

Any way I can force this?

Edit:
Here's a small example, just to clarify what I mean:

graph G {
    node [style=filled,fillcolor=black];
    BigNode [fillcolor=skyblue,shape=Msquare];

    node [style=filled,fillcolor=red,shape=circle];
    edge [style=invis]
    1 -- BigNode[len=0.5];
    2 -- BigNode[len=1];
}

I'd like for BigNode to be painted over node 1.

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

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

发布评论

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

评论(2

小…红帽 2024-08-19 04:50:49

我确实找到了一种(某种)解决方案......
我发现,如果您将节点定义推迟到最后,即使您之前为该节点定义了边,它也会被绘制在最顶部。
我意识到这与我之前定义的内容相矛盾,但这是这种情况下唯一可能的解决方案,也是我最终不得不使用的解决方案。

在我的简短示例中,您可以这样做:

graph G {
    node[style=filled,fillcolor=black];
    // Definition of BigNode moved to the end of the file
    /*BigNode [fillcolor=skyblue,shape=Msquare];*/ 

    node[style=filled,fillcolor=red,shape=circle];
    edge[style=invis]
    1 -- BigNode[len=0.5];
    2 -- BigNode[len=1];

    // Defined after already defining edges for BigNode
    BigNode [fillcolor=skyblue,shape=Msquare];
}

在生成的图中,BigNode 绘制在节点 1

I did find one (sort of) solution...
I found that if you postpone only the node definition to the end, even if you defined edges for this node earlier, it will be painted top-most.
I realize this contradicts what I defined earlier, but this was the only possible solution in this case and it was the one I eventually had to use.

In my short example, you would do this:

graph G {
    node[style=filled,fillcolor=black];
    // Definition of BigNode moved to the end of the file
    /*BigNode [fillcolor=skyblue,shape=Msquare];*/ 

    node[style=filled,fillcolor=red,shape=circle];
    edge[style=invis]
    1 -- BigNode[len=0.5];
    2 -- BigNode[len=1];

    // Defined after already defining edges for BigNode
    BigNode [fillcolor=skyblue,shape=Msquare];
}

In the resulting graph, BigNode is painted over node 1

挽手叙旧 2024-08-19 04:50:49

我认为这是不可能的。官方 neato 指南 在第 6 页到第 9 页上讨论了节点分层。它看起来像您能做的最多就是调整边的长度并固定节点:您实际上无法控制节点如何彼此分层。

I don't think it's possible. The official neato guide talks about node layering on pages 6 through 9. It looks like the most you can do is adjust the length of edges and pin down nodes: you can't actually control how nodes layer over each other.

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