votca 2024-dev
Loading...
Searching...
No Matches
edge.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#ifndef VOTCA_TOOLS_EDGE_H
20#define VOTCA_TOOLS_EDGE_H
21
22// Standard includes
23#include <iostream>
24#include <limits>
25#include <utility>
26#include <vector>
27
28// Local VOTCA includes
29#include "types.h"
30
31namespace votca {
32namespace tools {
33
42class Edge {
43 protected:
44 std::vector<Index> vertices_;
45
46 public:
47 Edge() = default;
48 virtual ~Edge() = default;
51 Edge(Index ID1, Index ID2);
53 Index getOtherEndPoint(Index ver) const;
55 Index getEndPoint1() const { return vertices_.front(); }
57 Index getEndPoint2() const { return vertices_.back(); }
58
65 bool loop() const { return vertices_.front() == vertices_.back(); }
66
68 bool contains(Index ID) const;
70 virtual bool operator==(const Edge& ed) const;
72 virtual bool operator!=(const Edge& ed) const;
73
82 virtual bool operator<(const Edge& ed) const;
83 virtual bool operator>(const Edge& ed) const;
84 virtual bool operator<=(const Edge& ed) const;
85 virtual bool operator>=(const Edge& ed) const;
86
88 friend std::ostream& operator<<(std::ostream& os, const Edge& ed);
89};
90
91// Value used as a dummy object
92const Edge DUMMY_EDGE(std::numeric_limits<Index>::max(),
93 std::numeric_limits<Index>::max());
94} // namespace tools
95} // namespace votca
96
98namespace std {
99template <>
100class hash<votca::tools::Edge> {
101 public:
102 size_t operator()(const votca::tools::Edge& ed) const {
103 return hash<votca::Index>()(ed.getEndPoint1()) ^
104 hash<votca::Index>()(ed.getEndPoint2());
105 }
106};
107} // namespace std
108#endif // VOTCA_TOOLS_EDGE_H
size_t operator()(const votca::tools::Edge &ed) const
Definition edge.h:102
Connects to vertices.
Definition edge.h:42
virtual bool operator<=(const Edge &ed) const
Definition edge.cc:76
virtual ~Edge()=default
std::vector< Index > vertices_
Definition edge.h:44
virtual bool operator==(const Edge &ed) const
Checks if Edges are equivalent.
Definition edge.cc:49
virtual bool operator!=(const Edge &ed) const
Checks if Edges are not equivalent.
Definition edge.cc:61
virtual bool operator>=(const Edge &ed) const
Definition edge.cc:82
virtual bool operator>(const Edge &ed) const
Definition edge.cc:80
Index getEndPoint1() const
grab the smaller integer
Definition edge.h:55
Index getEndPoint2() const
grab the larger integer
Definition edge.h:57
Index getOtherEndPoint(Index ver) const
Given one of the integers in the edge the other will be output.
Definition edge.cc:37
bool contains(Index ID) const
Determine if the edge contains the Index ID.
Definition edge.cc:45
virtual bool operator<(const Edge &ed) const
Definition edge.cc:63
bool loop() const
Checks to see if an edge loops back on itself.
Definition edge.h:65
friend std::ostream & operator<<(std::ostream &os, const Edge &ed)
Print the contents of the edge.
Definition edge.cc:84
STL namespace.
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