5

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.

2 Answers 2

5

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.

1
  • That's what I feared. And my script ended up being changed like you mentioned. Feb 6, 2012 at 18:10
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.