4.1.10.2. rule/CompositionMatch

class mod.RCMatch

A class for interactively constructing match between two rules used for composition. That is, for two rules \(p_1 = (L_1 \leftarrow K_1 \rightarrow R_1)\) and \(p_2 = (L_2 \leftarrow K_2 \rightarrow R_2)\), an object represents match between \(R_1\) and \(L_2\) which indicates a common subgraph \(R_1 \leftarrow M \rightarrow L_2\).

__init__(rFirst, rSecond, labelSettings=LabelSettings(LabelType.String, LabelRelation.Specialisation))

Construct an empty overlap.

Parameters:
  • rFirst (Rule) – the first rule \(p_1\).

  • rSecond (Rule) – the second rule \(p_2\).

  • labelSettings (LabelSettings) – the settings to use for the morphisms \(R_1 \leftarrow M \rightarrow L_2\).

Raises:

LogicError – if either rule is None.

__str__()
first
second

(Read-only) The rules \(p_1\) and \(p_2\).

Type:

Rule

labelSettings

(Read-only) The settings for the morphisms in the match.

Type:

LabelSettings

size

(Read-only) The number of currently mapped pairs of vertices.

Type:

int

__getitem__(vFirst)
__getitem__(vSecond)
Parameters:
Returns:

the vertex the given vertex is mapped to, or a null vertex if it is not mapped.

Raises:
  • LogicError – if either vertex is a null vertex.

  • LogicError – if either vertex does not belong to their respective rules.

void push(vFirst, vSecond)

Extend the common subgraph (match) of \(R_1\) and \(L_2\) by identifying the given vertices from each of the graphs.

Raises:
  • LogicError – if either vertex is a null vertex.

  • LogicError – if either vertex does not belong to their respective rules.

  • LogicError – if either vertex is already mapped.

  • LogicError – if the extension of the match is infeasible.

pop()

Pop the latest pushed vertex pair.

Raises:

LogicError – if self.size == 0.

compose(*, verbose=False)
Parameters:

verbose (bool) – whether to output debug messages from the composition algorithm.

Returns:

the composition of the two rules along the match. If the composition is not defined, None is returned.

Return type:

Rule

composeAll(*, maximum=False, verbose=False)
Parameters:
  • maximum (bool) – whether to only compose using the matches of maximum cardinality.

  • verbose (bool) – whether to output debug messages from the composition algorithm.

Returns:

the composition of the two rules along enumerated matches. The enumerated matches are all those that are extensions of the current match, and the match it self.

Return type:

list[Rule]