Export to DOT

Any anytree graph can be converted to a graphviz graph.

This tree:

>>> from anytree import Node
>>> root = Node("root")
>>> s0 = Node("sub0", parent=root)
>>> s0b = Node("sub0B", parent=s0)
>>> s0a = Node("sub0A", parent=s0)
>>> s1 = Node("sub1", parent=root)
>>> s1a = Node("sub1A", parent=s1)
>>> s1b = Node("sub1B", parent=s1)
>>> s1c = Node("sub1C", parent=s1)
>>> s1ca = Node("sub1Ca", parent=s1c)

Can be rendered to a tree by RenderTreeGraph:

>>> from anytree.dotexport import RenderTreeGraph
>>> RenderTreeGraph(root).to_picture("tree.png")
_images/tree.png
class anytree.dotexport.RenderTreeGraph(*args, **kwargs)[source]

Bases: anytree.exporter.dotexporter.DotExporter

Legacy. Use anytree.exporter.DotExporter instead.

static esc(str)

Escape Strings.

to_dotfile(filename)

Write graph to filename.

>>> from anytree import Node
>>> root = Node("root")
>>> s0 = Node("sub0", parent=root)
>>> s0b = Node("sub0B", parent=s0)
>>> s0a = Node("sub0A", parent=s0)
>>> s1 = Node("sub1", parent=root)
>>> s1a = Node("sub1A", parent=s1)
>>> s1b = Node("sub1B", parent=s1)
>>> s1c = Node("sub1C", parent=s1)
>>> s1ca = Node("sub1Ca", parent=s1c)
>>> from anytree.exporter import DotExporter
>>> DotExporter(root).to_dotfile("tree.dot")

The generated file should be handed over to the dot tool from the http://www.graphviz.org/ package:

$ dot tree.dot -T png -o tree.png
to_picture(filename)

Write graph to a temporary file and invoke dot.

The output file type is automatically detected from the file suffix.

`graphviz` needs to be installed, before usage of this method.