Changeset 1356af for src/Graph


Ignore:
Timestamp:
Jul 12, 2017, 7:10:32 PM (7 years ago)
Author:
Frederik Heber <frederik.heber@…>
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:
0dc8bf2
Parents:
6e5b8d
git-author:
Frederik Heber <frederik.heber@…> (05/19/17 09:25:53)
git-committer:
Frederik Heber <frederik.heber@…> (07/12/17 19:10:32)
Message:

Moved BoostGraphCreator::createFromRange into extra impl module.

Location:
src/Graph
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/Graph/BoostGraphCreator.cpp

    r6e5b8d r1356af  
    3939
    4040#include <algorithm>
    41 #include <iterator>
    4241
    4342#include "CodePatterns/Assert.hpp"
    44 #include "CodePatterns/Log.hpp"
    4543
    4644#include "Atom/atom.hpp"
    47 #include "Bond/bond.hpp"
    4845#include "molecule.hpp"
    4946
     
    105102}
    106103
    107 template <typename iterator>
    108 void BoostGraphCreator::createFromRange(
    109     const iterator &_begin,
    110     const iterator &_end,
    111     const size_t &_no_nodes,
    112     const predicate_t &_pred
    113     )
    114 {
    115   graph = UndirectedGraph();
    116 
    117   // add vertices
    118   for(iterator iter = _begin; iter != _end; ++iter) {
    119     const atomId_t atomid = (*iter)->getId();
    120     Vertex v = boost::add_vertex(atomid, graph);
    121     const atomId_t vertexname = boost::get(boost::get(boost::vertex_name, graph), v);
    122     const nodeId_t vertexindex = boost::get(boost::get(boost::vertex_index, graph), v);
    123     LOG(2, "DEBUG: Adding node " << vertexindex << " associated to atom #" << vertexname);
    124     ASSERT( vertexname == atomid,
    125         "BoostGraphCreator::createFromRange() - atomid "+toString(atomid)
    126         +" is not name of vertex "+toString(vertexname)+".");
    127     atomids_nodeids.insert( std::make_pair(vertexname, vertexindex) );
    128   }
    129 
    130   // add edges
    131   for(iterator iter = _begin; iter != _end; ++iter) {
    132     LOG(2, "DEBUG: Looking at atom " << (*iter)->getId());
    133     const BondList& ListOfBonds = (*iter)->getListOfBonds();
    134     for(BondList::const_iterator bonditer = ListOfBonds.begin();
    135         bonditer != ListOfBonds.end(); ++bonditer) {
    136       LOG(2, "DEBUG: Looking at bond " << *(*bonditer));
    137       const atomId_t leftid = (*bonditer)->leftatom->getId();
    138       const nodeId_t leftnodeid = getNodeId(leftid);
    139       const atomId_t rightid = (*bonditer)->rightatom->getId();
    140       const nodeId_t rightnodeid = getNodeId(rightid);
    141       // only pick each bond once and evaluate predicate
    142       if ((leftid == (*iter)->getId())
    143           && (_pred(**bonditer))) {
    144         LOG(3, "DEBUG: ADDING edge " << leftnodeid << " <-> " << rightnodeid);
    145         boost::add_edge(leftnodeid, rightnodeid, graph);
    146       } else {
    147         LOG(3, "DEBUG: Discarding edge " << leftnodeid << " <-> " << rightnodeid);
    148       }
    149     }
    150   }
    151   LOG(2, "DEBUG: We have " << getNumVertices() << " nodes and " << getNumEdges()
    152       << " edges in the molecule graph.");
    153 }
    154 
    155 
  • src/Graph/BoostGraphCreator.hpp

    r6e5b8d r1356af  
    116116  nodeId_t getNodeId(const atomId_t &_atomid) const;
    117117
    118 private:
    119118  /** General purpose function that contains the internal logic of walking the
    120119   * bonds of a set of atoms given by \a _begin and \a _end iterators and
     
    145144};
    146145
     146#include "BoostGraphCreator_impl.hpp"
     147
    147148
    148149#endif /* GRAPH_BOOSTGRAPHCREATOR_HPP_ */
  • src/Graph/Makefile.am

    r6e5b8d r1356af  
    1717        Graph/BoostGraphCreator.hpp \
    1818        Graph/BoostGraphHelpers.hpp \
     19        Graph/BoostGraphCreator_impl.hpp \
    1920        Graph/BreadthFirstSearchGatherer.hpp \
    2021        Graph/BuildInducedSubgraph.hpp \
     
    2324        Graph/DepthFirstSearchAnalysis.hpp \
    2425        Graph/ListOfLocalAtoms.hpp
    25 
    2626
    2727noinst_LTLIBRARIES += libMolecuilderGraph.la
Note: See TracChangeset for help on using the changeset viewer.