2.2.5. DGGraphInterface.h

This header contains the defintinos for the hypergraph interface for mod::DG.

2.2.5.1. Class DG::Vertex

class DG::Vertex

A descriptor of either a vertex in a graph, or a null vertex.

2.2.5.1.1. Synopsis

class DG::Vertex {
    friend class DG;
    friend class HyperEdge;
    friend class VertexIterator;
    friend class SourceIterator;
    friend class TargetIterator;
    Vertex(std::shared_ptr<DG> g, std::size_t vId);
public:
    Vertex();
    friend std::ostream &operator<<(std::ostream &s, const Vertex &v);
    friend bool operator==(const Vertex &v1, const Vertex &v2);
    friend bool operator!=(const Vertex &v1, const Vertex &v2);
    friend bool operator<(const Vertex &v1, const Vertex &v2);
    bool isNull() const;
    std::size_t getId() const;
    std::shared_ptr<DG> getDG() const;
    std::size_t inDegree() const;
    InEdgeRange inEdges() const;
    std::size_t outDegree() const;
    OutEdgeRange outEdges() const;
    std::shared_ptr<Graph> getGraph() const;
private:
    std::shared_ptr<DG> g;
    std::size_t vId;
};

2.2.5.1.2. Details

Vertex()

Constructs a null descriptor.

bool isNull() const
Returns:whether this is a null descriptor or not.
std::size_t getId() const
Returns:the index of the vertex. It will be in the range \([0, numVertices + numEdges[\).
Throws:LogicError if it is a null descriptor.
std::shared_ptr<DG> getDG() const
Returns:the derivation graph the vertex belongs to.
Throws:LogicError if it is a null descriptor.
std::size_t inDegree() const
Returns:the in-degree of the vertex, including multiplicity of target multisets.
Throws:LogicError if it is a null descriptor.
InEdgeRange inEdges() const
Returns:a range of in-hyperedges for this vertex.
Throws:LogicError if it is a null descriptor.
std::size_t getOutDegree() const
Returns:the out-degree of the vertex, including multiplicity of source multisets.
Throws:LogicError if it is a null descriptor.
OutEdgeRange outEdges() const
Returns:a range of out-hyperedges for this vertex.
Throws:LogicError if it is a null descriptor.
std::shared_ptr<Graph> &getGraph() const
Returns:the graph label of the vertex.
Throws:LogicError if it is a null descriptor.

2.2.5.2. Class DG::HyperEdge

class DG::HyperEdge

A descriptor of either a hyperedge in a derivation graph, or a null edge.

2.2.5.2.1. Synopsis

class DG::HyperEdge {
    friend class DerivationRef; // TODO: remove
    friend class EdgeIterator;
    friend class InEdgeIterator;
    friend class OutEdgeIterator;
    HyperEdge(std::shared_ptr<DG> g, std::size_t eId);
public:
    HyperEdge();
    friend std::ostream &operator<<(std::ostream &s, const HyperEdge &e);
    friend bool operator==(const HyperEdge &e1, const HyperEdge &e2);
    friend bool operator!=(const HyperEdge &e1, const HyperEdge &e2);
    friend bool operator<(const HyperEdge &e1, const HyperEdge &e2);
    bool isNull() const;
    std::size_t getId() const;
    std::shared_ptr<DG> getDG() const;
    std::size_t numSources() const;
    SourceRange sources() const;
    std::size_t numTargets() const;
    TargetRange targets() const;
    RuleRange rules() const;
    HyperEdge getInverse() const;
public:
    void print(const GraphPrinter &printer, const std::string &matchColour) const;
private:
    std::shared_ptr<DG> g;
    std::size_t eId;
};

2.2.5.2.2. Details

HyperEdge()

Constructs a null descriptor.

bool isNull() const
Returns:whether this is a null descriptor or not.
std::size_t getId() const
Returns:the index of the hyperedge. It will be in the range \([0, numVertices + numEdges[\).
Throws:LogicError if it is a null descriptor.
std::shared_ptr<DG> getDG() const
Returns:the derivation graph the hyperedge belongs to.
Throws:LogicError if it is a null descriptor.
std::size_t numSources() const
Returns:the number of sources of the hyperedge.
Throws:LogicError if it is a null descriptor.
SourceRange sources() const
Returns:the sources of the hyperedge.
Throws:LogicError if it is a null descriptor.
std::size_t numTargets() const
Returns:the number of targets of the hyperedge.
Throws:LogicError if it is a null descriptor.
TargetRange targets() const
Returns:the targets of the hyperedge.
Throws:LogicError if it is a null descriptor.
RuleRange rules() const
Returns:a range of the rules associated with the hyperedge.
Throws:LogicError if it is a null descriptor.
HyperEdge getInverse() const
Returns:a descriptor for the inverse hyperedge of this one, if it exists. Otherwise a null descriptor is returned.
Throws:LogicError if it is a null descriptor.
void print(const GraphPrinter &printer, const std::string &matchColour) const

Print the derivations represented by the hyperedge. All possible Double-Pushout diagrams are printed. The matchColour must be a valid colour for TikZ, which is applied to the rule and its image in the bottom span.

Throws:LogicError if it is a null descriptor.

2.2.5.3. Class DG::VertexIterator

class DG::VertexIterator

An iterator for traversing all vertices in a derivation graph. It models a forward iterator.

2.2.5.3.1. Synopsis

class DG::VertexIterator : public boost::iterator_facade<VertexIterator, Vertex, std::forward_iterator_tag, Vertex> {
    friend class DG;
    VertexIterator(std::shared_ptr<DG> g);
public:
    VertexIterator();
private:
    friend class boost::iterator_core_access;
    Vertex dereference() const;
    bool equal(const VertexIterator &iter) const;
    void increment();
private:
    std::shared_ptr<DG> g;
    std::size_t vId;
};

2.2.5.3.2. Details

VertexIterator()

Construct a past-the-end iterator.

2.2.5.4. Class DG::VertexRange

class DG::VertexRange

A range of all vertices in a derivation graph.

2.2.5.4.1. Synopsis

struct DG::VertexRange {
    using iterator = VertexIterator;
    using const_iterator = iterator;
private:
    friend class DG;
    VertexRange(std::shared_ptr<DG> g);
public:
    VertexIterator begin() const;
    VertexIterator end() const;
private:
    std::shared_ptr<DG> g;
};

2.2.5.5. Class DG::EdgeIterator

class DG::EdgeIterator

An iterator for traversing all edges in a graph. It models a forward iterator.

2.2.5.5.1. Synopsis

class DG::EdgeIterator : public boost::iterator_facade<EdgeIterator, HyperEdge, std::forward_iterator_tag, HyperEdge> {
    friend class DG;
    EdgeIterator(std::shared_ptr<DG> g);
public:
    EdgeIterator();
private:
    friend class boost::iterator_core_access;
    HyperEdge dereference() const;
    bool equal(const EdgeIterator &iter) const;
    void increment();
private:
    std::shared_ptr<DG> g;
    std::size_t eId;
};

2.2.5.5.2. Details

EdgeIterator()

Construct a past-the-end iterator.

2.2.5.6. Class DG::EdgeRange

class DG::EdgeRange

A range of all edges in a derivation graph.

2.2.5.6.1. Synopsis

struct DG::EdgeRange {
    using iterator = EdgeIterator;
    using const_iterator = iterator;
private:
    friend class DG;
    EdgeRange(std::shared_ptr<DG> g);
public:
    EdgeIterator begin() const;
    EdgeIterator end() const;
private:
    std::shared_ptr<DG> g;
};

2.2.5.7. Class DG::InEdgeIterator

class DG::InEdgeIterator

An iterator for enumerating all in-edges of a vertex. It models a forward iterator.

2.2.5.7.1. Synopsis

class DG::InEdgeIterator : public boost::iterator_facade<InEdgeIterator, HyperEdge, std::forward_iterator_tag, HyperEdge> {
    friend class InEdgeRange;
    InEdgeIterator(std::shared_ptr<DG> g, std::size_t vId);
public:
    InEdgeIterator();
private:
    friend class boost::iterator_core_access;
    HyperEdge dereference() const;
    bool equal(const InEdgeIterator &iter) const;
    void increment();
private:
    std::shared_ptr<DG> g;
    std::size_t vId, eId;
};

2.2.5.7.2. Details

InEdgeIterator()

Construct a past-the-end iterator.

2.2.5.8. Class DG::InEdgeRange

class DG::InEdgeRange

A range of all in-edges of a vertex.

2.2.5.8.1. Synopsis

struct DG::InEdgeRange {
    using iterator = InEdgeIterator;
    using const_iterator = iterator;
private:
    friend class Vertex;
    InEdgeRange(std::shared_ptr<DG> g, std::size_t vId);
public:
    InEdgeIterator begin() const;
    InEdgeIterator end() const;
private:
    std::shared_ptr<DG> g;
    std::size_t vId;
};

2.2.5.9. Class DG::OutEdgeIterator

class DG::OutEdgeIterator

An iterator for enumerating all out-edges of a vertex. It models a forward iterator.

2.2.5.9.1. Synopsis

class DG::OutEdgeIterator : public boost::iterator_facade<OutEdgeIterator, HyperEdge, std::forward_iterator_tag, HyperEdge> {
    friend class OutEdgeRange;
    OutEdgeIterator(std::shared_ptr<DG> g, std::size_t vId);
public:
    OutEdgeIterator();
private:
    friend class boost::iterator_core_access;
    HyperEdge dereference() const;
    bool equal(const OutEdgeIterator &iter) const;
    void increment();
private:
    std::shared_ptr<DG> g;
    std::size_t vId, eId;
};

2.2.5.9.2. Details

OutEdgeIterator()

Construct a past-the-end iterator.

2.2.5.10. Class DG::OutEdgeRange

class DG::OutEdgeRange

A range of all out-edges of a vertex.

2.2.5.10.1. Synopsis

struct DG::OutEdgeRange {
    using iterator = OutEdgeIterator;
    using const_iterator = iterator;
private:
    friend class Vertex;
    OutEdgeRange(std::shared_ptr<DG> g, std::size_t vId);
public:
    OutEdgeIterator begin() const;
    OutEdgeIterator end() const;
private:
    std::shared_ptr<DG> g;
    std::size_t vId;
};

2.2.5.11. Class DG::SourceIterator

class DG::SourceIterator

An iterator for enumerating all sources of a hyperedge. It models a forward iterator.

2.2.5.11.1. Synopsis

class DG::SourceIterator : public boost::iterator_facade<SourceIterator, Vertex, std::forward_iterator_tag, Vertex> {
    friend class SourceRange;
    SourceIterator(std::shared_ptr<DG> g, std::size_t eId);
public:
    SourceIterator();
private:
    friend class boost::iterator_core_access;
    Vertex dereference() const;
    bool equal(const SourceIterator &iter) const;
    void increment();
private:
    std::shared_ptr<DG> g;
    std::size_t eId, vId;
};

2.2.5.11.2. Details

SourceIterator()

Construct a past-the-end iterator.

2.2.5.12. Class DG::SourceRange

class DG::SourceRange

A range of all sources of a hyperedge.

2.2.5.12.1. Synopsis

struct DG::SourceRange {
    using iterator = SourceIterator;
    using const_iterator = iterator;
private:
    friend class HyperEdge;
    SourceRange(std::shared_ptr<DG> g, std::size_t eId);
public:
    SourceIterator begin() const;
    SourceIterator end() const;
private:
    std::shared_ptr<DG> g;
    std::size_t eId;
};

2.2.5.13. Class DG::TargetIterator

class DG::TargetIterator

An iterator for enumerating all targets of a hyperedge. It models a forward iterator.

2.2.5.13.1. Synopsis

class DG::TargetIterator : public boost::iterator_facade<TargetIterator, Vertex, std::forward_iterator_tag, Vertex> {
    friend class TargetRange;
    TargetIterator(std::shared_ptr<DG> g, std::size_t eId);
public:
    TargetIterator();
private:
    friend class boost::iterator_core_access;
    Vertex dereference() const;
    bool equal(const TargetIterator &iter) const;
    void increment();
private:
    std::shared_ptr<DG> g;
    std::size_t eId, vId;
};

2.2.5.13.2. Details

TargetIterator()

Construct a past-the-end iterator.

2.2.5.14. Class DG::TargetRange

class DG::TargetRange

A range of all sources of a hyperedge.

2.2.5.14.1. Synopsis

struct DG::TargetRange {
    using iterator = TargetIterator;
    using const_iterator = iterator;
private:
    friend class HyperEdge;
    TargetRange(std::shared_ptr<DG> g, std::size_t eId);
public:
    TargetIterator begin() const;
    TargetIterator end() const;
private:
    std::shared_ptr<DG> g;
    std::size_t eId;
};

2.2.5.15. Class DG::RuleIterator

class DG::RuleIterator

An iterator for enumerating all rules of a hyperedge. It models a forward iterator.

2.2.5.15.1. Synopsis

class DG::RuleIterator : public boost::iterator_facade<RuleIterator, std::shared_ptr<Rule>, std::forward_iterator_tag, std::shared_ptr<Rule> > {
    friend class RuleRange;
    RuleIterator(std::shared_ptr<DG> g, std::size_t eId);
public:
    RuleIterator();
private:
    friend class boost::iterator_core_access;
    std::shared_ptr<Rule> dereference() const;
    bool equal(const RuleIterator &iter) const;
    void increment();
private:
    std::shared_ptr<DG> g;
    std::size_t eId, i;
};

2.2.5.15.2. Details

RuleIterator()

Construct a past-the-end iterator.

2.2.5.16. Class DG::RuleRange

class DG::RuleRange

A range of all rules of a hyperedge.

2.2.5.16.1. Synopsis

struct DG::RuleRange {
    using iterator = RuleIterator;
    using const_iterator = iterator;
private:
    friend class HyperEdge;
    RuleRange(std::shared_ptr<DG> g, std::size_t eId);
public:
    RuleIterator begin() const;
    RuleIterator end() const;
    std::size_t size() const;
private:
    std::shared_ptr<DG> g;
    std::size_t eId;
};