4.1.12.4. rule/Rule¶
- class mod.Rule¶
- This class models a graph transformation rule in the Double Pushout formalism, as the span \(L \leftarrow K \rightarrow R\). The three graphs are referred to as respectively the “left”, “context”, and “right” graphs of the rule. See Graph, Rule, and Molecule Model for more details. - The class implements the - protocols.Graphprotocol, which gives access to a graph view of the rule which has the left, context, and right graphs combined into a single graph, called the core graph. In addition to the combined graph view that this claas offers, there are also three graph views representing the- left,- contextSee rule/GraphInterface for details of how to use these four graph interfaces.- context¶
- (Read-only) A proxy object representing the context graph of the rule. - Type:
 
 - right¶
- (Read-only) A proxy object representing the right graph of the rule. - Type:
 
 - makeInverse()¶
- Returns:
- a rule representing the inversion of this rule. 
- Return type:
- Raises:
- LogicErrorif inversion is not possible (due to matching constraints).
 
 - print(printCombined=False)¶
- print(first, second=None, printCombined=False)
- Print the rule, using either the default options or the options in - firstand- second. If- firstand- secondare 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 - Nonethen it is set to- first.
- printCombined (bool) – whether a depiction of the rule as a single combined graph is printed. 
 
- 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.pdffor respectively the left side, context, and right side graphs. If- firstand- secondare the same, the two file prefixes are equal.
- Return type:
 
 - printTermState()¶
- Print the term state for the rule. 
 - getGMLString(withCoords=False)¶
- Returns:
- the GML representation of the rule, optionally with generated 2D coordinates. 
- Return type:
- Raises:
- LogicErrorwhen 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:
- Raises:
- LogicErrorwhen coordinates are requested, but none can be generated.
 
 - labelType¶
- (Read-only) The intended label type for this rule, or None if no specific label type is intended. - Type:
 
 - 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, labelSettings=LabelSettings(LabelType.String, LabelRelation.Isomorphism))¶
- Parameters:
- maxNumMatches (int) – the maximum number of isomorphisms to search for. 
- labelSettings (LabelSettings) – the label settings to use during the search. 
 
- Returns:
- the number of isomorphisms found between - otherand this rule, but at most- maxNumMatches.
- Return type:
 
 - monomorphism(host, maxNumMatches=1, labelSettings=LabelSettings(LabelType.String, LabelRelation.Isomorphism))¶
- Parameters:
- maxNumMatches (int) – the maximum number of morphisms to search for. 
- labelSettings (LabelSettings) – the label settings to use during the search. 
 
- Returns:
- the number of monomorphisms from this rule to subgraphs of - host, though at most- maxNumMatches.
- Return type:
 
 - isomorphicLeftRight(other, labelSettings=LabelSettings(LabelType.String, LabelRelation.Isomorphism))¶
- Parameters:
- labelSettings (LabelSettings) – the label settings to use during the search. 
 
- Returns:
- whether the left-hand sides are isomorphic and the right-hand sides are isomorphic. 
- Return type:
 
 - getVertexFromExternalId(id)¶
- If the rule was not loaded from an external data format, then this function always return a null descriptor. - Note - In general there is no correlation between external and internal ids. 
 - minExternalId¶
- maxExternalId¶
- If the rule was not loaded from an external data format, then these attributes are always return 0. Otherwise, they are the minimum/maximum external id from which non-null vertices can be obtained from - getVertexFromExternalId(). If no such minimum and maximum exists, then they are 0.- Type:
 
 
4.1.12.4.1. Loading Functions¶
- static Rule.fromGMLString(s, name=None, *, invert=False, add=True, printStereoWarnings=True)¶
- static Rule.fromGMLFile(f, name=None, *, invert=False, add=True, printStereoWarnings=True)¶
- Load a rule from a GML string or file, and maybe store it in a global list. The name of the rule is the one specified in the GML string, though when - invert=Truethe string “, inverse” is appended to the name.- Note - If the GML string/file specifies matching constraints it is currently not possible to invert the rule. There is however a configuration option to ignore matching constraints when inverting rules. - Parameters:
- s (str) – the GML string to load a rule from. 
- name (str) – the name of the rule. If none is given the - ruleIDin the GML is used, and if that is not present, then the default name is used.
- invert (bool) – whether to invert the loaded rule. 
- add (bool) – whether to append the rule to - inputRulesor not.
- printStereoWarnings (bool) – whether to print warnings due to unhandled stereo information. 
 
- Returns:
- the rule in the GML string, possibly inverted. 
- Return type:
 
- static Rule.fromDFS(s, name=None, *, invert=False, add=True)¶
- Load a rule from a RuleDFS string. - Parameters:
- name (str) – the name of the rule. If none is given the default name is used. 
- invert (bool) – whether to invert the loaded rule. 
- name – the name of the rule. If none is given the default name is used. 
- add (bool) – whether to append the rule to - inputRulesor not.
 
- Returns:
- the loaded rule. 
- Return type:
- Raises:
- InputErroron bad input.
 
- mod.inputRules¶
- A list of rules to which explicitly loaded rules as default are appended. 
- class mod.VertexMapRuleRule¶
- Implements the - protocols.VertexMapprotocol.