Changeset 1be100
- 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)
- Files:
-
- 4 edited
-
src/Actions/GraphAction/ChemicalSpaceEvaluatorAction.cpp (modified) (10 diffs)
-
src/Graph/Graph6Reader.cpp (modified) (4 diffs)
-
src/Graph/Graph6Reader.hpp (modified) (2 diffs)
-
tests/regression/Graph/ChemicalSpaceEvaluator/testsuite-chemical-space-evaluator.at (modified) (1 diff)
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; -
src/Graph/Graph6Reader.cpp
rd951a5 r1be100 57 57 if (*_it <126) { 58 58 //6-bit encoding 59 num_nodes = *_it-6 4;59 num_nodes = *_it-63; 60 60 } else if (*_it++ == 126) { 61 61 unsigned int packets = 3; … … 66 66 } 67 67 for(unsigned int i =0; i<packets*packet_size; ++i) { 68 unsigned char packet = (*_it++) - 6 4;68 unsigned char packet = (*_it++) - 63; 69 69 ASSERT(packet<=(1<<(packet_size+1)), 70 70 "The input is malformed. " … … 84 84 void Graph6Reader::next_edge(std::istream_iterator<unsigned char> &_it) { 85 85 unsigned int bit = 0; 86 int cur_byte = 0;87 86 while(!bit && !eos) { 88 87 if (++row==column) { … … 95 94 } 96 95 if (bit_pos<0) { 97 ASSERT((*_it >= 63) && (*_it <= 126), 96 ASSERT(_it != std::istream_iterator<unsigned char>(), 97 "Graph6Reader::next_edge() - less characters than expected in string."); 98 ASSERT((*_it >= 64) && (*_it <= 126), 98 99 "The input contains a non-printable ascii char in the matrix encoding"); 99 100 cur_byte = (*_it) - 63; -
src/Graph/Graph6Reader.hpp
rd951a5 r1be100 44 44 eos(false), 45 45 bit_pos(-1), 46 cur_byte(0), 46 47 num_nodes(0) 47 48 {} … … 66 67 bool eos; 67 68 int bit_pos; 69 int cur_byte; 68 70 static const int packet_size; 69 71 -
tests/regression/Graph/ChemicalSpaceEvaluator/testsuite-chemical-space-evaluator.at
rd951a5 r1be100 26 26 AT_CHECK([../../molecuilder \ 27 27 --parse-homologies $file \ 28 --evaluate-chemical-space --graph6 ' B`' --elements C C], 0, [stdout], [stderr])28 --evaluate-chemical-space --graph6 'A`' --elements C C], 0, [stdout], [stderr]) 29 29 AT_CHECK([fgrep "2 nodes in the fragment graph." stdout], 0, [ignore], [ignore]) 30 30 AT_CHECK([fgrep "Added 3 graph degree combinations" stdout], 0, [ignore], [ignore]) 31 AT_CHECK([fgrep "The graph with degrees ( 1; ) has a total energy of -78.9805" stdout], 0, [ignore], [ignore])32 AT_CHECK([fgrep "The graph with degrees ( 2; ) has a total energy of -77.7951" stdout], 0, [ignore], [ignore])33 AT_CHECK([fgrep "The graph with degrees ( 3; ) has a total energy of -38.1564" stdout], 0, [ignore], [ignore])31 AT_CHECK([fgrep "The graph with degrees ( 1; ) has a total BOSSANOVA energy of -78.9805" stdout], 0, [ignore], [ignore]) 32 AT_CHECK([fgrep "The graph with degrees ( 2; ) has a total BOSSANOVA energy of -77.7951" stdout], 0, [ignore], [ignore]) 33 AT_CHECK([fgrep "The graph with degrees ( 3; ) has a total BOSSANOVA energy of -38.1564" stdout], 0, [ignore], [ignore]) 34 34 35 35 AT_CLEANUP 36 36 37 AT_SETUP([Graph - evaluate chemical space II]) 38 AT_KEYWORDS([graph evaluate-chemical-space graph6]) 39 40 file=homologies.dat 41 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Graph/ChemicalSpaceEvaluator/pre/homologies_CC.dat $file], 0) 42 AT_CHECK([chmod u+w $file], 0) 43 AT_CHECK([../../molecuilder \ 44 --parse-homologies $file \ 45 --evaluate-chemical-space --graph6 'BW' --elements C C C], 0, [stdout], [stderr]) 46 AT_CHECK([fgrep "3 nodes in the fragment graph." stdout], 0, [ignore], [ignore]) 47 AT_CHECK([fgrep "Added 9 graph degree combinations" stdout], 0, [ignore], [ignore]) 48 AT_CHECK([fgrep "The graph with degrees ( 1; 1; ) has a total BOSSANOVA energy of -117.884" stdout], 0, [ignore], [ignore]) 49 AT_CHECK([fgrep "The graph with degrees ( 1; 2; ) has a total BOSSANOVA energy of -116.699" stdout], 0, [ignore], [ignore]) 50 AT_CHECK([fgrep "The graph with degrees ( 1; 3; ) has a total BOSSANOVA energy of -77.0602" stdout], 0, [ignore], [ignore]) 51 AT_CHECK([fgrep "The graph with degrees ( 2; 1; ) has a total BOSSANOVA energy of -116.699" stdout], 0, [ignore], [ignore]) 52 AT_CHECK([fgrep "The graph with degrees ( 2; 2; ) has a total BOSSANOVA energy of -115.513" stdout], 0, [ignore], [ignore]) 53 AT_CHECK([fgrep "The graph with degrees ( 3; 1; ) has a total BOSSANOVA energy of -77.0602" stdout], 0, [ignore], [ignore]) 54 55 AT_CLEANUP
Note:
See TracChangeset
for help on using the changeset viewer.
