我试图绘制一个PDG,但是当我添加数据依赖项时,它的格式会出现错误。
我所拥有的
当我只绘制控件依赖项时,图形看起来很好:
digraph {
4[label="4. int x=1"];
5[label="5. int y=2"];
6[label="6. while(x>0)"];
8[label="8. x=(y+x)"];
10[label="10. z=x+y"];
ENTRY -> 4[rank=same, splines=line];
ENTRY -> 5[rank=same, splines=line];
ENTRY -> 6[rank=same, splines=line];
ENTRY -> 10[rank=same, splines=line];
6 -> 8[splines=line];
}

当我试图添加数据依赖项时,图形的格式出现了错误:
digraph {
4[label="4. int x=1"];
5[label="5. int y=2"];
6[label="6. while(x>0)"];
8[label="8. x=(y+x)"];
10[label="10. z=x+y"];
ENTRY -> 4[rank=same, splines=line];
ENTRY -> 5[rank=same, splines=line];
ENTRY -> 6[rank=same, splines=line];
ENTRY -> 10[rank=same, splines=line];
6 -> 8[splines=line];
4 -> 6[style=dashed, splines=curved, color=red];
8 -> 6[style=dashed, splines=curved, color=red];
4 -> 8[style=dashed, splines=curved, color=red];
5 -> 8[style=dashed, splines=curved, color=red];
4 -> 10[style=dashed, splines=curved, color=red];
5 -> 10[style=dashed, splines=curved, color=red];
8 -> 10[style=dashed, splines=curved, color=red];
}

我试图添加属性"splines=line“来绘制直线(control .),但是它不像预期的那样工作。我还试验了属性“权重”和“等级”.
谁能给我个提示吗?是否可以为节点设置订单?类似: Entry =第一行和第一个元素节点4=第二行和第一个元素.节点8=第三行和第一元素
期望的

发布于 2017-10-22 10:18:26
正确地使用rank = same,加上不可见的边缘,以保持中间节点的顺序,应该会有所帮助:
digraph so
{
splines=true;
4[label="4. int x=1"];
5[label="5. int y=2"];
6[label="6. while(x>0)"];
8[label="8. x=(y+x)"];
10[label="10. z=x+y"];
{ rank = same; 4 5 6 10 }
ENTRY -> { 4 5 6 10 }
6 -> 8;
edge[style=dashed, color=red];
{ 4 8 } -> 6;
{ 4 5 } -> 8;
{ 4 5 8 } -> 10;
// keep graphViz from re-ordering these nodes:
4 -> 5 -> 6 -> 10[ style = invis ];
}收益率

https://stackoverflow.com/questions/46872521
复制相似问题