3.1.14. Rule

3.1.14.1. Class Rule

class mod.Rule

Model of a transformation rule in the Double Pushout formalism.

id

(Read-only) The unique instance id among all Rule instances.

Type:unsigned int
numVertices

(Read-only) The number of vertices in the rule.

Type:int
vertices

(Read-only) An iterable of all vertices in the rule.

Type:RuleVertexRange
numEdges

(Read-only) The number of edges in the rule.

Type:int
edges

(Read-only) An iterable of all edges in the rule.

Type:RuleEdgeRange
left

(Read-only) A proxy object representing the left graph of the rule.

Type:RuleLeftGraph
context

(Read-only) A proxy object representing the context graph of the rule.

Type:RuleContextGraph
right

(Read-only) A proxy object representing the right graph of the rule.

Type:RuleRightGraph
makeInverse()
Returns:a rule representing the inversion of this rule.
Return type:Rule
Raises:InputError if inversion is not possible (due to matching constraints).
print()
print(first, second=None)

Print the rule, using either the default options or the options in first and second. If first and second are the same, only one depiction will be made.

Parameters:
  • first (GraphPrinter) – the printing options used for the first depiction.
  • second (GraphPrinter) – the printing options used for the second depiction. If it is None then it is set to first.
Returns:

a pair of filename prefixes for the PDF-files that will be compiled in post-processing. The actual names can be obtained by appending _L.pdf, _K.pdf, and _R.pdf for respectively the left side, context, and right side graphs. If first and second are the same, the two file prefixes are equal.

Return type:

(string, string)

getGMLString(withCoords=False)
Returns:the GML representation of the rule, optionally with generated 2D coordinates.
Return type:string
Raises:LogicError when coordinates are requested, but none can be generated.
printGML(withCoords=False)

Print the rule in GML format, optionally with generated 2D coordinates.

Returns:the filename of the printed GML file.
Return type:string
Raises:LogicError when coordinates are requested, but none can be generated.
name

The name of the rule. The default name includes the unique instance id.

Type:string
numLeftComponents

(Read-only) The number of connected components of the left graph.

Type:std::size_t
numRightComponents

(Read-only) The number of connected components of the right graph.

Type:std::size_t
isomorphism(other, maxNumMatches=1)
Parameters:
  • other (Rule) – the other Rule for comparison.
  • maxNumMatches (std::size_t) – the maximum number of isomorphisms to search for.
Returns:

the number of isomorphisms found between other and this rule, but at most maxNumMatches.

Return type:

std::size_t

monomorphism(host, maxNumMatches=1)
Parameters:
  • host (Rule) – the host Rule to check for subgraphs.
  • maxNumMatches (std::size_t) – the maximum number of morphisms to search for.
Returns:

the number of monomorphisms from this rule to subgraphs of host, though at most maxNumMatches.

Return type:

std::size_t

mod.ruleGMLString(s, invert=False)

Load a rule from a GML string, and store either that rule or its inverse. The name of the rule is the one specified in the GML string, though when invert=True the string ”, inverse” is appended to the name.

Note

If the GML string specifies matching constraints it is not possible to invert the rule. There is however a configuration option to ignore matching constraints when inverting rules.

Parameters:
  • s (string) – the GML string to load a rule from.
  • invert (bool) – whether or not to invert the loaded rule.
Returns:

the rule in the GML string, possibly inverted.

Return type:

Rule

mod.ruleGML(s, invert=False)

Read file and pass the contents to ruleGMLString().

Parameters:
  • s (string) – name of the GML file to be loaded.
  • invert (bool) – whether or not to invert the loaded rule.
Returns:

the rule in the GML file, possibly inverted.

Return type:

Rule