2.2.11. GraphGraphInterface.h

This header contains the defintinos for the graph interface for mod::Graph.

2.2.11.1. Class Graph::Vertex

class Graph::Vertex

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

2.2.11.1.1. Synopsis

class Graph::Vertex {
    friend class Graph;
    friend class Edge;
    friend class VertexIterator;
    friend class VertexRange;
    Vertex(std::shared_ptr<Graph> 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<Graph> getGraph() const;
    std::size_t getDegree() const;
    IncidentEdgeRange incidentEdges() const;
    const std::string &getStringLabel() const;
    AtomId getAtomId() const;
    Charge getCharge() const;
    bool getRadical() const;
private:
    std::shared_ptr<Graph> g;
    std::size_t vId;
};

2.2.11.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[\).
Throws:LogicError if it is a null descriptor.
std::shared_ptr<Graph> getGraph() const
Returns:the graph the vertex belongs to.
Throws:LogicError if it is a null descriptor.
std::size_t getDegree() const
Returns:the degree of the vertex.
Throws:LogicError if it is a null descriptor.
IncidentEdgeRange incidentEdges() const
Returns:a range of incident edges to this vertex.
Throws:LogicError if it is a null descriptor.
const std::string &getStringLabel() const
Returns:the string label of the vertex.
Throws:LogicError if it is a null descriptor.
AtomId getAtomId() const
Returns:the atom id of the vertex.
Throws:LogicError if it is a null descriptor.
Charge getCharge() const
Returns:the charge of the vertex.
Throws:LogicError if it is a null descriptor.
bool getRadical() const
Returns:the radical status of the vertex.
Throws:LogicError if it is a null descriptor.

2.2.11.2. Class Graph::Edge

class Graph::Edge

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

2.2.11.2.1. Synopsis

class Graph::Edge {
    friend class EdgeIterator;
    friend class IncidentEdgeIterator;
    Edge(std::shared_ptr<Graph> g, std::size_t vId, std::size_t eId);
public:
    Edge();
    friend std::ostream &operator<<(std::ostream &s, const Edge &e);
    friend bool operator==(const Edge &e1, const Edge &e2);
    friend bool operator!=(const Edge &e1, const Edge &e2);
    friend bool operator<(const Edge &e1, const Edge &e2);
    bool isNull() const;
    std::shared_ptr<Graph> getGraph() const;
    Vertex source() const;
    Vertex target() const;
    const std::string &getStringLabel() const;
    BondType getBondType() const;
private:
    std::shared_ptr<Graph> g;
    std::size_t vId, eId;
};

2.2.11.2.2. Details

Edge()

Constructs a null descriptor.

bool isNull() const
Returns:whether this is a null descriptor or not.
std::shared_ptr<Graph> getGraph() const
Returns:the graph the edge belongs to.
Throws:LogicError if it is a null descriptor.
Vertex source() const
Returns:the source vertex of the edge.
Throws:LogicError if it is a null descriptor.
Vertex target() const
Returns:the target vertex of the edge.
Throws:LogicError if it is a null descriptor.
const std::string &getStringLabel() const
Returns:the string label of the edge.
Throws:LogicError if it is a null descriptor.
BondType getBondType() const
Returns:the bond type of the edge.
Throws:LogicError if it is a null descriptor.

2.2.11.3. Class Graph::VertexIterator

class Graph::VertexIterator

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

2.2.11.3.1. Synopsis

class Graph::VertexIterator : public boost::iterator_facade<VertexIterator, Vertex, std::forward_iterator_tag, Vertex> {
    friend class Graph;
    VertexIterator(std::shared_ptr<Graph> 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<Graph> g;
    std::size_t vId;
};

2.2.11.3.2. Details

VertexIterator()

Construct a past-the-end iterator.

2.2.11.4. Class Graph::VertexRange

class Graph::VertexRange

A range of all vertices in a graph.

2.2.11.5. Class Graph::EdgeIterator

class Graph::EdgeIterator

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

2.2.11.5.1. Synopsis

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

2.2.11.5.2. Details

EdgeIterator()

Construct a past-the-end iterator.

2.2.11.6. Class Graph::EdgeRange

class Graph::EdgeRange

A range of all edges in a graph.

2.2.11.7. Class Graph::IncidnetEdgeIterator

class Graph::IncidnetEdgeIterator

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

2.2.11.7.1. Synopsis

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

2.2.11.7.2. Details

IncidentEdgeIterator()

Construct a past-the-end iterator.

2.2.11.8. Class Graph::IncidentEdgeRange

class Graph::IncidentEdgeRange

A range of all incident edges to a vertex in a graph.