Changeset 5f612ee for src/molecule_graph.cpp
- Timestamp:
- Apr 27, 2010, 2:25:42 PM (15 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 632bc3
- Parents:
- 13d5a9 (diff), c695c9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_graph.cpp
r13d5a9 r5f612ee 17 17 #include "memoryallocator.hpp" 18 18 #include "molecule.hpp" 19 #include "World.hpp" 19 20 20 21 struct BFSAccounting … … 58 59 59 60 if (!input) { 60 Log() << Verbose(1) << "Opening silica failed \n";61 DoLog(1) && (Log() << Verbose(1) << "Opening silica failed \n"); 61 62 }; 62 63 63 64 *input >> ws >> atom1; 64 65 *input >> ws >> atom2; 65 Log() << Verbose(1) << "Scanning file\n";66 DoLog(1) && (Log() << Verbose(1) << "Scanning file\n"); 66 67 while (!input->eof()) // Check whether we read everything already 67 68 { … … 106 107 LinkedCell *LC = NULL; 107 108 bool free_BG = false; 109 double * const cell_size = World::getInstance().getDomain(); 108 110 109 111 if (BG == NULL) { … … 113 115 114 116 BondDistance = bonddistance; // * ((IsAngstroem) ? 1. : 1./AtomicLengthToAngstroem); 115 Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl;117 DoLog(0) && (Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl); 116 118 // remove every bond from the list 117 119 bond *Binder = NULL; … … 126 128 // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering) 127 129 CountAtoms(); 128 Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl;130 DoLog(1) && (Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl); 129 131 130 132 if ((AtomCount > 1) && (bonddistance > 1.)) { 131 Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl;133 DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl); 132 134 LC = new LinkedCell(this, bonddistance); 133 135 134 136 // create a list to map Tesselpoint::nr to atom * 135 Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl;137 DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl); 136 138 AtomMap = Calloc<atom *> (AtomCount, "molecule::CreateAdjacencyList - **AtomCount"); 137 139 Walker = start; … … 142 144 143 145 // 3a. go through every cell 144 Log() << Verbose(2) << "Celling ... " << endl;146 DoLog(2) && (Log() << Verbose(2) << "Celling ... " << endl); 145 147 for (LC->n[0] = 0; LC->n[0] < LC->N[0]; LC->n[0]++) 146 148 for (LC->n[1] = 0; LC->n[1] < LC->N[1]; LC->n[1]++) 147 149 for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) { 148 const Linked Nodes *List = LC->GetCurrentCell();149 //Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;150 const LinkedCell::LinkedNodes *List = LC->GetCurrentCell(); 151 // Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl; 150 152 if (List != NULL) { 151 for (Linked Nodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {153 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 152 154 Walker = AtomMap[(*Runner)->nr]; 153 //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;155 // Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl; 154 156 // 3c. check for possible bond between each atom in this and every one in the 27 cells 155 157 for (n[0] = -1; n[0] <= 1; n[0]++) 156 158 for (n[1] = -1; n[1] <= 1; n[1]++) 157 159 for (n[2] = -1; n[2] <= 1; n[2]++) { 158 const Linked Nodes *OtherList = LC->GetRelativeToCurrentCell(n);159 //Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;160 const LinkedCell::LinkedNodes *OtherList = LC->GetRelativeToCurrentCell(n); 161 // Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl; 160 162 if (OtherList != NULL) { 161 for (Linked Nodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {163 for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) { 162 164 if ((*OtherRunner)->nr > Walker->nr) { 163 165 OtherWalker = AtomMap[(*OtherRunner)->nr]; 164 //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl; 166 // Log() << Verbose(0) << "Current other Atom is " << *OtherWalker << "." << endl; 167 const double distance = OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size); 168 // Log() << Verbose(1) << "Checking distance " << distance << " against typical bond length of " << bonddistance*bonddistance << "." << endl; 165 169 (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 166 const double distance = OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size);167 170 const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance); 168 if ((OtherWalker->father->nr > Walker->father->nr) && (status)) { // create bond if distance is smaller 169 //Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl; 170 AddBond(Walker->father, OtherWalker->father, 1); // also increases molecule::BondCount 171 // Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl; 172 if (OtherWalker->father->nr > Walker->father->nr) { 173 if (status) { // create bond if distance is smaller 174 // Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl; 175 AddBond(Walker->father, OtherWalker->father, 1); // also increases molecule::BondCount 176 } else { 177 // Log() << Verbose(1) << "Not Adding: distance too great." << endl; 178 } 171 179 } else { 172 //Log() << Verbose(1) << "Not Adding: Wrong label order or distance too great." << endl;180 // Log() << Verbose(1) << "Not Adding: Wrong order of labels." << endl; 173 181 } 174 182 } … … 181 189 Free(&AtomMap); 182 190 delete (LC); 183 Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl;191 DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl); 184 192 185 193 // correct bond degree by comparing valence and bond degree 186 Log() << Verbose(2) << "Correcting bond degree ... " << endl;194 DoLog(2) && (Log() << Verbose(2) << "Correcting bond degree ... " << endl); 187 195 CorrectBondDegree(); 188 196 … … 190 198 ActOnAllAtoms( &atom::OutputBondOfAtom ); 191 199 } else 192 Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl;193 Log() << Verbose(0) << "End of CreateAdjacencyList." << endl;200 DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl); 201 DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl); 194 202 if (free_BG) 195 203 delete(BG); … … 202 210 void molecule::OutputBondsList() const 203 211 { 204 Log() << Verbose(1) << endl << "From contents of bond chain list:";212 DoLog(1) && (Log() << Verbose(1) << endl << "From contents of bond chain list:"); 205 213 bond *Binder = first; 206 214 while (Binder->next != last) { 207 215 Binder = Binder->next; 208 Log() << Verbose(0) << *Binder << "\t" << endl;209 } 210 Log() << Verbose(0) << endl;216 DoLog(0) && (Log() << Verbose(0) << *Binder << "\t" << endl); 217 } 218 DoLog(0) && (Log() << Verbose(0) << endl); 211 219 } 212 220 ; … … 225 233 226 234 if (BondCount != 0) { 227 Log() << Verbose(1) << "Correcting Bond degree of each bond ... " << endl;235 DoLog(1) && (Log() << Verbose(1) << "Correcting Bond degree of each bond ... " << endl); 228 236 do { 229 237 OldNo = No; 230 238 No = SumPerAtom( &atom::CorrectBondDegree ); 231 239 } while (OldNo != No); 232 Log() << Verbose(0) << " done." << endl;240 DoLog(0) && (Log() << Verbose(0) << " done." << endl); 233 241 } else { 234 Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl;235 } 236 Log() << Verbose(0) << No << " bonds could not be corrected." << endl;242 DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl); 243 } 244 DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl); 237 245 238 246 return (No); … … 253 261 bond *Binder = first; 254 262 if ((Binder->next != last) && (Binder->next->Type == Undetermined)) { 255 Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl;263 DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl); 256 264 Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack); 257 265 while (Subgraphs->next != NULL) { … … 308 316 Walker->GraphNr = DFS.CurrentGraphNr; 309 317 Walker->LowpointNr = DFS.CurrentGraphNr; 310 Log() << Verbose(1) << "Setting Walker[" << Walker->Name << "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl;318 DoLog(1) && (Log() << Verbose(1) << "Setting Walker[" << Walker->Name << "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl); 311 319 DFS.AtomStack->Push(Walker); 312 320 DFS.CurrentGraphNr++; … … 335 343 if (Binder == NULL) 336 344 break; 337 Log() << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl;345 DoLog(2) && (Log() << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl); 338 346 // (4) Mark Binder used, ... 339 347 Binder->MarkUsed(black); 340 348 OtherAtom = Binder->GetOtherAtom(Walker); 341 Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->Name << "." << endl;349 DoLog(2) && (Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->Name << "." << endl); 342 350 if (OtherAtom->GraphNr != -1) { 343 351 // (4a) ... if "other" atom has been visited (GraphNr != 0), set lowpoint to minimum of both, go to (3) … … 345 353 DFS.BackEdgeStack->Push(Binder); 346 354 Walker->LowpointNr = (Walker->LowpointNr < OtherAtom->GraphNr) ? Walker->LowpointNr : OtherAtom->GraphNr; 347 Log() << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->Name << "] to " << Walker->LowpointNr << "." << endl;355 DoLog(3) && (Log() << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->Name << "] to " << Walker->LowpointNr << "." << endl); 348 356 } else { 349 357 // (4b) ... otherwise set OtherAtom as Ancestor of Walker and Walker as OtherAtom, go to (2) … … 351 359 OtherAtom->Ancestor = Walker; 352 360 Walker = OtherAtom; 353 Log() << Verbose(3) << "(4b) Not Visited: OtherAtom[" << OtherAtom->Name << "]'s Ancestor is now " << OtherAtom->Ancestor->Name << ", Walker is OtherAtom " << OtherAtom->Name << "." << endl;361 DoLog(3) && (Log() << Verbose(3) << "(4b) Not Visited: OtherAtom[" << OtherAtom->Name << "]'s Ancestor is now " << OtherAtom->Ancestor->Name << ", Walker is OtherAtom " << OtherAtom->Name << "." << endl); 354 362 break; 355 363 } … … 373 381 374 382 // (5) if Ancestor of Walker is ... 375 Log() << Verbose(1) << "(5) Number of Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "] is " << Walker->Ancestor->GraphNr << "." << endl;383 DoLog(1) && (Log() << Verbose(1) << "(5) Number of Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "] is " << Walker->Ancestor->GraphNr << "." << endl); 376 384 377 385 if (Walker->Ancestor->GraphNr != DFS.Root->GraphNr) { … … 380 388 // (6a) set Ancestor's Lowpoint number to minimum of of its Ancestor and itself, go to Step(8) 381 389 Walker->Ancestor->LowpointNr = (Walker->Ancestor->LowpointNr < Walker->LowpointNr) ? Walker->Ancestor->LowpointNr : Walker->LowpointNr; 382 Log() << Verbose(2) << "(6) Setting Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s Lowpoint to " << Walker->Ancestor->LowpointNr << "." << endl;390 DoLog(2) && (Log() << Verbose(2) << "(6) Setting Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s Lowpoint to " << Walker->Ancestor->LowpointNr << "." << endl); 383 391 } else { 384 392 // (7) (Ancestor of Walker is a separating vertex, remove all from stack till Walker (including), these and Ancestor form a component 385 393 Walker->Ancestor->SeparationVertex = true; 386 Log() << Verbose(2) << "(7) Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s is a separating vertex, creating component." << endl;394 DoLog(2) && (Log() << Verbose(2) << "(7) Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s is a separating vertex, creating component." << endl); 387 395 mol->SetNextComponentNumber(Walker->Ancestor, DFS.ComponentNumber); 388 Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Ancestor's Compont is " << DFS.ComponentNumber << "." << endl;396 DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Ancestor's Compont is " << DFS.ComponentNumber << "." << endl); 389 397 mol->SetNextComponentNumber(Walker, DFS.ComponentNumber); 390 Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl;398 DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl); 391 399 do { 392 400 OtherAtom = DFS.AtomStack->PopLast(); 393 401 LeafWalker->Leaf->AddCopyAtom(OtherAtom); 394 402 mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber); 395 Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl;403 DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl); 396 404 } while (OtherAtom != Walker); 397 405 DFS.ComponentNumber++; 398 406 } 399 407 // (8) Walker becomes its Ancestor, go to (3) 400 Log() << Verbose(2) << "(8) Walker[" << Walker->Name << "] is now its Ancestor " << Walker->Ancestor->Name << ", backstepping. " << endl;408 DoLog(2) && (Log() << Verbose(2) << "(8) Walker[" << Walker->Name << "] is now its Ancestor " << Walker->Ancestor->Name << ", backstepping. " << endl); 401 409 Walker = Walker->Ancestor; 402 410 DFS.BackStepping = true; … … 422 430 //DFS.AtomStack->Output(out); 423 431 mol->SetNextComponentNumber(DFS.Root, DFS.ComponentNumber); 424 Log() << Verbose(3) << "(9) Root[" << DFS.Root->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl;432 DoLog(3) && (Log() << Verbose(3) << "(9) Root[" << DFS.Root->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl); 425 433 mol->SetNextComponentNumber(Walker, DFS.ComponentNumber); 426 Log() << Verbose(3) << "(9) Walker[" << Walker->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl;434 DoLog(3) && (Log() << Verbose(3) << "(9) Walker[" << Walker->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl); 427 435 do { 428 436 OtherAtom = DFS.AtomStack->PopLast(); 429 437 LeafWalker->Leaf->AddCopyAtom(OtherAtom); 430 438 mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber); 431 Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl;439 DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl); 432 440 } while (OtherAtom != Walker); 433 441 DFS.ComponentNumber++; … … 436 444 Walker = DFS.Root; 437 445 Binder = mol->FindNextUnused(Walker); 438 Log() << Verbose(1) << "(10) Walker is Root[" << DFS.Root->Name << "], next Unused Bond is " << Binder << "." << endl;446 DoLog(1) && (Log() << Verbose(1) << "(10) Walker is Root[" << DFS.Root->Name << "], next Unused Bond is " << Binder << "." << endl); 439 447 if (Binder != NULL) { // Root is separation vertex 440 Log() << Verbose(1) << "(11) Root is a separation vertex." << endl;448 DoLog(1) && (Log() << Verbose(1) << "(11) Root is a separation vertex." << endl); 441 449 Walker->SeparationVertex = true; 442 450 } … … 493 501 bond *Binder = NULL; 494 502 495 Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl; 503 if (AtomCount == 0) 504 return SubGraphs; 505 DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl); 496 506 DepthFirstSearchAnalysis_Init(DFS, this); 497 507 … … 503 513 // put into new subgraph molecule and add this to list of subgraphs 504 514 LeafWalker = new MoleculeLeafClass(LeafWalker); 505 LeafWalker->Leaf = new molecule(elemente);515 LeafWalker->Leaf = World::getInstance().createMolecule(); 506 516 LeafWalker->Leaf->AddCopyAtom(DFS.Root); 507 517 … … 515 525 516 526 if (Binder == NULL) { 517 Log() << Verbose(2) << "No more Unused Bonds." << endl;527 DoLog(2) && (Log() << Verbose(2) << "No more Unused Bonds." << endl); 518 528 break; 519 529 } else … … 532 542 533 543 // From OldGraphNr to CurrentGraphNr ranges an disconnected subgraph 534 Log() << Verbose(0) << "Disconnected subgraph ranges from " << OldGraphNr << " to " << DFS.CurrentGraphNr << "." << endl;544 DoLog(0) && (Log() << Verbose(0) << "Disconnected subgraph ranges from " << OldGraphNr << " to " << DFS.CurrentGraphNr << "." << endl); 535 545 LeafWalker->Leaf->Output((ofstream *)&cout); 536 Log() << Verbose(0) << endl;546 DoLog(0) && (Log() << Verbose(0) << endl); 537 547 538 548 // step on to next root … … 552 562 // free all and exit 553 563 DepthFirstSearchAnalysis_Finalize(DFS); 554 Log() << Verbose(0) << "End of DepthFirstSearchAnalysis" << endl;564 DoLog(0) && (Log() << Verbose(0) << "End of DepthFirstSearchAnalysis" << endl); 555 565 return SubGraphs; 556 566 } … … 578 588 void molecule::OutputGraphInfoPerAtom() const 579 589 { 580 Log() << Verbose(1) << "Final graph info for each atom is:" << endl;590 DoLog(1) && (Log() << Verbose(1) << "Final graph info for each atom is:" << endl); 581 591 ActOnAllAtoms( &atom::OutputGraphInfo ); 582 592 } … … 588 598 void molecule::OutputGraphInfoPerBond() const 589 599 { 590 Log() << Verbose(1) << "Final graph info for each bond is:" << endl;600 DoLog(1) && (Log() << Verbose(1) << "Final graph info for each bond is:" << endl); 591 601 bond *Binder = first; 592 602 while (Binder->next != last) { 593 603 Binder = Binder->next; 594 Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <";595 Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp.";604 DoLog(2) && (Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <"); 605 DoLog(0) && (Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp."); 596 606 Binder->leftatom->OutputComponentNumber(); 597 Log() << Verbose(0) << " === ";598 Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp.";607 DoLog(0) && (Log() << Verbose(0) << " === "); 608 DoLog(0) && (Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp."); 599 609 Binder->rightatom->OutputComponentNumber(); 600 Log() << Verbose(0) << ">." << endl;610 DoLog(0) && (Log() << Verbose(0) << ">." << endl); 601 611 if (Binder->Cyclic) // cyclic ?? 602 Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl;612 DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl); 603 613 } 604 614 } … … 674 684 do { // look for Root 675 685 Walker = BFS.BFSStack->PopFirst(); 676 Log() << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *BFS.Root << "." << endl;686 DoLog(2) && (Log() << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *BFS.Root << "." << endl); 677 687 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { 678 688 if ((*Runner) != BackEdge) { // only walk along DFS spanning tree (otherwise we always find SP of one being backedge Binder) … … 681 691 if (OtherAtom->type->Z != 1) { 682 692 #endif 683 Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl;693 DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl); 684 694 if (BFS.ColorList[OtherAtom->nr] == white) { 685 695 BFS.TouchedStack->Push(OtherAtom); … … 687 697 BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor 688 698 BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1; 689 Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " lightgray, its predecessor is " << Walker->Name << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl;699 DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " lightgray, its predecessor is " << Walker->Name << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl); 690 700 //if (BFS.ShortestPathList[OtherAtom->nr] < MinimumRingSize[Walker->GetTrueFather()->nr]) { // Check for maximum distance 691 Log() << Verbose(3) << "Putting OtherAtom into queue." << endl;701 DoLog(3) && (Log() << Verbose(3) << "Putting OtherAtom into queue." << endl); 692 702 BFS.BFSStack->Push(OtherAtom); 693 703 //} 694 704 } else { 695 Log() << Verbose(3) << "Not Adding, has already been visited." << endl;705 DoLog(3) && (Log() << Verbose(3) << "Not Adding, has already been visited." << endl); 696 706 } 697 707 if (OtherAtom == BFS.Root) … … 699 709 #ifdef ADDHYDROGEN 700 710 } else { 701 Log() << Verbose(2) << "Skipping hydrogen atom " << *OtherAtom << "." << endl;711 DoLog(2) && (Log() << Verbose(2) << "Skipping hydrogen atom " << *OtherAtom << "." << endl); 702 712 BFS.ColorList[OtherAtom->nr] = black; 703 713 } 704 714 #endif 705 715 } else { 706 Log() << Verbose(2) << "Bond " << *(*Runner) << " not Visiting, is the back edge." << endl;716 DoLog(2) && (Log() << Verbose(2) << "Bond " << *(*Runner) << " not Visiting, is the back edge." << endl); 707 717 } 708 718 } 709 719 BFS.ColorList[Walker->nr] = black; 710 Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl;720 DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl); 711 721 if (OtherAtom == BFS.Root) { // if we have found the root, check whether this cycle wasn't already found beforehand 712 722 // step through predecessor list … … 718 728 } 719 729 if (OtherAtom == BackEdge->rightatom) { // if each atom in found cycle is cyclic, loop's been found before already 720 Log() << Verbose(3) << "This cycle was already found before, skipping and removing seeker from search." << endl;730 DoLog(3) && (Log() << Verbose(3) << "This cycle was already found before, skipping and removing seeker from search." << endl); 721 731 do { 722 732 OtherAtom = BFS.TouchedStack->PopLast(); 723 733 if (BFS.PredecessorList[OtherAtom->nr] == Walker) { 724 Log() << Verbose(4) << "Removing " << *OtherAtom << " from lists and stacks." << endl;734 DoLog(4) && (Log() << Verbose(4) << "Removing " << *OtherAtom << " from lists and stacks." << endl); 725 735 BFS.PredecessorList[OtherAtom->nr] = NULL; 726 736 BFS.ShortestPathList[OtherAtom->nr] = -1; … … 756 766 RingSize = 1; 757 767 BFS.Root->GetTrueFather()->IsCyclic = true; 758 Log() << Verbose(1) << "Found ring contains: ";768 DoLog(1) && (Log() << Verbose(1) << "Found ring contains: "); 759 769 Walker = BFS.Root; 760 770 while (Walker != BackEdge->rightatom) { 761 Log() << Verbose(0) << Walker->Name << " <-> ";771 DoLog(0) && (Log() << Verbose(0) << Walker->Name << " <-> "); 762 772 Walker = BFS.PredecessorList[Walker->nr]; 763 773 Walker->GetTrueFather()->IsCyclic = true; 764 774 RingSize++; 765 775 } 766 Log() << Verbose(0) << Walker->Name << " with a length of " << RingSize << "." << endl << endl;776 DoLog(0) && (Log() << Verbose(0) << Walker->Name << " with a length of " << RingSize << "." << endl << endl); 767 777 // walk through all and set MinimumRingSize 768 778 Walker = BFS.Root; … … 776 786 MinRingSize = RingSize; 777 787 } else { 778 Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[Walker->GetTrueFather()->nr] << " found." << endl;788 DoLog(1) && (Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[Walker->GetTrueFather()->nr] << " found." << endl); 779 789 } 780 790 }; … … 854 864 855 865 } 856 Log() << Verbose(1) << "Minimum ring size of " << *Root << " is " << MinimumRingSize[Root->GetTrueFather()->nr] << "." << endl;857 } 858 Log() << Verbose(1) << "Minimum ring size is " << MinRingSize << ", over " << NumCycles << " cycles total." << endl;866 DoLog(1) && (Log() << Verbose(1) << "Minimum ring size of " << *Root << " is " << MinimumRingSize[Root->GetTrueFather()->nr] << "." << endl); 867 } 868 DoLog(1) && (Log() << Verbose(1) << "Minimum ring size is " << MinRingSize << ", over " << NumCycles << " cycles total." << endl); 859 869 } else 860 Log() << Verbose(1) << "No rings were detected in the molecular structure." << endl;870 DoLog(1) && (Log() << Verbose(1) << "No rings were detected in the molecular structure." << endl); 861 871 } 862 872 ; … … 886 896 //BackEdgeStack->Output(out); 887 897 888 Log() << Verbose(1) << "Analysing cycles ... " << endl;898 DoLog(1) && (Log() << Verbose(1) << "Analysing cycles ... " << endl); 889 899 NumCycles = 0; 890 900 while (!BackEdgeStack->IsEmpty()) { … … 897 907 ResetBFSAccounting(Walker, BFS); 898 908 899 Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl;909 DoLog(1) && (Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl); 900 910 OtherAtom = NULL; 901 911 CyclicStructureAnalysis_CyclicBFSFromRootToRoot(BackEdge, BFS); … … 927 937 } 928 938 if (i == vertex->ListOfBonds.size()) { 929 eLog() << Verbose(0) << "Error: All Component entries are already occupied!" << endl;939 DoeLog(0) && (eLog()<< Verbose(0) << "Error: All Component entries are already occupied!" << endl); 930 940 performCriticalExit(); 931 941 } 932 942 } else { 933 eLog() << Verbose(0) << "Error: Given vertex is NULL!" << endl;943 DoeLog(0) && (eLog()<< Verbose(0) << "Error: Given vertex is NULL!" << endl); 934 944 performCriticalExit(); 935 945 } … … 969 979 void OutputAlreadyVisited(int *list) 970 980 { 971 Log() << Verbose(4) << "Already Visited Bonds:\t";981 DoLog(4) && (Log() << Verbose(4) << "Already Visited Bonds:\t"); 972 982 for (int i = 1; i <= list[0]; i++) 973 Log() << Verbose(0) << list[i] << " ";974 Log() << Verbose(0) << endl;983 DoLog(0) && (Log() << Verbose(0) << list[i] << " "); 984 DoLog(0) && (Log() << Verbose(0) << endl); 975 985 } 976 986 ; … … 978 988 /** Storing the bond structure of a molecule to file. 979 989 * Simply stores Atom::nr and then the Atom::nr of all bond partners per line. 980 * \param *out output stream for debugging981 990 * \param *path path to file 991 * \param *filename name of file 982 992 * \return true - file written successfully, false - writing failed 983 993 */ 984 bool molecule::StoreAdjacencyToFile(char *path )994 bool molecule::StoreAdjacencyToFile(char *path, char *filename) 985 995 { 986 996 ofstream AdjacencyFile; … … 988 998 bool status = true; 989 999 990 line << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE; 1000 if (path != NULL) 1001 line << path << "/" << filename; 1002 else 1003 line << filename; 991 1004 AdjacencyFile.open(line.str().c_str(), ios::out); 992 Log() << Verbose(1) << "Saving adjacency list ... ";1005 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... "); 993 1006 if (AdjacencyFile != NULL) { 994 1007 AdjacencyFile << "m\tn" << endl; 995 1008 ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile); 996 1009 AdjacencyFile.close(); 997 Log() << Verbose(1) << "done." << endl;1010 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 998 1011 } else { 999 Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;1012 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl); 1000 1013 status = false; 1001 1014 } … … 1007 1020 /** Storing the bond structure of a molecule to file. 1008 1021 * Simply stores Atom::nr and then the Atom::nr of all bond partners, one per line. 1009 * \param *out output stream for debugging1010 1022 * \param *path path to file 1023 * \param *filename name of file 1011 1024 * \return true - file written successfully, false - writing failed 1012 1025 */ 1013 bool molecule::StoreBondsToFile(char *path )1026 bool molecule::StoreBondsToFile(char *path, char *filename) 1014 1027 { 1015 1028 ofstream BondFile; … … 1017 1030 bool status = true; 1018 1031 1019 line << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE; 1032 if (path != NULL) 1033 line << path << "/" << filename; 1034 else 1035 line << filename; 1020 1036 BondFile.open(line.str().c_str(), ios::out); 1021 Log() << Verbose(1) << "Saving adjacency list ... ";1037 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... "); 1022 1038 if (BondFile != NULL) { 1023 1039 BondFile << "m\tn" << endl; 1024 1040 ActOnAllAtoms(&atom::OutputBonds, &BondFile); 1025 1041 BondFile.close(); 1026 Log() << Verbose(1) << "done." << endl;1042 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 1027 1043 } else { 1028 Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;1044 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl); 1029 1045 status = false; 1030 1046 } … … 1039 1055 filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE; 1040 1056 File.open(filename.str().c_str(), ios::out); 1041 Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... ";1057 DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... "); 1042 1058 if (File == NULL) 1043 1059 return false; … … 1080 1096 //Log() << Verbose(0) << endl; 1081 1097 } else { 1082 Log() << Verbose(0) << "Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << Walker->ListOfBonds.size() << "." << endl;1098 DoLog(0) && (Log() << Verbose(0) << "Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << Walker->ListOfBonds.size() << "." << endl); 1083 1099 status = false; 1084 1100 } … … 1103 1119 1104 1120 if (!CheckAdjacencyFileAgainstMolecule_Init(path, File, CurrentBonds)) { 1105 Log() << Verbose(1) << "Adjacency file not found." << endl;1121 DoLog(1) && (Log() << Verbose(1) << "Adjacency file not found." << endl); 1106 1122 return true; 1107 1123 } … … 1129 1145 1130 1146 if (status) { // if equal we parse the KeySetFile 1131 Log() << Verbose(1) << "done: Equal." << endl;1147 DoLog(1) && (Log() << Verbose(1) << "done: Equal." << endl); 1132 1148 } else 1133 Log() << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl;1149 DoLog(1) && (Log() << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl); 1134 1150 return status; 1135 1151 } … … 1147 1163 bool status = true; 1148 1164 if (ReferenceStack->IsEmpty()) { 1149 Log() << Verbose(1) << "ReferenceStack is empty!" << endl;1165 DoLog(1) && (Log() << Verbose(1) << "ReferenceStack is empty!" << endl); 1150 1166 return false; 1151 1167 } … … 1162 1178 if (OtherAtom == ListOfLocalAtoms[(*Runner)->rightatom->nr]) { // found the bond 1163 1179 LocalStack->Push((*Runner)); 1164 Log() << Verbose(3) << "Found local edge " << *(*Runner) << "." << endl;1180 DoLog(3) && (Log() << Verbose(3) << "Found local edge " << *(*Runner) << "." << endl); 1165 1181 break; 1166 1182 } 1167 1183 } 1168 1184 Binder = ReferenceStack->PopFirst(); // loop the stack for next item 1169 Log() << Verbose(3) << "Current candidate edge " << Binder << "." << endl;1185 DoLog(3) && (Log() << Verbose(3) << "Current candidate edge " << Binder << "." << endl); 1170 1186 ReferenceStack->Push(Binder); 1171 1187 } while (FirstBond != Binder); … … 1216 1232 BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor 1217 1233 BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1; 1218 Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " " << ((BFS.ColorList[OtherAtom->nr] == white) ? "white" : "lightgray") << ", its predecessor is " << Walker->Name << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl;1234 DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " " << ((BFS.ColorList[OtherAtom->nr] == white) ? "white" : "lightgray") << ", its predecessor is " << Walker->Name << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl); 1219 1235 if ((((BFS.ShortestPathList[OtherAtom->nr] < BFS.BondOrder) && (Binder != Bond)))) { // Check for maximum distance 1220 Log() << Verbose(3);1236 DoLog(3) && (Log() << Verbose(3)); 1221 1237 if (AddedAtomList[OtherAtom->nr] == NULL) { // add if it's not been so far 1222 1238 AddedAtomList[OtherAtom->nr] = Mol->AddCopyAtom(OtherAtom); 1223 Log() << Verbose(0) << "Added OtherAtom " << OtherAtom->Name;1239 DoLog(0) && (Log() << Verbose(0) << "Added OtherAtom " << OtherAtom->Name); 1224 1240 AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder); 1225 Log() << Verbose(0) << " and bond " << *(AddedBondList[Binder->nr]) << ", ";1241 DoLog(0) && (Log() << Verbose(0) << " and bond " << *(AddedBondList[Binder->nr]) << ", "); 1226 1242 } else { // this code should actually never come into play (all white atoms are not yet present in BondMolecule, that's why they are white in the first place) 1227 Log() << Verbose(0) << "Not adding OtherAtom " << OtherAtom->Name;1243 DoLog(0) && (Log() << Verbose(0) << "Not adding OtherAtom " << OtherAtom->Name); 1228 1244 if (AddedBondList[Binder->nr] == NULL) { 1229 1245 AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder); 1230 Log() << Verbose(0) << ", added Bond " << *(AddedBondList[Binder->nr]);1246 DoLog(0) && (Log() << Verbose(0) << ", added Bond " << *(AddedBondList[Binder->nr])); 1231 1247 } else 1232 Log() << Verbose(0) << ", not added Bond ";1233 } 1234 Log() << Verbose(0) << ", putting OtherAtom into queue." << endl;1248 DoLog(0) && (Log() << Verbose(0) << ", not added Bond "); 1249 } 1250 DoLog(0) && (Log() << Verbose(0) << ", putting OtherAtom into queue." << endl); 1235 1251 BFS.BFSStack->Push(OtherAtom); 1236 1252 } else { // out of bond order, then replace … … 1238 1254 BFS.ColorList[OtherAtom->nr] = white; // unmark if it has not been queued/added, to make it available via its other bonds (cyclic) 1239 1255 if (Binder == Bond) 1240 Log() << Verbose(3) << "Not Queueing, is the Root bond";1256 DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is the Root bond"); 1241 1257 else if (BFS.ShortestPathList[OtherAtom->nr] >= BFS.BondOrder) 1242 Log() << Verbose(3) << "Not Queueing, is out of Bond Count of " << BFS.BondOrder;1258 DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is out of Bond Count of " << BFS.BondOrder); 1243 1259 if (!Binder->Cyclic) 1244 Log() << Verbose(0) << ", is not part of a cyclic bond, saturating bond with Hydrogen." << endl;1260 DoLog(0) && (Log() << Verbose(0) << ", is not part of a cyclic bond, saturating bond with Hydrogen." << endl); 1245 1261 if (AddedBondList[Binder->nr] == NULL) { 1246 1262 if ((AddedAtomList[OtherAtom->nr] != NULL)) { // .. whether we add or saturate … … 1259 1275 void BreadthFirstSearchAdd_VisitedNode(molecule *Mol, struct BFSAccounting &BFS, atom *&Walker, atom *&OtherAtom, bond *&Binder, bond *&Bond, atom **&AddedAtomList, bond **&AddedBondList, bool IsAngstroem) 1260 1276 { 1261 Log() << Verbose(3) << "Not Adding, has already been visited." << endl;1277 DoLog(3) && (Log() << Verbose(3) << "Not Adding, has already been visited." << endl); 1262 1278 // This has to be a cyclic bond, check whether it's present ... 1263 1279 if (AddedBondList[Binder->nr] == NULL) { … … 1305 1321 // followed by n+1 till top of stack. 1306 1322 Walker = BFS.BFSStack->PopFirst(); // pop oldest added 1307 Log() << Verbose(1) << "Current Walker is: " << Walker->Name << ", and has " << Walker->ListOfBonds.size() << " bonds." << endl;1323 DoLog(1) && (Log() << Verbose(1) << "Current Walker is: " << Walker->Name << ", and has " << Walker->ListOfBonds.size() << " bonds." << endl); 1308 1324 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { 1309 1325 if ((*Runner) != NULL) { // don't look at bond equal NULL 1310 1326 Binder = (*Runner); 1311 1327 OtherAtom = (*Runner)->GetOtherAtom(Walker); 1312 Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl;1328 DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl); 1313 1329 if (BFS.ColorList[OtherAtom->nr] == white) { 1314 1330 BreadthFirstSearchAdd_UnvisitedNode(Mol, BFS, Walker, OtherAtom, Binder, Bond, AddedAtomList, AddedBondList, IsAngstroem); … … 1319 1335 } 1320 1336 BFS.ColorList[Walker->nr] = black; 1321 Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl;1337 DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl); 1322 1338 } 1323 1339 BreadthFirstSearchAdd_Free(BFS); … … 1344 1360 // reset parent list 1345 1361 ParentList = Calloc<atom*> (AtomCount, "molecule::BuildInducedSubgraph_Init: **ParentList"); 1346 Log() << Verbose(3) << "Resetting ParentList." << endl;1362 DoLog(3) && (Log() << Verbose(3) << "Resetting ParentList." << endl); 1347 1363 } 1348 1364 ; … … 1351 1367 { 1352 1368 // fill parent list with sons 1353 Log() << Verbose(3) << "Filling Parent List." << endl;1369 DoLog(3) && (Log() << Verbose(3) << "Filling Parent List." << endl); 1354 1370 atom *Walker = mol->start; 1355 1371 while (Walker->next != mol->end) { … … 1357 1373 ParentList[Walker->father->nr] = Walker; 1358 1374 // Outputting List for debugging 1359 Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl;1375 DoLog(4) && (Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl); 1360 1376 } 1361 1377 … … 1375 1391 atom *OtherAtom = NULL; 1376 1392 // check each entry of parent list and if ok (one-to-and-onto matching) create bonds 1377 Log() << Verbose(3) << "Creating bonds." << endl;1393 DoLog(3) && (Log() << Verbose(3) << "Creating bonds." << endl); 1378 1394 Walker = Father->start; 1379 1395 while (Walker->next != Father->end) { … … 1386 1402 OtherAtom = (*Runner)->GetOtherAtom(Walker); 1387 1403 if (ParentList[OtherAtom->nr] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond 1388 Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[Walker->nr]->Name << " and " << ParentList[OtherAtom->nr]->Name << "." << endl;1404 DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[Walker->nr]->Name << " and " << ParentList[OtherAtom->nr]->Name << "." << endl); 1389 1405 mol->AddBond(ParentList[Walker->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree); 1390 1406 } … … 1411 1427 atom **ParentList = NULL; 1412 1428 1413 Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl;1429 DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl); 1414 1430 BuildInducedSubgraph_Init(ParentList, Father->AtomCount); 1415 1431 BuildInducedSubgraph_FillParentList(this, Father, ParentList); 1416 1432 status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList); 1417 1433 BuildInducedSubgraph_Finalize(ParentList); 1418 Log() << Verbose(2) << "End of BuildInducedSubgraph." << endl;1434 DoLog(2) && (Log() << Verbose(2) << "End of BuildInducedSubgraph." << endl); 1419 1435 return status; 1420 1436 } … … 1433 1449 int size; 1434 1450 1435 Log() << Verbose(1) << "Begin of CheckForConnectedSubgraph" << endl;1436 Log() << Verbose(2) << "Disconnected atom: ";1451 DoLog(1) && (Log() << Verbose(1) << "Begin of CheckForConnectedSubgraph" << endl); 1452 DoLog(2) && (Log() << Verbose(2) << "Disconnected atom: "); 1437 1453 1438 1454 // count number of atoms in graph … … 1456 1472 } 1457 1473 if (!BondStatus) { 1458 Log() << Verbose(0) << (*Walker) << endl;1474 DoLog(0) && (Log() << Verbose(0) << (*Walker) << endl); 1459 1475 return false; 1460 1476 } 1461 1477 } 1462 1478 else { 1463 Log() << Verbose(0) << "none." << endl;1479 DoLog(0) && (Log() << Verbose(0) << "none." << endl); 1464 1480 return true; 1465 1481 } 1466 Log() << Verbose(0) << "none." << endl;1467 1468 Log() << Verbose(1) << "End of CheckForConnectedSubgraph" << endl;1482 DoLog(0) && (Log() << Verbose(0) << "none." << endl); 1483 1484 DoLog(1) && (Log() << Verbose(1) << "End of CheckForConnectedSubgraph" << endl); 1469 1485 1470 1486 return true;
Note:
See TracChangeset
for help on using the changeset viewer.