indigoX
|
Template base class for all graphs used in the indigoX library. More...
#include <indigox/graph/base_graph.hpp>
Public Types | |
using | ComponentContain = std::vector< VertContain > |
Type for storing components. More... | |
using | CycleEdgeContain = std::vector< EdgeContain > |
Type for storing edge cycles. More... | |
using | CycleVertContain = std::vector< VertContain > |
Type for storing vertex cycles. More... | |
using | EdgeContain = std::vector< E > |
Type for storing edges. More... | |
using | EdgeIter = typename graph_type::edge_iterator |
Type for iterator over edges. More... | |
using | EdgeMap = indigox::utils::SimpleBiMap< E, EdgeType > |
Type for bidirectional mapping of E to edge descriptor type. More... | |
using | EdgeType = typename graph_type::edge_descriptor |
Type of the graph edge descriptor. More... | |
using | graph_type = boost::adjacency_list< boost::setS, boost::listS, typename D::is_directed_t, VP, EP > |
Type of the underlying boost graph. More... | |
using | NbrsContain = std::map< V, VertContain > |
Type for storing neighbours. More... | |
using | NbrsIter = typename graph_type::adjacency_iterator |
Type for iterator over neighbours of vertex descriptor. More... | |
using | PredIter = typename graph_type::inv_adjacency_iterator |
Type for iterator over predecessors of a vertex descriptor. More... | |
using | SubgraphType = S |
using | VertContain = std::vector< V > |
Type for storing vertices. More... | |
using | VertIter = typename graph_type::vertex_iterator |
Type for iterator over graph vertex descriptors. More... | |
using | VertMap = indigox::utils::SimpleBiMap< V, VertType > |
Type for bidirectional mapping of V to vertex descriptor type. More... | |
using | VertType = typename graph_type::vertex_descriptor |
Type of the graph vertex descriptor. More... | |
Public Member Functions | |
BaseGraph () | |
Default constructor. More... | |
virtual | ~BaseGraph () |
int64_t | Degree (const V &v) const |
Degree of a vertex. More... | |
const ComponentContain & | GetConnectedComponents () |
Get the connected components of the graph. More... | |
const CycleEdgeContain & | GetCycles () |
Get the cycles of the graph. More... | |
E | GetEdge (const V &u, const V &v) const |
Get the edge between two vertices. More... | |
const EdgeContain & | GetEdges () const |
Get the edges of the graph. More... | |
const VertContain & | GetNeighbours (const V &v) |
Get the neighbouring vertices of a vertex. More... | |
const VertContain & | GetPredecessors (const V &v) |
Get the predecessor vertices of a vertex. More... | |
V | GetSourceVertex (const E &e) const |
Get the source vertex of an edge. More... | |
const VertContain & | GetSuccessors (const V &v) |
V | GetTargetVertex (const E &e) const |
Get the target vertex of an edge. More... | |
std::pair< V, V > | GetVertices (const E &e) const |
Get the two vertices that make up an edge. More... | |
const VertContain & | GetVertices () const |
Get the vertices of the graph. More... | |
bool | HasEdge (const E &e) const |
Is the edge in the graph. More... | |
bool | HasEdge (const V &u, const V &v) const |
Does an edge exist between two vertices. More... | |
bool | HasVertex (const V &v) const |
Is the vertex in the graph. More... | |
int64_t | InDegree (const V &v) const |
Indegree of a vertex. More... | |
bool | IsConnected () |
Determine if the graph is connected. More... | |
bool | IsCyclic (const V &v) |
Determine if a vertex of this graph is cyclic. More... | |
bool | IsCyclic (const V &v, uint32_t sz) |
bool | IsCyclic (const E &e) |
Determine if an edge of this graph is cycle. More... | |
bool | IsCyclic (const E &e, uint32_t sz) |
int64_t | NumConnectedComponents () |
Get the number of connected components of the graph. More... | |
int64_t | NumCycles () |
int64_t | NumEdges () const |
Number of edges in the graph. More... | |
int64_t | NumVertices () const |
Number of vertices in the graph. More... | |
virtual S | Subgraph (std::vector< V > &verts)=0 |
virtual S | Subgraph (std::vector< V > &verts, std::vector< E > &edges)=0 |
Protected Member Functions | |
void | AddEdge (const V &u, const V &v, const E &e) |
Add a new edge to the graph. More... | |
void | AddVertex (const V &v) |
Add a new vertex to the graph. More... | |
void | RemoveEdge (const E &e) |
Remove an edge from the graph. More... | |
void | RemoveEdge (const V &u, const V &v) |
Remove an edge from the graph. More... | |
void | RemoveVertex (const V &v) |
Remove a vertex from the graph. More... | |
Protected Attributes | |
std::shared_ptr< BaseImpl > | m_basedata |
Friends | |
struct | algorithm::access |
Friendship allows graph algorithm access to internals. More... | |
class | cereal::access |
Friendship allows serialisation. More... | |
Template base class for all graphs used in the indigoX library.
V | type of the graph vertices. |
E | type of the graph edges. |
D | type indicating the directed nature of the graph. Defaults to Undirected. |
VertProp | type of the label for a vertex. Defaults to GraphLabel. |
EdgeProp | type of the label for an edge. Defaults to GraphLabel. |
Graph classes should contain an IXGraphBase member, not inherit from it. Vertex and Edge types are purely interacted with though the use of raw pointers. The IXGraphBase class will never deallocate any memory passed to it.
using ComponentContain = std::vector<VertContain> |
Type for storing components.
using CycleEdgeContain = std::vector<EdgeContain> |
Type for storing edge cycles.
using CycleVertContain = std::vector<VertContain> |
Type for storing vertex cycles.
using EdgeContain = std::vector<E> |
Type for storing edges.
using EdgeIter = typename graph_type::edge_iterator |
Type for iterator over edges.
using EdgeMap = indigox::utils::SimpleBiMap<E, EdgeType> |
Type for bidirectional mapping of E to edge descriptor type.
using EdgeType = typename graph_type::edge_descriptor |
Type of the graph edge descriptor.
using graph_type = boost::adjacency_list<boost::setS, boost::listS, typename D::is_directed_t, VP, EP> |
Type of the underlying boost graph.
using NbrsContain = std::map<V, VertContain> |
Type for storing neighbours.
using NbrsIter = typename graph_type::adjacency_iterator |
Type for iterator over neighbours of vertex descriptor.
using PredIter = typename graph_type::inv_adjacency_iterator |
Type for iterator over predecessors of a vertex descriptor.
using SubgraphType = S |
using VertContain = std::vector<V> |
Type for storing vertices.
using VertIter = typename graph_type::vertex_iterator |
Type for iterator over graph vertex descriptors.
using VertMap = indigox::utils::SimpleBiMap<V, VertType> |
Type for bidirectional mapping of V to vertex descriptor type.
using VertType = typename graph_type::vertex_descriptor |
Type of the graph vertex descriptor.
|
inline |
Default constructor.
|
inlinevirtual |
|
protected |
Add a new edge to the graph.
Vertex u is used as the source and vertex v as the target. If u and/or v are not already part of the graph, they are added. It is the callers responsibility to ensure that the edge is not part of the graph.
u,v | vertices the edge is between. |
e | the edge. |
|
protected |
Add a new vertex to the graph.
It is the callers responsability to ensure that the vertex added is not already part of the graph. If it is, a mismatch between the vertices in the graph and the what the _verts member thinks are in the graph may arise.
v | the vertex to add. |
int64_t Degree | ( | const V & | v | ) | const |
Degree of a vertex.
In the case of a directed graph, the degree of a vertex is the number of edges leaving the vertex.
v | the vertex to get the degree of. |
const BaseGraph< V, E, S, D, VP, EP >::ComponentContain & GetConnectedComponents | ( | ) |
Get the connected components of the graph.
const BaseGraph< V, E, S, D, VP, EP >::CycleEdgeContain & GetCycles | ( | ) |
Get the cycles of the graph.
E GetEdge | ( | const V & | u, |
const V & | v | ||
) | const |
Get the edge between two vertices.
It is the callers responsibilty to ensure that the vertices are a part of the graph.
u,v | vertices to get the edge between. |
const BaseGraph< V, E, S, D, VP, EP >::EdgeContain & GetEdges | ( | ) | const |
Get the edges of the graph.
[out] | edges | the vector where the list of edges will be set. The vector is cleared before any edges are added to it. |
const BaseGraph< V, E, S, D, VP, EP >::VertContain & GetNeighbours | ( | const V & | v | ) |
Get the neighbouring vertices of a vertex.
The neighbours of a vertex are those for which the edge v -> u exists within the graph. It is the callers responsibilty to ensure that the vertex is a part of the graph.
v | the vertex to get the neighbours of. | |
[out] | nbrs | the vector where the list of neighbours will be set. The vector is cleared before any neighbouring vertices are added to it. |
const BaseGraph< V, E, S, D, VP, EP >::VertContain & GetPredecessors | ( | const V & | v | ) |
Get the predecessor vertices of a vertex.
The predecessors of a vertex are those for which the edge u -> v exists within the graph. For an undirected graph, this is equivalent to the neighbours. It is the callers responsibilty to ensure that the vertex is a part of the graph.
[in] | v | the vertex to get the predecessors of. |
[out] | pres | the vector where the list of predecessors will be set. The vector is cleared before any predecessing vertices are added to it. |
V GetSourceVertex | ( | const E & | e | ) | const |
Get the source vertex of an edge.
It is the callers responsibilty to ensure that the edge is a part of the graph.
e | the edge to get the source of. |
const BaseGraph< V, E, S, D, VP, EP >::VertContain & GetSuccessors | ( | const V & | v | ) |
V GetTargetVertex | ( | const E & | e | ) | const |
Get the target vertex of an edge.
It is the callers responsibilty to ensure that the edge is a part of the graph.
e | the edge to get the target of. |
std::pair< V, V > GetVertices | ( | const E & | e | ) | const |
Get the two vertices that make up an edge.
It is the callers responsibility to ensure that the edge is a part of the graph.
e | the edge to get vertices of. |
const BaseGraph< V, E, S, D, VP, EP >::VertContain & GetVertices | ( | ) | const |
Get the vertices of the graph.
[out] | verts | the vector where the list of vertices will be set. The vector is cleared before any vertices are added to it. |
bool HasEdge | ( | const E & | e | ) | const |
Is the edge in the graph.
e | edge to search for. |
bool HasEdge | ( | const V & | u, |
const V & | v | ||
) | const |
Does an edge exist between two vertices.
u,v | vertices to check between. |
bool HasVertex | ( | const V & | v | ) | const |
Is the vertex in the graph.
v | vertex to search for. |
int64_t InDegree | ( | const V & | v | ) | const |
Indegree of a vertex.
The indegree of a vertex is the number of edges entering the vertex. For an undirected graph, this is equivalent to Degree(V) const. It is the callers responsibilty to ensure that the vertex is a part of the graph.
v | the vertex to get indegree of. |
bool IsConnected | ( | ) |
Determine if the graph is connected.
bool IsCyclic | ( | const V & | v | ) |
Determine if a vertex of this graph is cyclic.
v | the vertex to check if in a cycle |
bool IsCyclic | ( | const V & | v, |
uint32_t | sz | ||
) |
bool IsCyclic | ( | const E & | e | ) |
Determine if an edge of this graph is cycle.
e | the edge to check if in a cycle. |
bool IsCyclic | ( | const E & | e, |
uint32_t | sz | ||
) |
int64_t NumConnectedComponents | ( | ) |
Get the number of connected components of the graph.
int64_t NumCycles | ( | ) |
int64_t NumEdges | ( | ) | const |
Number of edges in the graph.
int64_t NumVertices | ( | ) | const |
Number of vertices in the graph.
|
protected |
Remove an edge from the graph.
It is the callers responsibility to ensure that the edge is a part of the graph.
e | the edge to remove. |
|
protected |
Remove an edge from the graph.
It is the callers responsibility to ensure that there is an edge between u and v to remove.
u,v | vertices to remove an edge from between. |
Referenced by BaseGraph< CMGVertex, CMGEdge, CondensedMolecularGraph >::RemoveEdge().
|
protected |
Remove a vertex from the graph.
Removing a vertex also removes all edges incident on it. It is the callers responsibility to ensure that the vertex removed is within the graph.
v | the vertex to remove. |
|
pure virtual |
Implemented in CondensedMolecularGraph, and MolecularGraph.
|
pure virtual |
Implemented in CondensedMolecularGraph, and MolecularGraph.
|
friend |
Friendship allows graph algorithm access to internals.
|
friend |
Friendship allows serialisation.
|
protected |
Referenced by access::GetEdgeMap(), access::GetGraph(), and access::GetVertexMap().