Changeset e3ec8a8 for src/Graph/BreadthFirstSearchGatherer.cpp
- Timestamp:
- Jul 12, 2017, 7:10:32 PM (8 years ago)
- Branches:
- Action_Thermostats, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Exclude_Hydrogens_annealWithBondGraph, Fix_Verbose_Codepatterns, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, Recreated_GuiChecks, StoppableMakroAction, TremoloParser_IncreasedPrecision
- Children:
- 966ce7
- Parents:
- 0dc8bf2
- git-author:
- Frederik Heber <frederik.heber@…> (05/19/17 09:27:11)
- git-committer:
- Frederik Heber <frederik.heber@…> (07/12/17 19:10:32)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Graph/BreadthFirstSearchGatherer.cpp
r0dc8bf2 re3ec8a8 44 44 #include <boost/graph/breadth_first_search.hpp> 45 45 46 struct found_max_distance {}; // exception when doing limited BFS 47 46 48 /** 47 49 * I have no idea why this is so complicated with BGL ... … … 54 56 { 55 57 public: 56 distance_recorder(DistanceMap dist) : d(dist) {} 58 distance_recorder( 59 DistanceMap dist, 60 const int _max_distance) : d(dist), max_distance(_max_distance) {} 57 61 58 62 template <typename Edge, typename Graph> … … 62 66 } 63 67 68 template <typename Vertex, typename Graph> 69 void discover_vertex(Vertex u, const Graph &g) const { 70 if ((max_distance >= 0) && (d[u] >= max_distance)) 71 throw found_max_distance(); 72 } 73 64 74 private: 65 75 DistanceMap d; 76 const int max_distance; 66 77 }; 67 78 68 79 template <typename DistanceMap> 69 distance_recorder<DistanceMap> record_distance(DistanceMap d )80 distance_recorder<DistanceMap> record_distance(DistanceMap d, const size_t _max_distance) 70 81 { 71 return distance_recorder<DistanceMap>(d );82 return distance_recorder<DistanceMap>(d, _max_distance); 72 83 } 73 84 … … 76 87 {} 77 88 78 std::vector<atomId_t> BreadthFirstSearchGatherer::operator()(const atomId_t &_discoverfrom) 89 std::vector<atomId_t> BreadthFirstSearchGatherer::operator()( 90 const atomId_t &_discoverfrom, 91 const int &_max_distance) 79 92 { 80 93 std::vector<atomId_t> returnids; … … 86 99 const BoostGraphCreator::nodeId_t discoverfrom_nodeid = BGcreator.getNodeId(_discoverfrom); 87 100 distances[ boost::vertex(discoverfrom_nodeid, BGgraph) ] = 0; 88 boost::breadth_first_search( 89 BGgraph, 90 boost::vertex(discoverfrom_nodeid, BGgraph), 91 boost::visitor(record_distance(&distances[0]))); 101 try { 102 boost::breadth_first_search( 103 BGgraph, 104 boost::vertex(discoverfrom_nodeid, BGgraph), 105 boost::visitor(record_distance(&distances[0], _max_distance))); 106 } catch (found_max_distance &e) { 107 // where are at discovery horizon 108 } 92 109 LOG(3, "DEBUG: From atom #" << _discoverfrom 93 110 << " BFS discovered the following distances " << distances);
Note:
See TracChangeset
for help on using the changeset viewer.