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 |
|
---|
17 | #include <map>
|
---|
18 | #include <stddef.h>
|
---|
19 | #include <vector>
|
---|
20 |
|
---|
21 | #include "types.hpp"
|
---|
22 |
|
---|
23 | struct BoostGraphCreator;
|
---|
24 |
|
---|
25 | /** This struct performs a BFS on a given boost::graph and finds
|
---|
26 | * all nodes, i.e. atoms, up to a given limit.
|
---|
27 | */
|
---|
28 | struct BreadthFirstSearchGatherer
|
---|
29 | {
|
---|
30 | //!> typedef for the distance map to the obtained atomic id set.
|
---|
31 | typedef std::map<atomId_t, size_t> distance_map_t;
|
---|
32 |
|
---|
33 | /** Cstor of class BreadthFirstSearchGatherer.
|
---|
34 | *
|
---|
35 | * \param _graph graph to work on
|
---|
36 | */
|
---|
37 | BreadthFirstSearchGatherer(BoostGraphCreator &_graph);
|
---|
38 |
|
---|
39 | /** Discovers all nodes from the given \a _discoverfrom and returns
|
---|
40 | * the vector of ids.
|
---|
41 | *
|
---|
42 | * \param _discoverfrom node to start BFS from
|
---|
43 | * \param _max_distance max distance to discover (negative means all)
|
---|
44 | */
|
---|
45 | std::vector<atomId_t> operator()(
|
---|
46 | const atomId_t &_discoverfrom,
|
---|
47 | const int &_max_distance = -1);
|
---|
48 |
|
---|
49 | /** Getter to the internal map of distances of each atomic id.
|
---|
50 | *
|
---|
51 | * \return ref to distance map
|
---|
52 | */
|
---|
53 | const distance_map_t& getDistances() const
|
---|
54 | { return distance_map; }
|
---|
55 |
|
---|
56 | private:
|
---|
57 | //!> typedef for a vector of BFS discovery distances
|
---|
58 | typedef std::vector<size_t> distances_t;
|
---|
59 |
|
---|
60 | //!> BFS discovery distances for the returned atomic id set
|
---|
61 | distance_map_t distance_map;
|
---|
62 |
|
---|
63 | //!> graph to operate on
|
---|
64 | BoostGraphCreator &BGcreator;
|
---|
65 | };
|
---|
66 |
|
---|
67 |
|
---|
68 | #endif /* GRAPH_BREADTHFIRSTSEARCHGATHERER_HPP_ */
|
---|