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