In [1]:
%cd -q ..

import graphviz

graphviz.__version__, graphviz.version()
Out[1]:
('0.19', (2, 49, 3))
In [2]:
def make_graph(node_label=None, graph_name=None, **node_kwargs):
    result = graphviz.Digraph(name=graph_name)
    result.node('A', label=node_label, **node_kwargs)
    print(result)
    return result
In [3]:
make_graph(node_label='"')
digraph {
	A [label="\""]
}

Out[3]:
A "
In [4]:
make_graph(node_label='\\"')
digraph {
	A [label="\""]
}

Out[4]:
A "
In [5]:
make_graph(node_label=r'\\')
digraph {
	A [label="\\"]
}

Out[5]:
A \
In [6]:
make_graph(node_label=r'\\"')
digraph {
	A [label="\\\""]
}

Out[6]:
A \"
In [7]:
make_graph(node_label=r'node: \N')
digraph {
	A [label="node: \N"]
}

Out[7]:
A node: A
In [8]:
make_graph(node_label=r'graph: \G', graph_name='spam')
digraph spam {
	A [label="graph: \G"]
}

Out[8]:
spam A graph: spam
In [9]:
make_graph(node_label='spam', URL=r'https://example.org/\L')
digraph {
	A [label=spam URL="https://example.org/\L"]
}

Out[9]:
In [10]:
make_graph(node_label=r'centered\nleft\lright\r')
digraph {
	A [label="centered\nleft\lright\r"]
}

Out[10]:
A centered left right