aryagraph.io.dot.to_dot#

aryagraph.io.dot.to_dot(g: Graph, *, name: str | None = None, node_attrs: bool | Iterable[str] = True, edge_attrs: bool | Iterable[str] = True, rankdir: str | None = None) → str[source]#

DOT text for g.

Parameters:
  • name – Graph ID (defaults to g.name).

  • node_attrs, edge_attrs – Write all attributes, none, or the named ones. Numbers are written as DOT numerals, booleans as true/false, sequences of numbers as "x,y" (Graphviz’s point syntax) and other containers as JSON.

  • rankdir – Graphviz layout direction ("TB", "LR", …), written as a graph attribute.

Notes

Nodes with a cluster attribute are grouped into subgraph cluster_… blocks (with the attributes in g.attrs["clusters"]), which is exactly what from_dot() produces, so clusters round-trip. Scalar graph attributes are written in a graph [...] statement.

Examples

>>> print(to_dot(DiGraph([("a", "b b")])), end="")
digraph {
  a;
  "b b";
  a -> "b b";
}