3.1.4. DG¶
3.1.4.1. Class DG
¶

class
mod.
DG
¶ The main derivation graph class. A derivation graph is a directed hypergraph \(H = (V, E)\). Each vertex is annotated with a graph, and each hyperedge is annotated with a transformation rule. A derivation graph can either be calculated from a strategy or loaded from external data.

numVertices
¶ (Readonly) The number of vertices in the derivation graph.
Type: int

vertices
¶ (Readonly) An iterable of all vertices in the derivation graph.
Type: DGVertexRange

numEdges
¶ (Readonly) The number of hyperedges in the derivation graph.
Type: int

edges
¶ (Readonly) An iterable of all hyperedges in the derivation graph.
Type: DGEdgeRange

findVertex
(g)¶ Parameters: g ( Graph
) – the graph to find a vertex which has it associated.Returns: a vertex descriptor for which the given graph is associated, or a null descriptor if no such vertex exists. Return type: DGVertex

findEdge
(sources, targets)¶ 
findEdge
(sourceGraphs, targetGraphs) Parameters:  sources (list of
Vertex
) – the list of source vertices the resulting hyperedge must have.  targets (list of
Vertex
) – the list of targets vertices the resulting hyperedge must have.  sourceGraphs (list of
Graph
) – the list of graphs that must be associated with the source vertices the resulting hyperedge must have.  targetGraphs (list of
Graph
) – the list of graphs that must be associated with the targets vertices the resulting hyperedge must have.
Returns: a hyperedge with the given sources and targets. If no such hyperedge exists in the derivation graph then a null edge is returned. In the second version, the graphs are put through
findVertex()
first.Raises: LogicError
if a vertex descriptor is null, or does not belong to the derivation graph. sources (list of

calc
()¶ Create the actual derivation graph.

products
¶ The subset of the vertex graphs which were discovered by the calculation.
Type: list of Graph

print
(printer=DGPrinter(), data=None)¶ Print the derivation graph in style of a hypergraph. The appearance and structure of the visualisation can optionally be configured by giving a DG printer and/or data object.
Parameters:  printer (
DGPrinter
) – the printer to use governing the appearance.  data (
DGPrintData
) – the extra data to use encoding the structure of the graph.
 printer (

dump
()¶ Export the derivation graph to an external file. The vertex graphs are exported as well.
Returns: the filename of the exported derivation graph. Return type: string

list
()¶ List information about the calculation.

listStats
()¶ Lists various statistics for the derivation graph.


mod.
dgDerivations
(ders)¶ Parameters: ders (list of Derivation
) – the list of derivations to include in the derivation graph.Returns: a derivation graph from a list of Derivation
.Return type: DG

mod.
dgAbstract
(s)¶ Parameters: s (string) – the abstract specification of a derivation graph. Returns: Construct a derivation graph from an abstract set of derivations. See DG::abstract()
for the specification format.Return type: DG

mod.
dgRuleComp
(graphs, strat)¶ Initialize a derivation graph defined by a strategy.
Parameters: Returns: the derivation graph object. The calculation method must be called to create the actual derivation graph.
Return type:

mod.
dgDump
(graphs, rules, file)¶ Load a derivation graph dump.
Parameters: Returns: the loaded derivation graph.
Return type:

mod.
diffDGs
(dg1, dg2)¶ Compare two derivation graphs and lists the difference. This is not a general isomorphism check; two vertices are equal if they have the same graph attached. Edges are equal if the head and tail sets are equal and if the attached rule is the same.
Parameters:
3.1.4.2. Class DerivationRef
¶

class
mod.
DerivationRef
¶ A reference to a derivation in a specific derivation graph, or an invalid reference.

id
¶ (Readonly) If the reference is valid, this is the id of the pointed to derivation.
Type: unsigned int

dg
¶ (Readonly) If the reference is valid, this is the derivation graph the reference points into.
Type: DG

isValid
()¶ Returns: whether or not the reference is valid. Return type: bool

derivation
¶ (Readonly) If the reference is valid, this is the pointed to derivation.
Type: Derivation

print
(printer=GraphPrinter(), matchColour="ForestGreen")¶ Print the derivation pointed to by the derivation reference. All possible DoublePushout diagrams for the derivation are printed.
Parameters:  printer (
GraphPrinter
) – the printer to use for the figures.  matchColour (string) – the TikZ colour to use for the rule and its image in the bottom span.
 printer (
