Search code examples
graphviz

How to draw an empty cluster in graphviz?


I have the following dot file which is programmatically generated:

digraph{
  a
  subgraph b {
    label="My label"
    cluster=true
  }
}

Since there is no node in the subgraph the cluster is not drawn at all. Of course I could simply use a regular node with the attribute "shape=rect" but that would make the generating code more complex. So, is there a way to display an empty cluster / subgraph (just the box and the label)?


Solution

  • Sorry, there seems to be no way to have a nodeless cluster. From the dot point-of-view, there are two problems:

    • what size should it be?
    • where should it be located? (if there are many of these empty clusters, this gets very confusing)

    Maybe your program could count the nodes in each cluster and add an invisible "bogus" node if the count was zero, but positioning the empty clusters might still be odd.