emicklei / dot

Go package for writing descriptions using the Graphviz DOT and Mermaid language
MIT License
282 stars 19 forks source link

Using label as ID #16

Closed saantiaguilera closed 4 years ago

saantiaguilera commented 4 years ago

In DOT language, the ID is something apart from the label attribute. You are indexing the map by labels instead of by IDs.

This makes us unable to create subgraphs with a same label (but different IDs).

Solution

Probably you should be indexing your g.subgraphs by g.ID instead of g.Attr("label")

emicklei commented 4 years ago

thank you for reporting this. I will have a look at the changes for this, hopefully it does not require a breaking one.

saantiaguilera commented 4 years ago

No worries. As a temporary fix I'm doing:

s := graph.Subgraph(somethingUnique, dot.ClusterOption{})
s.Attr("label", "The same label I want for more subgraphs")

This way your map uses somethingUnique for indexing the subgraphs but the DOT label used is "The same label I want for more subgraphs"

emicklei commented 4 years ago

The module has been updated with the fix, please use v0.10.2