votca 2024.2-dev
Loading...
Searching...
No Matches
graphvisitor.h
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#ifndef VOTCA_TOOLS_GRAPHVISITOR_H
21#define VOTCA_TOOLS_GRAPHVISITOR_H
22
23// Standard includes
24#include <set>
25#include <vector>
26
27// Local VOTCA includes
28#include "edge.h"
29#include "graphnode.h"
30
47namespace votca {
48namespace tools {
49
50class Graph;
51
53 protected:
55 std::set<Index> explored_;
56
59
61 virtual void addEdges_(const Graph& graph, Index vertex) = 0;
62 virtual Edge getEdge_() = 0;
64 public:
65 virtual void exploreNode(std::pair<Index, GraphNode>& vertex_and_node,
66 Graph& graph, Edge edge = DUMMY_EDGE);
67
68 GraphVisitor() = default;
69
71 std::vector<Index> getUnexploredVertex(const Edge edge) const;
72
76 virtual bool queEmpty() const;
77
78 void setStartingVertex(Index vertex) { startingVertex_ = vertex; }
80
82 void initialize(Graph& graph);
83
87 virtual void exec(Graph& graph, Edge edge);
88
92 Edge nextEdge(Graph graph);
93
95 std::set<Index> getExploredVertices() const;
96
98 bool vertexExplored(const Index vertex) const;
99};
100} // namespace tools
101} // namespace votca
102
103#endif // VOTCA_TOOLS_GRAPHVISITOR_H
Connects to vertices.
Definition edge.h:42
virtual void exec(Graph &graph, Edge edge)
std::vector< Index > getUnexploredVertex(const Edge edge) const
Determine which vertices in the edge, if any, have not been explored.
std::set< Index > getExploredVertices() const
Get the set of all the vertices that have been explored.
virtual Edge getEdge_()=0
Index startingVertex_
The vertex the visitor started on.
virtual bool queEmpty() const
virtual void addEdges_(const Graph &graph, Index vertex)=0
What is done to an individual graph node as it is explored.
virtual void exploreNode(std::pair< Index, GraphNode > &vertex_and_node, Graph &graph, Edge edge=DUMMY_EDGE)
Edge(0,0) is a dummy value.
void setStartingVertex(Index vertex)
Index getStartingVertex() const
Edge nextEdge(Graph graph)
std::set< Index > explored_
set containing all the vertix ids that have been explored
void initialize(Graph &graph)
Initialize the graphvisitor the default starting point is 0.
bool vertexExplored(const Index vertex) const
Has the vertex been explored.
const Edge DUMMY_EDGE(std::numeric_limits< Index >::max(), std::numeric_limits< Index >::max())
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26