2.2.10.5. rule/Rule.h

2.2.10.5.1. Class rule::Rule

class rule::Rule

Model of a transformation rule in the Double Pushout formalism. See rule/GraphInterface.h for the documentation for the graph interface for this class.

2.2.10.5.1.1. Synopsis

struct Rule {
    class Vertex;
    class Edge;
    class VertexIterator;
    class VertexRange;
    class EdgeIterator;
    class EdgeRange;
    class IncidentEdgeIterator;
    class IncidentEdgeRange;
public:
    class LeftGraph;
    class ContextGraph;
    class RightGraph;
private:
    Rule(const Rule&) = delete;
    Rule &operator=(const Rule&) = delete;
    Rule(Rule&&) = delete;
    Rule &operator=(Rule&&) = delete;
private:
    Rule(std::unique_ptr<lib::Rules::Real> r);
public:
    ~Rule();
    unsigned int getId() const;
    friend std::ostream &operator<<(std::ostream &s, const Rule &r);
    const lib::Rules::Real &getRule() const;
public: // graph interface
    std::size_t numVertices() const;
    VertexRange vertices() const;
    std::size_t numEdges() const;
    EdgeRange edges() const;
    LeftGraph getLeft() const;
    ContextGraph getContext() const;
    RightGraph getRight() const;
public:
    std::shared_ptr<Rule> makeInverse() const;
    std::pair<std::string, std::string> print() const;
    std::pair<std::string, std::string> print(const graph::Printer &first, const graph::Printer &second) const;
    void printTermState() const;
    std::string getGMLString(bool withCoords = false) const;
    std::string printGML(bool withCoords = false) const;
    const std::string &getName() const;
    void setName(std::string name);
    boost::optional<LabelType> getLabelType() const;
    std::size_t getNumLeftComponents() const;
    std::size_t getNumRightComponents() const;
    std::size_t isomorphism(std::shared_ptr<Rule> r, std::size_t maxNumMatches, LabelSettings labelSettings) const;
    std::size_t monomorphism(std::shared_ptr<Rule> r, std::size_t maxNumMatches, LabelSettings labelSettings) const;
    Vertex getVertexFromExternalId(int id) const;
    int getMinExternalId() const;
    int getMaxExternalId() const;
public:
    static std::shared_ptr<Rule> ruleGMLString(const std::string &data, bool invert);
    static std::shared_ptr<Rule> ruleGML(const std::string &file, bool invert);
    static std::shared_ptr<Rule> makeRule(std::unique_ptr<lib::Rules::Real> r);
    static std::shared_ptr<Rule> makeRule(std::unique_ptr<lib::Rules::Real> r, std::map<int, std::size_t> externalToInternalIds);
private:
    struct Pimpl;
    std::unique_ptr<Pimpl> p;
};

2.2.10.5.1.2. Details

unsigned int getId() const
Returns:the unique instance id among all Rule instances.
std::size_t numVertices() const
Returns:the number of vertices in the rule.
VertexRange vertices() const
Returns:a range of all vertices in the rule.
std::size_t numEdges() const
Returns:the number of edges in the rule.
EdgeRange edges() const
Returns:a range of all edges in the rule.
LeftGraph getLeft() const
Returns:a proxy object representing the left graph of the rule.
ContextGraph getContext() const
Returns:a proxy object representing the context graph of the rule.
RightGraph getRight() const
Returns:a proxy object representing the rule graph of the rule.
std::shared_ptr<Rule> makeInverse() const
Returns:a rule representing the inversion of this rule.
Raises:LogicError if inversion is not possible (due to matching constraints).
std::pair<std::string, std::string> print() const
std::pair<std::string, std::string> print(const graph::Printer &first, const graph::Printer &second) const

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.

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.
void printTermState() const

Print the term state for the rule.

std::string getGMLString(bool withCoords = false) const
Returns:the GML representation of the rule, optionally with generated 2D coordinates.
Throws:LogicError when coordinates are requested, but none can be generated.
std::string printGML(bool withCoords = false) const

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

Returns:the filename of the printed GML file.
Throws:LogicError when coordinates are requested, but none can be generated.
const std::string &getName() const
void setName(std::string name)

Access the name of the rule.

boost::optional<LabelType> getLabelType() const
Returns:the intended label type for this rule, or nothing if no specific label type is intended.
std::size_t getNumLeftComponents() const
Returns:the number of connected components in the left graph.
std::size_t getNumRightComponents() const
Returns:the number of connected components in the right graph.
std::size_t isomorphism(std::shared_ptr<Rule> r, std::size_t maxNumMatches, LabelSettings labelSettings) const
Returns:the number of isomorphisms found between r and this graph, but at most maxNumMatches.
std::size_t monomorphism(std::shared_ptr<Rule> r, std::size_t maxNumMatches, LabelSettings labelSettings) const
Returns:the number of monomorphism from this rule to subgraphs of r, though at most maxNumMatches.
Vertex getVertexFromExternalId(int id) const

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.

Returns:the vertex descriptor for the given external id. The descriptor is null if the external id was not used.
int getMinExternalId() const
int getMaxExternalId() const

If the rule was not loaded from an external data format, then these functions always return 0. Otherwise, return the minimum/maximum external id from which non-null vertices can be obtained from getVertexFromExternalId(). If no such minimum and maximum exists, then 0 will be returned.

static std::shared_ptr<Rule> ruleGMLString(const std::string &data, bool invert)

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.

Returns:the loaded (possibly inverted) rule.
Throws:InputError on bad data and when inversion fails due to constraints.
static std::shared_ptr<Rule> ruleGML(const std::string &file, bool invert)

Read file and pass the contents to ruleGMLString().

Returns:the loaded (possibly inverted) rule.
Throws:InputError on bad data and when inversion fails due to constraints.
static std::shared_ptr<Rule> makeRule(std::unique_ptr<lib::Rules::Real> r)
static std::shared_ptr<Rule> makeRule(std::unique_ptr<lib::Rules::Real> r, std::map<int, std::size_t> externalToInternalIds)
Returns:a rule wrapping the given internal rule object. If an id mapping is given, it will be used for the getVertexFromExternalId() function.