| [df855a] | 1 | /* | 
|---|
|  | 2 | * BreadthFirstSearchGatherer.hpp | 
|---|
|  | 3 | * | 
|---|
|  | 4 | *  Created on: May 17, 2017 | 
|---|
|  | 5 | *      Author: heber | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
|  | 8 |  | 
|---|
|  | 9 | #ifndef GRAPH_BREADTHFIRSTSEARCHGATHERER_HPP_ | 
|---|
|  | 10 | #define GRAPH_BREADTHFIRSTSEARCHGATHERER_HPP_ | 
|---|
|  | 11 |  | 
|---|
|  | 12 | // include config.h | 
|---|
|  | 13 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 14 | #include <config.h> | 
|---|
|  | 15 | #endif | 
|---|
|  | 16 |  | 
|---|
| [53ef16e] | 17 | #include <map> | 
|---|
| [df855a] | 18 | #include <stddef.h> | 
|---|
|  | 19 | #include <vector> | 
|---|
|  | 20 |  | 
|---|
|  | 21 | #include "types.hpp" | 
|---|
|  | 22 |  | 
|---|
| [d07be9] | 23 | class bond; | 
|---|
| [df855a] | 24 | struct BoostGraphCreator; | 
|---|
|  | 25 |  | 
|---|
|  | 26 | /** This struct performs a BFS on a given boost::graph and finds | 
|---|
|  | 27 | * all nodes, i.e. atoms, up to a given limit. | 
|---|
|  | 28 | */ | 
|---|
|  | 29 | struct BreadthFirstSearchGatherer | 
|---|
|  | 30 | { | 
|---|
| [53ef16e] | 31 | //!> typedef for the distance map to the obtained atomic id set. | 
|---|
|  | 32 | typedef std::map<atomId_t, size_t> distance_map_t; | 
|---|
|  | 33 |  | 
|---|
| [df855a] | 34 | /** Cstor of class BreadthFirstSearchGatherer. | 
|---|
|  | 35 | * | 
|---|
|  | 36 | * \param _graph graph to work on | 
|---|
|  | 37 | */ | 
|---|
|  | 38 | BreadthFirstSearchGatherer(BoostGraphCreator &_graph); | 
|---|
|  | 39 |  | 
|---|
|  | 40 | /** Discovers all nodes from the given \a _discoverfrom and returns | 
|---|
|  | 41 | * the vector of ids. | 
|---|
| [060fc3] | 42 | * | 
|---|
|  | 43 | * \param _discoverfrom node to start BFS from | 
|---|
|  | 44 | * \param _max_distance max distance to discover (0 means all) | 
|---|
| [df855a] | 45 | */ | 
|---|
| [060fc3] | 46 | std::vector<atomId_t> operator()( | 
|---|
|  | 47 | const atomId_t &_discoverfrom, | 
|---|
|  | 48 | const size_t &_max_distance = 0); | 
|---|
| [df855a] | 49 |  | 
|---|
| [53ef16e] | 50 | /** Getter to the internal map of distances of each atomic id. | 
|---|
|  | 51 | * | 
|---|
|  | 52 | * \return ref to distance map | 
|---|
|  | 53 | */ | 
|---|
|  | 54 | const distance_map_t& getDistances() const | 
|---|
|  | 55 | { return distance_map; } | 
|---|
|  | 56 |  | 
|---|
| [d07be9] | 57 | /** This is a default predicate which returns always true. | 
|---|
|  | 58 | * | 
|---|
|  | 59 | * \return true | 
|---|
|  | 60 | */ | 
|---|
|  | 61 | static bool AlwaysTruePredicate(const bond &_bond) { return true; } | 
|---|
|  | 62 |  | 
|---|
| [df855a] | 63 | private: | 
|---|
| [53ef16e] | 64 | //!> typedef for a vector of BFS discovery distances | 
|---|
| [df855a] | 65 | typedef std::vector<size_t> distances_t; | 
|---|
|  | 66 |  | 
|---|
| [53ef16e] | 67 | //!> BFS discovery distances for the returned atomic id set | 
|---|
|  | 68 | distance_map_t distance_map; | 
|---|
|  | 69 |  | 
|---|
| [df855a] | 70 | //!> graph to operate on | 
|---|
|  | 71 | BoostGraphCreator &BGcreator; | 
|---|
|  | 72 | }; | 
|---|
|  | 73 |  | 
|---|
|  | 74 |  | 
|---|
|  | 75 | #endif /* GRAPH_BREADTHFIRSTSEARCHGATHERER_HPP_ */ | 
|---|