gpt4 book ai didi

graphviz:进行细微调整以使图看起来更好

转载 作者:行者123 更新时间:2023-12-04 03:13:58 24 4
gpt4 key购买 nike

我在这里有一个测试图,我想对其进行调整以使其看起来更好。

这是graphviz(点)源test6.dot:

digraph G {
ranksep=0.3; size="6.0,6.0";
node [fontsize=11];

subgraph clusterA {
X2 [shape=box];

node [style=filled];
1 -> 2 -> 3 -> X2 -> 5;
6;
7;
label = "A";
color=blue
}
X1 [shape=box];
subgraph clusterB {
node [style=filled];
8;
9;
10 -> 11 -> 12;
12 -> 9;
12 -> 8 -> 13;
13 -> 14;
label = "B";
color=blue
}
subgraph clusterC {
label = "C";
{
node [style="invis"];
gap;
}
node [shape=box];

edge [style="invis"];
X3 -> gap -> X4;
}

14 -> X4 -> 3;
6 -> X1 -> 10;
{ edge [dir="both"];
8 -> X3 -> 7;
}

9 -> X3
}
我要提出的问题/更改:
  • 我希望节点10 -> 11 -> 12 -> 8 -> 13 -> 14的流在垂直线上(水平交换8和9)。我怎样才能做到这一点? (与1 -> 2 -> 3 -> X2 -> 5相同;交换6和1)
  • 我希望X1处于与10相同的垂直位置,并且与6处于相同的水平位置。我该怎么做?
  • 我希望8和X3和7处于相同的垂直位置,也要与14和X4和3处于相同的垂直位置。我该怎么做?
  • ranksep=0.3;语句非常有用,但请注意8 -> 13 -> 14X3 -> gap -> X4的差距更大。为什么不遵守ranksep = 0.3规则,我该如何解决?
  • 最佳答案

    以下是我能做的最好的事情:幻像节点和边缘帮助。但是我似乎不鼓励在横向方向(rankdir的另一个方向)上进行特定的排序。


     digraph G {
    ranksep=0.3; size="6.0,6.0";
    rankdir=TB;

    node [fontsize=11];

    subgraph clusterA {
    X2 [shape=box];
    label = "A";
    color=blue;

    node [style=filled];
    /* force 1, 6, and 7 to be at the top together,
    add enough phantoms to keep things in nice columns */
    {
    node [style="invis", label=""];
    phantom3;
    phantom4;
    phantom5;
    phantom6;
    }


    rank = same;
    1 -> 2 -> 3 -> X2 -> 5;

    edge [style="invis"];
    6 -> phantom3 -> phantom5;
    7 -> phantom4 -> phantom6;

    }
    subgraph clusterB {
    node [style=filled];
    label = "B";
    color=blue;
    /* create an invisible phantom node
    to take up space */
    {
    node [style="invis",label=""];
    phantom1;
    phantom1b;
    }

    { rank=same; 11;
    phantom1;
    }

    10 -> 11 -> 12 -> 8 -> 13 -> 14;
    12 -> 9;
    phantom1 -> 9 -> phantom1b [style="invis"];

    }


    /* force X1 to be at the same vertical pos as 10
    (this yields a warning though) */
    { rank = same;
    X1 [shape=box];
    10;
    }

    6 -> X1;
    X1 -> 10 [weight=0.5];

    subgraph clusterC {
    label = "C";

    phantom2 [style="invis", label=""];

    node [shape=box];

    edge [style="invis"];
    X3 -> phantom2 -> X4;
    }

    9 -> X3 [weight=0.5];

    {
    edge [weight=20];
    14 -> X4 -> 3;
    3 -> X4 -> 14 [style="invis"];
    /* add a reverse path so graphviz doesn't force 14 above X4 above 3 */
    }
    {
    edge [dir="both", weight=20];
    8 -> X3 -> 7;
    7 -> X3 -> 8 [style="invis"];
    edge [style="invis"];
    X4 -> phantom6;
    1 -> phantom2;
    8 -> phantom2;
    }

    }

    关于graphviz:进行细微调整以使图看起来更好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2094380/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com