我正在构建一个epsilon NFA,以使用规范构造识别正则表达式.我正在使用子图来对正则表达式的各个部分进行分组.由于dot决定移动节点的顺序,*运算符给了我特别的麻烦.我已经尝试添加边缘权重以强制特定边缘变短以保持边缘的顺序,但这似乎不起作用.
我想要做的是强制子图中的节点按特定顺序放置,以便输出图可以识别为特定类型的(众所周知的)构造.在下面的示例中,我希望边缘3,4,5和6按此顺序放置,但是点将它们按6,3,4,5的顺序放置.任何指针都会被欣赏.
请注意,当前权重参数与完全没有权重参数没有任何区别.
我有以下内容
digraph G {
rankdir = LR;
node [shape = none];
0 [label = "start"];
node [shape = circle];
1 [label = "q1"];
2 [label = "q2"];
3 [label = "q3"];
4 [label = "q4"];
5 [label = "q5"];
node [shape = doublecircle];
6 [label = "q6"];
subgraph re1 {
rank = same;
edge[label = "0"];
1 -> 2;
};
subgraph re2 {
rank = same;
edge[label = "ε"];
3 -> 4 [weight = 10];
edge[label = "1"];
4 -> 5 [weight = 10];
edge[label = "ε"];
5 -> 6 [weight = 10];
5 -> 4 [weight = 1];
6 -> 3 [weight = 1];
};
edge[color=black];
0 -> 1
edge[label = "ε"];
2 -> 3;
}
Run Code Online (Sandbox Code Playgroud)

mar*_*pet 34
这是我写这个图的方式:
rankdir=LR添加的图形rank=same.constraint=false到了与图形方向相反的边缘 - 从节点4到节点5的边缘,以及从节点6到节点3的边缘.这里的来源:
digraph G {
0 [label = "start", shape = none];
node [shape = circle];
1 [label = "q1"];
2 [label = "q2"];
3 [label = "q3"];
4 [label = "q4"];
5 [label = "q5"];
6 [label = "q6", shape = doublecircle];
{rank = same; 0 -> 1; }
1 -> 2 [label = "0"];
{rank = same; 2 -> 3 [label = "ε"]; }
4 -> 5 [label = "1"];
edge [label = "ε"];
3 -> 4;
5 -> 6;
5 -> 4 [constraint = false];
6 -> 3 [constraint = false];
}
Run Code Online (Sandbox Code Playgroud)
这是结果:

现在,如果你愿意,你可以保留rankdir=LR,只需取你发布的标记,删除权重并添加constraint=false到我所做的相同边缘,它也可以.