Layout Graphviz:在三个簇中的节点之间创建具有直边的流程图
我正在尝试重新创建此区块链流程图 我无法将某些边设置为水平,即使将边权重设置为100并使用不可见节点。我写的代码如下。我创建了三个簇,其中两个簇(第二个簇和第三个簇)在节点之间放置了假边Layout Graphviz:在三个簇中的节点之间创建具有直边的流程图,layout,graphviz,dot,pygraphviz,Layout,Graphviz,Dot,Pygraphviz,我正在尝试重新创建此区块链流程图 我无法将某些边设置为水平,即使将边权重设置为100并使用不可见节点。我写的代码如下。我创建了三个簇,其中两个簇(第二个簇和第三个簇)在节点之间放置了假边 digraph S { rankdir=TB subgraph cluster1 { graph [style="invis"] rank="same" node [fixedsize="true", width="3", heig
digraph S {
rankdir=TB
subgraph cluster1 {
graph [style="invis"]
rank="same"
node [fixedsize="true", width="3", height="1", shape="diamond", style="filled"]
A [label="Is multi-party\nrequired?", fillcolor=""]
B [label="Is trusted_authority\nrequired?", fillcolor=""]
C [label="Is operation\ncentralized?", fillcolor=""]
D [label="Is immutability\nrequired?", fillcolor=""]
E [label="Is high performace\nrequired?", fillcolor=""]
F [label="Is transparency\nrequired?", fillcolor=""]
A -> B [label="Yes"]
B -> C [label="No"]
C -> D [label="No"]
D -> E [label="Yes"]
E -> F [label="No"]
}
subgraph cluster2 {
graph [style="invis"]
rank="same"
node [shape="diamond", fixedsize="true", width="3", height="1", style="filled"]
P [label="Is trusted authority\ndecentralizable", fillcolor=""]
P1 [style="invis"]
P2 [style="invis"]
Q [label="Can big data be\nstored off-chain", fillcolor=""]
R [label="Can encrypted data\nbe shared", fillcolor=""]
P -> P1 -> P2 -> Q -> R [style="invis", dir="none"]
}
B -> P [label="Yes", weight=200]
P -> C [label="Yes"]
E -> Q [label="Yes", weight=1]
Q -> F [label="Yes"]
F -> R [label="No", weight=1]
subgraph cluster3 {
graph [style="invis"]
rank="same"
node [shape="box", style="filled"]
X [label="Consider Conventional\nDatabase", fillcolor=""]
Y [label="Consider Blockchain", fillcolor=""]
Z [label="Consider DLTs", fillcolor=""]
X -> Y -> Z [style="invis", dir="none"]
}
A -> X [label="No"]
P -> X [label="No", weight=100]
C -> X [label="Yes", weight=200]
D -> X [label="No"]
Q -> X [label="No"]
F -> Y [label="Yes"]
R -> Y [label="Yes"]
R -> Z [label="No", weight=100]
}
然而,即使修改不同的权重并将约束设置为false,第三个簇仍然位于前两个簇之间。或者第一簇,应该是最左边的,在中间。
这里是一个输出
配重未按预期工作。我错过什么了吗?请帮忙!谢谢我很接近,但需要两步才能到达那里。
1.将以下内容另存为myfile.gv,然后运行dot-tdot myfile.gv>myfile.dot 这将固定节点
digraph S {
graph [splines=polyline compound=true]
subgraph clusterA {
graph [style="invis" margin=30]
rank="min"
node [fixedsize="true", width="3", height="1", shape="diamond", style="filled"]
A [label="Is multi-party\nrequired?", fillcolor=""]
B [label="Is trusted_authority\nrequired?", fillcolor=""]
C [label="Is operation\ncentralized?", fillcolor=""]
D [label="Is immutability\nrequired?", fillcolor=""]
E [label="Is high performace\nrequired?", fillcolor=""]
F [label="Is transparency\nrequired?", fillcolor=""]
A:s -> B:n [label="Yes"]
B:s -> C:n [label="No"]
C:s -> D:n [label="No"]
D:s -> E:n [label="Yes"]
E:s -> F:n [label="No"]
}
subgraph clusterB {
graph [style="invis" margin=30]
rank="same"
node [shape="diamond", fixedsize="true", width="3", height="1", style="filled"]
P [label="Is trusted authority\ndecentralizable", fillcolor=""]
Q [label="Can big data be\nstored off-chain", fillcolor=""]
R [label="Can encrypted data\nbe shared", fillcolor=""]
node [label="" style="invis" shape=plain]
x0
x1
x2
x0 -> P -> x1 -> x2 -> Q -> R [style="invis"] // , dir="none"]
}
subgraph clusterC {
graph [style="invis" margin=30]
rank="max"
node [shape="box", style="filled"]
X [label="Consider Conventional\nDatabase", fillcolor=""]
Y [label="Consider Blockchain", fillcolor=""]
Z [label="Consider DLTs", fillcolor=""]
node [label="" style="invis" shape=plain]
z0
z1
z2
z0 -> z1 -> X -> z2 -> Y -> Z [style="invis"] // , dir="none"]
}
}
2,在最后一个paren之前将以下内容添加到myfile.dot并运行
neato-n1-Tpng myfile.dot>myfile.png
这将对边进行布线
[B:e -> P:w \[label="Yes" constraint=false\];
P:sw -> C:ne \[label="Yes" constraint=false\]
E:e -> Q:w \[label="Yes" constraint=false\]
Q:sw -> F:ne \[label="Yes" constraint=false\]
F:e -> R:w \[label="No" constraint=false\]
A:e -> X:n \[label="No" constraint=false\]
P -> X \[label="No" constraint=false\]
C:e -> X:w \[label="Yes" constraint=false\]
D:e -> X \[label="No" constraint=false\]
Q -> X \[label="No" constraint=false\]
F -> Y \[label="Yes" constraint=false\]
R -> Y \[label="Yes" constraint=false\]
R -> Z \[label="No" constraint=false\]
E -> Q \[ltail=clusterA,lhead=clusterB\];
Q -> Y \[ltail=clusterB,lhead=clusterC\];][1]