简体   繁体   English

在DOT图中,如何移动群集并防止线不必要地交叉?

[英]In DOT graph, how to move cluster and prevent lines crossing needlessly?

I'm using Graphviz to generate this diagram: 我正在使用Graphviz生成此图: 我得到什么

The output is not optimal. 输出不是最佳的。 An XZ line needlessly crosses an XY line; XZ线不必要地与XY线交叉; I would expect Y to be above X. I've tried many options from the doco but to no avail. 我希望Y高于X。我尝试了doco的许多选项,但无济于事。 This is the kind of output I am expecting: 我期望的是这种输出: 我想要的是

How can I get Graphviz to produce better optimised diagrams? 如何获得Graphviz以生成更好的优化图?

NOTE: I'd like to automate the generation of similar diagrams so solutions specific to the scenario above (eg. invisible edges from X0 -> Y1, Y11 -> X03 or whatnot) wont help. 注意:我想自动生成类似的图表,因此上述方案的特定解决方案(例如,X0-> Y1,Y11-> X03或其他什么都不可见的边)将无济于事。 I'm looking for a way to be able to generically trust things like: 我正在寻找一种能够普遍信任以下内容的方法:

  • AXB will be a straight line. AXB将是一条直线。
  • Y will be above AXB if it doesn't interact with Z. 如果不与Z交互,则Y将高于AXB。
  • X->Y->X wont needlessly cause large gaps between X nodes. X-> Y-> X不会不必要地在X节点之间造成较大的间隙。

The dot file content is: 点文件的内容为:

digraph G {
  rankdir=LR

  subgraph cluster_x {
    node [style=filled,color=green]
    "X.0" -> "X.0.1" -> "X.0.2" -> "X.0.3" -> "X.0.4"
  }

  subgraph cluster_y {
    node [style=filled,color=lightblue]
    "Y.1" -> "Y.1.1"
  }

  subgraph cluster_z {
    node [style=filled,color=crimson]
    "Z.1" -> "Z.1.1"
    "Z.2"
  }

  A -> "X.0"
  "X.0.1" -> "Y.1"
  "X.0.1" -> "Z.2"
  "X.0.2" -> "Z.1"
  "Y.1.1" -> "X.0.2"
  "Z.1.1" -> "X.0.4"
  "Z.2" -> "Z.1.1"
  "X.0.4" -> B
}

It's nontrivial. 这是不平凡的。 We are open to volunteers to help with layout algorithms. 我们向志愿者开放,以帮助他们设计布局算法。 Emden Gansner and I made a big start on a complete overhaul of dot (with cleaner data structures for subgraphs and long edges, and use sifting for mincross) but we didn't finish. Emden Gansner和我在点的全面检修方面取得了重大进展(对子图和长边使用了更整洁的数据结构,并对mincross使用了筛选),但我们没有完成。 We wrote new level assignment cpde that I think Emden back-hacked into the old dot layout engine. 我们写了新的关卡分配cpde,我认为Emden可以将其破解到旧的点布局引擎中。 it is probably a few months of effort if someone wants to pick it up and take it further. 如果有人想拿起它并进一步走下去,可能要花费几个月的时间。 Contact us at graphviz.org 通过graphviz.org与我们联系

In general constraint machines (like dot) can be a little brittle. 通常,约束机器(例如点)可能会有些脆弱。 Either they get the right solution on their own, or maybe you can add a few tweaks but as soon as the input changes even a little, the tweaks break everything and it's no good. 他们要么自己获得了正确的解决方案,要么您可以添加一些调整,但是只要输入内容稍有变化,这些调整就破坏了一切,而且没有好处。 Because of the serial nature of the layout passes, it is hard for example to favor a different level assignment in order to reduce crossings later. 由于布局遍历的连续性质,例如很难支持不同的层分配以减少以后的穿越。 There might be some work in the Graph Drawing conference if someone wants to look it up and implement it. 如果有人想查找并实现它,则在Graph Drawing会议中可能会有一些工作。

Stephen North 史蒂芬·诺斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM