2.2.15. Rule.h

2.2.15.1. Class Rule

class Rule

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

2.2.15.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 GraphPrinter &first, const GraphPrinter &second) 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);
    std::size_t getNumLeftComponents() const;
    std::size_t getNumRightComponents() const;
    std::size_t isomorphism(std::shared_ptr<Rule> r, std::size_t maxNumMatches) const;
    std::size_t monomorphism(std::shared_ptr<Rule> r, std::size_t maxNumMatches) 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);
private:
    struct Pimpl;
    std::unique_ptr<Pimpl> p;
};

2.2.15.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:InputError 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 GraphPrinter &first, const GraphPrinter &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.
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.

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) 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) const
Returns:the number of monomorphism from this rule to subgraphs of r, though at most maxNumMatches.
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)
Returns:a rule wrapping the given internal rule object.