votca
2024.2-dev
Loading...
Searching...
No Matches
tools
src
libtools
graph_df_visitor.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
// Standard includes
21
#include <algorithm>
22
23
// Local VOTCA includes
24
#include "
votca/tools/edge.h
"
25
#include "
votca/tools/graph.h
"
26
#include "
votca/tools/graph_df_visitor.h
"
27
#include "
votca/tools/graphnode.h
"
28
29
using namespace
std
;
30
31
namespace
votca
{
32
namespace
tools {
33
34
bool
Graph_DF_Visitor::queEmpty
()
const
{
return
edge_list_
.empty(); }
35
36
Edge
Graph_DF_Visitor::getEdge_
() {
37
Edge
ed =
edge_list_
.back();
38
edge_list_
.pop_back();
39
return
ed;
40
}
41
42
// Add edges to be explored
43
void
Graph_DF_Visitor::addEdges_
(
const
Graph
& g,
Index
vertex) {
44
auto
eds = g.
getNeighEdges
(vertex);
45
if
(
edge_list_
.empty()) {
46
// If first edges to be added
47
for
(
auto
ed : eds) {
48
Index
neigh_vert = ed.getOtherEndPoint(vertex);
49
if
(
explored_
.count(neigh_vert) == 0) {
50
edge_list_
.push_back(ed);
51
}
52
}
53
}
else
{
54
for
(
const
auto
& ed : eds) {
55
Index
neigh_vert = ed.getOtherEndPoint(vertex);
56
if
(
explored_
.count(neigh_vert) == 0) {
57
edge_list_
.push_back(ed);
58
}
else
{
59
// Check if edge has already been added earlier in the queue
60
// if so we wil move it to the end
61
list<Edge>::iterator edge_found_iterator =
62
find(
edge_list_
.begin(),
edge_list_
.end(), ed);
63
if
(edge_found_iterator !=
edge_list_
.end()) {
64
// Move the edge to the back if it was stored earlier on.
65
edge_list_
.splice(
edge_list_
.end(),
edge_list_
, edge_found_iterator);
66
}
67
}
68
}
69
}
70
}
71
}
// namespace tools
72
}
// namespace votca
votca::tools::Edge
Connects to vertices.
Definition
edge.h:42
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_DF_Visitor::queEmpty
bool queEmpty() const override
Definition
graph_df_visitor.cc:34
votca::tools::Graph_DF_Visitor::addEdges_
void addEdges_(const Graph &g, Index vertex) override
Definition
graph_df_visitor.cc:43
votca::tools::Graph_DF_Visitor::getEdge_
Edge getEdge_() override
Definition
graph_df_visitor.cc:36
votca::tools::Graph_DF_Visitor::edge_list_
std::list< Edge > edge_list_
Definition
graph_df_visitor.h:45
votca::tools::Graph
Definition
graph.h:43
votca::tools::Graph::getNeighEdges
std::vector< Edge > getNeighEdges(Index vertex) const
Returns all the edges in the graph connected to vertex vertex
Definition
graph.h:106
edge.h
graph.h
graph_df_visitor.h
graphnode.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