1# graphviz - create dot, save, render, view
2
3"""Assemble DOT source code and render it with Graphviz.
4
5Example:
6 >>> import graphviz # doctest: +NO_EXE
7 >>> dot = graphviz.Digraph(comment='The Round Table')
8
9 >>> dot.node('A', 'King Arthur')
10 >>> dot.node('B', 'Sir Bedevere the Wise')
11 >>> dot.node('L', 'Sir Lancelot the Brave')
12
13 >>> dot.edges(['AB', 'AL'])
14
15 >>> dot.edge('B', 'L', constraint='false')
16
17 >>> print(dot) #doctest: +NORMALIZE_WHITESPACE
18 // The Round Table
19 digraph {
20 A [label="King Arthur"]
21 B [label="Sir Bedevere the Wise"]
22 L [label="Sir Lancelot the Brave"]
23 A -> B
24 A -> L
25 B -> L [constraint=false]
26 }
27"""
28
29from ._defaults import set_default_engine, set_default_format, set_jupyter_format
30
31from .backend import (DOT_BINARY, UNFLATTEN_BINARY,
32 render, pipe, pipe_string, pipe_lines, pipe_lines_string,
33 unflatten, version, view)
34from .exceptions import (ExecutableNotFound, CalledProcessError,
35 RequiredArgumentError, FileExistsError,
36 UnknownSuffixWarning, FormatSuffixMismatchWarning,
37 DotSyntaxWarning)
38from .graphs import Graph, Digraph
39from .jupyter_integration import SUPPORTED_JUPYTER_FORMATS
40from .parameters import ENGINES, FORMATS, RENDERERS, FORMATTERS
41from .quoting import escape, nohtml
42from .sources import Source
43
44__all__ = ['ENGINES', 'FORMATS', 'RENDERERS', 'FORMATTERS',
45 'DOT_BINARY', 'UNFLATTEN_BINARY',
46 'SUPPORTED_JUPYTER_FORMATS',
47 'Graph', 'Digraph',
48 'Source',
49 'escape', 'nohtml',
50 'render', 'pipe', 'pipe_string', 'pipe_lines', 'pipe_lines_string',
51 'unflatten', 'version', 'view',
52 'ExecutableNotFound', 'CalledProcessError',
53 'RequiredArgumentError', 'FileExistsError',
54 'UnknownSuffixWarning', 'FormatSuffixMismatchWarning',
55 'DotSyntaxWarning',
56 'set_default_engine', 'set_default_format', 'set_jupyter_format']
57
58__title__ = 'graphviz'
59__version__ = '0.21.1.dev0'
60__author__ = 'Sebastian Bank <sebastian.bank@uni-leipzig.de>'
61__license__ = 'MIT, see LICENSE.txt'
62__copyright__ = 'Copyright (c) 2013-2025 Sebastian Bank'
63
64ENGINES = ENGINES
65""":class:`set` of known layout commands used for rendering
66(``'dot'``, ``'neato'``, ...)."""
67
68FORMATS = FORMATS
69""":class:`set` of known output formats for rendering
70(``'pdf'``, ``'png'``, ...)."""
71
72RENDERERS = RENDERERS
73""":class:`set` of known output renderers for rendering
74(``'cairo'``, ``'gd'``, ...)."""
75
76FORMATTERS = FORMATTERS
77""":class:`set` of known output formatters for rendering
78(``'cairo'``, ``'gd'``, ...)."""
79
80SUPPORTED_JUPYTER_FORMATS = SUPPORTED_JUPYTER_FORMATS
81""":class:`set` of supported formats for ``_repr_mimebundle_()``
82(``'svg'``, ``'png'``, ...)."""
83
84DOT_BINARY = DOT_BINARY
85""":class:`pathlib.Path` of rendering command (``Path('dot')``)."""
86
87UNFLATTEN_BINARY = UNFLATTEN_BINARY
88""":class:`pathlib.Path` of unflatten command (``Path('unflatten')``)."""
89
90
91ExecutableNotFound = ExecutableNotFound
92
93
94CalledProcessError = CalledProcessError
95
96
97RequiredArgumentError = RequiredArgumentError
98
99
100FileExistsError = FileExistsError
101
102
103UnknownSuffixWarning = UnknownSuffixWarning
104
105
106FormatSuffixMismatchWarning = FormatSuffixMismatchWarning
107
108
109DotSyntaxWarning = DotSyntaxWarning