votca 2024-dev
Loading...
Searching...
No Matches
edge.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#include <iostream>
23#include <vector>
24
25// Local VOTCA includes
26#include "votca/tools/edge.h"
27
28namespace votca {
29namespace tools {
30
31using namespace std;
32
34 vertices_ = vector<Index>{min({ID1, ID2}), max({ID1, ID2})};
35}
36
38 if (ver == vertices_.front()) {
39 return vertices_.back();
40 } else {
41 return vertices_.front();
42 }
43}
44
45bool Edge::contains(Index ID) const {
46 return (vertices_.front() == ID || vertices_.back() == ID);
47}
48
49bool Edge::operator==(const Edge& ed) const {
50 if (this->vertices_.front() == ed.vertices_.front() &&
51 this->vertices_.back() == ed.vertices_.back()) {
52 return true;
53 }
54 if (this->vertices_.back() == ed.vertices_.front() &&
55 this->vertices_.front() == ed.vertices_.back()) {
56 return true;
57 }
58 return false;
59}
60
61bool Edge::operator!=(const Edge& ed) const { return !(*this == ed); }
62
63bool Edge::operator<(const Edge& ed) const {
64 if (this->vertices_.front() < ed.vertices_.front()) {
65 return true;
66 }
67 if (this->vertices_.front() > ed.vertices_.front()) {
68 return false;
69 }
70 if (this->vertices_.back() < ed.vertices_.back()) {
71 return true;
72 }
73 return false;
74}
75
76bool Edge::operator<=(const Edge& ed) const {
77 return (*this < ed || *this == ed);
78}
79
80bool Edge::operator>(const Edge& ed) const { return !(*this <= ed); }
81
82bool Edge::operator>=(const Edge& ed) const { return !(*this < ed); }
84ostream& operator<<(ostream& os, const Edge& ed) {
85 os << "Vertices" << endl;
86 os << ed.vertices_.front() << " " << ed.vertices_.back() << endl;
87 return os;
88}
89} // namespace tools
90} // namespace votca
Connects to vertices.
Definition edge.h:42
virtual bool operator<=(const Edge &ed) const
Definition edge.cc:76
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 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
STL namespace.
std::ostream & operator<<(std::ostream &out, const Correlate &c)
Definition correlate.h:53
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26