Force GraphViz force distance between nodes

余生长醉 提交于 2019-12-22 10:15:48

问题


I use GraphViz with the following dot file:

digraph G
{
    rankdir=LR;
    subgraph commits
    {
        "5c071a6b2c" -> "968bda3251" -> "9754d40473" -> "9e59700d33" -> "2a3242efa4";
    }
    subgraph annotations
    {
        "V1.0" [shape=box];
        "br/HEAD" [shape=box];
        "V1.0" -> "9e59700d33" [weight=0];
        "br/HEAD" -> "2a3242efa4" [weight=0];
    }
}

It give me something like that:

But I want something like that:

                                        V1.0         br/HEAD
                                          |             |
                                         \/            \/

5c071a6b2c -> 968bda3251 -> 9754d40473 -> 9e59700d33 -> 2a3242efa4

How can I do that?

For your help, Thanks by advance.


回答1:


This will align the annotations with the commits:

digraph G
{
    rankdir=LR;
    subgraph commits
    {
        "5c071a6b2c" -> "968bda3251" -> "9754d40473" -> "9e59700d33" -> "2a3242efa4";
    }
    subgraph annotations1
    {
        rank="same";
        "V1.0" [shape=box];
        "V1.0" -> "9e59700d33" [weight=0];
    }
    subgraph annotations2
    {
        rank="same";
        "br/HEAD" [shape=box];
        "br/HEAD" -> "2a3242efa4" [weight=0];
    }
}

Since the rank="same"; effects the whole subgraph I had to split the annotations in two different subgraphs.

Result is:



来源:https://stackoverflow.com/questions/14236804/force-graphviz-force-distance-between-nodes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!