aryagraph.io.dot.from_dot#

aryagraph.io.dot.from_dot(text: str, *, dag: bool = False) → Graph[source]#

Parse DOT text into a Graph (graph) or DiGraph (digraph).

With dag, a digraph is returned as a DAG (raising CycleError on a cycle). Syntax errors raise DotSyntaxError (a ValueError) with the line and column.

>>> g = from_dot('digraph { a -> {b c} [color=red]; b -> c }')
>>> sorted(g.edges)
[('a', 'b'), ('a', 'c'), ('b', 'c')]