source: src/FunctionApproximation/Subgraph/SubgraphEdge.hpp@ 6aed89

Fix_FitPotential_needs_atomicnumbers
Last change on this file since 6aed89 was 6aed89, checked in by Frederik Heber <heber@…>, 9 years ago

tempcommit: Merge with 4266ebf9

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 * SubgraphEdge.hpp
3 *
4 * Created on: Oct 3, 2016
5 * Author: heber
6 */
7
8
9#ifndef FUNCTIONAPPROXIMATION_SUBGRAPH_SUBGRAPHEDGE_HPP_
10#define FUNCTIONAPPROXIMATION_SUBGRAPH_SUBGRAPHEDGE_HPP_
11
12// include config.h
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
17/** This class represents a single edge in a PotentialSubgraph.
18 *
19 * Each edge contains two indices and two types.
20 */
21class SubgraphEdge
22{
23public:
24
25 //!> typedef for the two indices of the edge
26 typedef std::pair<size_t, size_t> indices_t;
27 //!> typedef for the underlying type of the particle
28 typedef unsigned int ParticleType_t;
29 //!> typedef for the two particle types of the argument
30 typedef std::pair<ParticleType_t, ParticleType_t> types_t;
31
32 /** Default constructor for class SubgraphEdge.
33 *
34 */
35 SubgraphEdge() :
36 indices( std::make_pair(0,1) ),
37 types( std::make_pair(0,0) )
38 {}
39
40 /** Constructor for class SubgraphEdge.
41 *
42 * \param _indices pair of indices associated with the \a _distance
43 * \param _types pair of particle type
44 */
45 SubgraphEdge(const indices_t &_indices, const types_t &_types) :
46 indices( _indices ),
47 types( _types )
48 {}
49
50 ~SubgraphEdge();
51
52 /** Comparator with respect to the pair of types.
53 *
54 * \note We'll have this as static function to allow usage in e.g. STL's sort.
55 *
56 * \param one first edge
57 * \param other other edge to compare to \a one to
58 * \return true - first type is less or if equal, second type is less, else
59 */
60 bool static TypeComparator(const SubgraphEdge &one, const SubgraphEdge &other)
61 {
62 if (one.types.first < other.types.first)
63 return true;
64 else if (one.types.first > other.types.first)
65 return false;
66 else
67 return one.types.second < other.types.second;
68 }
69
70 /** Less comparator for SubgraphEdge.
71 *
72 * @param other other edge to compare to
73 * @return true - this edge is less than \a other, false - else
74 */
75 bool operator<(const SubgraphEdge &other) const
76 {
77 if (types.first < other.types.first)
78 return true;
79 else if (types.first > other.types.first)
80 return false;
81 else if (types.second < other.types.second)
82 return true;
83 else if (types.second > other.types.second)
84 return false;
85 else {
86 if (indices.first < other.indices.first)
87 return true;
88 else if (indices.first > other.indices.first)
89 return false;
90 else
91 return indices.second < other.indices.second;
92 }
93 }
94
95 /** Equality operator for SubgraphEdge.
96 *
97 * \note This compares only types and indices.
98 *
99 * @param other other edge to compare to
100 * @return true - this edge is equal to \a other, false - else
101 */
102 bool operator==(const SubgraphEdge &other) const
103 {
104 if (types.first != other.types.first)
105 return false;
106 else if (types.second != other.types.second)
107 return false;
108 if (indices.first != other.indices.first)
109 return false;
110 else if (indices.second != other.indices.second)
111 return false;
112 else
113 return true;
114 }
115
116 //!> indices between which the distance is given
117 indices_t indices;
118 //!> indices between which the distance is given
119 types_t types;
120};
121
122
123#endif /* FUNCTIONAPPROXIMATION_SUBGRAPH_SUBGRAPHEDGE_HPP_ */
Note: See TracBrowser for help on using the repository browser.