indigoX
BaseGraph< V, E, S, D, VP, EP > Class Template Referenceabstract

Template base class for all graphs used in the indigoX library. More...

#include <indigox/graph/base_graph.hpp>

+ Inheritance diagram for BaseGraph< V, E, S, D, VP, EP >:
+ Collaboration diagram for BaseGraph< V, E, S, D, VP, EP >:

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 ComponentContainGetConnectedComponents ()
 Get the connected components of the graph. More...
 
const CycleEdgeContainGetCycles ()
 Get the cycles of the graph. More...
 
GetEdge (const V &u, const V &v) const
 Get the edge between two vertices. More...
 
const EdgeContainGetEdges () const
 Get the edges of the graph. More...
 
const VertContainGetNeighbours (const V &v)
 Get the neighbouring vertices of a vertex. More...
 
const VertContainGetPredecessors (const V &v)
 Get the predecessor vertices of a vertex. More...
 
GetSourceVertex (const E &e) const
 Get the source vertex of an edge. More...
 
const VertContainGetSuccessors (const 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 VertContainGetVertices () 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...
 

Detailed Description

template<class V, class E, class S, class D = Undirected, class VP = GraphLabel, class EP = GraphLabel>
class indigox::graph::BaseGraph< V, E, S, D, VP, EP >

Template base class for all graphs used in the indigoX library.

Template Parameters
Vtype of the graph vertices.
Etype of the graph edges.
Dtype indicating the directed nature of the graph. Defaults to Undirected.
VertProptype of the label for a vertex. Defaults to GraphLabel.
EdgeProptype 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.

Member Typedef Documentation

◆ ComponentContain

using ComponentContain = std::vector<VertContain>

Type for storing components.

◆ CycleEdgeContain

using CycleEdgeContain = std::vector<EdgeContain>

Type for storing edge cycles.

◆ CycleVertContain

using CycleVertContain = std::vector<VertContain>

Type for storing vertex cycles.

◆ EdgeContain

using EdgeContain = std::vector<E>

Type for storing edges.

◆ EdgeIter

using EdgeIter = typename graph_type::edge_iterator

Type for iterator over edges.

◆ EdgeMap

Type for bidirectional mapping of E to edge descriptor type.

◆ EdgeType

using EdgeType = typename graph_type::edge_descriptor

Type of the graph edge descriptor.

◆ graph_type

using graph_type = boost::adjacency_list<boost::setS, boost::listS, typename D::is_directed_t, VP, EP>

Type of the underlying boost graph.

◆ NbrsContain

using NbrsContain = std::map<V, VertContain>

Type for storing neighbours.

◆ NbrsIter

using NbrsIter = typename graph_type::adjacency_iterator

Type for iterator over neighbours of vertex descriptor.

◆ PredIter

using PredIter = typename graph_type::inv_adjacency_iterator

Type for iterator over predecessors of a vertex descriptor.

◆ SubgraphType

using SubgraphType = S

◆ VertContain

using VertContain = std::vector<V>

Type for storing vertices.

◆ VertIter

using VertIter = typename graph_type::vertex_iterator

Type for iterator over graph vertex descriptors.

◆ VertMap

Type for bidirectional mapping of V to vertex descriptor type.

◆ VertType

using VertType = typename graph_type::vertex_descriptor

Type of the graph vertex descriptor.

Constructor & Destructor Documentation

◆ BaseGraph()

BaseGraph ( )
inline

Default constructor.

◆ ~BaseGraph()

virtual ~BaseGraph ( )
inlinevirtual

Member Function Documentation

◆ AddEdge()

void AddEdge ( const V &  u,
const V &  v,
const E &  e 
)
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.

Parameters
u,vvertices the edge is between.
ethe edge.

◆ AddVertex()

void AddVertex ( const V &  v)
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.

Parameters
vthe vertex to add.

◆ Degree()

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.

Parameters
vthe vertex to get the degree of.
Returns
pair of the degree of the vertex and if it is valid.

◆ GetConnectedComponents()

const BaseGraph< V, E, S, D, VP, EP >::ComponentContain & GetConnectedComponents ( )

Get the connected components of the graph.

Returns
reference to the connected components of the graph.

◆ GetCycles()

const BaseGraph< V, E, S, D, VP, EP >::CycleEdgeContain & GetCycles ( )

Get the cycles of the graph.

Returns
the cycles of the graph.

◆ GetEdge()

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.

Parameters
u,vvertices to get the edge between.
Returns
a pair of the edge between the two vertces and if it is valid.

◆ GetEdges()

const BaseGraph< V, E, S, D, VP, EP >::EdgeContain & GetEdges ( ) const

Get the edges of the graph.

Parameters
[out]edgesthe vector where the list of edges will be set. The vector is cleared before any edges are added to it.
Returns
the number of edges added to the vector.

◆ GetNeighbours()

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.

Parameters
vthe vertex to get the neighbours of.
[out]nbrsthe vector where the list of neighbours will be set. The vector is cleared before any neighbouring vertices are added to it.
Returns
if the vector has been populated or not.

◆ GetPredecessors()

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.

Parameters
[in]vthe vertex to get the predecessors of.
[out]presthe vector where the list of predecessors will be set. The vector is cleared before any predecessing vertices are added to it.
Returns
if the vector has been populated or not.

◆ GetSourceVertex()

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.

Parameters
ethe edge to get the source of.
Returns
a pair of the source vertex of the edge and if it is valid.

◆ GetSuccessors()

const BaseGraph< V, E, S, D, VP, EP >::VertContain & GetSuccessors ( const V &  v)

◆ GetTargetVertex()

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.

Parameters
ethe edge to get the target of.
Returns
the target vertex of the edge.

◆ GetVertices() [1/2]

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.

Parameters
ethe edge to get vertices of.
Returns
a pair of a pair of the two vertices making up the edge and if they are valid.

◆ GetVertices() [2/2]

const BaseGraph< V, E, S, D, VP, EP >::VertContain & GetVertices ( ) const

Get the vertices of the graph.

Parameters
[out]vertsthe vector where the list of vertices will be set. The vector is cleared before any vertices are added to it.
Returns
the number of vertices added to the vector.

◆ HasEdge() [1/2]

bool HasEdge ( const E &  e) const

Is the edge in the graph.

Parameters
eedge to search for.
Returns
if the requested edge is contained in the graph or not.

◆ HasEdge() [2/2]

bool HasEdge ( const V &  u,
const V &  v 
) const

Does an edge exist between two vertices.

Parameters
u,vvertices to check between.
Returns
if there is an edge between the two vertices.

◆ HasVertex()

bool HasVertex ( const V &  v) const

Is the vertex in the graph.

Parameters
vvertex to search for.
Returns
if the requested vertex is contained in the graph or not.

◆ InDegree()

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.

Parameters
vthe vertex to get indegree of.
Returns
pair of the indegree of the vertex and if it is valid.

◆ IsConnected()

bool IsConnected ( )

Determine if the graph is connected.

Returns
if the graph is connected or not.

◆ IsCyclic() [1/4]

bool IsCyclic ( const V &  v)

Determine if a vertex of this graph is cyclic.

Parameters
vthe vertex to check if in a cycle
Returns
if the vertex is in a cycle or not.

◆ IsCyclic() [2/4]

bool IsCyclic ( const V &  v,
uint32_t  sz 
)

◆ IsCyclic() [3/4]

bool IsCyclic ( const E &  e)

Determine if an edge of this graph is cycle.

Parameters
ethe edge to check if in a cycle.
Returns
if the edge is in a cycle or not.

◆ IsCyclic() [4/4]

bool IsCyclic ( const E &  e,
uint32_t  sz 
)

◆ NumConnectedComponents()

int64_t NumConnectedComponents ( )

Get the number of connected components of the graph.

Returns
the number of cnnected components of the graph.

◆ NumCycles()

int64_t NumCycles ( )

◆ NumEdges()

int64_t NumEdges ( ) const

Number of edges in the graph.

Returns
the number of edges in the graph.

◆ NumVertices()

int64_t NumVertices ( ) const

Number of vertices in the graph.

Returns
the number of vertices in the graph.

◆ RemoveEdge() [1/2]

void RemoveEdge ( const E &  e)
protected

Remove an edge from the graph.

It is the callers responsibility to ensure that the edge is a part of the graph.

Parameters
ethe edge to remove.

◆ RemoveEdge() [2/2]

void RemoveEdge ( const V &  u,
const V &  v 
)
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.

Parameters
u,vvertices to remove an edge from between.

Referenced by BaseGraph< CMGVertex, CMGEdge, CondensedMolecularGraph >::RemoveEdge().

◆ RemoveVertex()

void RemoveVertex ( const V &  v)
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.

Parameters
vthe vertex to remove.

◆ Subgraph() [1/2]

virtual S Subgraph ( std::vector< V > &  verts)
pure virtual

◆ Subgraph() [2/2]

virtual S Subgraph ( std::vector< V > &  verts,
std::vector< E > &  edges 
)
pure virtual

Friends And Related Function Documentation

◆ algorithm::access

friend struct algorithm::access
friend

Friendship allows graph algorithm access to internals.

◆ cereal::access

friend class cereal::access
friend

Friendship allows serialisation.

Member Data Documentation

◆ m_basedata

std::shared_ptr<BaseImpl> m_basedata
protected

The documentation for this class was generated from the following files: