自上而下的子图,左右内部子图
我想让我的图表看起来像这样:
但我只能得到这个:
问题是,rankdir
在子图
中不起作用。
那么,如何模仿呢?
代码:
digraph G {
node [shape = circle]
0 [style = invis]
0 -> "0A"
subgraph clusterA {
label=A
"0A"
"1A"
"2A" -> "0A" [label=•]
}
subgraph clusterB {
label=B
"0B"
"1B"
"2B" -> "0B" [label=•]
}
subgraph clusterC {
label=C
"0C"
"1C"
"2C" -> "0C" [label=•]
}
subgraph clusterD {
label=D
"0D"
"1D"
"2D" -> "0D" [label=•]
}
subgraph clusterE {
label=E
"0E"
"1E"
"2E" -> "0E" [label=•]
}
subgraph clusterF {
label=F
{node [shape = doublecircle] "0F" "1F"}
"2F" -> "0F" [label=•]
}
"0A" -> "1B" [label=a]
"1A" -> "2B" [label=a]
"0B" -> "1C" [label=b]
"1B" -> "2C" [label=b]
"0C" -> "1D" [label=c]
"1C" -> "2D" [label=c]
"0D" -> "1E" [label=d]
"1D" -> "2E" [label=d]
"0E" -> "1F" [label=e]
"1E" -> "2F" [label=e]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
复制特定的图形布局通常可以通过以下方式实现:
以下是我复制图形的方法 - 或至少是它的一部分:
这个解决方案不是很直观。要实现这一点,需要注意以下几点:
rankdir="LR"
,它的边缘比TB
更好,尽管它与图形的方向并不真正对应结果是:
Reproducing particular graph layouts usually can be achieved with:
Here's how I reproduced your graph - or at least a part of it:
This solution is not very intuitive. A couple of points to achieve this:
rankdir="LR"
which resulted in nicer edges thanTB
, though it does not really correspond with the direction of the graphThe result is:
看起来rank=same可能是一个更干净的解决方案。查看在 Graphviz 中将集群置于相同等级 。
您还可以使用“constraint=false”和不可见边来仔细控制节点等级。这与上面的答案基本相同。
It looks like rank=same might be a cleaner solution. Take a look at Placing clusters on the same rank in Graphviz.
You can also use 'constraint=false' and invisible edges to carefully control node rank. This is basically the same answer as the above.
使用
group
更新@marapet的答案An update on @marapet's answer using
group
使用constraint = false应该让子图中的节点变成你想要的方式
http://www.graphviz.org/doc/info/attrs.html #d:constraint
之后,您会发现您的子图没有按照您想要的方式彼此对齐。像这样的事情可以解决这个问题。
Using constraint=false should get the nodes in your subgraphs to turn out the way you want
http://www.graphviz.org/doc/info/attrs.html#d:constraint
After that you'll find that your subgraphs don't line up with each other the way you want. Something like this could resolve that.
rankdir 不能直接在子图中工作,但是如果您添加另一组大括号(无论它叫什么),rankdir 就可以工作。见下文。然后,显然您需要更多技巧来恢复您所追求的对齐和排序。
rankdir doesn't work directly in the subgraph, but if you add another set of curly braces - whatever that's called - rankdir works. See below. Then, obviously you need more tricks to restore the alignment and ordering you're after.