本文介绍了Graphviz:如何使子图节点成一直线排列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以下列方式使用Graphviz可视化我的源代码存储库的历史记录(从上到下或从左到右无关紧要):

I'm trying to visualize the history of my source-code repository using Graphviz in the following fashion (top-to-bottom or left-to-right doesn't matter):

m1 -> m2 ----> m3 -----> m4 -> m5
    \                    ^
     \-> b1 -> b2 -> b3 -/

给出此点文件:

digraph git {
    subgraph master {
        m1 -> m2 -> m3 -> m4 -> m5
    }
    subgraph branch {
        m2 -> b1 // branch from master
        b1 -> b2 -> b3
        b3 -> m4 // merge into master
    }
}

我应该设置什么属性以将子图(属于同一分支)的所有节点放在一条直线上?

what attribute should I set to have all the nodes of a sub-graph (that belongs to the same branch) to be placed on a straight-line?

推荐答案

最简单的解决方案是将分支和合并边的weight设置为0:

The simplest solution is to set the weight of the branching and merging edges to 0:

digraph git {
    rankdir=LR
    subgraph master {
        m1 -> m2 -> m3 -> m4 -> m5
    }
    subgraph branch {
        m2 -> b1[weight=0] // branch from master
        b1 -> b2 -> b3
        b3 -> m4[weight=0] // merge into master
    }
}

rankdir=LR将布局从上到下更改为左右.

rankdir=LR changes the layout from top-bottom to left-right.

另请参阅我对类似问题的回答:强制使用主线"节点在Graphviz(或替代方法)中成一条直线

See also my answers to a similar question:Forcing "main line" nodes into a straight line in Graphviz (or alternatives)

这篇关于Graphviz:如何使子图节点成一直线排列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 04:27