/* * BreadthFirstSearchGatherer.hpp * * Created on: May 17, 2017 * Author: heber */ #ifndef GRAPH_BREADTHFIRSTSEARCHGATHERER_HPP_ #define GRAPH_BREADTHFIRSTSEARCHGATHERER_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include "types.hpp" class bond; struct BoostGraphCreator; /** This struct performs a BFS on a given boost::graph and finds * all nodes, i.e. atoms, up to a given limit. */ struct BreadthFirstSearchGatherer { //!> typedef for the distance map to the obtained atomic id set. typedef std::map distance_map_t; /** Cstor of class BreadthFirstSearchGatherer. * * \param _graph graph to work on */ BreadthFirstSearchGatherer(BoostGraphCreator &_graph); /** Discovers all nodes from the given \a _discoverfrom and returns * the vector of ids. * * \param _discoverfrom node to start BFS from * \param _max_distance max distance to discover (negative means all) */ std::vector operator()( const atomId_t &_discoverfrom, const int &_max_distance = -1); /** Getter to the internal map of distances of each atomic id. * * \return ref to distance map */ const distance_map_t& getDistances() const { return distance_map; } /** This is a default predicate which returns always true. * * \return true */ static bool AlwaysTruePredicate(const bond &_bond) { return true; } private: //!> typedef for a vector of BFS discovery distances typedef std::vector distances_t; //!> BFS discovery distances for the returned atomic id set distance_map_t distance_map; //!> graph to operate on BoostGraphCreator &BGcreator; }; #endif /* GRAPH_BREADTHFIRSTSEARCHGATHERER_HPP_ */