3.2.15.3. rule/CompositionMatch.hpp

class rule::CompositionMatch

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\).

See also [AFMS-RC] for details of how composition of rules can be computed.

class Result

Representation of the full result of a composition.

std::shared_ptr<Rule> rule

The composed rule.

VertexMap<Rule, Rule> mFirstToSecond

A map of vertices in \(p_1\) to the vertices of \(p_2\), i.e., the match used for composition.

VertexMap<Rule, Rule> mFirstToRes

A map of vertices in \(p_1\) to the vertices of the composed rule.

VertexMap<Rule, Rule> mSecondToRes

A map of vertices in \(p_2\) to the vertices of the composed rule.

explicit CompositionMatch(std::shared_ptr<Rule> rFirst, std::shared_ptr<Rule> rSecond, LabelSettings labelSettings)

Construct an empty overlap.

Throws:

LogicError – if either rule is null.

CompositionMatch(const CompositionMatch &other)
CompositionMatch &operator=(const CompositionMatch &other)
friend std::ostream &operator<<(std::ostream &s, const CompositionMatch &mb)
std::shared_ptr<Rule> getFirst() const
std::shared_ptr<Rule> getSecond() const
Returns:

the rules \(p_1\) and \(p_2\).

LabelSettings getLabelSettings() const
Returns:

the settings for the morphisms in the match.

int size() const
Returns:

the number of currently mapped pairs of vertices.

Rule::LeftGraph::Vertex operator[](Rule::RightGraph::Vertex vFirst) const
Rule::RightGraph::Vertex operator[](Rule::LeftGraph::Vertex vSecond) const
Returns:

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

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

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

void push(Rule::RightGraph::Vertex vFirst, Rule::LeftGraph::Vertex vSecond)

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

Throws:
  • 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.

void pop()

Pop the latest pushed vertex pair.

Throws:

LogicError – if size() == 0.

std::shared_ptr<Rule> compose(bool verbose) const
std::optional<Result> composeWithMaps(bool verbose) const
Parameters:

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

Returns:

the composition of the two rules along the match, either just the composed rule or the composed rule with maps relating its vertices and the vertices in the input. If the composition is not defined, a null pointer or empty optional is returned.

std::vector<std::shared_ptr<Rule>> composeAll(bool maximum, bool verbose) const
std::vector<Result> composeAllWithMaps(bool maximum, bool verbose) const
Parameters:
  • maximum – whether to only compose using the matches of maximum cardinality.

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

Returns:

the composition of the two rules along enumerated matches, either just the composed rules or each of the composed rules with maps relating their vertices and the vertices in the input, including the full match used for each particular composition. The enumerated matches are all those that are extensions of the current match, and the match itself.