gvgen
gvgen copied to clipboard
Nested subgraphs are not nesting correctly.
I think there's a problem with subgraph creation.
A single nested set of graphs will create the expected graph, but multiple sets of nested structures do not seem to generate the correct dot.
Example of working, single nest:
from gvgen import *
graph = GvGen()
# Everything in our graph should be within this
mainContainer = graph.newItem("Main Container")
# a2 nests under a1 which nests under mainContainer
a1 = graph.newItem("a1", mainContainer)
a2 = graph.newItem("a2", a1)
a3 = graph.newItem("a3", a2)
with open("testout.dot", 'w') as f:
graph.dot(f)
Results in:
However, an attempt to add a second set of nested objects results in unexpected results:
from gvgen import *
graph = GvGen()
# Everything in our graph should be within this
mainContainer = graph.newItem("Main Container")
# a2 nests under a1 which nests under mainContainer
a1 = graph.newItem("a1", mainContainer)
a2 = graph.newItem("a2", a1)
a3 = graph.newItem("a3", a2)
b1 = graph.newItem("b1", mainContainer)
b2 = graph.newItem("b2", b1)
b3 = graph.newItem("b3", b2)
with open("testout.dot", 'w') as f:
graph.dot(f)
Results in:
Which is not correct, the expected output should look closer to:
Looking at https://github.com/stricaud/gvgen/issues/9 it looks like this issue arose previously, and @stricaud attempted to address.
The problem lies in the browse
and tree
functions.
I wrote an alternative implementation here - it doesn't include styling or smartlinks but does do the nested rendering correctly - hope it helps!
Demo script showing the issue: https://gist.github.com/hyakuhei/33f48cf48cc15062631634433ac7454b
Thanks, this is indeed an issue. I have no time to fix it right now but will be on this ASAP.
If you want to work on fixing this and publish a pull request, I would be more than happy to merge it! If not, still need to wait a little.
I decided to implement my own dot-generator instead of looking to fix this in GvGen. It doesn't manage styling the same way but handles drawing, nesting and implements a similar idea to the smartLinks feature you have in GvGen.
The Dot class in util.py contains all the functionality