GraphViz创建常规边

时间:2014-03-13 19:08:56

标签: graphviz image-graphviz

我在Mediawiki网站中使用GraphViz,这意味着我无法处理svg文件(不幸的是)。 我创建了这个图

digraph GPPubProcess{
rankdir="TB";
node [shape = box fontsize=10];
edge [fontsize=10];
graph[size="7.75,10.25" overlap = false];

subgraph c2 {
    rank="same";
    N02 [label="Two?" shape=hexagon margin=0];
    N03 [label="Three"];
}

subgraph c4 {
    rank="same";
    N07 [label="Seven"];
    N06 [label="Six?" shape=hexagon margin=0];
    N05 [label="Five"];
}

subgraph c8 {
    rank="same";
    N11 [label="Eleven)" shape=hexagon margin=0];
    N12 [label="Twelve"];
}

subgraph c9 {
    rank="same";
    N13 [label="Thirteen?" shape=hexagon margin=0]];
    N14 [label="Fourteen"];
N17 [label="COMPLETED"];
}

N00 [shape=point];
N01 [label="One"];
N02 [label="Two?" shape=hexagon margin=0];
N04 [label="Four?" shape=hexagon margin=0];
N08 [label="Eight"];
N09 [label="Nine"];
N10 [label="Ten?" shape=hexagon margin=0];
N99 [shape=point];
N00->N01:n;
N01:s->N02:n;
N02:s->N04:n [label="  yes"];
N04:s->N05:n [label="  no" weight=30];
N05:s->N08:n [weight=30];
N08:s->N09:n [weight=30];
N09:s->N10:n [weight=30];
N10:s->N11:n [label="  no" weight=30];
N11:s->N17:n [label="  no"];
N17:s->N99;

N02 -> N03 [weight=0];
N04:e -> N06:n [label="  yes"];
N06 -> N05 [label="  no"] [weight=0];
N06 -> N07 [label="  yes"];
N10:e -> N06:s [label="  yes" weight=5];
N03:s -> N07:n;
N07:e -> N09:e [weight=0];

N11:e -> N12:w;

N15 [label="Fifteen"];
N16 [label="Sixteen"];

N12:s->N13:n [weight=5];
N13:s->N15:n [label="  no"];
N15:s->N16:n;

N13:e->N14:w [label="  yes" weight=5];

N14:n->N07:s;

N16:w->N05:w [weight=0];

}

几乎产生我喜欢的东西,但链接十六 - 五,十 - >六和十三 - 十四在节点之间产生很多障碍。有没有办法使他们正规化?

六和五之间的联系方向错误但我无法做到正确吗?有诀窍吗?

非常感谢。

乔治

1 个答案:

答案 0 :(得分:0)

我首先删除weight和指南针指令(:n,:e,:s,:w)。那些迫使dot做出一些奇怪的决定,特别是罗盘点。如果您需要更改默认版本,请一次进行一次小更改。不幸的是,你尝试强制点制作特定图表的次数越多,它就越容易获得。

由于您无法使用SVG,因此在某些时候您必须放弃准确获取所需的图形并接受点创建的图形。你可以强迫点数的限制。

六到五之间的链接(N06 -> N05)的箭头应该是六到五。如果你看到箭头指向六个,我认为这是早期版本的Graphviz中的一个错误。尝试更新到最新版本。

此代码:

digraph GPPubProcess{
    rankdir="TB";
    node [shape = box fontsize=10];
    edge [fontsize=10];
    graph[size="7.75,10.25" overlap = false];

    subgraph c2 {
        rank="same";
        N02 [label="Two?" shape=hexagon margin=0];
        N03 [label="Three"];
    }

    subgraph c4 {
        rank="same";
        N07 [label="Seven"];
        N06 [label="Six?" shape=hexagon margin=0];
        N05 [label="Five"];
    }

    subgraph c8 {
        rank="same";
        N11 [label="Eleven)" shape=hexagon margin=0];
        N12 [label="Twelve"];
    }

    subgraph c9 {
        rank="same";
        N13 [label="Thirteen?" shape=hexagon margin=0];
        N14 [label="Fourteen"];
        N17 [label="COMPLETED"];
    }

    N00 [shape=point];
    N01 [label="One"];
    N02 [label="Two?" shape=hexagon margin=0];
    N04 [label="Four?" shape=hexagon margin=0];
    N08 [label="Eight"];
    N09 [label="Nine"];
    N10 [label="Ten?" shape=hexagon margin=0];
    N99 [shape=point];
    N00->N01;
    N01->N02;
    N02->N04 [label="  yes"];
    N04->N05 [label="  no"];
    N05->N08;
    N08->N09;
    N09->N10;
    N10->N11 [label="  no"];
    N11->N17 [label="  no"];
    N17->N99;

    N02 -> N03;
    N04 -> N06 [label="  yes"];
    N06 -> N05 [label="  no"];
    N06 -> N07 [label="  yes"];
    N10 -> N06 [label="  yes"];
    N03 -> N07;
    N07 -> N09;

    N11 -> N12;

    N15 [label="Fifteen"];
    N16 [label="Sixteen"];

    N12->N13;
    N13->N15 [label="  no"];
    N15->N16;

    N13->N14  [label="  yes"];
    N14->N07;

    N16->N05;

}

创建了这张图:

no constraints

[constraint=false]添加到N06 -> N05有助于消除N06周围的交叉点,但然后将N11和N17推向左侧:

with constraint