votca 2024.2-dev
Loading...
Searching...
No Matches
votca::tools::Graph Class Reference

#include <graph.h>

Inheritance diagram for votca::tools::Graph:
Collaboration diagram for votca::tools::Graph:

Public Member Functions

 Graph ()
 
virtual ~Graph ()=default
 
 Graph (std::vector< Edge > edges, std::unordered_map< Index, GraphNode > nodes)
 
bool operator!= (const Graph &graph) const
 
bool operator== (const Graph &graph) const
 
std::vector< std::pair< Index, GraphNode > > getIsolatedNodes (void) const
 
std::vector< std::pair< Index, GraphNode > > getNeighNodes (Index vertex) const
 
void setNode (Index vertex, GraphNode &graph_node)
 set the Node associated with vertex 'vert'
 
void setNode (std::pair< Index, GraphNode > &id_and_node)
 
std::vector< IndexgetJunctions () const
 Gets all vertices with degree of 3 or greater.
 
GraphNode getNode (const Index vertex) const
 Return a copy of the graph node at vertex 'vert'.
 
virtual std::vector< std::pair< Index, GraphNode > > getNodes () const
 Return all the vertices and their graph nodes that are within the graph.
 
std::vector< IndexgetNeighVertices (Index vertex) const
 
std::string getId () const
 Returns the id of graph.
 
virtual std::vector< EdgegetEdges ()
 Returns all the edges in the graph.
 
std::vector< EdgegetNeighEdges (Index vertex) const
 Returns all the edges in the graph connected to vertex vertex
 
std::vector< IndexgetVertices () const
 Returns all the vertices in the graph.
 
Index getMaxDegree () const
 Finds the max degree of a vertex in the graph.
 
Index getDegree (Index vertex) const
 Calcualtes the degree, or number of edges connected to vertex vertex
 
virtual std::vector< IndexgetVerticesDegree (Index degree) const
 Returns all the vertices with degree specified by degree
 
bool vertexExist (Index vertex) const
 Determines if a vertex exists within the graph.
 
virtual bool edgeExist (const Edge &edge) const
 Determines if an edge is stored in the graph.
 
void clearNodes ()
 Remove contents of all nodes.
 
void copyNodes (Graph &graph)
 

Protected Member Functions

void calcId_ ()
 Calculate the id of the graph.
 

Protected Attributes

EdgeContainer edge_container_
 
std::unordered_map< Index, GraphNodenodes_
 
std::string id_
 

Friends

std::ostream & operator<< (std::ostream &os, const Graph graph)
 

Detailed Description

Definition at line 43 of file graph.h.

Constructor & Destructor Documentation

◆ Graph() [1/2]

votca::tools::Graph::Graph ( )
inline

Definition at line 58 of file graph.h.

◆ ~Graph()

virtual votca::tools::Graph::~Graph ( )
virtualdefault

◆ Graph() [2/2]

votca::tools::Graph::Graph ( std::vector< Edge > edges,
std::unordered_map< Index, GraphNode > nodes )

Constructor

Parameters
edges- vector of edges where each edge is composed of two s (vertex ids) describing a link between the vertices
nodes- unordered_map where the key is the vertex id and the target is the graph node

Definition at line 45 of file graph.cc.

Member Function Documentation

◆ calcId_()

void votca::tools::Graph::calcId_ ( )
protected

Calculate the id of the graph.

Definition at line 129 of file graph.cc.

◆ clearNodes()

void votca::tools::Graph::clearNodes ( )

Remove contents of all nodes.

Definition at line 120 of file graph.cc.

◆ copyNodes()

void votca::tools::Graph::copyNodes ( Graph & graph)

Copies nodes from one graph to another. This should only be used in cases where the graph does not contain nodes before the copy.

Definition at line 122 of file graph.cc.

◆ edgeExist()

virtual bool votca::tools::Graph::edgeExist ( const Edge & edge) const
inlinevirtual

Determines if an edge is stored in the graph.

Definition at line 132 of file graph.h.

◆ getDegree()

Index votca::tools::Graph::getDegree ( Index vertex) const

Calcualtes the degree, or number of edges connected to vertex vertex

Definition at line 140 of file graph.cc.

◆ getEdges()

virtual std::vector< Edge > votca::tools::Graph::getEdges ( )
inlinevirtual

Returns all the edges in the graph.

Definition at line 103 of file graph.h.

◆ getId()

std::string votca::tools::Graph::getId ( ) const
inline

Returns the id of graph.

Definition at line 100 of file graph.h.

◆ getIsolatedNodes()

vector< pair< Index, GraphNode > > votca::tools::Graph::getIsolatedNodes ( void ) const

Find all the vertices that are isolated (not connected to any other vertex) and return them in a vector with their corresponding graph node.

Definition at line 65 of file graph.cc.

◆ getJunctions()

vector< Index > votca::tools::Graph::getJunctions ( ) const

Gets all vertices with degree of 3 or greater.

Definition at line 110 of file graph.cc.

◆ getMaxDegree()

Index votca::tools::Graph::getMaxDegree ( ) const
inline

Finds the max degree of a vertex in the graph.

Will look at each of the vertices and find the vertex with the most edges connected to it. It will count the number of edges this corresponds to the maximum degree of the graph.

Definition at line 120 of file graph.h.

◆ getNeighEdges()

std::vector< Edge > votca::tools::Graph::getNeighEdges ( Index vertex) const
inline

Returns all the edges in the graph connected to vertex vertex

Definition at line 106 of file graph.h.

◆ getNeighNodes()

vector< pair< Index, GraphNode > > votca::tools::Graph::getNeighNodes ( Index vertex) const

Returns a vector of the vertices and their graph nodes that are directly connected to the vertex 'vert'

Definition at line 76 of file graph.cc.

◆ getNeighVertices()

std::vector< Index > votca::tools::Graph::getNeighVertices ( Index vertex) const
inline

Returns all the vertices of the graph connected to vertex vert through an edge.

Definition at line 95 of file graph.h.

◆ getNode()

GraphNode votca::tools::Graph::getNode ( const Index vertex) const

Return a copy of the graph node at vertex 'vert'.

Definition at line 97 of file graph.cc.

◆ getNodes()

vector< pair< Index, GraphNode > > votca::tools::Graph::getNodes ( void ) const
virtual

Return all the vertices and their graph nodes that are within the graph.

Reimplemented in votca::tools::ReducedGraph.

Definition at line 102 of file graph.cc.

◆ getVertices()

vector< Index > votca::tools::Graph::getVertices ( ) const

Returns all the vertices in the graph.

Definition at line 166 of file graph.cc.

◆ getVerticesDegree()

vector< Index > votca::tools::Graph::getVerticesDegree ( Index degree) const
virtual

Returns all the vertices with degree specified by degree

Reimplemented in votca::tools::ReducedGraph.

Definition at line 162 of file graph.cc.

◆ operator!=()

bool votca::tools::Graph::operator!= ( const Graph & graph) const

Equivalence and non equivalence operators work by determine if the contents of each graph node in each of the graphs are the same.

Definition at line 59 of file graph.cc.

◆ operator==()

bool votca::tools::Graph::operator== ( const Graph & graph) const

Definition at line 63 of file graph.cc.

◆ setNode() [1/2]

void votca::tools::Graph::setNode ( Index vertex,
GraphNode & graph_node )

set the Node associated with vertex 'vert'

Definition at line 87 of file graph.cc.

◆ setNode() [2/2]

void votca::tools::Graph::setNode ( std::pair< Index, GraphNode > & id_and_node)

Definition at line 93 of file graph.cc.

◆ vertexExist()

bool votca::tools::Graph::vertexExist ( Index vertex) const

Determines if a vertex exists within the graph.

Definition at line 152 of file graph.cc.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const Graph graph )
friend

Definition at line 170 of file graph.cc.

Member Data Documentation

◆ edge_container_

EdgeContainer votca::tools::Graph::edge_container_
protected

Definition at line 45 of file graph.h.

◆ id_

std::string votca::tools::Graph::id_
protected

This is the id of the graph to graphs that contain the same content are considered equal

Definition at line 51 of file graph.h.

◆ nodes_

std::unordered_map<Index, GraphNode> votca::tools::Graph::nodes_
protected

Definition at line 47 of file graph.h.


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