molfoundry.DGPrinter#

class molfoundry.DGPrinter#

Configures how a derivation graph is rendered by DG.print(): which vertices and hyperedges are visible, their captions/labels and colors, and how hyperedges and their rules are labeled.

property graphPrinter: GraphPrinter#

The graph printer used for the molecule depictions embedded in the derivation graph. Returns a live handle, so configure it directly, e.g. dgPrinter.graphPrinter.drawStyle = DrawStyle.xkcd for the hand-drawn style.

property withShortcutEdges: bool#

Whether a single-source/single-target hyperedge is drawn as a plain arrow rather than through a rectangle junction (default True).

property withShortcutEdgesAfterVisibility: bool#

Whether the shortcut test counts only the visible connectors (True) or the full hyperedge (False, the default).

property withGraphName: bool#

Whether a vertex caption includes its graph’s name (default True).

property withRuleId: bool#

Whether a hyperedge label includes its rules’ ids (default True).

property withRuleName: bool#

Whether a hyperedge label includes its rules’ names (default False).

property layout: Layout#

Layout.Stress (SMACOF / neato-like force layout, the default) or Layout.Dot (a layered / hierarchical layout that ranks educts above their products, like Graphviz dot).

Type:

Which layout positions the derivation graph

property layoutRankDir: str#

'TB' (top→bottom, the default), 'BT', 'LR' (left→right), or 'RL'. Ignored by the 'stress' layout.

Type:

Flow direction for the 'dot' layout

property vertexLabelSep: str#

The separator joining a vertex caption’s pieces (default ', ').

property edgeLabelSep: str#

The separator joining a hyperedge label’s pieces (default ', ').

pushVertexColor(f, extendToEdges=True)#

Push a vertex color function. A vertex’s color is the first non-empty result, trying the most recently pushed function first. When extendToEdges is set (the default), a single-source/single-target edge whose endpoints share a color inherits it (below an explicit edge color).

Parameters:
Return type:

None

popVertexColor()#

Pop the most recently pushed vertex color function.

Return type:

None

pushVertexVisible(f)#

Push a vertex visibility predicate. A vertex is drawn only if every pushed predicate accepts it (and hyperedges then keep only their visible connectors).

Parameters:

f (Callable[[DG.Vertex], bool])

Return type:

None

popVertexVisible()#

Pop the most recently pushed vertex visibility predicate.

Return type:

None

pushVertexLabel(f)#

Push a vertex label function; its result is appended to the caption.

Parameters:

f (Callable[[DG.Vertex], str])

Return type:

None

popVertexLabel()#

Pop the most recently pushed vertex label function.

Return type:

None

pushEdgeColor(f)#

Push a hyperedge color function. An edge’s color is the first non-empty result (most recently pushed first); it takes precedence over a color inherited from same-colored endpoints.

Parameters:

f (Callable[[DG.HyperEdge], str])

Return type:

None

popEdgeColor()#

Pop the most recently pushed hyperedge color function.

Return type:

None

pushEdgeVisible(f)#

Push a hyperedge visibility predicate. An edge is drawn only if every pushed predicate accepts it.

Parameters:

f (Callable[[DG.HyperEdge], bool])

Return type:

None

popEdgeVisible()#

Pop the most recently pushed hyperedge visibility predicate.

Return type:

None

pushEdgeLabel(f)#

Push a hyperedge label function; its result is appended to the label.

Parameters:

f (Callable[[DG.HyperEdge], str])

Return type:

None

popEdgeLabel()#

Pop the most recently pushed hyperedge label function.

Return type:

None