Changeset a67d19 for src/molecule_graph.cpp
- Timestamp:
- Apr 22, 2010, 2:00:03 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:
- 299554
- Parents:
- 6613ec
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_graph.cpp
r6613ec ra67d19 59 59 60 60 if (!input) { 61 Log() << Verbose(1) << "Opening silica failed \n";61 DoLog(1) && (Log() << Verbose(1) << "Opening silica failed \n"); 62 62 }; 63 63 64 64 *input >> ws >> atom1; 65 65 *input >> ws >> atom2; 66 Log() << Verbose(1) << "Scanning file\n";66 DoLog(1) && (Log() << Verbose(1) << "Scanning file\n"); 67 67 while (!input->eof()) // Check whether we read everything already 68 68 { … … 115 115 116 116 BondDistance = bonddistance; // * ((IsAngstroem) ? 1. : 1./AtomicLengthToAngstroem); 117 Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl;117 DoLog(0) && (Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl); 118 118 // remove every bond from the list 119 119 bond *Binder = NULL; … … 128 128 // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering) 129 129 CountAtoms(); 130 Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl;130 DoLog(1) && (Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl); 131 131 132 132 if ((AtomCount > 1) && (bonddistance > 1.)) { 133 Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl;133 DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl); 134 134 LC = new LinkedCell(this, bonddistance); 135 135 136 136 // create a list to map Tesselpoint::nr to atom * 137 Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl;137 DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl); 138 138 AtomMap = Calloc<atom *> (AtomCount, "molecule::CreateAdjacencyList - **AtomCount"); 139 139 Walker = start; … … 144 144 145 145 // 3a. go through every cell 146 Log() << Verbose(2) << "Celling ... " << endl;146 DoLog(2) && (Log() << Verbose(2) << "Celling ... " << endl); 147 147 for (LC->n[0] = 0; LC->n[0] < LC->N[0]; LC->n[0]++) 148 148 for (LC->n[1] = 0; LC->n[1] < LC->N[1]; LC->n[1]++) … … 183 183 Free(&AtomMap); 184 184 delete (LC); 185 Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl;185 DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl); 186 186 187 187 // correct bond degree by comparing valence and bond degree 188 Log() << Verbose(2) << "Correcting bond degree ... " << endl;188 DoLog(2) && (Log() << Verbose(2) << "Correcting bond degree ... " << endl); 189 189 CorrectBondDegree(); 190 190 … … 192 192 ActOnAllAtoms( &atom::OutputBondOfAtom ); 193 193 } else 194 Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl;195 Log() << Verbose(0) << "End of CreateAdjacencyList." << endl;194 DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl); 195 DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl); 196 196 if (free_BG) 197 197 delete(BG); … … 204 204 void molecule::OutputBondsList() const 205 205 { 206 Log() << Verbose(1) << endl << "From contents of bond chain list:";206 DoLog(1) && (Log() << Verbose(1) << endl << "From contents of bond chain list:"); 207 207 bond *Binder = first; 208 208 while (Binder->next != last) { 209 209 Binder = Binder->next; 210 Log() << Verbose(0) << *Binder << "\t" << endl;211 } 212 Log() << Verbose(0) << endl;210 DoLog(0) && (Log() << Verbose(0) << *Binder << "\t" << endl); 211 } 212 DoLog(0) && (Log() << Verbose(0) << endl); 213 213 } 214 214 ; … … 227 227 228 228 if (BondCount != 0) { 229 Log() << Verbose(1) << "Correcting Bond degree of each bond ... " << endl;229 DoLog(1) && (Log() << Verbose(1) << "Correcting Bond degree of each bond ... " << endl); 230 230 do { 231 231 OldNo = No; 232 232 No = SumPerAtom( &atom::CorrectBondDegree ); 233 233 } while (OldNo != No); 234 Log() << Verbose(0) << " done." << endl;234 DoLog(0) && (Log() << Verbose(0) << " done." << endl); 235 235 } else { 236 Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl;237 } 238 Log() << Verbose(0) << No << " bonds could not be corrected." << endl;236 DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl); 237 } 238 DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl); 239 239 240 240 return (No); … … 255 255 bond *Binder = first; 256 256 if ((Binder->next != last) && (Binder->next->Type == Undetermined)) { 257 Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl;257 DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl); 258 258 Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack); 259 259 while (Subgraphs->next != NULL) { … … 310 310 Walker->GraphNr = DFS.CurrentGraphNr; 311 311 Walker->LowpointNr = DFS.CurrentGraphNr; 312 Log() << Verbose(1) << "Setting Walker[" << Walker->Name << "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl;312 DoLog(1) && (Log() << Verbose(1) << "Setting Walker[" << Walker->Name << "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl); 313 313 DFS.AtomStack->Push(Walker); 314 314 DFS.CurrentGraphNr++; … … 337 337 if (Binder == NULL) 338 338 break; 339 Log() << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl;339 DoLog(2) && (Log() << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl); 340 340 // (4) Mark Binder used, ... 341 341 Binder->MarkUsed(black); 342 342 OtherAtom = Binder->GetOtherAtom(Walker); 343 Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->Name << "." << endl;343 DoLog(2) && (Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->Name << "." << endl); 344 344 if (OtherAtom->GraphNr != -1) { 345 345 // (4a) ... if "other" atom has been visited (GraphNr != 0), set lowpoint to minimum of both, go to (3) … … 347 347 DFS.BackEdgeStack->Push(Binder); 348 348 Walker->LowpointNr = (Walker->LowpointNr < OtherAtom->GraphNr) ? Walker->LowpointNr : OtherAtom->GraphNr; 349 Log() << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->Name << "] to " << Walker->LowpointNr << "." << endl;349 DoLog(3) && (Log() << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->Name << "] to " << Walker->LowpointNr << "." << endl); 350 350 } else { 351 351 // (4b) ... otherwise set OtherAtom as Ancestor of Walker and Walker as OtherAtom, go to (2) … … 353 353 OtherAtom->Ancestor = Walker; 354 354 Walker = OtherAtom; 355 Log() << Verbose(3) << "(4b) Not Visited: OtherAtom[" << OtherAtom->Name << "]'s Ancestor is now " << OtherAtom->Ancestor->Name << ", Walker is OtherAtom " << OtherAtom->Name << "." << endl;355 DoLog(3) && (Log() << Verbose(3) << "(4b) Not Visited: OtherAtom[" << OtherAtom->Name << "]'s Ancestor is now " << OtherAtom->Ancestor->Name << ", Walker is OtherAtom " << OtherAtom->Name << "." << endl); 356 356 break; 357 357 } … … 375 375 376 376 // (5) if Ancestor of Walker is ... 377 Log() << Verbose(1) << "(5) Number of Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "] is " << Walker->Ancestor->GraphNr << "." << endl;377 DoLog(1) && (Log() << Verbose(1) << "(5) Number of Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "] is " << Walker->Ancestor->GraphNr << "." << endl); 378 378 379 379 if (Walker->Ancestor->GraphNr != DFS.Root->GraphNr) { … … 382 382 // (6a) set Ancestor's Lowpoint number to minimum of of its Ancestor and itself, go to Step(8) 383 383 Walker->Ancestor->LowpointNr = (Walker->Ancestor->LowpointNr < Walker->LowpointNr) ? Walker->Ancestor->LowpointNr : Walker->LowpointNr; 384 Log() << Verbose(2) << "(6) Setting Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s Lowpoint to " << Walker->Ancestor->LowpointNr << "." << endl;384 DoLog(2) && (Log() << Verbose(2) << "(6) Setting Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s Lowpoint to " << Walker->Ancestor->LowpointNr << "." << endl); 385 385 } else { 386 386 // (7) (Ancestor of Walker is a separating vertex, remove all from stack till Walker (including), these and Ancestor form a component 387 387 Walker->Ancestor->SeparationVertex = true; 388 Log() << Verbose(2) << "(7) Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s is a separating vertex, creating component." << endl;388 DoLog(2) && (Log() << Verbose(2) << "(7) Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s is a separating vertex, creating component." << endl); 389 389 mol->SetNextComponentNumber(Walker->Ancestor, DFS.ComponentNumber); 390 Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Ancestor's Compont is " << DFS.ComponentNumber << "." << endl;390 DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Ancestor's Compont is " << DFS.ComponentNumber << "." << endl); 391 391 mol->SetNextComponentNumber(Walker, DFS.ComponentNumber); 392 Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl;392 DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl); 393 393 do { 394 394 OtherAtom = DFS.AtomStack->PopLast(); 395 395 LeafWalker->Leaf->AddCopyAtom(OtherAtom); 396 396 mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber); 397 Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl;397 DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl); 398 398 } while (OtherAtom != Walker); 399 399 DFS.ComponentNumber++; 400 400 } 401 401 // (8) Walker becomes its Ancestor, go to (3) 402 Log() << Verbose(2) << "(8) Walker[" << Walker->Name << "] is now its Ancestor " << Walker->Ancestor->Name << ", backstepping. " << endl;402 DoLog(2) && (Log() << Verbose(2) << "(8) Walker[" << Walker->Name << "] is now its Ancestor " << Walker->Ancestor->Name << ", backstepping. " << endl); 403 403 Walker = Walker->Ancestor; 404 404 DFS.BackStepping = true; … … 424 424 //DFS.AtomStack->Output(out); 425 425 mol->SetNextComponentNumber(DFS.Root, DFS.ComponentNumber); 426 Log() << Verbose(3) << "(9) Root[" << DFS.Root->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl;426 DoLog(3) && (Log() << Verbose(3) << "(9) Root[" << DFS.Root->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl); 427 427 mol->SetNextComponentNumber(Walker, DFS.ComponentNumber); 428 Log() << Verbose(3) << "(9) Walker[" << Walker->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl;428 DoLog(3) && (Log() << Verbose(3) << "(9) Walker[" << Walker->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl); 429 429 do { 430 430 OtherAtom = DFS.AtomStack->PopLast(); 431 431 LeafWalker->Leaf->AddCopyAtom(OtherAtom); 432 432 mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber); 433 Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl;433 DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl); 434 434 } while (OtherAtom != Walker); 435 435 DFS.ComponentNumber++; … … 438 438 Walker = DFS.Root; 439 439 Binder = mol->FindNextUnused(Walker); 440 Log() << Verbose(1) << "(10) Walker is Root[" << DFS.Root->Name << "], next Unused Bond is " << Binder << "." << endl;440 DoLog(1) && (Log() << Verbose(1) << "(10) Walker is Root[" << DFS.Root->Name << "], next Unused Bond is " << Binder << "." << endl); 441 441 if (Binder != NULL) { // Root is separation vertex 442 Log() << Verbose(1) << "(11) Root is a separation vertex." << endl;442 DoLog(1) && (Log() << Verbose(1) << "(11) Root is a separation vertex." << endl); 443 443 Walker->SeparationVertex = true; 444 444 } … … 497 497 if (AtomCount == 0) 498 498 return SubGraphs; 499 Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl;499 DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl); 500 500 DepthFirstSearchAnalysis_Init(DFS, this); 501 501 … … 519 519 520 520 if (Binder == NULL) { 521 Log() << Verbose(2) << "No more Unused Bonds." << endl;521 DoLog(2) && (Log() << Verbose(2) << "No more Unused Bonds." << endl); 522 522 break; 523 523 } else … … 536 536 537 537 // From OldGraphNr to CurrentGraphNr ranges an disconnected subgraph 538 Log() << Verbose(0) << "Disconnected subgraph ranges from " << OldGraphNr << " to " << DFS.CurrentGraphNr << "." << endl;538 DoLog(0) && (Log() << Verbose(0) << "Disconnected subgraph ranges from " << OldGraphNr << " to " << DFS.CurrentGraphNr << "." << endl); 539 539 LeafWalker->Leaf->Output((ofstream *)&cout); 540 Log() << Verbose(0) << endl;540 DoLog(0) && (Log() << Verbose(0) << endl); 541 541 542 542 // step on to next root … … 556 556 // free all and exit 557 557 DepthFirstSearchAnalysis_Finalize(DFS); 558 Log() << Verbose(0) << "End of DepthFirstSearchAnalysis" << endl;558 DoLog(0) && (Log() << Verbose(0) << "End of DepthFirstSearchAnalysis" << endl); 559 559 return SubGraphs; 560 560 } … … 582 582 void molecule::OutputGraphInfoPerAtom() const 583 583 { 584 Log() << Verbose(1) << "Final graph info for each atom is:" << endl;584 DoLog(1) && (Log() << Verbose(1) << "Final graph info for each atom is:" << endl); 585 585 ActOnAllAtoms( &atom::OutputGraphInfo ); 586 586 } … … 592 592 void molecule::OutputGraphInfoPerBond() const 593 593 { 594 Log() << Verbose(1) << "Final graph info for each bond is:" << endl;594 DoLog(1) && (Log() << Verbose(1) << "Final graph info for each bond is:" << endl); 595 595 bond *Binder = first; 596 596 while (Binder->next != last) { 597 597 Binder = Binder->next; 598 Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <";599 Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp.";598 DoLog(2) && (Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <"); 599 DoLog(0) && (Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp."); 600 600 Binder->leftatom->OutputComponentNumber(); 601 Log() << Verbose(0) << " === ";602 Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp.";601 DoLog(0) && (Log() << Verbose(0) << " === "); 602 DoLog(0) && (Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp."); 603 603 Binder->rightatom->OutputComponentNumber(); 604 Log() << Verbose(0) << ">." << endl;604 DoLog(0) && (Log() << Verbose(0) << ">." << endl); 605 605 if (Binder->Cyclic) // cyclic ?? 606 Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl;606 DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl); 607 607 } 608 608 } … … 678 678 do { // look for Root 679 679 Walker = BFS.BFSStack->PopFirst(); 680 Log() << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *BFS.Root << "." << endl;680 DoLog(2) && (Log() << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *BFS.Root << "." << endl); 681 681 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { 682 682 if ((*Runner) != BackEdge) { // only walk along DFS spanning tree (otherwise we always find SP of one being backedge Binder) … … 685 685 if (OtherAtom->type->Z != 1) { 686 686 #endif 687 Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl;687 DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl); 688 688 if (BFS.ColorList[OtherAtom->nr] == white) { 689 689 BFS.TouchedStack->Push(OtherAtom); … … 691 691 BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor 692 692 BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1; 693 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;693 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); 694 694 //if (BFS.ShortestPathList[OtherAtom->nr] < MinimumRingSize[Walker->GetTrueFather()->nr]) { // Check for maximum distance 695 Log() << Verbose(3) << "Putting OtherAtom into queue." << endl;695 DoLog(3) && (Log() << Verbose(3) << "Putting OtherAtom into queue." << endl); 696 696 BFS.BFSStack->Push(OtherAtom); 697 697 //} 698 698 } else { 699 Log() << Verbose(3) << "Not Adding, has already been visited." << endl;699 DoLog(3) && (Log() << Verbose(3) << "Not Adding, has already been visited." << endl); 700 700 } 701 701 if (OtherAtom == BFS.Root) … … 703 703 #ifdef ADDHYDROGEN 704 704 } else { 705 Log() << Verbose(2) << "Skipping hydrogen atom " << *OtherAtom << "." << endl;705 DoLog(2) && (Log() << Verbose(2) << "Skipping hydrogen atom " << *OtherAtom << "." << endl); 706 706 BFS.ColorList[OtherAtom->nr] = black; 707 707 } 708 708 #endif 709 709 } else { 710 Log() << Verbose(2) << "Bond " << *(*Runner) << " not Visiting, is the back edge." << endl;710 DoLog(2) && (Log() << Verbose(2) << "Bond " << *(*Runner) << " not Visiting, is the back edge." << endl); 711 711 } 712 712 } 713 713 BFS.ColorList[Walker->nr] = black; 714 Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl;714 DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl); 715 715 if (OtherAtom == BFS.Root) { // if we have found the root, check whether this cycle wasn't already found beforehand 716 716 // step through predecessor list … … 722 722 } 723 723 if (OtherAtom == BackEdge->rightatom) { // if each atom in found cycle is cyclic, loop's been found before already 724 Log() << Verbose(3) << "This cycle was already found before, skipping and removing seeker from search." << endl;724 DoLog(3) && (Log() << Verbose(3) << "This cycle was already found before, skipping and removing seeker from search." << endl); 725 725 do { 726 726 OtherAtom = BFS.TouchedStack->PopLast(); 727 727 if (BFS.PredecessorList[OtherAtom->nr] == Walker) { 728 Log() << Verbose(4) << "Removing " << *OtherAtom << " from lists and stacks." << endl;728 DoLog(4) && (Log() << Verbose(4) << "Removing " << *OtherAtom << " from lists and stacks." << endl); 729 729 BFS.PredecessorList[OtherAtom->nr] = NULL; 730 730 BFS.ShortestPathList[OtherAtom->nr] = -1; … … 760 760 RingSize = 1; 761 761 BFS.Root->GetTrueFather()->IsCyclic = true; 762 Log() << Verbose(1) << "Found ring contains: ";762 DoLog(1) && (Log() << Verbose(1) << "Found ring contains: "); 763 763 Walker = BFS.Root; 764 764 while (Walker != BackEdge->rightatom) { 765 Log() << Verbose(0) << Walker->Name << " <-> ";765 DoLog(0) && (Log() << Verbose(0) << Walker->Name << " <-> "); 766 766 Walker = BFS.PredecessorList[Walker->nr]; 767 767 Walker->GetTrueFather()->IsCyclic = true; 768 768 RingSize++; 769 769 } 770 Log() << Verbose(0) << Walker->Name << " with a length of " << RingSize << "." << endl << endl;770 DoLog(0) && (Log() << Verbose(0) << Walker->Name << " with a length of " << RingSize << "." << endl << endl); 771 771 // walk through all and set MinimumRingSize 772 772 Walker = BFS.Root; … … 780 780 MinRingSize = RingSize; 781 781 } else { 782 Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[Walker->GetTrueFather()->nr] << " found." << endl;782 DoLog(1) && (Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[Walker->GetTrueFather()->nr] << " found." << endl); 783 783 } 784 784 }; … … 858 858 859 859 } 860 Log() << Verbose(1) << "Minimum ring size of " << *Root << " is " << MinimumRingSize[Root->GetTrueFather()->nr] << "." << endl;861 } 862 Log() << Verbose(1) << "Minimum ring size is " << MinRingSize << ", over " << NumCycles << " cycles total." << endl;860 DoLog(1) && (Log() << Verbose(1) << "Minimum ring size of " << *Root << " is " << MinimumRingSize[Root->GetTrueFather()->nr] << "." << endl); 861 } 862 DoLog(1) && (Log() << Verbose(1) << "Minimum ring size is " << MinRingSize << ", over " << NumCycles << " cycles total." << endl); 863 863 } else 864 Log() << Verbose(1) << "No rings were detected in the molecular structure." << endl;864 DoLog(1) && (Log() << Verbose(1) << "No rings were detected in the molecular structure." << endl); 865 865 } 866 866 ; … … 890 890 //BackEdgeStack->Output(out); 891 891 892 Log() << Verbose(1) << "Analysing cycles ... " << endl;892 DoLog(1) && (Log() << Verbose(1) << "Analysing cycles ... " << endl); 893 893 NumCycles = 0; 894 894 while (!BackEdgeStack->IsEmpty()) { … … 901 901 ResetBFSAccounting(Walker, BFS); 902 902 903 Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl;903 DoLog(1) && (Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl); 904 904 OtherAtom = NULL; 905 905 CyclicStructureAnalysis_CyclicBFSFromRootToRoot(BackEdge, BFS); … … 973 973 void OutputAlreadyVisited(int *list) 974 974 { 975 Log() << Verbose(4) << "Already Visited Bonds:\t";975 DoLog(4) && (Log() << Verbose(4) << "Already Visited Bonds:\t"); 976 976 for (int i = 1; i <= list[0]; i++) 977 Log() << Verbose(0) << list[i] << " ";978 Log() << Verbose(0) << endl;977 DoLog(0) && (Log() << Verbose(0) << list[i] << " "); 978 DoLog(0) && (Log() << Verbose(0) << endl); 979 979 } 980 980 ; … … 997 997 line << filename; 998 998 AdjacencyFile.open(line.str().c_str(), ios::out); 999 Log() << Verbose(1) << "Saving adjacency list ... ";999 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... "); 1000 1000 if (AdjacencyFile != NULL) { 1001 1001 AdjacencyFile << "m\tn" << endl; 1002 1002 ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile); 1003 1003 AdjacencyFile.close(); 1004 Log() << Verbose(1) << "done." << endl;1004 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 1005 1005 } else { 1006 Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;1006 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl); 1007 1007 status = false; 1008 1008 } … … 1029 1029 line << filename; 1030 1030 BondFile.open(line.str().c_str(), ios::out); 1031 Log() << Verbose(1) << "Saving adjacency list ... ";1031 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... "); 1032 1032 if (BondFile != NULL) { 1033 1033 BondFile << "m\tn" << endl; 1034 1034 ActOnAllAtoms(&atom::OutputBonds, &BondFile); 1035 1035 BondFile.close(); 1036 Log() << Verbose(1) << "done." << endl;1036 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 1037 1037 } else { 1038 Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;1038 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl); 1039 1039 status = false; 1040 1040 } … … 1049 1049 filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE; 1050 1050 File.open(filename.str().c_str(), ios::out); 1051 Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... ";1051 DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... "); 1052 1052 if (File == NULL) 1053 1053 return false; … … 1090 1090 //Log() << Verbose(0) << endl; 1091 1091 } else { 1092 Log() << Verbose(0) << "Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << Walker->ListOfBonds.size() << "." << endl;1092 DoLog(0) && (Log() << Verbose(0) << "Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << Walker->ListOfBonds.size() << "." << endl); 1093 1093 status = false; 1094 1094 } … … 1113 1113 1114 1114 if (!CheckAdjacencyFileAgainstMolecule_Init(path, File, CurrentBonds)) { 1115 Log() << Verbose(1) << "Adjacency file not found." << endl;1115 DoLog(1) && (Log() << Verbose(1) << "Adjacency file not found." << endl); 1116 1116 return true; 1117 1117 } … … 1139 1139 1140 1140 if (status) { // if equal we parse the KeySetFile 1141 Log() << Verbose(1) << "done: Equal." << endl;1141 DoLog(1) && (Log() << Verbose(1) << "done: Equal." << endl); 1142 1142 } else 1143 Log() << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl;1143 DoLog(1) && (Log() << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl); 1144 1144 return status; 1145 1145 } … … 1157 1157 bool status = true; 1158 1158 if (ReferenceStack->IsEmpty()) { 1159 Log() << Verbose(1) << "ReferenceStack is empty!" << endl;1159 DoLog(1) && (Log() << Verbose(1) << "ReferenceStack is empty!" << endl); 1160 1160 return false; 1161 1161 } … … 1172 1172 if (OtherAtom == ListOfLocalAtoms[(*Runner)->rightatom->nr]) { // found the bond 1173 1173 LocalStack->Push((*Runner)); 1174 Log() << Verbose(3) << "Found local edge " << *(*Runner) << "." << endl;1174 DoLog(3) && (Log() << Verbose(3) << "Found local edge " << *(*Runner) << "." << endl); 1175 1175 break; 1176 1176 } 1177 1177 } 1178 1178 Binder = ReferenceStack->PopFirst(); // loop the stack for next item 1179 Log() << Verbose(3) << "Current candidate edge " << Binder << "." << endl;1179 DoLog(3) && (Log() << Verbose(3) << "Current candidate edge " << Binder << "." << endl); 1180 1180 ReferenceStack->Push(Binder); 1181 1181 } while (FirstBond != Binder); … … 1226 1226 BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor 1227 1227 BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1; 1228 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;1228 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); 1229 1229 if ((((BFS.ShortestPathList[OtherAtom->nr] < BFS.BondOrder) && (Binder != Bond)))) { // Check for maximum distance 1230 Log() << Verbose(3);1230 DoLog(3) && (Log() << Verbose(3)); 1231 1231 if (AddedAtomList[OtherAtom->nr] == NULL) { // add if it's not been so far 1232 1232 AddedAtomList[OtherAtom->nr] = Mol->AddCopyAtom(OtherAtom); 1233 Log() << Verbose(0) << "Added OtherAtom " << OtherAtom->Name;1233 DoLog(0) && (Log() << Verbose(0) << "Added OtherAtom " << OtherAtom->Name); 1234 1234 AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder); 1235 Log() << Verbose(0) << " and bond " << *(AddedBondList[Binder->nr]) << ", ";1235 DoLog(0) && (Log() << Verbose(0) << " and bond " << *(AddedBondList[Binder->nr]) << ", "); 1236 1236 } 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) 1237 Log() << Verbose(0) << "Not adding OtherAtom " << OtherAtom->Name;1237 DoLog(0) && (Log() << Verbose(0) << "Not adding OtherAtom " << OtherAtom->Name); 1238 1238 if (AddedBondList[Binder->nr] == NULL) { 1239 1239 AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder); 1240 Log() << Verbose(0) << ", added Bond " << *(AddedBondList[Binder->nr]);1240 DoLog(0) && (Log() << Verbose(0) << ", added Bond " << *(AddedBondList[Binder->nr])); 1241 1241 } else 1242 Log() << Verbose(0) << ", not added Bond ";1243 } 1244 Log() << Verbose(0) << ", putting OtherAtom into queue." << endl;1242 DoLog(0) && (Log() << Verbose(0) << ", not added Bond "); 1243 } 1244 DoLog(0) && (Log() << Verbose(0) << ", putting OtherAtom into queue." << endl); 1245 1245 BFS.BFSStack->Push(OtherAtom); 1246 1246 } else { // out of bond order, then replace … … 1248 1248 BFS.ColorList[OtherAtom->nr] = white; // unmark if it has not been queued/added, to make it available via its other bonds (cyclic) 1249 1249 if (Binder == Bond) 1250 Log() << Verbose(3) << "Not Queueing, is the Root bond";1250 DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is the Root bond"); 1251 1251 else if (BFS.ShortestPathList[OtherAtom->nr] >= BFS.BondOrder) 1252 Log() << Verbose(3) << "Not Queueing, is out of Bond Count of " << BFS.BondOrder;1252 DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is out of Bond Count of " << BFS.BondOrder); 1253 1253 if (!Binder->Cyclic) 1254 Log() << Verbose(0) << ", is not part of a cyclic bond, saturating bond with Hydrogen." << endl;1254 DoLog(0) && (Log() << Verbose(0) << ", is not part of a cyclic bond, saturating bond with Hydrogen." << endl); 1255 1255 if (AddedBondList[Binder->nr] == NULL) { 1256 1256 if ((AddedAtomList[OtherAtom->nr] != NULL)) { // .. whether we add or saturate … … 1269 1269 void BreadthFirstSearchAdd_VisitedNode(molecule *Mol, struct BFSAccounting &BFS, atom *&Walker, atom *&OtherAtom, bond *&Binder, bond *&Bond, atom **&AddedAtomList, bond **&AddedBondList, bool IsAngstroem) 1270 1270 { 1271 Log() << Verbose(3) << "Not Adding, has already been visited." << endl;1271 DoLog(3) && (Log() << Verbose(3) << "Not Adding, has already been visited." << endl); 1272 1272 // This has to be a cyclic bond, check whether it's present ... 1273 1273 if (AddedBondList[Binder->nr] == NULL) { … … 1315 1315 // followed by n+1 till top of stack. 1316 1316 Walker = BFS.BFSStack->PopFirst(); // pop oldest added 1317 Log() << Verbose(1) << "Current Walker is: " << Walker->Name << ", and has " << Walker->ListOfBonds.size() << " bonds." << endl;1317 DoLog(1) && (Log() << Verbose(1) << "Current Walker is: " << Walker->Name << ", and has " << Walker->ListOfBonds.size() << " bonds." << endl); 1318 1318 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { 1319 1319 if ((*Runner) != NULL) { // don't look at bond equal NULL 1320 1320 Binder = (*Runner); 1321 1321 OtherAtom = (*Runner)->GetOtherAtom(Walker); 1322 Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl;1322 DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl); 1323 1323 if (BFS.ColorList[OtherAtom->nr] == white) { 1324 1324 BreadthFirstSearchAdd_UnvisitedNode(Mol, BFS, Walker, OtherAtom, Binder, Bond, AddedAtomList, AddedBondList, IsAngstroem); … … 1329 1329 } 1330 1330 BFS.ColorList[Walker->nr] = black; 1331 Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl;1331 DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl); 1332 1332 } 1333 1333 BreadthFirstSearchAdd_Free(BFS); … … 1354 1354 // reset parent list 1355 1355 ParentList = Calloc<atom*> (AtomCount, "molecule::BuildInducedSubgraph_Init: **ParentList"); 1356 Log() << Verbose(3) << "Resetting ParentList." << endl;1356 DoLog(3) && (Log() << Verbose(3) << "Resetting ParentList." << endl); 1357 1357 } 1358 1358 ; … … 1361 1361 { 1362 1362 // fill parent list with sons 1363 Log() << Verbose(3) << "Filling Parent List." << endl;1363 DoLog(3) && (Log() << Verbose(3) << "Filling Parent List." << endl); 1364 1364 atom *Walker = mol->start; 1365 1365 while (Walker->next != mol->end) { … … 1367 1367 ParentList[Walker->father->nr] = Walker; 1368 1368 // Outputting List for debugging 1369 Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl;1369 DoLog(4) && (Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl); 1370 1370 } 1371 1371 … … 1385 1385 atom *OtherAtom = NULL; 1386 1386 // check each entry of parent list and if ok (one-to-and-onto matching) create bonds 1387 Log() << Verbose(3) << "Creating bonds." << endl;1387 DoLog(3) && (Log() << Verbose(3) << "Creating bonds." << endl); 1388 1388 Walker = Father->start; 1389 1389 while (Walker->next != Father->end) { … … 1396 1396 OtherAtom = (*Runner)->GetOtherAtom(Walker); 1397 1397 if (ParentList[OtherAtom->nr] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond 1398 Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[Walker->nr]->Name << " and " << ParentList[OtherAtom->nr]->Name << "." << endl;1398 DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[Walker->nr]->Name << " and " << ParentList[OtherAtom->nr]->Name << "." << endl); 1399 1399 mol->AddBond(ParentList[Walker->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree); 1400 1400 } … … 1421 1421 atom **ParentList = NULL; 1422 1422 1423 Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl;1423 DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl); 1424 1424 BuildInducedSubgraph_Init(ParentList, Father->AtomCount); 1425 1425 BuildInducedSubgraph_FillParentList(this, Father, ParentList); 1426 1426 status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList); 1427 1427 BuildInducedSubgraph_Finalize(ParentList); 1428 Log() << Verbose(2) << "End of BuildInducedSubgraph." << endl;1428 DoLog(2) && (Log() << Verbose(2) << "End of BuildInducedSubgraph." << endl); 1429 1429 return status; 1430 1430 } … … 1443 1443 int size; 1444 1444 1445 Log() << Verbose(1) << "Begin of CheckForConnectedSubgraph" << endl;1446 Log() << Verbose(2) << "Disconnected atom: ";1445 DoLog(1) && (Log() << Verbose(1) << "Begin of CheckForConnectedSubgraph" << endl); 1446 DoLog(2) && (Log() << Verbose(2) << "Disconnected atom: "); 1447 1447 1448 1448 // count number of atoms in graph … … 1466 1466 } 1467 1467 if (!BondStatus) { 1468 Log() << Verbose(0) << (*Walker) << endl;1468 DoLog(0) && (Log() << Verbose(0) << (*Walker) << endl); 1469 1469 return false; 1470 1470 } 1471 1471 } 1472 1472 else { 1473 Log() << Verbose(0) << "none." << endl;1473 DoLog(0) && (Log() << Verbose(0) << "none." << endl); 1474 1474 return true; 1475 1475 } 1476 Log() << Verbose(0) << "none." << endl;1477 1478 Log() << Verbose(1) << "End of CheckForConnectedSubgraph" << endl;1476 DoLog(0) && (Log() << Verbose(0) << "none." << endl); 1477 1478 DoLog(1) && (Log() << Verbose(1) << "End of CheckForConnectedSubgraph" << endl); 1479 1479 1480 1480 return true;
Note:
See TracChangeset
for help on using the changeset viewer.