Changeset 6e5907 for src/Graph/BoostGraphCreator.cpp
- Timestamp:
- Jul 5, 2017, 7:40:48 PM (8 years ago)
- Branches:
- ForceAnnealing_oldresults, IndependentFragmentGrids_IntegrationTest
- Children:
- 89235ea
- Parents:
- 6afd46
- git-author:
- Frederik Heber <frederik.heber@…> (05/18/17 17:45:47)
- git-committer:
- Frederik Heber <frederik.heber@…> (07/05/17 19:40:48)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Graph/BoostGraphCreator.cpp
r6afd46 r6e5907 85 85 std::back_inserter(atomids), getAtomId); 86 86 ASSERT( _atoms.size() == atomids.size(), 87 "BoostGraphCreator::createFromAtom() - atomids and atoms differ in size?"); 87 "BoostGraphCreator::createFromAtom() - atomids " 88 +toString(atomids.size())+" and atoms "+toString(_atoms.size()) 89 +" differ in size?"); 88 90 std::sort(atomids.begin(), atomids.end()); 89 91 const predicate_t predicate = boost::bind(inSetPredicate, boost::ref(atomids), _1); … … 95 97 } 96 98 99 BoostGraphCreator::nodeId_t BoostGraphCreator::getNodeId( 100 const atomId_t &_atomid) const 101 { 102 atomids_nodeids_t::const_iterator iter = 103 atomids_nodeids.find(_atomid); 104 return (iter == atomids_nodeids.end()) ? (nodeId_t)-1 : iter->second; 105 } 106 97 107 template <typename iterator> 98 108 void BoostGraphCreator::createFromRange( … … 101 111 const size_t &_no_nodes, 102 112 const predicate_t &_pred 103 ) { 104 // convert BondGraph into boost::graph 105 UndirectedGraph molgraph(_no_nodes); 113 ) 114 { 115 graph = UndirectedGraph(); 116 117 // add vertices 106 118 for(iterator iter = _begin; iter != _end; ++iter) { 107 LOG(2, "DEBUG: Looking at node " << (*iter)->getId()); 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()); 108 133 const BondList& ListOfBonds = (*iter)->getListOfBonds(); 109 134 for(BondList::const_iterator bonditer = ListOfBonds.begin(); 110 135 bonditer != ListOfBonds.end(); ++bonditer) { 136 LOG(2, "DEBUG: Looking at bond " << *(*bonditer)); 111 137 const atomId_t leftid = (*bonditer)->leftatom->getId(); 138 const nodeId_t leftnodeid = getNodeId(leftid); 112 139 const atomId_t rightid = (*bonditer)->rightatom->getId(); 140 const nodeId_t rightnodeid = getNodeId(rightid); 113 141 // only pick each bond once and evaluate predicate 114 142 if ((leftid == (*iter)->getId()) 115 143 && (_pred(**bonditer))) { 116 LOG(3, "DEBUG: ADDING edge " << left id << " <-> " << rightid);117 boost::add_edge(left id, rightid, graph);144 LOG(3, "DEBUG: ADDING edge " << leftnodeid << " <-> " << rightnodeid); 145 boost::add_edge(leftnodeid, rightnodeid, graph); 118 146 } else { 119 LOG(3, "DEBUG: Discarding edge " << left id << " <-> " << rightid);147 LOG(3, "DEBUG: Discarding edge " << leftnodeid << " <-> " << rightnodeid); 120 148 } 121 149 }
Note:
See TracChangeset
for help on using the changeset viewer.