Graphitti
A toolkit/software architecture to ease creating high-performance neural network simulators
Loading...
Searching...
No Matches
GraphManager< VertexProperties > Class Template Reference

A templated wrapper around the Boost Graph Library (BGL). More...

#include <GraphManager.h>

Public Types

using Graph
 Using directive for graphml graph type (adjacency list)
 
using EdgeIterator = typename boost::graph_traits<Graph>::edge_iterator
 
using VertexIterator = typename boost::graph_traits<Graph>::vertex_iterator
 
using EdgeDescriptor = typename boost::graph_traits<Graph>::edge_descriptor
 

Public Member Functions

void setFilePath (string filePath)
 Set the path for the graphML File to be read.
 
template<class Property >
void registerProperty (const string &propName, Property property)
 Registers a graph property with its attribute name in the graphml file.
 
bool readGraph ()
 Loads a graph from a graphml file into a BGL graph.
 
pair< VertexIterator, VertexIterator > vertices ()
 Exposes the BGL Vertex Iterators of the stored Graph.
 
pair< EdgeIterator, EdgeIterator > edges () const
 Exposes the BGL Edge Iterators of the stored Graph.
 
size_t source (const EdgeDescriptor &edge) const
 Retrieves the source vertex index for the given Edge.
 
size_t target (const EdgeDescriptor &edge) const
 Retrieves the target vertex index for the given Edge.
 
double weight (const EdgeDescriptor &edge) const
 Retrieves the weight of an edge.
 
VertexPropertiesoperator[] (size_t vertex)
 Direct access to the VertexProperties of a vertex descriptor.
 
const VertexPropertiesoperator[] (size_t vertex) const
 Direct access to the VertexProperties of a vertex descriptor.
 
const list< EdgeDescriptor > edgesSortByTarget () const
 Returns a list of EdgeDescriptors in ascending order by target vertexID.
 
size_t numVertices () const
 Retrieves the number of vertices in the current graph.
 
size_t numEdges () const
 Retrieves the number of edges in the current graph.
 
 GraphManager (const GraphManager &graphManager)=delete
 Delete copy and move methods to avoid copy instances of the singleton.
 
GraphManageroperator= (const GraphManager &graphManager)=delete
 
 GraphManager (GraphManager &&graphManager)=delete
 
GraphManageroperator= (GraphManager &&graphManager)=delete
 

Static Public Member Functions

static GraphManagergetInstance ()
 Returns a single instance of the GraphManager.
 

Detailed Description

template<typename VertexProperties>
class GraphManager< VertexProperties >

A templated wrapper around the Boost Graph Library (BGL).

Definition at line 51 of file GraphManager.h.

Member Typedef Documentation

◆ EdgeDescriptor

template<typename VertexProperties >
using GraphManager< VertexProperties >::EdgeDescriptor = typename boost::graph_traits<Graph>::edge_descriptor

Definition at line 59 of file GraphManager.h.

◆ EdgeIterator

template<typename VertexProperties >
using GraphManager< VertexProperties >::EdgeIterator = typename boost::graph_traits<Graph>::edge_iterator

Definition at line 57 of file GraphManager.h.

◆ Graph

template<typename VertexProperties >
using GraphManager< VertexProperties >::Graph
Initial value:
boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, VertexProperties,
The structure to hold the Graph properties.
Definition Global.h:264
The structure to hold the edge properties.
Definition Global.h:256
Parent structure to store common properties for all graph vertices.
Definition Global.h:234

Using directive for graphml graph type (adjacency list)

Definition at line 54 of file GraphManager.h.

◆ VertexIterator

template<typename VertexProperties >
using GraphManager< VertexProperties >::VertexIterator = typename boost::graph_traits<Graph>::vertex_iterator

Definition at line 58 of file GraphManager.h.

Member Function Documentation

◆ edges()

template<typename VertexProperties >
pair< typename GraphManager< VertexProperties >::EdgeIterator, typename GraphManager< VertexProperties >::EdgeIterator > GraphManager< VertexProperties >::edges ( ) const

Exposes the BGL Edge Iterators of the stored Graph.

Retrieves the edges of the graph.

Returns
a pair of EdgeIterators where first points to the beginning and second points to the end of the edges vector
A pair of EdgeIterators for the graph edges.

Definition at line 215 of file GraphManager.h.

◆ edgesSortByTarget()

template<typename VertexProperties >
const list< typename GraphManager< VertexProperties >::EdgeDescriptor > GraphManager< VertexProperties >::edgesSortByTarget ( ) const

Returns a list of EdgeDescriptors in ascending order by target vertexID.

Returns a list of EdgeDescriptors sorted by target vertexID.

Returns
List of EdgeDescriptors in ascending order by target vertexID
A sorted list of EdgeDescriptors.

Definition at line 272 of file GraphManager.h.

◆ getInstance()

template<typename VertexProperties >
static GraphManager & GraphManager< VertexProperties >::getInstance ( )
inlinestatic

Returns a single instance of the GraphManager.

Returns
The single instance of the GraphManager

Definition at line 63 of file GraphManager.h.

◆ numEdges()

template<typename VertexProperties >
size_t GraphManager< VertexProperties >::numEdges ( ) const

Retrieves the number of edges in the current graph.

Returns
The number of edges in the current graph
The number of edges.

Definition at line 297 of file GraphManager.h.

◆ numVertices()

template<typename VertexProperties >
size_t GraphManager< VertexProperties >::numVertices ( ) const

Retrieves the number of vertices in the current graph.

Returns
The number of vertices in the current graph
The number of vertices.

Definition at line 290 of file GraphManager.h.

◆ operator[]() [1/2]

template<typename VertexProperties >
VertexProperties & GraphManager< VertexProperties >::operator[] ( size_t vertex)

Direct access to the VertexProperties of a vertex descriptor.

Directly access the VertexProperties of a vertex descriptor.

Parameters
vertexthe vertex descriptor (index)
Returns
the VertexProperties of the vertex descriptor
Parameters
vertexThe vertex descriptor (index).
Returns
The VertexProperties of the vertex.

Definition at line 254 of file GraphManager.h.

◆ operator[]() [2/2]

template<typename VertexProperties >
const VertexProperties & GraphManager< VertexProperties >::operator[] ( size_t vertex) const

Direct access to the VertexProperties of a vertex descriptor.

Directly access the VertexProperties of a vertex descriptor (const).

Parameters
vertexthe vertex descriptor (index)
Returns
the VertexProperties of the vertex descriptor
Parameters
vertexThe vertex descriptor (index).
Returns
The VertexProperties of the vertex.

Definition at line 263 of file GraphManager.h.

◆ readGraph()

template<typename VertexProperties >
bool GraphManager< VertexProperties >::readGraph ( )

Loads a graph from a graphml file into a BGL graph.

Reads a graph from a GraphML file into a BGL graph.

Returns
The graph loaded as an adjacency list
True if the graph was successfully read, false otherwise.

Definition at line 176 of file GraphManager.h.

◆ registerProperty()

template<typename VertexProperties >
template<class Property >
void GraphManager< VertexProperties >::registerProperty ( const string & propName,
Property property )
inline

Registers a graph property with its attribute name in the graphml file.

Note: We are passing a pointer to a data member of the Struct that will hold the property. The BGL will use this when loading the graphML file. Reference: https://www.studytonight.com/cpp/pointer-to-members.php

Template Parameters
PropertyPointer to a Struct data member that will hold the property
Parameters
propNameThe attribute name inthe graphml file
propertyPointer to the property to be registered

Definition at line 82 of file GraphManager.h.

◆ setFilePath()

template<typename VertexProperties >
void GraphManager< VertexProperties >::setFilePath ( string filePath)

Set the path for the graphML File to be read.

Sets the file path for the graphML file.

Parameters
filePathThe absolute path to the graphML file
filePathThe absolute path to the graphML file.

Definition at line 169 of file GraphManager.h.

◆ source()

template<typename VertexProperties >
size_t GraphManager< VertexProperties >::source ( const EdgeDescriptor & edge) const

Retrieves the source vertex index for the given Edge.

Retrieves the source vertex of a given edge.

Parameters
edgethe EdgeDescriptor
Returns
the source vertex index for the given Edge
Parameters
edgeThe edge descriptor.
Returns
The source vertex index.

Definition at line 224 of file GraphManager.h.

◆ target()

template<typename VertexProperties >
size_t GraphManager< VertexProperties >::target ( const EdgeDescriptor & edge) const

Retrieves the target vertex index for the given Edge.

Retrieves the target vertex of a given edge.

Parameters
edgethe EdgeDescriptor
Returns
the target vertex index for the given Edge
Parameters
edgeThe edge descriptor.
Returns
The target vertex index.

Definition at line 234 of file GraphManager.h.

◆ vertices()

template<typename VertexProperties >
pair< typename GraphManager< VertexProperties >::VertexIterator, typename GraphManager< VertexProperties >::VertexIterator > GraphManager< VertexProperties >::vertices ( )

Exposes the BGL Vertex Iterators of the stored Graph.

Retrieves the vertices of the graph.

Returns
a pair of VertexIterators where first points to the beginning and second points to the end of the vertices vector
A pair of VertexIterators for the graph vertices.

Definition at line 205 of file GraphManager.h.

◆ weight()

template<typename VertexProperties >
double GraphManager< VertexProperties >::weight ( const EdgeDescriptor & edge) const

Retrieves the weight of an edge.

Parameters
edgethe EdgeDescriptor
Returns
the weight of the given edge

Definition at line 244 of file GraphManager.h.


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