- Timestamp:
- Dec 6, 2010, 7:37:05 PM (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:
- 4c1230
- Parents:
- fd19ff
- git-author:
- Frederik Heber <heber@…> (12/06/10 19:15:03)
- git-committer:
- Frederik Heber <heber@…> (12/06/10 19:37:05)
- Location:
- src
- Files:
-
- 3 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FragmentationAction/DepthFirstSearchAction.cpp
rfd19ff ra564be 24 24 #include "config.hpp" 25 25 #include "Helpers/Log.hpp" 26 #include "Helpers/Verbose.hpp" 26 27 #include "molecule.hpp" 27 28 #include "Descriptors/MoleculeDescriptor.hpp" 28 29 #include "Descriptors/MoleculeIdDescriptor.hpp" 29 #include "stackclass.hpp"30 #include "Helpers/Verbose.hpp"31 30 #include "World.hpp" 32 31 … … 51 50 int *MinimumRingSize = new int[mol->getAtomCount()]; 52 51 atom **ListOfAtoms = NULL; 53 class StackClass<bond *> *BackEdgeStack = NULL;54 class StackClass<bond *> *LocalBackEdgeStack = NULL;52 std::deque<bond *> *BackEdgeStack = NULL; 53 std::deque<bond *> *LocalBackEdgeStack = NULL; 55 54 mol->CreateAdjacencyList(params.distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 56 55 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack); … … 61 60 ListOfAtoms = NULL; 62 61 Subgraphs->FillBondStructureFromReference(mol, ListOfAtoms, false); // we want to keep the created ListOfLocalAtoms 63 LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);62 LocalBackEdgeStack = new std::deque<bond *>; // no need to have it Subgraphs->Leaf->BondCount size 64 63 Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack); 65 64 Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize); -
src/Actions/FragmentationAction/FragmentationAction.cpp
rfd19ff ra564be 24 24 #include "config.hpp" 25 25 #include "Helpers/Log.hpp" 26 #include "Helpers/Verbose.hpp" 26 27 #include "molecule.hpp" 27 28 #include "Descriptors/MoleculeDescriptor.hpp" 28 #include "stackclass.hpp"29 29 #include "World.hpp" 30 30 -
src/Actions/FragmentationAction/SubgraphDissectionAction.cpp
rfd19ff ra564be 30 30 #include "Helpers/Verbose.hpp" 31 31 #include "molecule.hpp" 32 #include "stackclass.hpp"33 32 #include "World.hpp" 34 33 … … 103 102 // 2. scan for connected subgraphs 104 103 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 105 class StackClass<bond *> *BackEdgeStack = NULL;104 std::deque<bond *> *BackEdgeStack = NULL; 106 105 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack); 107 106 delete(BackEdgeStack); -
src/Makefile.am
rfd19ff ra564be 209 209 parser.hpp \ 210 210 periodentafel.hpp \ 211 stackclass.hpp \212 211 ThermoStatContainer.hpp \ 213 212 triangleintersectionlist.hpp \ -
src/molecule.cpp
rfd19ff ra564be 40 40 41 41 #include "periodentafel.hpp" 42 #include "stackclass.hpp"43 42 #include "tesselation.hpp" 44 43 #include "LinearAlgebra/Vector.hpp" -
src/molecule.hpp
rfd19ff ra564be 16 16 #include <map> 17 17 #include <set> 18 #include <stack> 18 19 #include <deque> 19 20 #include <list> … … 48 49 class Vector; 49 50 class Shape; 50 template <class> class StackClass;51 51 52 52 /******************************** Some definitions for easier reading **********************************/ … … 226 226 227 227 // Graph analysis 228 MoleculeLeafClass * DepthFirstSearchAnalysis( class StackClass<bond *> *&BackEdgeStack) const;229 void CyclicStructureAnalysis( class StackClass<bond *> *BackEdgeStack, int *&MinimumRingSize) const;230 bool PickLocalBackEdges(atom **ListOfLocalAtoms, class StackClass<bond *> *&ReferenceStack, class StackClass<bond *> *&LocalStack) const;228 MoleculeLeafClass * DepthFirstSearchAnalysis(std::deque<bond *> *&BackEdgeStack) const; 229 void CyclicStructureAnalysis(std::deque<bond *> *BackEdgeStack, int *&MinimumRingSize) const; 230 bool PickLocalBackEdges(atom **ListOfLocalAtoms, std::deque<bond *> *&ReferenceStack, std::deque<bond *> *&LocalStack) const; 231 231 bond * FindNextUnused(atom *vertex) const; 232 232 void SetNextComponentNumber(atom *vertex, int nr) const; -
src/molecule_fragmentation.cpp
rfd19ff ra564be 36 36 #include "LinearAlgebra/RealSpaceMatrix.hpp" 37 37 #include "Box.hpp" 38 #include "stackclass.hpp"39 38 40 39 /************************************* Functions for class molecule *********************************/ … … 613 612 fstream File; 614 613 bool FragmentationToDo = true; 615 class StackClass<bond *> *BackEdgeStack = NULL, *LocalBackEdgeStack = NULL;614 std::deque<bond *> *BackEdgeStack = NULL, *LocalBackEdgeStack = NULL; 616 615 bool CheckOrder = false; 617 616 Graph **FragmentList = NULL; … … 656 655 MolecularWalker->FillBondStructureFromReference(this, ListOfAtoms, false); // we want to keep the created ListOfLocalAtoms 657 656 DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl); 658 LocalBackEdgeStack = new StackClass<bond *>(MolecularWalker->Leaf->BondCount);657 LocalBackEdgeStack = new std::deque<bond *>; // (MolecularWalker->Leaf->BondCount); 659 658 // // check the list of local atoms for debugging 660 659 // Log() << Verbose(0) << "ListOfLocalAtoms for this subgraph is:" << endl; … … 884 883 885 884 886 /** Looks through a StackClass<atom *> and returns the likeliest removal candiate.885 /** Looks through a std::deque<atom *> and returns the likeliest removal candiate. 887 886 * \param *out output stream for debugging messages 888 887 * \param *&Leaf KeySet to look through … … 1743 1742 double tmp; 1744 1743 Vector Translationvector; 1745 // class StackClass<atom *> *CompStack = NULL;1746 class StackClass<atom *> *AtomStack = new StackClass<atom *>(getAtomCount());1744 //std::deque<atom *> *CompStack = NULL; 1745 std::deque<atom *> *AtomStack = new std::deque<atom *>; // (getAtomCount()); 1747 1746 bool flag = true; 1748 1747 … … 1785 1784 for (int i=getAtomCount();i--;) 1786 1785 ColorList[i] = white; 1787 AtomStack->Push(Binder->leftatom); 1788 while (!AtomStack->IsEmpty()) { 1789 Walker = AtomStack->PopFirst(); 1786 AtomStack->push_front(Binder->leftatom); 1787 while (!AtomStack->empty()) { 1788 Walker = AtomStack->front(); 1789 AtomStack->pop_front(); 1790 1790 //Log() << Verbose (3) << "Current Walker is: " << *Walker << "." << endl; 1791 1791 ColorList[Walker->nr] = black; // mark as explored … … 1795 1795 OtherWalker = (*Runner)->GetOtherAtom(Walker); 1796 1796 if (ColorList[OtherWalker->nr] == white) { 1797 AtomStack-> Push(OtherWalker); // push if yet unexplored1797 AtomStack->push_front(OtherWalker); // push if yet unexplored 1798 1798 } 1799 1799 } -
src/molecule_graph.cpp
rfd19ff ra564be 19 19 20 20 #include "Helpers/MemDebug.hpp" 21 22 #include <stack> 21 23 22 24 #include "atom.hpp" … … 38 40 #include "LinearAlgebra/RealSpaceMatrix.hpp" 39 41 #include "Box.hpp" 40 #include "stackclass.hpp"41 42 42 43 struct BFSAccounting … … 45 46 int *ShortestPathList; 46 47 enum Shading *ColorList; 47 class StackClass<atom *> *BFSStack;48 class StackClass<atom *> *TouchedStack;48 std::deque<atom *> *BFSStack; 49 std::deque<atom *> *TouchedStack; 49 50 int AtomCount; 50 51 int BondOrder; … … 59 60 struct DFSAccounting 60 61 { 61 class StackClass<atom *> *AtomStack;62 class StackClass<bond *> *BackEdgeStack;62 std::deque<atom *> *AtomStack; 63 std::deque<bond *> *BackEdgeStack; 63 64 int CurrentGraphNr; 64 65 int ComponentNumber; … … 310 311 int *MinimumRingSize = NULL; 311 312 MoleculeLeafClass *Subgraphs = NULL; 312 class StackClass<bond *> *BackEdgeStack = NULL;313 std::deque<bond *> *BackEdgeStack = NULL; 313 314 for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 314 315 if ((!(*AtomRunner)->ListOfBonds.empty()) && ((*(*AtomRunner)->ListOfBonds.begin())->Type == Undetermined)) { … … 370 371 Walker->LowpointNr = DFS.CurrentGraphNr; 371 372 DoLog(1) && (Log() << Verbose(1) << "Setting Walker[" << Walker->getName() << "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl); 372 DFS.AtomStack-> Push(Walker);373 DFS.AtomStack->push_front(Walker); 373 374 DFS.CurrentGraphNr++; 374 375 } … … 404 405 // (4a) ... if "other" atom has been visited (GraphNr != 0), set lowpoint to minimum of both, go to (3) 405 406 Binder->Type = BackEdge; 406 DFS.BackEdgeStack-> Push(Binder);407 DFS.BackEdgeStack->push_front(Binder); 407 408 Walker->LowpointNr = (Walker->LowpointNr < OtherAtom->GraphNr) ? Walker->LowpointNr : OtherAtom->GraphNr; 408 409 DoLog(3) && (Log() << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->getName() << "] to " << Walker->LowpointNr << "." << endl); … … 451 452 DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->getName() << "]'s Compont is " << DFS.ComponentNumber << "." << endl); 452 453 do { 453 OtherAtom = DFS.AtomStack->PopLast(); 454 ASSERT(!DFS.AtomStack->empty(), "DepthFirstSearchAnalysis_CheckForaNewComponent() - DFS.AtomStack is empty!"); 455 OtherAtom = DFS.AtomStack->front(); 456 DFS.AtomStack->pop_front(); 454 457 LeafWalker->Leaf->AddCopyAtom(OtherAtom); 455 458 mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber); … … 487 490 DoLog(3) && (Log() << Verbose(3) << "(9) Walker[" << Walker->getName() << "]'s Component is " << DFS.ComponentNumber << "." << endl); 488 491 do { 489 OtherAtom = DFS.AtomStack->PopLast(); 492 ASSERT(!DFS.AtomStack->empty(), "DepthFirstSearchAnalysis_CleanRootStackDownTillWalker() - DFS.AtomStack is empty!"); 493 OtherAtom = DFS.AtomStack->front(); 494 DFS.AtomStack->pop_front(); 490 495 LeafWalker->Leaf->AddCopyAtom(OtherAtom); 491 496 mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber); 492 DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->getName() << "]'s Compon t is " << DFS.ComponentNumber << "." << endl);497 DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->getName() << "]'s Component is " << DFS.ComponentNumber << "." << endl); 493 498 } while (OtherAtom != Walker); 494 499 DFS.ComponentNumber++; … … 513 518 void DepthFirstSearchAnalysis_Init(struct DFSAccounting &DFS, const molecule * const mol) 514 519 { 515 DFS.AtomStack = new StackClass<atom *> (mol->getAtomCount());520 DFS.AtomStack = new std::deque<atom *> (mol->getAtomCount()); 516 521 DFS.CurrentGraphNr = 0; 517 522 DFS.ComponentNumber = 0; 518 523 DFS.BackStepping = false; 519 524 mol->ResetAllBondsToUnused(); 520 DFS.BackEdgeStack-> ClearStack();525 DFS.BackEdgeStack->clear(); 521 526 } 522 527 ; … … 544 549 * We use the algorithm from [Even, Graph Algorithms, p.62]. 545 550 * \param *out output stream for debugging 546 * \param *&BackEdgeStack NULL pointer to StackClasswith all the found back edges, allocated and filled on return551 * \param *&BackEdgeStack NULL pointer to std::deque<bond *> with all the found back edges, allocated and filled on return 547 552 * \return list of each disconnected subgraph as an individual molecule class structure 548 553 */ 549 MoleculeLeafClass * molecule::DepthFirstSearchAnalysis( class StackClass<bond *> *&BackEdgeStack) const554 MoleculeLeafClass * molecule::DepthFirstSearchAnalysis(std::deque<bond *> *&BackEdgeStack) const 550 555 { 551 556 struct DFSAccounting DFS; 552 BackEdgeStack = new StackClass<bond *> (BondCount);557 BackEdgeStack = new std::deque<bond *> (BondCount); 553 558 DFS.BackEdgeStack = BackEdgeStack; 554 559 MoleculeLeafClass *SubGraphs = new MoleculeLeafClass(NULL); … … 566 571 DFS.Root = *iter; 567 572 // (1) mark all edges unused, empty stack, set atom->GraphNr = -1 for all 568 DFS.AtomStack-> ClearStack();573 DFS.AtomStack->clear(); 569 574 570 575 // put into new subgraph molecule and add this to list of subgraphs … … 687 692 BFS.ShortestPathList = new int[AtomCount]; 688 693 BFS.ColorList = new enum Shading[AtomCount]; 689 BFS.BFSStack = new StackClass<atom *> (AtomCount);690 BFS.TouchedStack = new StackClass<atom *> (AtomCount);694 BFS.BFSStack = new std::deque<atom *> (AtomCount); 695 BFS.TouchedStack = new std::deque<atom *> (AtomCount); 691 696 692 697 for (int i = AtomCount; i--;) { … … 718 723 { 719 724 atom *Walker = NULL; 720 while (!BFS.TouchedStack->IsEmpty()) { 721 Walker = BFS.TouchedStack->PopFirst(); 725 while (!BFS.TouchedStack->empty()) { 726 Walker = BFS.TouchedStack->front(); 727 BFS.TouchedStack->pop_front(); 722 728 BFS.PredecessorList[Walker->nr] = NULL; 723 729 BFS.ShortestPathList[Walker->nr] = -1; … … 734 740 { 735 741 BFS.ShortestPathList[Walker->nr] = 0; 736 BFS.BFSStack-> ClearStack(); // start with empty BFS stack737 BFS.BFSStack-> Push(Walker);738 BFS.TouchedStack-> Push(Walker);742 BFS.BFSStack->clear(); // start with empty BFS stack 743 BFS.BFSStack->push_front(Walker); 744 BFS.TouchedStack->push_front(Walker); 739 745 }; 740 746 … … 749 755 atom *OtherAtom = NULL; 750 756 do { // look for Root 751 Walker = BFS.BFSStack->PopFirst(); 757 ASSERT(!BFS.BFSStack->empty(), "CyclicStructureAnalysis_CyclicBFSFromRootToRoot() - BFS.BFSStack is empty!"); 758 Walker = BFS.BFSStack->front(); 759 BFS.BFSStack->pop_front(); 752 760 DoLog(2) && (Log() << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *BFS.Root << "." << endl); 753 761 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { … … 759 767 DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << "." << endl); 760 768 if (BFS.ColorList[OtherAtom->nr] == white) { 761 BFS.TouchedStack-> Push(OtherAtom);769 BFS.TouchedStack->push_front(OtherAtom); 762 770 BFS.ColorList[OtherAtom->nr] = lightgray; 763 771 BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor … … 766 774 //if (BFS.ShortestPathList[OtherAtom->nr] < MinimumRingSize[Walker->GetTrueFather()->nr]) { // Check for maximum distance 767 775 DoLog(3) && (Log() << Verbose(3) << "Putting OtherAtom into queue." << endl); 768 BFS.BFSStack-> Push(OtherAtom);776 BFS.BFSStack->push_front(OtherAtom); 769 777 //} 770 778 } else { … … 796 804 DoLog(3) && (Log() << Verbose(3) << "This cycle was already found before, skipping and removing seeker from search." << endl); 797 805 do { 798 OtherAtom = BFS.TouchedStack->PopLast(); 806 ASSERT(!BFS.TouchedStack->empty(), "CyclicStructureAnalysis_CyclicBFSFromRootToRoot() - BFS.TouchedStack is empty!"); 807 OtherAtom = BFS.TouchedStack->front(); 808 BFS.TouchedStack->pop_front(); 799 809 if (BFS.PredecessorList[OtherAtom->nr] == Walker) { 800 810 DoLog(4) && (Log() << Verbose(4) << "Removing " << *OtherAtom << " from lists and stacks." << endl); … … 802 812 BFS.ShortestPathList[OtherAtom->nr] = -1; 803 813 BFS.ColorList[OtherAtom->nr] = white; 804 BFS.BFSStack->RemoveItem(OtherAtom); 814 // rats ... deque has no find() 815 std::deque<atom *>::iterator iter = find( 816 BFS.BFSStack->begin(), 817 BFS.BFSStack->end(), 818 OtherAtom); 819 ASSERT(iter != BFS.BFSStack->end(), 820 "CyclicStructureAnalysis_CyclicBFSFromRootToRoot() - can't find "+toString(*OtherAtom)+" on stack!"); 821 BFS.BFSStack->erase(iter); 805 822 } 806 } while ((!BFS.TouchedStack-> IsEmpty()) && (BFS.PredecessorList[OtherAtom->nr] == NULL));807 BFS.TouchedStack-> Push(OtherAtom); // last was wrongly popped823 } while ((!BFS.TouchedStack->empty()) && (BFS.PredecessorList[OtherAtom->nr] == NULL)); 824 BFS.TouchedStack->push_front(OtherAtom); // last was wrongly popped 808 825 OtherAtom = BackEdge->rightatom; // set to not Root 809 826 } else 810 827 OtherAtom = BFS.Root; 811 828 } 812 } while ((!BFS.BFSStack-> IsEmpty()) && (OtherAtom != BFS.Root) && (OtherAtom != NULL)); // || (ShortestPathList[OtherAtom->nr] < MinimumRingSize[Walker->GetTrueFather()->nr])));829 } while ((!BFS.BFSStack->empty()) && (OtherAtom != BFS.Root) && (OtherAtom != NULL)); // || (ShortestPathList[OtherAtom->nr] < MinimumRingSize[Walker->GetTrueFather()->nr]))); 813 830 }; 814 831 … … 871 888 ResetBFSAccounting(Walker, BFS); 872 889 while (OtherAtom != NULL) { // look for Root 873 Walker = BFS.BFSStack->PopFirst(); 890 ASSERT(!BFS.BFSStack->empty(), "CyclicStructureAnalysis_BFSToNextCycle() - BFS.BFSStack is empty!"); 891 Walker = BFS.BFSStack->front(); 892 BFS.BFSStack->pop_front(); 874 893 //Log() << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *Root << "." << endl; 875 894 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { … … 879 898 //Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *Binder << "." << endl; 880 899 if (BFS.ColorList[OtherAtom->nr] == white) { 881 BFS.TouchedStack-> Push(OtherAtom);900 BFS.TouchedStack->push_front(OtherAtom); 882 901 BFS.ColorList[OtherAtom->nr] = lightgray; 883 902 BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor … … 889 908 break; 890 909 } else 891 BFS.BFSStack-> Push(OtherAtom);910 BFS.BFSStack->push_front(OtherAtom); 892 911 } else { 893 912 //Log() << Verbose(3) << "Not Adding, has already been visited." << endl; … … 947 966 * \todo BFS from the not-same-LP to find back to starting point of tributary cycle over more than one bond 948 967 */ 949 void molecule::CyclicStructureAnalysis( class StackClass<bond *> * BackEdgeStack, int *&MinimumRingSize) const968 void molecule::CyclicStructureAnalysis(std::deque<bond *> * BackEdgeStack, int *&MinimumRingSize) const 950 969 { 951 970 struct BFSAccounting BFS; … … 963 982 DoLog(1) && (Log() << Verbose(1) << "Analysing cycles ... " << endl); 964 983 NumCycles = 0; 965 while (!BackEdgeStack->IsEmpty()) { 966 BackEdge = BackEdgeStack->PopFirst(); 984 while (!BackEdgeStack->empty()) { 985 BackEdge = BackEdgeStack->front(); 986 BackEdgeStack->pop_front(); 967 987 // this is the target 968 988 BFS.Root = BackEdge->leftatom; … … 1227 1247 * \return true - everything ok, false - ReferenceStack was empty 1228 1248 */ 1229 bool molecule::PickLocalBackEdges(atom **ListOfLocalAtoms, class StackClass<bond *> *&ReferenceStack, class StackClass<bond *> *&LocalStack) const1249 bool molecule::PickLocalBackEdges(atom **ListOfLocalAtoms, std::deque<bond *> *&ReferenceStack, std::deque<bond *> *&LocalStack) const 1230 1250 { 1231 1251 bool status = true; 1232 if (ReferenceStack-> IsEmpty()) {1252 if (ReferenceStack->empty()) { 1233 1253 DoLog(1) && (Log() << Verbose(1) << "ReferenceStack is empty!" << endl); 1234 1254 return false; 1235 1255 } 1236 bond *Binder = ReferenceStack->PopFirst(); 1256 bond *Binder = ReferenceStack->front(); 1257 ReferenceStack->pop_front(); 1237 1258 bond *FirstBond = Binder; // mark the first bond, so that we don't loop through the stack indefinitely 1238 1259 atom *Walker = NULL, *OtherAtom = NULL; 1239 ReferenceStack-> Push(Binder);1260 ReferenceStack->push_front(Binder); 1240 1261 1241 1262 do { // go through all bonds and push local ones … … 1245 1266 OtherAtom = (*Runner)->GetOtherAtom(Walker); 1246 1267 if (OtherAtom == ListOfLocalAtoms[(*Runner)->rightatom->nr]) { // found the bond 1247 LocalStack-> Push((*Runner));1268 LocalStack->push_front((*Runner)); 1248 1269 DoLog(3) && (Log() << Verbose(3) << "Found local edge " << *(*Runner) << "." << endl); 1249 1270 break; 1250 1271 } 1251 1272 } 1252 Binder = ReferenceStack->PopFirst(); // loop the stack for next item 1273 ASSERT(!ReferenceStack->empty(), "molecule::PickLocalBackEdges() - ReferenceStack is empty!"); 1274 Binder = ReferenceStack->front(); // loop the stack for next item 1275 ReferenceStack->pop_front(); 1253 1276 DoLog(3) && (Log() << Verbose(3) << "Current candidate edge " << Binder << "." << endl); 1254 ReferenceStack-> Push(Binder);1277 ReferenceStack->push_front(Binder); 1255 1278 } while (FirstBond != Binder); 1256 1279 … … 1266 1289 BFS.ShortestPathList = new int[AtomCount]; 1267 1290 BFS.ColorList = new enum Shading[AtomCount]; 1268 BFS.BFSStack = new StackClass<atom *> (AtomCount);1291 BFS.BFSStack = new std::deque<atom *> (AtomCount); 1269 1292 1270 1293 BFS.Root = Root; 1271 BFS.BFSStack-> ClearStack();1272 BFS.BFSStack-> Push(Root);1294 BFS.BFSStack->clear(); 1295 BFS.BFSStack->push_front(Root); 1273 1296 1274 1297 // initialise each vertex as white with no predecessor, empty queue, color Root lightgray … … 1318 1341 } 1319 1342 DoLog(0) && (Log() << Verbose(0) << ", putting OtherAtom into queue." << endl); 1320 BFS.BFSStack-> Push(OtherAtom);1343 BFS.BFSStack->push_front(OtherAtom); 1321 1344 } else { // out of bond order, then replace 1322 1345 if ((AddedAtomList[OtherAtom->nr] == NULL) && (Binder->Cyclic)) … … 1360 1383 1361 1384 /** Adds atoms up to \a BondCount distance from \a *Root and notes them down in \a **AddedAtomList. 1362 * Gray vertices are always enqueued in an StackClass<atom *> FIFO queue, the rest is usual BFS with adding vertices found was1385 * Gray vertices are always enqueued in an std::deque<atom *> FIFO queue, the rest is usual BFS with adding vertices found was 1363 1386 * white and putting into queue. 1364 1387 * \param *out output stream for debugging … … 1384 1407 1385 1408 // and go on ... Queue always contains all lightgray vertices 1386 while (!BFS.BFSStack-> IsEmpty()) {1409 while (!BFS.BFSStack->empty()) { 1387 1410 // we have to pop the oldest atom from stack. This keeps the atoms on the stack always of the same ShortestPath distance. 1388 1411 // e.g. if current atom is 2, push to end of stack are of length 3, but first all of length 2 would be popped. They again 1389 1412 // append length of 3 (their neighbours). Thus on stack we have always atoms of a certain length n at bottom of stack and 1390 1413 // followed by n+1 till top of stack. 1391 Walker = BFS.BFSStack->PopFirst(); // pop oldest added 1414 Walker = BFS.BFSStack->front(); // pop oldest added 1415 BFS.BFSStack->pop_front(); 1392 1416 DoLog(1) && (Log() << Verbose(1) << "Current Walker is: " << Walker->getName() << ", and has " << Walker->ListOfBonds.size() << " bonds." << endl); 1393 1417 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { -
src/moleculelist.cpp
rfd19ff ra564be 42 42 #include "LinearAlgebra/RealSpaceMatrix.hpp" 43 43 #include "Box.hpp" 44 #include "stackclass.hpp"45 44 46 45 #include "Helpers/Assert.hpp" -
src/unittests/Makefile.am
rfd19ff ra564be 42 42 ShapeUnittest \ 43 43 SingletonTest \ 44 StackClassUnitTest \45 44 SubspaceFactorizerUnitTest \ 46 45 TesselationUnitTest \ … … 104 103 ShapeUnittest.cpp \ 105 104 SingletonTest.cpp \ 106 stackclassunittest.cpp \107 105 tesselationunittest.cpp \ 108 106 tesselation_boundarytriangleunittest.cpp \ … … 144 142 RegistryUnitTest.hpp \ 145 143 SingletonTest.hpp \ 146 stackclassunittest.hpp \147 144 tesselationunittest.hpp \ 148 145 tesselation_boundarytriangleunittest.hpp \ … … 251 248 SingletonTest_LDADD = ${ALLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB} 252 249 253 StackClassUnitTest_SOURCES = UnitTestMain.cpp stackclassunittest.cpp stackclassunittest.hpp254 StackClassUnitTest_LDADD = ${ALLLIBS}255 256 250 SubspaceFactorizerUnitTest_SOURCES = UnitTestMain.cpp SubspaceFactorizerUnittest.cpp SubspaceFactorizerUnittest.hpp 257 251 SubspaceFactorizerUnitTest_LDADD = ${GSLLIBS}
Note:
See TracChangeset
for help on using the changeset viewer.