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

Contains a graph that consits of vertices with degree of 1 or greater than 3. More...

#include <reducedgraph.h>

Inheritance diagram for votca::tools::ReducedGraph:
Collaboration diagram for votca::tools::ReducedGraph:

Public Member Functions

 ReducedGraph ()=default
 
 ReducedGraph (std::vector< ReducedEdge > reduced_edges)
 
 ReducedGraph (std::vector< ReducedEdge > reduced_edges, std::unordered_map< Index, GraphNode > nodes)
 
std::vector< std::vector< Edge > > expandEdge (const Edge &edge) const
 Allows one to return all edges connecting two vertices of the reduced graph.
 
Graph expandGraph () const
 This method will return a copy of the full graph.
 
std::vector< std::pair< Index, GraphNode > > getNodes (void) const override
 Gets the junctions in the graph.
 
std::vector< IndexgetVerticesDegree (Index degree) const override
 Returns all the vertices with degree specified by degree
 
- Public Member Functions inherited from votca::tools::Graph
 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'.
 
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
 
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)
 

Private Member Functions

void init_ (std::vector< ReducedEdge > reduced_edges, std::unordered_map< Index, GraphNode > nodes)
 

Private Attributes

std::unordered_map< Edge, std::vector< std::vector< Index > > > expanded_edges_
 
std::set< Indexjunctions_
 

Friends

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

Additional Inherited Members

- Protected Member Functions inherited from votca::tools::Graph
void calcId_ ()
 Calculate the id of the graph.
 
- Protected Attributes inherited from votca::tools::Graph
EdgeContainer edge_container_
 
std::unordered_map< Index, GraphNodenodes_
 
std::string id_
 

Detailed Description

Contains a graph that consits of vertices with degree of 1 or greater than 3.

The point of this class is to reduce the computational complexity of a regular graph. This is achieved by removing any vertices with degree 2. For example a graph:

1 - 2 - 3 - 4 - 5 - 9 | | | 6 - 7 8

Would be reduced to

1 - 2 - 3 - 4 - 9 | _ | | 8

Notice that the vertices 5, 6 and 7 have been removed, there also exist two edges connecting 2 to 3. The reduced graph still contains all the information associated with the full graph but when used with graph algorithms only the vertices and nodes associated with the reduced graph are used.

Definition at line 55 of file reducedgraph.h.

Constructor & Destructor Documentation

◆ ReducedGraph() [1/3]

votca::tools::ReducedGraph::ReducedGraph ( )
default

◆ ReducedGraph() [2/3]

votca::tools::ReducedGraph::ReducedGraph ( std::vector< ReducedEdge > reduced_edges)

Definition at line 303 of file reducedgraph.cc.

◆ ReducedGraph() [3/3]

votca::tools::ReducedGraph::ReducedGraph ( std::vector< ReducedEdge > reduced_edges,
std::unordered_map< Index, GraphNode > nodes )

Definition at line 314 of file reducedgraph.cc.

Member Function Documentation

◆ expandEdge()

vector< vector< Edge > > votca::tools::ReducedGraph::expandEdge ( const Edge & edge) const

Allows one to return all edges connecting two vertices of the reduced graph.

In this case if edge (2,3) were passed in:

1 - 2 - 3 - 4 - 5 - 9 | | | 6 - 7 8

Reduced Graph

1 - 2 - 3 - 4 - 9 | _ | | 8

The following vectors would be returned

vec_edges = expandEdge(Edge(2,3)); vec_edges.at(0); // 2-3 vec_edges.at(1); // 2-6, 6-7, 7-3

Definition at line 351 of file reducedgraph.cc.

◆ expandGraph()

Graph votca::tools::ReducedGraph::expandGraph ( ) const

This method will return a copy of the full graph.

Definition at line 338 of file reducedgraph.cc.

◆ getNodes()

vector< pair< Index, GraphNode > > votca::tools::ReducedGraph::getNodes ( void ) const
overridevirtual

Gets the junctions in the graph.

This method is different from the regular graph method as it must account for edges that loop around and refer to the same vertex.

E.g.

  • - | |
  • -1 - 2 - 3

This is composed of the edges: 1, 1 1, 2 2, 3

Thus 1 is the only junction that exists in the reduced graph

Reimplemented from votca::tools::Graph.

Definition at line 365 of file reducedgraph.cc.

◆ getVerticesDegree()

vector< Index > votca::tools::ReducedGraph::getVerticesDegree ( Index degree) const
overridevirtual

Returns all the vertices with degree specified by degree

Reimplemented from votca::tools::Graph.

Definition at line 383 of file reducedgraph.cc.

◆ init_()

void votca::tools::ReducedGraph::init_ ( std::vector< ReducedEdge > reduced_edges,
std::unordered_map< Index, GraphNode > nodes )
private

Definition at line 264 of file reducedgraph.cc.

Friends And Related Symbol Documentation

◆ operator<<

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

Definition at line 398 of file reducedgraph.cc.

Member Data Documentation

◆ expanded_edges_

std::unordered_map<Edge, std::vector<std::vector<Index> > > votca::tools::ReducedGraph::expanded_edges_
private

The inherited graph stores all the edges describing the graph after it has been reduced. However, in order to expand the edges back to the vertices that make them up a second variable is needed.

E.g.

1 - 2 - 4 - 9 - 5

The edge

1 - 5

Would be stored in the parent graph datastructure, the rest of the vertices are stored as a vector in the expanded_edges_ object

Definition at line 73 of file reducedgraph.h.

◆ junctions_

std::set<Index> votca::tools::ReducedGraph::junctions_
private

Definition at line 79 of file reducedgraph.h.


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