【问题标题】:Graphviz how to fix the x pos of clustersGraphviz如何修复集群的x pos
【发布时间】:2020-12-04 20:58:52
【问题描述】:

目前,我正在尝试修复集群的 x Pos,因为它们似乎在四处移动,从而创建了一个杂乱的图形。所有子图都有rank=samenewrank=trueconstraint 值设置为 true 仅适用于从一个集群到另一个集群的边。

尝试了http://martin-loetzsch.de/S-DOT/constraint.html 的许多选项,但无法正常工作。有谁知道为什么子图会像上面一样水平移动?

// layered_view
digraph layered_view {
    bgcolor=transparent fontsize=8 nodesep=0.2 rankdir=TB splines=ortho
    switch_1 -> lake [label="" color=gold4 constraint=True dir=both style=solid]
    switch_1 -> lake [label="" color=chartreuse4 constraint=True dir=both style=solid]
    switch_1 -> switch_2 [label="" color=gold4 constraint=True dir=both style=solid]
    switch_1 -> switch_2 [label="" color=chartreuse4 constraint=True dir=both style=solid]
    switch_1 -> azure_1 [label="" color=gold4 constraint=True dir=both style=solid]
    switch_1 -> azure_1 [label="" color=chartreuse4 constraint=True dir=both style=solid]
    switch_2 -> watson [label="" color=goldenrod4 constraint=True dir=both style=solid]
    lake -> tsX [label="" color=chartreuse4 constraint=True dir=both style=solid]
    lake -> ptX [label="" color=chartreuse4 constraint=True dir=both style=solid]
    switch_1 -> dropBox [label="" color=chartreuse4 constraint=True dir=both style=solid]
    switch_1 -> ptX [label="" color=gold4 constraint=True dir=both style=solid]
    switch_1 -> tsX [label="" color=goldenrod4 constraint=True dir=both style=solid]
    switch_1 -> watson [label="" color=goldenrod4 constraint=True dir=both style=solid]
    // software
    subgraph cluster_software {
        bgcolor=green color=black concentrate=true fontsize=8 label=Software newrank=true rank=same splines=ortho
        // applications
        subgraph cluster_applications {
            bgcolor=green color=black concentrate=true fontsize=8 label=Applications newrank=true rank=same splines=ortho
            tsX [label=tsX color=black fillcolor=chartreuse1 fixedsize=true shape=rectangle style=filled width=1.3 xlabel=""]
            ptX [label=ptX color=black fillcolor=chartreuse1 fixedsize=true shape=rectangle style=filled width=1.3 xlabel=""]
        }
        // cloud
        subgraph cluster_cloud {
            bgcolor=green color=black concentrate=true fontsize=8 label=Cloud newrank=true rank=same splines=ortho
            azure_1 [label=azure_1 color=black fillcolor=darkolivegreen1 fixedsize=true shape=rectangle style=filled width=1.3 xlabel=""]
            dropBox [label=dropBox color=black fillcolor=darkolivegreen1 fixedsize=true shape=rectangle style=filled width=1.3 xlabel=""]
        }
    }
    // systems
    subgraph cluster_systems {
        bgcolor=green color=black concentrate=true fontsize=8 label=Systems newrank=true rank=same splines=ortho
        // computing
        subgraph cluster_computing {
            bgcolor=green color=black concentrate=true fontsize=8 label=Computing newrank=true rank=same splines=ortho
            "ex-uni" [label="ex-uni" color=black fillcolor=cadetblue fixedsize=true shape=rectangle style=filled width=1.3 xlabel=""]
        }
        // sensors
        subgraph cluster_sensors {
            bgcolor=green color=black concentrate=true fontsize=8 label=Sensors newrank=true rank=same splines=ortho
            watson [label=watson color=black fillcolor=blue fixedsize=true shape=rectangle style=filled width=1.3 xlabel=""]
        }
        // storage
        subgraph cluster_storage {
            bgcolor=green color=black concentrate=true fontsize=8 label=Storages newrank=true rank=same splines=ortho
            lake [label=lake color=black fillcolor=deepskyblue2 fixedsize=true shape=rectangle style=filled width=1.3 xlabel=""]
        }
    }
    // network
    subgraph cluster_network {
        bgcolor=green color=black concentrate=true fontsize=8 label=Network newrank=true rank=same splines=ortho
        // switch
        subgraph cluster_switch {
            bgcolor=green color=black concentrate=true fontsize=8 label=Switch newrank=true rank=same splines=ortho
            switch_1 [label=switch_1 color=black fillcolor=gold fixedsize=true shape=rectangle style=filled width=1.3 xlabel=""]
        }
    }
    // artifacts
    subgraph cluster_artifacts {
        bgcolor=green color=black concentrate=true fontsize=8 label=Artifacts newrank=true rank=same splines=ortho
        switch_2 [label=switch_2 color=black fillcolor=white fixedsize=true shape=rectangle style=filled width=1.3 xlabel=""]
    }
}

【问题讨论】:

  • 你愿意分享 .gv 文件吗?
  • @sroush 已添加点文件内容。

标签: graphviz subgraph


【解决方案1】:

我还没有找到一种简单的方法来轻松移动集群。这是一个可以做你想做的事情(我认为)并且不需要过多摆弄源代码的kludge:

  1. 用 /* ... */ 注释掉所有边缘(边缘导致不对齐)
  2. 在末尾添加这些行(以产生所需的对齐方式):
switch_1 -> switch_2  -> watson [style=invis]  
watson -> {azure_1 tsX}         [style=invis]
  1. 使用 -Tdot 运行 dot 作为输出文件格式
  2. 编辑输出文件并重新插入您注释掉的边
  3. 使用 -n 选项运行neato 以固定节点和集群并添加边

neato -n -Tpng mylile.dot >myfile.png

捐赠:

【讨论】:

  • 感谢您的努力。我正在寻求一个通用解决方案,因为它需要使用更多节点。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-10-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多