I am writing a visualisation with graphviz in python. I imported graphviz and pylab. I figured out how to save the graphic representation
import graphviz as gv
import pylab
g1 = gv.Graph(format='png')
g1.node('A')
g1.node('B')
g1.edge('A', 'B')
g1.view()
print(g1.source)
filename = g1.render(filename='img/g1')
pylab.savefig('filename.png')
How can i save the source to a .dot file?