1

次のドット ファイルで GraphViz を使用します。

digraph "Fast-forward"
{
    rankdir=LR;
    subgraph master
    {
        "5c071a6b2c" -> "968bda3251";
    }
    subgraph branch
    {
        "35ee8ce6b6" [color="blue"] [style="filled"];
        "968bda3251" -> "9754d40473" [weight=0];
        "9754d40473" -> "9e59700d33" -> "35ee8ce6b6";
    }
    subgraph c1
    {
        rankdir=LR;
        rank="same";
        "remote/master/HEAD" [shape=box];
        "remote/master/HEAD" -> "35ee8ce6b6" [weight=0];
        oldmh [label="master/HEAD"] [shape=box] [color="red"] [style="filled"];
        newmh [label="master/HEAD"] [shape=box] [color="blue"] [style="filled"];
        oldmh -> "968bda3251" [weight=0];
        newmh -> "35ee8ce6b6" [weight=0];
    }
}

それは私にそのようなものを与えます: 袋物

しかし、私はそのようなものが欲しい:

                                                     white
                                                        |
                                                       \/
                     "9754d40473" -> "9e59700d33" -> "35ee8ce6b6";
                     /                                  /\

5c071a6b2c -> 968bda3251

             /\                                         |
              |
            red                                       blue

どうやってやるの?

よろしくお願いいたします。

4

2 に答える 2

3

私は最初に特別なニーズ(同じランクにある、特別な形/色を持っているなど)を持つすべてのノードを定義し、次にリンクを定義する傾向があります。rank=sameこれにより、ノードが正しくグループ化され、正しい順序で定義されることが保証されます。

がないweight=0と、すべてのサイドリンクが上部に表示されます。一番下に必要なものに追加weight=0します。

digraph "Fast-forward"
{
    rankdir=LR;
    subgraph c1 {
        rank="same";
        "968bda3251";
        oldmh [label="master/HEAD"] [shape=box] [color="red"] [style="filled"];
    }
    subgraph c2
    {
        rank="same";
        "remote/master/HEAD" [shape=box];
        "35ee8ce6b6" [color="blue"] [style="filled"];
        newmh [label="master/HEAD"] [shape=box] [color="blue"] [style="filled"];
    }
    "5c071a6b2c" -> "968bda3251" -> "9754d40473" -> "9e59700d33" -> "35ee8ce6b6";
    oldmh -> "968bda3251" [weight=0];
    "remote/master/HEAD" -> "35ee8ce6b6";
    newmh -> "35ee8ce6b6" [weight=0];
}

ドットからの結果

96から97の間のジョギングが本当に必要な場合は、次のように行うことができます。

digraph "Fast-forward"
{
    rankdir=LR;
    subgraph c1 {
        rank=same;
        "968bda3251";
        oldmh [label="master/HEAD"] [shape=box] [color="red"] [style="filled"];
    }
    subgraph c1p5 {
        rank=same;
        "9754d40473";
        inviso [style="invis"];
    }
    subgraph c2
    {
        rank="same";
        "remote/master/HEAD" [shape=box];
        "35ee8ce6b6" [color="blue"] [style="filled"];
        newmh [label="master/HEAD"] [shape=box] [color="blue"] [style="filled"];
    }
    "5c071a6b2c" -> "968bda3251";
    "968bda3251" -> "9754d40473" [weight=0];
    "9754d40473" -> "9e59700d33" -> "35ee8ce6b6";
    oldmh -> "968bda3251" [weight=0];
    "remote/master/HEAD" -> "35ee8ce6b6";
    newmh -> "35ee8ce6b6" [weight=0];
    "968bda3251" -> inviso [style="invis"];
    "9754d40473" -> inviso [style="invis"];
}

ここに画像の説明を入力してください

于 2013-01-15T22:39:10.027 に答える
0

rank="same"サブグラフのすべてのノードに影響するため、ラベル付けサブグラフを 2 つの部分に分割する必要があります。

digraph "Fast-forward"
{
    rankdir=LR;
    subgraph master
    {
        "5c071a6b2c" -> "968bda3251";
    }
    subgraph branch
    {
        "968bda3251" -> "9754d40473" [weight=0];
        "9754d40473" -> "9e59700d33" -> "35ee8ce6b6";
        "35ee8ce6b6" [color="blue"] [style="filled"];
    }
    subgraph c1
    {
        rank="same";
        "remote/master/HEAD" [shape=box];
        "remote/master/HEAD" -> "35ee8ce6b6" [weight=0];
        newmh [label="master/HEAD"] [shape=box] [color="blue"] [style="filled"];
        newmh -> "35ee8ce6b6" [weight=0];
    }
    subgraph c2
    {
        rank="same";
        oldmh [label="master/HEAD"] [shape=box] [color="red"] [style="filled"];
        oldmh -> "968bda3251" [weight=0];
    }
}

これにより、次のことが得られます。 ここに画像の説明を入力

于 2013-01-10T10:55:10.763 に答える