votca 2024-dev
Loading...
Searching...
No Matches
reducededge.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_REDUCEDEDGE_H
21#define VOTCA_TOOLS_REDUCEDEDGE_H
22
23// Local VOTCA includes
24#include "edge.h"
25
26namespace votca {
27namespace tools {
28
49class ReducedEdge : public Edge {
50
51 public:
52 ReducedEdge() = default;
55 ReducedEdge(std::vector<Index> vertices);
56
57 ReducedEdge(Index vertex1, Index vertex2)
58 : ReducedEdge(std::vector<Index>{vertex1, vertex2}){};
59
61 std::vector<Index> getChain() const { return vertices_; }
62
77 bool vertexExistInChain(const int& vertex) const;
78
97 std::vector<Edge> expand() const;
98
100 bool operator==(const ReducedEdge& edge) const;
102 bool operator!=(const ReducedEdge& edge) const;
103
133 bool operator<(const ReducedEdge& edge) const;
134 bool operator>(const ReducedEdge& edge) const;
135 bool operator<=(const ReducedEdge& edge) const;
136 bool operator>=(const ReducedEdge& edge) const;
137
138 using Edge::operator!=;
139 using Edge::operator==;
140 using Edge::operator<;
141 using Edge::operator>;
142 using Edge::operator<=;
143 using Edge::operator>=;
144
146 friend std::ostream& operator<<(std::ostream& os, const ReducedEdge& edge);
147};
148
149} // namespace tools
150} // namespace votca
151
153namespace std {
154template <>
155class hash<votca::tools::ReducedEdge> {
156 public:
157 size_t operator()(const votca::tools::ReducedEdge& ed) const {
158 size_t value = 1;
159 auto vertices = ed.getChain();
160 for (auto vertex : vertices) {
161 value += hash<size_t>()(static_cast<size_t>(vertex)) ^ value;
162 }
163 return value;
164 }
165};
166} // namespace std
167#endif // VOTCA_TOOLS_REDUCEDEDGE_H
size_t operator()(const votca::tools::ReducedEdge &ed) const
Connects to vertices.
Definition edge.h:42
std::vector< Index > vertices_
Definition edge.h:44
Connects two vertices, also stores the vertices between the endpoints.
Definition reducededge.h:49
bool operator!=(const ReducedEdge &edge) const
Checks if Edges are not equivalent.
std::vector< Index > getChain() const
Returns a vector of vertices that constitute the edge.
Definition reducededge.h:61
std::vector< Edge > expand() const
Method expands the edge into its parts.
bool operator>=(const ReducedEdge &edge) const
bool vertexExistInChain(const int &vertex) const
Provided a vertex this method will determine if it exists within the reduced edge.
ReducedEdge(Index vertex1, Index vertex2)
Definition reducededge.h:57
friend std::ostream & operator<<(std::ostream &os, const ReducedEdge &edge)
Print the contents of the edge.
bool operator==(const ReducedEdge &edge) const
Checks if Edges are equivalent.
bool operator<=(const ReducedEdge &edge) const
bool operator>(const ReducedEdge &edge) const
bool operator<(const ReducedEdge &edge) const
STL namespace.
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26