我有以下Graphviz:
graph {
node[width = 0.6, height = 0.6, fixedsize=true, shape=circle];
nodesep = 0.5;
a[label="22"];
b[label="22"];
c[label="34"];
d[label="22"];
e[label="99"];
f[label="34"];
g[label="40"];
h[label="37"];
i[label="22"];
j[label="99"];
k[label="135"];
l[label="129"];
m[label="40"];
edge[penwidth=1.0]; //principal path edges
a -- b;
b -- d;
c -- f;
d -- i;
e -- j;
g -- m;
edge[penwidth=1.0]; //other edges
a -- c;
b -- e;
c -- g;
d -- h;
e -- k;
g -- l;
}
这给我画了一个漂亮的树形图。然后,我想更改一些内容(特别是'绘制具有匹配值的路径),所以我这样做了,following this example:
graph {
node[width = 0.6, height = 0.6, fixedsize=true, shape=circle];
nodesep = 0.5;
subgraph cluster_0 {
style = rounded;
a[label="22"];
b[label="22"];
d[label="22"];
i[label="22"];
}
subgraph cluster_1 {
style = rounded;
c[label="34"];
f[shape=diamond, label="34"];
}
subgraph cluster_2 {
style = rounded;
e[label="99"];
j[shape=diamond,label="99"];
}
subgraph cluster_3 {
style = rounded;
g[label="40"];
m[shape=diamond, label="40"];
}
node[shape = diamond];
h[shape=diamond, label="37"];
k[label="135"];
l[label="129"];
edge[penwidth=1.0]; //principal path edges
a -- b;
b -- d;
c -- f;
d -- i;
e -- j;
g -- m;
edge[penwidth=3.0]; //other edges
a -- c;
b -- e;
c -- g;
d -- h;
e -- k;
g -- l;
}
但是,最终结果是每个群集都是垂直的,看起来并不像树一样。有没有办法让第二张图看起来更像第一张?