Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In graphviz: can I have node ids that are unique within clusters only?

Tags:

graphviz

dot

I understand that node ids should be unique within a graphviz (here: dot) file.

However, I wish I could have them be unique within their cluster only, that is, I'd like the following file to produce 4 nodes:

digraph G {


  subgraph cluster_clust_one {
     node [shape=record];

     a [label = "A / 1"];
     b [label = "B / 1"];

     a -> b;
  }


  subgraph cluster_clust_two {
     node [shape=record];

     a [label = "A / 2"];
     b [label = "B / 2"];

     a -> b;
  }

}

However, it doesn't, because the node ids are not unique. Obviously, I can solve this by assigning unique ids, for example by changing cluster_clust_two to

  subgraph cluster_clust_two {
     node [shape=record];

     c [label = "A / 2"];
     d [label = "B / 2"];

     c -> d;
  }

Unfortunately, this would entail changing a script that produces the dot files which I wouldn't want to do if not absolutely necessary. So if there is a flag or something I could set instead, I'd prefer this route.

like image 742
René Nyffenegger Avatar asked Feb 06 '12 07:02

René Nyffenegger


Video Answer


2 Answers

You could prepend the node name with the name of the cluster like cluster_clust_two__a. It would still mean a change in the generating script.

like image 136
dgw Avatar answered Sep 19 '22 16:09

dgw


As far as I know, there is no way to have separate nodes with identical IDs. A sensible workaround was proposed by dgw =)

like image 22
Antoine Gersant Avatar answered Sep 22 '22 16:09

Antoine Gersant