votca
2024.2-dev
Loading...
Searching...
No Matches
tools
src
libtools
graphdistvisitor.cc
Go to the documentation of this file.
1
/*
2
* Copyright 2009-2020 The VOTCA Development Team
3
* (http://www.votca.org)
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License")
6
*
7
* You may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
9
*
10
* http://www.apache.org/licenses/LICENSE-2.0
11
*
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
17
*
18
*/
19
20
// Local VOTCA includes
21
#include "
votca/tools/graphdistvisitor.h
"
22
#include "
votca/tools/edge.h
"
23
#include "
votca/tools/graph.h
"
24
#include "
votca/tools/graph_bf_visitor.h
"
25
#include "
votca/tools/graphnode.h
"
26
#include "
votca/tools/graphvisitor.h
"
27
28
using namespace
std
;
29
30
namespace
votca
{
31
namespace
tools {
32
33
// Add the distance to the node that has not yet been explored
34
void
GraphDistVisitor::exploreNode
(pair<Index, GraphNode>& p_gn,
Graph
& g,
35
Edge
ed) {
36
// Determine if the node has already been explored
37
Index
vertex = p_gn.first;
38
if
(vertex ==
startingVertex_
) {
39
p_gn.second.int_vals_[
"Dist"
] = 0;
40
p_gn.second.initStringId_();
41
// Update the graph with new graph node
42
g.
setNode
(p_gn);
43
}
else
{
44
// Node has not been explored
45
if
(
explored_
.count(vertex) == 0) {
46
Index
prev_vertex = ed.
getOtherEndPoint
(vertex);
47
GraphNode
gn_prev = g.
getNode
(prev_vertex);
48
p_gn.second.int_vals_[
"Dist"
] = gn_prev.
int_vals_
[
"Dist"
] + 1;
49
p_gn.second.initStringId_();
50
g.
setNode
(p_gn);
51
}
52
}
53
// Ensure the graph node is set to explored
54
GraphVisitor::exploreNode
(p_gn, g);
55
}
56
}
// namespace tools
57
}
// namespace votca
votca::tools::Edge
Connects to vertices.
Definition
edge.h:42
votca::tools::Edge::getOtherEndPoint
Index getOtherEndPoint(Index ver) const
Given one of the integers in the edge the other will be output.
Definition
edge.cc:37
votca::tools::GraphDistVisitor::exploreNode
void exploreNode(std::pair< Index, GraphNode > &p_gn, Graph &g, Edge ed=DUMMY_EDGE) override
Definition
graphdistvisitor.cc:34
votca::tools::GraphNode
A graph node that will take a variety of different values.
Definition
graphnode.h:46
votca::tools::GraphNode::int_vals_
std::unordered_map< std::string, Index > int_vals_
Definition
graphnode.h:49
votca::tools::GraphVisitor::startingVertex_
Index startingVertex_
The vertex the visitor started on.
Definition
graphvisitor.h:58
votca::tools::GraphVisitor::exploreNode
virtual void exploreNode(std::pair< Index, GraphNode > &vertex_and_node, Graph &graph, Edge edge=DUMMY_EDGE)
Edge(0,0) is a dummy value.
Definition
graphvisitor.cc:39
votca::tools::GraphVisitor::explored_
std::set< Index > explored_
set containing all the vertix ids that have been explored
Definition
graphvisitor.h:55
votca::tools::Graph
Definition
graph.h:43
votca::tools::Graph::getNode
GraphNode getNode(const Index vertex) const
Return a copy of the graph node at vertex 'vert'.
Definition
graph.cc:97
votca::tools::Graph::setNode
void setNode(Index vertex, GraphNode &graph_node)
set the Node associated with vertex 'vert'
Definition
graph.cc:87
edge.h
graph.h
graph_bf_visitor.h
graphdistvisitor.h
graphnode.h
graphvisitor.h
std
STL namespace.
votca
base class for all analysis tools
Definition
basebead.h:33
votca::Index
Eigen::Index Index
Definition
types.h:26
Generated by
1.12.0