I have a digital circuit simulator and need to draw a circuit diagram almost exactly like in this question (and answer) Block diagram layout with dot/graphviz
This is my first encounter with DOT and graphviz. Fortunately the DOT language specification is available and there are many examples as well.
However one detail is still unclear to me and I'm asking as a total newbie: I have a complete data to draw a graph. How do I create a DOT file from it?
As a text line by line?
# SIMPLIFIED PSEUDOCODE
dotlines = ["digraph CIRCUIT {"]
for node in all_nodes:
dotlines.append(" {}[{}];".format(node.name, node.data))
for edge in all_edges:
dotlines.append(" {} -> {};".format(edge.from_name, edge.to_name))
dotlines.append['}']
dot = "\n".join(dotlines)
Or should I convert my data somehow and use some module which exports it in the DOT format?