Changeset 3dedfbd for src/Graph/BoostGraphCreator.cpp
- Timestamp:
- Jul 5, 2017, 7:43:00 PM (8 years ago)
- Branches:
- ForceAnnealing_oldresults, IndependentFragmentGrids_IntegrationTest
- Children:
- 41eed2
- Parents:
- 89235ea
- git-author:
- Frederik Heber <frederik.heber@…> (05/19/17 09:25:53)
- git-committer:
- Frederik Heber <frederik.heber@…> (07/05/17 19:43:00)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Graph/BoostGraphCreator.cpp ¶
r89235ea r3dedfbd 39 39 40 40 #include <algorithm> 41 #include <iterator>42 41 43 42 #include "CodePatterns/Assert.hpp" 44 #include "CodePatterns/Log.hpp"45 43 46 44 #include "Atom/atom.hpp" 47 #include "Bond/bond.hpp"48 45 #include "molecule.hpp" 49 46 … … 105 102 } 106 103 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 &_pred113 )114 {115 graph = UndirectedGraph();116 117 // add vertices118 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 edges131 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 predicate142 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
Note:
See TracChangeset
for help on using the changeset viewer.