source: src/Graph/BreadthFirstSearchGatherer.hpp@ d619f5c

ForceAnnealing_oldresults IndependentFragmentGrids_IntegrationTest
Last change on this file since d619f5c was 6e1c14, checked in by Frederik Heber <frederik.heber@…>, 8 years ago

BreadthFirstSearchGatherer::getDistances() added.

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[6e5907]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
[6e1c14]17#include <map>
[6e5907]18#include <stddef.h>
19#include <vector>
20
21#include "types.hpp"
22
23struct 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 */
28struct BreadthFirstSearchGatherer
29{
[6e1c14]30 //!> typedef for the distance map to the obtained atomic id set.
31 typedef std::map<atomId_t, size_t> distance_map_t;
32
[6e5907]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.
[9b5fa6]41 *
42 * \param _discoverfrom node to start BFS from
43 * \param _max_distance max distance to discover (negative means all)
[6e5907]44 */
[9b5fa6]45 std::vector<atomId_t> operator()(
46 const atomId_t &_discoverfrom,
47 const int &_max_distance = -1);
[6e5907]48
[6e1c14]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
[6e5907]56private:
[6e1c14]57 //!> typedef for a vector of BFS discovery distances
[6e5907]58 typedef std::vector<size_t> distances_t;
59
[6e1c14]60 //!> BFS discovery distances for the returned atomic id set
61 distance_map_t distance_map;
62
[6e5907]63 //!> graph to operate on
64 BoostGraphCreator &BGcreator;
65};
66
67
68#endif /* GRAPH_BREADTHFIRSTSEARCHGATHERER_HPP_ */
Note: See TracBrowser for help on using the repository browser.