Changeset d619f5c for src/Graph/BoostGraphCreator.cpp
- Timestamp:
- Jul 5, 2017, 7:43:00 PM (8 years ago)
- Branches:
- ForceAnnealing_oldresults, IndependentFragmentGrids_IntegrationTest
- Children:
- effdea
- Parents:
- 6e1c14
- git-author:
- Frederik Heber <frederik.heber@…> (05/19/17 13:13:41)
- git-committer:
- Frederik Heber <frederik.heber@…> (07/05/17 19:43:00)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Graph/BoostGraphCreator.cpp
r6e1c14 rd619f5c 102 102 } 103 103 104 BoostGraphCreator::Edge BoostGraphCreator::findEdge(const atomId_t &_firstid, const atomId_t &_secondid) 105 { 106 edge_iter i, end; 107 const name_map_t name_map = boost::get(boost::vertex_name, graph); 108 for (boost::tie(i, end) = boost::edges(graph); i != end; ++i) { 109 const BoostGraphCreator::Edge &e = *i; 110 const Vertex u = source(e, graph); 111 const Vertex v = target(e, graph); 112 const atomId_t atomid_u = boost::get(name_map, u); 113 const atomId_t atomid_v = boost::get(name_map, v); 114 if (atomid_u == _firstid) { 115 if (atomid_v == _secondid) 116 break; 117 } else if (atomid_u == _secondid) { 118 if (atomid_v == _firstid) 119 break; 120 } 121 } 122 if (i != end) { 123 BoostGraphCreator::Edge e = *i; 124 return e; 125 } 126 127 return BoostGraphCreator::Edge(); 128 } 129 130 bool BoostGraphCreator::removeEdge(const atomId_t &_firstid, const atomId_t &_secondid) 131 { 132 // look through all edges 133 BoostGraphCreator::Edge e = findEdge(_firstid, _secondid); 134 135 // edge was found 136 if (e != BoostGraphCreator::Edge()) { 137 const Vertex u = source(e, graph); 138 const Vertex v = target(e, graph); 139 if (DoLog(3)) { 140 const name_map_t name_map = boost::get(boost::vertex_name, graph); 141 LOG(3, "DEBUG: Found edge " << boost::get(name_map, u) << " <-> " 142 << boost::get(name_map, v) << ", removing."); 143 } 144 boost::remove_edge(e, graph); 145 146 return true; 147 } 148 return false; 149 } 150 151 bool BoostGraphCreator::addEdge(const atomId_t &_firstid, const atomId_t &_secondid) 152 { 153 // look through all edges 154 BoostGraphCreator::Edge e = findEdge(_firstid, _secondid); 155 156 if (e != BoostGraphCreator::Edge()) { 157 return false; 158 } else { 159 const nodeId_t leftnodeid = getNodeId(_firstid); 160 const nodeId_t rightnodeid = getNodeId(_secondid); 161 162 boost::add_edge(leftnodeid, rightnodeid, graph); 163 164 return true; 165 } 166 }
Note:
See TracChangeset
for help on using the changeset viewer.