| 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 | */
|
|---|
| 21 | class SubgraphEdge
|
|---|
| 22 | {
|
|---|
| 23 | public:
|
|---|
| 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 | /** Dstor of class SubgraphEdge.
|
|---|
| 51 | *
|
|---|
| 52 | */
|
|---|
| 53 | virtual ~SubgraphEdge() {}
|
|---|
| 54 |
|
|---|
| 55 | /** Comparator with respect to the pair of types.
|
|---|
| 56 | *
|
|---|
| 57 | * \note We'll have this as static function to allow usage in e.g. STL's sort.
|
|---|
| 58 | *
|
|---|
| 59 | * \param one first edge
|
|---|
| 60 | * \param other other edge to compare to \a one to
|
|---|
| 61 | * \return true - first type is less or if equal, second type is less, else
|
|---|
| 62 | */
|
|---|
| 63 | bool static TypeComparator(const SubgraphEdge &one, const SubgraphEdge &other)
|
|---|
| 64 | {
|
|---|
| 65 | if (one.types.first < other.types.first)
|
|---|
| 66 | return true;
|
|---|
| 67 | else if (one.types.first > other.types.first)
|
|---|
| 68 | return false;
|
|---|
| 69 | else
|
|---|
| 70 | return one.types.second < other.types.second;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | /** Less comparator for SubgraphEdge.
|
|---|
| 74 | *
|
|---|
| 75 | * @param other other edge to compare to
|
|---|
| 76 | * @return true - this edge is less than \a other, false - else
|
|---|
| 77 | */
|
|---|
| 78 | bool operator<(const SubgraphEdge &other) const
|
|---|
| 79 | {
|
|---|
| 80 | if (types.first < other.types.first)
|
|---|
| 81 | return true;
|
|---|
| 82 | else if (types.first > other.types.first)
|
|---|
| 83 | return false;
|
|---|
| 84 | else if (types.second < other.types.second)
|
|---|
| 85 | return true;
|
|---|
| 86 | else if (types.second > other.types.second)
|
|---|
| 87 | return false;
|
|---|
| 88 | else {
|
|---|
| 89 | if (indices.first < other.indices.first)
|
|---|
| 90 | return true;
|
|---|
| 91 | else if (indices.first > other.indices.first)
|
|---|
| 92 | return false;
|
|---|
| 93 | else
|
|---|
| 94 | return indices.second < other.indices.second;
|
|---|
| 95 | }
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | /** Equality operator for SubgraphEdge.
|
|---|
| 99 | *
|
|---|
| 100 | * \note This compares only types and indices.
|
|---|
| 101 | *
|
|---|
| 102 | * @param other other edge to compare to
|
|---|
| 103 | * @return true - this edge is equal to \a other, false - else
|
|---|
| 104 | */
|
|---|
| 105 | bool operator==(const SubgraphEdge &other) const
|
|---|
| 106 | {
|
|---|
| 107 | if (types.first != other.types.first)
|
|---|
| 108 | return false;
|
|---|
| 109 | else if (types.second != other.types.second)
|
|---|
| 110 | return false;
|
|---|
| 111 | if (indices.first != other.indices.first)
|
|---|
| 112 | return false;
|
|---|
| 113 | else if (indices.second != other.indices.second)
|
|---|
| 114 | return false;
|
|---|
| 115 | else
|
|---|
| 116 | return true;
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | //!> indices between which the distance is given
|
|---|
| 120 | indices_t indices;
|
|---|
| 121 | //!> indices between which the distance is given
|
|---|
| 122 | types_t types;
|
|---|
| 123 | };
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 | #endif /* FUNCTIONAPPROXIMATION_SUBGRAPH_SUBGRAPHEDGE_HPP_ */
|
|---|