Graphviz: how to have sub-graph nodes lined-up in a straight line?

前端 未结 2 1410
攒了一身酷
攒了一身酷 2020-12-25 08:39

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         


        
2条回答
  •  轮回少年
    2020-12-25 09:27

    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 changes the layout from top-bottom to left-right.

    graphviz graph

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

提交回复
热议问题