- Timestamp:
- Apr 23, 2021, 8:51:43 PM (5 years ago)
- Branches:
- Candidate_v1.7.0, stable
- Children:
- 9171d8
- Parents:
- d951a5
- git-author:
- Frederik Heber <frederik.heber@…> (03/27/21 16:54:08)
- git-committer:
- Frederik Heber <frederik.heber@…> (04/23/21 20:51:43)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/GraphAction/ChemicalSpaceEvaluatorAction.cpp
rd951a5 r1be100 142 142 { 143 143 const BoostGraphCreator::Vertex u = source(e, graph); 144 const BoostGraphCreator::Vertex v = source(e, graph);144 const BoostGraphCreator::Vertex v = target(e, graph); 145 145 return getEdgeByVertices(u,v); 146 146 } … … 204 204 for (boost::tie(i, end) = boost::out_edges(v, graph); i != end; ++i) { 205 205 const BoostGraphCreator::Edge &e = *i; 206 const BoostGraphCreator::Vertex e1 = source(e, graph); 207 const BoostGraphCreator::Vertex e2 = target(e, graph); 208 const edge_by_vertices_t edge_by_vertices = getEdgeByVertices(e1,e2); 206 const edge_by_vertices_t edge_by_vertices = getEdgeVerticesByEdge(e, graph); 209 207 LOG(3, "DEBUG: Current edge is (" << edge_by_vertices << ")"); 210 208 const size_t index = getElementFromMap<edge_index_t, edge_by_vertices_t>( … … 231 229 std::pair<BoostGraphCreator::Edge, bool> edge_inserter = 232 230 boost::add_edge(v, h, newgraph.saturated_graph); 231 ASSERT( edge_inserter.second, 232 "Failed to insert hydrogen into saturation graph."); 233 233 } 234 234 LOG(2, "DEBUG: Added " << (max_valence - total_valence) … … 242 242 BoostGraphCreator::UndirectedGraph extractSubgraph( 243 243 const graph_t &_graph, 244 const Extractors::nodes_t &nodes) 244 const Extractors::nodes_t &nodes, 245 const edge_index_t &_edge_index, 246 edge_index_t &_subgraph_edge_index) 245 247 { 246 248 BoostGraphCreator::UndirectedGraph subgraph; 247 249 const Extractors::index_map_t index_map = boost::get(boost::vertex_index, _graph); 250 typedef std::map<Extractors::node_t, BoostGraphCreator::Vertex> graph_index_to_subgraph_vertex_t; 251 graph_index_to_subgraph_vertex_t graph_index_to_subgraph_vertex; 248 252 249 253 // add nodes 250 254 BoostGraphCreator::vertex_iter viter, vend; 251 255 for (boost::tie(viter, vend) = boost::vertices(_graph); viter != vend; ++viter) { 252 const size_t nodeid = boost::get(index_map, *viter);256 const Extractors::node_t nodeid = boost::get(index_map, *viter); 253 257 if (nodes.find(nodeid) != nodes.end()) { 254 boost::add_vertex(*viter, subgraph); 258 const BoostGraphCreator::Vertex vnew = boost::add_vertex(*viter, subgraph); 259 graph_index_to_subgraph_vertex.insert( std::make_pair(nodeid, vnew) ); 255 260 LOG(4, "DEBUG: Adding node " << *viter << " to subgraph."); 256 261 } 257 262 } 263 const Extractors::index_map_t subgraph_index_map = boost::get(boost::vertex_index, subgraph); 258 264 259 265 // add edges … … 264 270 const Extractors::node_t sourceindex = boost::get(index_map, boost::source(*i, _graph)); 265 271 const Extractors::node_t targetindex = boost::get(index_map, boost::target(*i, _graph)); 272 // we need to translate the vertex index from graph to subgraph 273 const Extractors::node_t subsourceindex = boost::get( 274 subgraph_index_map, graph_index_to_subgraph_vertex[sourceindex]); 275 const Extractors::node_t subtargetindex = boost::get( 276 subgraph_index_map, graph_index_to_subgraph_vertex[targetindex]); 266 277 if ((nodes.find(sourceindex) != nodes.end()) && (nodes.find(targetindex) != nodes.end()) 267 278 && (sourceindex < targetindex)) { 268 boost::add_edge(sourceindex, targetindex, subgraph); 269 LOG(4, "DEBUG: Adding edge " << sourceindex << "<->" << targetindex << " to subgraph."); 279 // and we need to translate the edge index from the graph to the subgraph 280 const std::pair<BoostGraphCreator::Edge, bool> newedgeinserter = 281 boost::add_edge(subsourceindex, subtargetindex, subgraph); 282 ASSERT( newedgeinserter.second, 283 "extractSubgraph() - could not insert edge "+toString(subsourceindex)+"<->" 284 +toString(subtargetindex)+"."); 285 const edge_by_vertices_t edge_by_vertices = getEdgeVerticesByEdge(*i, _graph); 286 const edge_index_t::const_iterator edgeiter = _edge_index.find(edge_by_vertices); 287 ASSERT( edgeiter != _edge_index.end(), 288 "extractSubgraph() - could not find edge "+toString(edge_by_vertices)+" in edge_index map." ); 289 const edge_by_vertices_t subgraph_edge_by_vertices = 290 getEdgeVerticesByEdge(newedgeinserter.first, subgraph); 291 _subgraph_edge_index.insert( std::make_pair(subgraph_edge_by_vertices, edgeiter->second) ); 292 LOG(4, "DEBUG: Adding edge " << sourceindex << "<->" << targetindex 293 << " in graph to subgraph as edge " << subsourceindex << "<->" << subtargetindex << "."); 270 294 } 271 295 } … … 412 436 } 413 437 414 typedef std::vector<415 std::pair<416 BoostGraphCreator::UndirectedGraph,417 degrees_t> > graphs_with_degrees_t;418 419 438 // 6. for every combination saturate fragments for lookup and energy contribution summation 439 size_t num_admissible = 0; 420 440 const HomologyContainer &container = World::getInstance().getHomologies(); 421 441 for (list_of_edge_degrees_t::const_iterator degrees_iter = list_of_edge_degrees.begin(); … … 436 456 continue; 437 457 } else { 458 ++num_admissible; 438 459 LOG(2, "DEBUG: The degree combination is admissable."); 439 460 } … … 452 473 453 474 // create subgraph 454 Extractors::UndirectedGraph newgraph = extractSubgraph(graph, current_nodes); 475 edge_index_t subgraph_edge_index; 476 Extractors::UndirectedGraph newgraph = extractSubgraph( 477 graph, current_nodes, edge_index, subgraph_edge_index); 455 478 456 479 const BoostGraphCreator::name_map_t new_name_map = … … 469 492 SaturatedGraph fragmentgraph = 470 493 saturateGraph(newgraph, new_name_map, 471 type_index_lookup, type_valence_map, edge_index,494 type_index_lookup, type_valence_map, subgraph_edge_index, 472 495 edges, current_degrees); 473 496 … … 514 537 LOG(1, "The graph with degrees " << current_degrees << " has a total BOSSANOVA energy of " << total_energy); 515 538 } 539 LOG(1, "There have been " << num_admissible << " admissible degree combinations for the given graph."); 516 540 517 541 return Action::success;
Note:
See TracChangeset
for help on using the changeset viewer.
