Reputation: 1069
I have the following graph on graphviz:
How do I make graphviz repeat the nodes in the graph so I can get a tree-like image like this:
Upvotes: 3
Views: 1783
Reputation: 60868
I don't think that you can make this modification of the graph within graphviz. You should feed graphviz a different graph, with the structure you desire. That graph can be obtained by a process like the following (pseudocode):
function visit(path: a list of nodes):
let n be the last node on the path
for every child c of n:
write (a copy of) c to output
if c is not in path:
visit(path + [c])
write root to output
visit([root])
Instead of this list path
you can also mark nodes as visited
before the recursive call and remove that flag after the call:
function visit(n: a node):
mark n as visited
for every child c of n:
write (a copy of) c to output
if c is not marked as visited:
visit(c)
mark n as not visited
write root to output
visit(root)
Upvotes: 1