为什么Graphviz没有按我的DOT文件的顺序来渲染?
为什么pre1这一行会最后才被渲染到末端?拓扑图的顺序完全颠倒了。pre4显示在顶部,pre1显示在底部。
pre1 -> mat1 -> res1;
pre2 -> mat2 -> res2;
pre3 -> mat3 -> res3;
pre4 -> mat4 -> res4;
下面是我的dot文件的内容,截图也在这里。
有什么简单的技巧可以修复吗?谢谢。

digraph G {
rankdir=LR;
node [
fontname="Arial",
shape=box,
style=filled,
fillcolor=lightgray,
margin="0.3,0.1"
];
mat1,mat2,mat3,mat4 [fillcolor=lightblue];
res1,res2,res3,res4 [shape=ellipse];
header1,header2 [shape=plain, fontweight=bold];
header1 [label="Unlocking Condition"];
header2 [label="Crafting Materials"];
header1 -> header2 [style=invis];
pre1 [label="Kill Mosquitoes"];
mat1 [label="Mosquito Proboscis×1\nMosquito Blood Sac×2\nDry Grass×4\nRope×1"];
res1 [label="Mosquito Proboscis\nEarly Game Piercing Weapon"];
pre2 [label="Kill Worker/Soldier Ants"];
mat2 [label="Ant Head×1\nAnt Mandible×2\nDry Grass×3\nRope×1"];
res2 [label="Ant Club\nHigh Damage Blunt Weapon (Easy to Obtain)"];
pre3 [label="Kill Ladybugs"];
mat3 [label="Ladybug Shell×2\nResin×1\nRope×1"];
res3 [label="Ladybug Dagger\nSmooth Transition Dagger"];
pre4 [label="Kill Fire Ants"];
mat4 [label="Fire Ant Stinger×2\nCharcoal Chunk×3\nGrind Paste×1\nRope×2"];
res4 [label="Spicy Carbon Dagger\nMid Game Core Piercing Weapon"];
pre1 -> mat1 -> res1;
pre2 -> mat2 -> res2;
pre3 -> mat3 -> res3;
pre4 -> mat4 -> res4;
}
解决方案
我已经按你说的方式进行了修改,你可能想把箭头的长度调长一些,这样看起来会好一些。
digraph G {
rankdir=TB;
node [
fontname="Arial",
shape=box,
style=filled,
fillcolor=lightgray,
margin="0.3,0.1"
];
mat1,mat2,mat3,mat4 [fillcolor=lightblue];
res1,res2,res3,res4 [shape=ellipse];
header1,header2 [shape=plain, fontweight=bold];
header1 [label="Unlocking Condition"];
header2 [label="Crafting Materials"];
header1 -> header2 [style=invis];
{ rank = same;
pre1 [label="Kill Mosquitoes"];
mat1 [label="Mosquito Proboscis×1\nMosquito Blood Sac×2\nDry Grass×4\nRope×1"];
res1 [label="Mosquito Proboscis\nEarly Game Piercing Weapon"];
pre1 -> mat1 -> res1;
}
{ rank = same;
pre2 [label="Kill Worker/Soldier Ants"];
mat2 [label="Ant Head×1\nAnt Mandible×2\nDry Grass×3\nRope×1"];
res2 [label="Ant Club\nHigh Damage Blunt Weapon (Easy to Obtain)"];
pre2 -> mat2 -> res2;
}
{ rank = same;
pre3 [label="Kill Ladybugs"];
mat3 [label="Ladybug Shell×2\nResin×1\nRope×1"];
res3 [label="Ladybug Dagger\nSmooth Transition Dagger"];
pre3 -> mat3 -> res3;
}
{ rank = same;
pre4 [label="Kill Fire Ants"];
mat4 [label="Fire Ant Stinger×2\nCharcoal Chunk×3\nGrind Paste×1\nRope×2"];
res4 [label="Spicy Carbon Dagger\nMid Game Core Piercing Weapon"];
pre4 -> mat4 -> res4;
}
pre1 -> pre2 -> pre3 -> pre4 [style=invis];
}
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。