votca 2024.2-dev
|
Contains a graph that consits of vertices with degree of 1 or greater than 3. More...
#include <reducedgraph.h>
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< Index > | getVerticesDegree (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< Index > | getJunctions () 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< Index > | getNeighVertices (Index vertex) const |
std::string | getId () const |
Returns the id of graph. | |
virtual std::vector< Edge > | getEdges () |
Returns all the edges in the graph. | |
std::vector< Edge > | getNeighEdges (Index vertex) const |
Returns all the edges in the graph connected to vertex vertex | |
std::vector< Index > | getVertices () 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< Index > | junctions_ |
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, GraphNode > | nodes_ |
std::string | id_ |
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.
|
default |
votca::tools::ReducedGraph::ReducedGraph | ( | std::vector< ReducedEdge > | reduced_edges | ) |
Definition at line 303 of file reducedgraph.cc.
votca::tools::ReducedGraph::ReducedGraph | ( | std::vector< ReducedEdge > | reduced_edges, |
std::unordered_map< Index, GraphNode > | nodes ) |
Definition at line 314 of file reducedgraph.cc.
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.
Graph votca::tools::ReducedGraph::expandGraph | ( | ) | const |
This method will return a copy of the full graph.
Definition at line 338 of file reducedgraph.cc.
|
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.
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.
Returns all the vertices with degree specified by degree
Reimplemented from votca::tools::Graph.
Definition at line 383 of file reducedgraph.cc.
|
private |
Definition at line 264 of file reducedgraph.cc.
|
friend |
Definition at line 398 of file reducedgraph.cc.
|
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.
|
private |
Definition at line 79 of file reducedgraph.h.