首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Graphviz:创建三个集群中节点之间的直边流程图

Graphviz:创建三个集群中节点之间的直边流程图
EN

Stack Overflow用户
提问于 2019-12-07 19:02:05
回答 1查看 871关注 0票数 1

我正在尝试重新创建这个区块链流程图。

我无法获得一些边缘作为水平,即使设置边界权重为100和使用无形的节点。下面是我写的代码。在这里,我创建了三个集群,在其中两个集群(第2和3d)中,我在节点之间放置了假边。

代码语言:javascript
复制
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] 
}

然而,即使在修改不同的权重并将约束设为假的情况下,第三簇仍然位于前两组之间。或者第一个集群,它被认为是最左边的,位于中间。

这是其中一个输出。

重量不像预期的那样起作用。我是不是遗漏了什么?请帮帮我!谢谢

EN

回答 1

Stack Overflow用户

发布于 2020-01-01 02:04:17

我靠得很近,但需要两步才能到那里。

  1. 将下面的内容保存为myfile.gv,然后运行dot -tdot myfile.gv >myfile.dot,这将锁定节点

代码语言:javascript
复制
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中,就在最后一个paren之前,并运行neato -n1 -Tpng myfile.dot >myfile.png,这将对边缘进行路由。

代码语言:javascript
复制
 [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]
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59229277

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档