Graphviz:创建三个簇中节点之间具有直边的流程图

问题描述 投票:0回答:1

我正在尝试重新创建此区块链流程图

Do you need blockchain?

即使将边缘权重设置为100并使用不可见节点,我也无法将某些边缘设为水平边缘。我写的代码如下。在此过程中,我创建了三个群集,在其中两个群集中(第2个和第3d个),我在节点之间放置了虚假边。

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] 
}

但是,即使修改了不同的weights并将constraints设置为false,第三个簇也始终位于前两个簇之间。或者第一个群集(应该是最左侧的群集)位于中间。

这里是输出之一。

Output received

砝码无法正常工作。我想念什么吗?请帮忙!谢谢

layout graphviz dot pygraphviz
1个回答
0
投票

我已经接近了,但是需要两个步骤才能到达那里。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,将以下内容添加到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]
© www.soinside.com 2019 - 2024. All rights reserved.