How do I get graphviz to generate fixed sized subgraphs?

自作多情 提交于 2019-12-05 01:36:08
Assaf Mendelson

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!