/* * SubgraphEdge.hpp * * Created on: Oct 3, 2016 * Author: heber */ #ifndef FUNCTIONAPPROXIMATION_SUBGRAPH_SUBGRAPHEDGE_HPP_ #define FUNCTIONAPPROXIMATION_SUBGRAPH_SUBGRAPHEDGE_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif /** This class represents a single edge in a PotentialGraph. * * Each edge contains two indices and two types. */ class SubgraphEdge { public: //!> typedef for the two indices of the edge typedef std::pair indices_t; //!> typedef for the underlying type of the particle typedef unsigned int ParticleType_t; //!> typedef for the two particle types of the argument typedef std::pair types_t; /** Default constructor for class SubgraphEdge. * */ SubgraphEdge() : indices( std::make_pair(0,1) ), types( std::make_pair(0,0) ) {} /** Constructor for class SubgraphEdge. * * \param _indices pair of indices associated with the \a _distance * \param _types pair of particle type */ SubgraphEdge(const indices_t &_indices, const types_t &_types) : indices( _indices ), types( _types ) {} /** Dstor of class SubgraphEdge. * */ virtual ~SubgraphEdge() {} /** Comparator with respect to the pair of types. * * \note We'll have this as static function to allow usage in e.g. STL's sort. * * \param one first edge * \param other other edge to compare to \a one to * \return true - first type is less or if equal, second type is less, else */ bool static TypeComparator(const SubgraphEdge &one, const SubgraphEdge &other) { if (one.types.first < other.types.first) return true; else if (one.types.first > other.types.first) return false; else return one.types.second < other.types.second; } /** Less comparator for SubgraphEdge. * * @param other other edge to compare to * @return true - this edge is less than \a other, false - else */ bool operator<(const SubgraphEdge &other) const { if (types.first < other.types.first) return true; else if (types.first > other.types.first) return false; else if (types.second < other.types.second) return true; else if (types.second > other.types.second) return false; else { if (indices.first < other.indices.first) return true; else if (indices.first > other.indices.first) return false; else return indices.second < other.indices.second; } } /** Equality operator for SubgraphEdge. * * \note This compares only types and indices. * * @param other other edge to compare to * @return true - this edge is equal to \a other, false - else */ bool operator==(const SubgraphEdge &other) const { if (types.first != other.types.first) return false; else if (types.second != other.types.second) return false; if (indices.first != other.indices.first) return false; else if (indices.second != other.indices.second) return false; else return true; } //!> indices between which the distance is given indices_t indices; //!> indices between which the distance is given types_t types; }; #endif /* FUNCTIONAPPROXIMATION_SUBGRAPH_SUBGRAPHEDGE_HPP_ */