Changeset ce5f05 for src/molecule_graph.cpp
- Timestamp:
- Mar 1, 2011, 10:16:46 AM (14 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:
- 3738f0
- Parents:
- 4092c5
- git-author:
- Frederik Heber <heber@…> (02/18/11 16:24:28)
- git-committer:
- Frederik Heber <heber@…> (03/01/11 10:16:46)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_graph.cpp
r4092c5 rce5f05 48 48 atom **PredecessorList; 49 49 int *ShortestPathList; 50 enum Shading *ColorList;50 enum bond::Shading *ColorList; 51 51 std::deque<atom *> *BFSStack; 52 52 std::deque<atom *> *TouchedStack; … … 308 308 for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) { 309 309 const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds(); 310 if ((!ListOfBonds.empty()) && ((*ListOfBonds.begin())->Type == Undetermined)) {310 if ((!ListOfBonds.empty()) && ((*ListOfBonds.begin())->Type == bond::Undetermined)) { 311 311 DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl); 312 312 Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack); … … 334 334 ; 335 335 336 /** Returns Shading as a char string.337 * \param color the Shading338 * \return string of the flag339 */340 string molecule::GetColor(enum Shading color) const341 {342 switch (color) {343 case white:344 return "white";345 break;346 case lightgray:347 return "lightgray";348 break;349 case darkgray:350 return "darkgray";351 break;352 case black:353 return "black";354 break;355 default:356 return "uncolored";357 break;358 };359 }360 ;361 336 362 337 /** Sets atom::GraphNr and atom::LowpointNr to BFSAccounting::CurrentGraphNr. … … 397 372 DoLog(2) && (Log() << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl); 398 373 // (4) Mark Binder used, ... 399 Binder->MarkUsed(b lack);374 Binder->MarkUsed(bond::black); 400 375 OtherAtom = Binder->GetOtherAtom(Walker); 401 376 DoLog(2) && (Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->getName() << "." << endl); 402 377 if (OtherAtom->GraphNr != -1) { 403 378 // (4a) ... if "other" atom has been visited (GraphNr != 0), set lowpoint to minimum of both, go to (3) 404 Binder->Type = BackEdge;379 Binder->Type = bond::BackEdge; 405 380 DFS.BackEdgeStack->push_front(Binder); 406 381 Walker->LowpointNr = (Walker->LowpointNr < OtherAtom->GraphNr) ? Walker->LowpointNr : OtherAtom->GraphNr; … … 408 383 } else { 409 384 // (4b) ... otherwise set OtherAtom as Ancestor of Walker and Walker as OtherAtom, go to (2) 410 Binder->Type = TreeEdge;385 Binder->Type = bond::TreeEdge; 411 386 OtherAtom->Ancestor = Walker; 412 387 Walker = OtherAtom; … … 664 639 if (DoLog(2)) { 665 640 ostream &out = (Log() << Verbose(2)); 666 out << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <";641 out << ((Binder->Type == bond::TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <"; 667 642 out << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp."; 668 643 Binder->leftatom->OutputComponentNumber(&out); … … 688 663 BFS.PredecessorList = new atom*[AtomCount]; 689 664 BFS.ShortestPathList = new int[AtomCount]; 690 BFS.ColorList = new enum Shading[AtomCount];665 BFS.ColorList = new enum bond::Shading[AtomCount]; 691 666 BFS.BFSStack = new std::deque<atom *> (AtomCount); 692 667 BFS.TouchedStack = new std::deque<atom *> (AtomCount); … … 695 670 BFS.ShortestPathList[i] = -1; 696 671 BFS.PredecessorList[i] = 0; 697 BFS.ColorList[i] = white;672 BFS.ColorList[i] = bond::white; 698 673 } 699 674 }; … … 723 698 BFS.PredecessorList[Walker->getNr()] = NULL; 724 699 BFS.ShortestPathList[Walker->getNr()] = -1; 725 BFS.ColorList[Walker->getNr()] = white;700 BFS.ColorList[Walker->getNr()] = bond::white; 726 701 } 727 702 }; … … 762 737 #endif 763 738 DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << "." << endl); 764 if (BFS.ColorList[OtherAtom->getNr()] == white) {739 if (BFS.ColorList[OtherAtom->getNr()] == bond::white) { 765 740 BFS.TouchedStack->push_front(OtherAtom); 766 BFS.ColorList[OtherAtom->getNr()] = lightgray;741 BFS.ColorList[OtherAtom->getNr()] = bond::lightgray; 767 742 BFS.PredecessorList[OtherAtom->getNr()] = Walker; // Walker is the predecessor 768 743 BFS.ShortestPathList[OtherAtom->getNr()] = BFS.ShortestPathList[Walker->getNr()] + 1; … … 780 755 } else { 781 756 DoLog(2) && (Log() << Verbose(2) << "Skipping hydrogen atom " << *OtherAtom << "." << endl); 782 BFS.ColorList[OtherAtom->getNr()] = b lack;757 BFS.ColorList[OtherAtom->getNr()] = bond::black; 783 758 } 784 759 #endif … … 787 762 } 788 763 } 789 BFS.ColorList[Walker->getNr()] = b lack;764 BFS.ColorList[Walker->getNr()] = bond::black; 790 765 DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->getName() << " black." << endl); 791 766 if (OtherAtom == BFS.Root) { // if we have found the root, check whether this cycle wasn't already found beforehand … … 807 782 BFS.PredecessorList[OtherAtom->getNr()] = NULL; 808 783 BFS.ShortestPathList[OtherAtom->getNr()] = -1; 809 BFS.ColorList[OtherAtom->getNr()] = white;784 BFS.ColorList[OtherAtom->getNr()] = bond::white; 810 785 // rats ... deque has no find() 811 786 std::deque<atom *>::iterator iter = find( … … 894 869 OtherAtom = (*Runner)->GetOtherAtom(Walker); 895 870 //Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *Binder << "." << endl; 896 if (BFS.ColorList[OtherAtom->getNr()] == white) {871 if (BFS.ColorList[OtherAtom->getNr()] == bond::white) { 897 872 BFS.TouchedStack->push_front(OtherAtom); 898 BFS.ColorList[OtherAtom->getNr()] = lightgray;873 BFS.ColorList[OtherAtom->getNr()] = bond::lightgray; 899 874 BFS.PredecessorList[OtherAtom->getNr()] = Walker; // Walker is the predecessor 900 875 BFS.ShortestPathList[OtherAtom->getNr()] = BFS.ShortestPathList[Walker->getNr()] + 1; … … 913 888 } 914 889 } 915 BFS.ColorList[Walker->getNr()] = b lack;890 BFS.ColorList[Walker->getNr()] = bond::black; 916 891 //Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl; 917 892 } … … 1041 1016 Runner != ListOfBonds.end(); 1042 1017 ++Runner) 1043 if ((*Runner)->IsUsed() == white)1018 if ((*Runner)->IsUsed() == bond::white) 1044 1019 return ((*Runner)); 1045 1020 return NULL; … … 1304 1279 BFS.PredecessorList = new atom*[AtomCount]; 1305 1280 BFS.ShortestPathList = new int[AtomCount]; 1306 BFS.ColorList = new enum Shading[AtomCount];1281 BFS.ColorList = new enum bond::Shading[AtomCount]; 1307 1282 BFS.BFSStack = new std::deque<atom *> (AtomCount); 1308 1283 … … 1316 1291 BFS.ShortestPathList[i] = -1; 1317 1292 if ((AddedAtomList != NULL) && (AddedAtomList[i] != NULL)) // mark already present atoms (i.e. Root and maybe others) as visited 1318 BFS.ColorList[i] = lightgray;1293 BFS.ColorList[i] = bond::lightgray; 1319 1294 else 1320 BFS.ColorList[i] = white;1295 BFS.ColorList[i] = bond::white; 1321 1296 } 1322 1297 //BFS.ShortestPathList[Root->getNr()] = 0; // done by Calloc … … 1337 1312 { 1338 1313 if (Binder != Bond) // let other atom white if it's via Root bond. In case it's cyclic it has to be reached again (yet Root is from OtherAtom already black, thus no problem) 1339 BFS.ColorList[OtherAtom->getNr()] = lightgray;1314 BFS.ColorList[OtherAtom->getNr()] = bond::lightgray; 1340 1315 BFS.PredecessorList[OtherAtom->getNr()] = Walker; // Walker is the predecessor 1341 1316 BFS.ShortestPathList[OtherAtom->getNr()] = BFS.ShortestPathList[Walker->getNr()] + 1; 1342 DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->getName() << " " << ((BFS.ColorList[OtherAtom->getNr()] == white) ? "white" : "lightgray") << ", its predecessor is " << Walker->getName() << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->getNr()] << " egde(s) long." << endl);1317 DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->getName() << " " << ((BFS.ColorList[OtherAtom->getNr()] == bond::white) ? "white" : "lightgray") << ", its predecessor is " << Walker->getName() << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->getNr()] << " egde(s) long." << endl); 1343 1318 if ((((BFS.ShortestPathList[OtherAtom->getNr()] < BFS.BondOrder) && (Binder != Bond)))) { // Check for maximum distance 1344 1319 DoLog(3) && (Log() << Verbose(3)); … … 1360 1335 } else { // out of bond order, then replace 1361 1336 if ((AddedAtomList[OtherAtom->getNr()] == NULL) && (Binder->Cyclic)) 1362 BFS.ColorList[OtherAtom->getNr()] = white; // unmark if it has not been queued/added, to make it available via its other bonds (cyclic)1337 BFS.ColorList[OtherAtom->getNr()] = bond::white; // unmark if it has not been queued/added, to make it available via its other bonds (cyclic) 1363 1338 if (Binder == Bond) 1364 1339 DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is the Root bond"); … … 1438 1413 OtherAtom = (*Runner)->GetOtherAtom(Walker); 1439 1414 DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << "." << endl); 1440 if (BFS.ColorList[OtherAtom->getNr()] == white) {1415 if (BFS.ColorList[OtherAtom->getNr()] == bond::white) { 1441 1416 BreadthFirstSearchAdd_UnvisitedNode(Mol, BFS, Walker, OtherAtom, Binder, Bond, AddedAtomList, AddedBondList, IsAngstroem); 1442 1417 } else { … … 1445 1420 } 1446 1421 } 1447 BFS.ColorList[Walker->getNr()] = b lack;1422 BFS.ColorList[Walker->getNr()] = bond::black; 1448 1423 DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->getName() << " black." << endl); 1449 1424 }
Note:
See TracChangeset
for help on using the changeset viewer.