# 3.1.7.3. dg/Printer¶

## 3.1.7.3.1. Class DGPrintData¶

class mod.DGPrintData

This class is used to hold extra data about how a specific derivation graph is visualised.

__init__(self, dg)
Parameters: dg (DG) – the derivation graph to hold data for.
dg

(Read-only) The derivation graph the object holds data for.

makeDuplicate(e, eDup)

Create another version of the given derivation and give it the given duplicate number.

Parameters: e (DGHyperEdge) – a reference to the derivation to duplicate. eDup (unsigned int) – the duplicate number for the new version of the derivation.
removeDuplicate(e, eDup)

Remove the version of the given derivation with the given duplicate number.

Parameters: e (DGHyperEdge) – a reference to the derivation to duplicate. eDup (unsigned int) – the duplicate number for the version of the derivation to remove.
reconnectTail(e, eDup, g, vDupTar)

Reconnect an arbitrary version of the tail specified by the given graph in the derivation duplicate given.

Parameters: e (DGHyperEdge) – a reference to the derivation to reconnect. eDup (unsigned int) – the duplicate number of the derivation to reconnect. g (Graph) – a graph representing the tail vertex to reconnect. vDupTar (unsigned int) – the new duplicate number for the tail vertex.
reconnectHead(e, eDup, g, vDupTar)

Reconnect an arbitrary version of the head specified by the given graph in the derivation duplicate given.

Parameters: e (DGHyperEdge) – a reference to the derivation to reconnect. eDup (unsigned int) – the duplicate number of the derivation to reconnect. g (Graph) – a graph representing the head vertex to reconnect. vDupTar (unsigned int) – the new duplicate number for the tail vertex.

## 3.1.7.3.2. Class DGPrinter¶

class mod.DGPrinter

This class is used to configure how derivation graphs are visualised, how much is visualised and which extra properties are printed.

graphPrinter

(Read-only) Retrieve the GraphPrinter used when printing images of graphs.

Type: GraphPrinter
withShortcutEdges

Control whether or not hyperedges $$(T, H)$$ with $$|T| = |H| = 1$$ are printed as a simple arrow without the usual rectangle.

Type: bool
withGraphImages

Control whether or not each vertex is printed with a image of its graph in it.

Type: bool
labelsAsLatexMath

Control whether or not labels on vertices and hyperedges are put inline $$\LaTeX$$ math. Specifically, a label label is written as $\mathrm{label'}$, with label' being label with all space characters escaped.

Type: bool
pushVertexVisible(f)

Add another function controlling the visibility of vertices. All visibility functions must return true for a vertex to be visible.

Parameters: f (bool(Graph, DG)) – the function to push for specifying vertex visibility.
popVertexVisible()

Remove the last pushed vertex visibility function.

pushEdgeVisible(f)

Add another function controlling the visibility of hyperedges. All visibility functions must return true for a hyperedge to be visible.

Parameters: f (bool(DGHyperEdge)) – the function to push for specifying hyperedge visibility.
popEdgeVisible()

Remove the last pushed hyperedge visibility function.

withShortcutEdgesAfterVisibility

Control whether or not hyperedges are depicted as simple arrows when all but 1 head and tail are hidden.

Type: bool
vertexLabelSep

The string used as separator between each part of each vertex label.

Type: string
edgeLabelSep

The string used as separator between each part of each edge label.

Type: string
pushVertexLabel(f)

Add another function for vertex labelling. The result of this function is added to the end of each label.

Parameters: f (string(Graph, DG)) – the function to push for labelling vertices.
popVertexLabel()

Remove the last pushed vertex labelling function.

pushEdgeLabel(f)

Add another function for edge labelling. The result of this function is appended to each label.

Parameters: f (string(DGHyperEdge)) – the function to push for labelling edges.
popEdgeLabel()

Remove the last pushed edge labelling function.

withGraphName

Control whether or not graph names are appended to the vertex labels (see also DGPrinter.pushVertexLabel()).

Type: bool
withRuleName

Control whether or not rule names are appended to the edge labels (see also DGPrinter.pushEdgeLabel()).

Type: bool
withRuleId

Control whether or not rule IDs are appended to the edge labels (see also DGPrinter.pushEdgeLabel()).

Type: bool
withInlineGraphs

Control whether or not graph depictions should be precompiled, or be included inline in the DG figure.

Type: bool
pushVertexColour(f, extendToEdges=True)

Add another function for colouring vertices. The final colour of a vertex is the result of the first colour function returning a non-empty string. The functions are evaluated in the order they are pushed and the resulting string is used directly as a colour in Tikz. A hyperedge is also coloured if at least one head and one tail can be coloured with a colour for which extendToEdges is True. In this case, the hyperedge (and a subset of the head and tail connectors) is coloured with the first applicable colour. The edge extension of vertex colour takes lower precedence than explicitly added hyperedge colouring functions.

Parameters: f (string(Graph, DG)) – the function to push for colouring vertices. extendToEdges (bool) – whether or not some hyperedges are coloured as well (see above).
popVertexColour()

Remove the last pushed vertex colouring function.

pushEdgeColour(f)

Add another function for colouring hyperedges. The final colour of a hyperedge (and all of its head and tail connectors) is the result of the first colour function returning a non-empty string.

Parameters: f (string(DGHyperEdge)) – the function to push for colouring hyperedges.
popEdgeColour()

Remove the last pushed hyperedge colouring function.