API reference

andrey.viz.to_graphviz#

andrey.viz.to_graphviz(structure, options=None)[source]#

Return structure as a Graphviz graph.

Parameters:
  • structure (GraphStructure) – Any kind. Node k is named "k" and carries its label as label; each edge keeps its endpoint marks as Graphviz arrow shapes: normal for an arrowhead, odot for a circle, none for a tail.

  • options (Mapping[str, object] | None) – Graphviz graph attributes, such as {"rankdir": "TB", "nodesep": 0.5}. Causes run left to right (rankdir="LR") unless options says otherwise.

Returns:

A directed graph. A directed edge runs from tail to arrowhead; an undirected edge has dir="none"; any other edge has dir="both", with arrowhead and arrowtail set from its marks; a digraph 2-cycle becomes two directed edges. Render or lay it out with pygraphviz, or pass it to any Graphviz tool through to_string().

Return type:

AGraph

Raises:

ImportError – If pygraphviz is not installed.