问题描述
我已经为此苦苦挣扎了一段时间,似乎找不到一个直接的答案.我正在graphviz中处理复合子图,似乎无法找到正确的设置组合来强制两个子图彼此对齐.
附上一个简单的例子来说明问题...
digraph g {
compound=true;
subgraph cluster_top {
graph [color=black, label="Top", rank=min];
nodeA; nodeB; nodeC
cluster_top_DUMMY [shape=point style=invis]
}
subgraph cluster_service {
graph [color=black, label="Bottom", rank=min];
node1; node2; node3; node4; node5; extra_long_node
cluster_bottom_DUMMY [shape=point style=invis]
}
cluster_top_DUMMY -> cluster_bottom_DUMMY [ style=invis ]
}
这将生成输出,其中Bottom子图比Top子图宽得多.
我真正想要的是确保顶部和底部始终保持完全相同的宽度.另外,如果有太多的节点无法容纳可用的宽度,则会生成更多的节点行.
一种可行的(坏的但可行的)解决方案是使用不可见的节点并设置宽度.请考虑以下内容:
digraph g {
compound=true;
subgraph cluster_top {
graph [color=black, label="Top", rank=min];
nodeAI0 [style=invisible]
nodeAI1 [style=invisible]
nodeAI2 [style=invisible,fixedsize=true,width=1.65]
nodeA; nodeB; nodeC
cluster_top_DUMMY [shape=point style=invis]
}
subgraph cluster_service {
graph [color=black, label="Bottom", rank=min];
node1; node2; node3; node4; node5; extra_long_node
cluster_bottom_DUMMY [shape=point style=invis]
}
cluster_top_DUMMY -> cluster_bottom_DUMMY [ style=invis ]
}
不可见节点(NodeAI0-NodeAI2)占据空间. fixedsize = true,width = 1.65使得最后一个尺寸恰好为1.65英寸.
另一个更好的解决方案是通过添加类似以下内容来专门设置相关的较长节点(以避免寻找正确的值):
node [fixedsize=true,width=0.75]
compound = true部分之后.
I've been struggling with this for a while and cannot seem to find a straight answer. I'm working with compound subgraphs in graphviz and cannot seem to find the right combination of settings to force two subgraphs to align with each other.
Enclosed is a simple example to show the problem...
digraph g {
compound=true;
subgraph cluster_top {
graph [color=black, label="Top", rank=min];
nodeA; nodeB; nodeC
cluster_top_DUMMY [shape=point style=invis]
}
subgraph cluster_service {
graph [color=black, label="Bottom", rank=min];
node1; node2; node3; node4; node5; extra_long_node
cluster_bottom_DUMMY [shape=point style=invis]
}
cluster_top_DUMMY -> cluster_bottom_DUMMY [ style=invis ]
}
This generates output with the Bottom subgraph significantly wider than the Top subgraph.
What I really want is for to ensure that both Top and Bottom are always exactly the same width. In addition, if there are too many nodes to fit into the available width, it would generate additional rows of nodes.
A possible (bad but working) solution would be to use invisible nodes and set width.Consider the following:
digraph g {
compound=true;
subgraph cluster_top {
graph [color=black, label="Top", rank=min];
nodeAI0 [style=invisible]
nodeAI1 [style=invisible]
nodeAI2 [style=invisible,fixedsize=true,width=1.65]
nodeA; nodeB; nodeC
cluster_top_DUMMY [shape=point style=invis]
}
subgraph cluster_service {
graph [color=black, label="Bottom", rank=min];
node1; node2; node3; node4; node5; extra_long_node
cluster_bottom_DUMMY [shape=point style=invis]
}
cluster_top_DUMMY -> cluster_bottom_DUMMY [ style=invis ]
}
The invisible nodes (NodeAI0-NodeAI2) take the space. fixedsize=true,width=1.65 makes the last one take exactly 1.65 inches.
Another, better solution would be to also set the relevant longer node specifically (to avoid having to look for the correct value) by adding something like:
node [fixedsize=true,width=0.75]
after the compound=true portion.
这篇关于如何获取graphviz生成固定大小的子图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!