- Timestamp:
- Apr 29, 2014, 12:42:43 PM (11 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:
- 237f93
- Parents:
- 4b10fd
- git-author:
- Frederik Heber <heber@…> (11/11/13 09:49:19)
- git-committer:
- Frederik Heber <heber@…> (04/29/14 12:42:43)
- Location:
- src/Graph
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Graph/CyclicStructureAnalysis.cpp
r4b10fd rec7511 36 36 37 37 #include "CyclicStructureAnalysis.hpp" 38 39 #include <algorithm> 38 40 39 41 #include "Atom/atom.hpp" … … 110 112 do { // look for Root 111 113 ASSERT(!BFSStack.empty(), "CyclicStructureAnalysis_CyclicBFSFromRootToRoot() - BFSStack is empty!"); 112 Walker = BFSStack. front();113 BFSStack.pop_ front();114 Walker = BFSStack.back(); 115 BFSStack.pop_back(); 114 116 LOG(2, "INFO: Current Walker is " << *Walker << ", we look for SP to Root " << *Root << "."); 115 117 const BondList& ListOfBonds = Walker->getListOfBonds(); … … 159 161 // if each atom in found cycle is cyclic, loop's been found before already 160 162 if (OtherAtom == BackEdge->rightatom) { // loop got round completely 161 LOG(3, "INFO: This cycle was already found before, skipping and removing seeker from search."); 162 do { 163 ASSERT(!TouchedStack.empty(), "CyclicStructureAnalysis_CyclicBFSFromRootToRoot() - TouchedStack is empty!"); 164 OtherAtom = TouchedStack.front(); 165 TouchedStack.pop_front(); 166 if (PredecessorList[OtherAtom->getNr()] == Walker) { 167 LOG(4, "INFO: Removing " << *OtherAtom << " from lists and stacks."); 168 PredecessorList[OtherAtom->getNr()] = NULL; 169 ShortestPathList[OtherAtom->getNr()] = -1; 170 ColorList[OtherAtom->getNr()] = GraphEdge::white; 171 // rats ... deque has no find() 172 std::deque<atom *>::iterator iter = find( 173 BFSStack.begin(), 174 BFSStack.end(), 175 OtherAtom); 176 ASSERT(iter != BFSStack.end(), 177 "CyclicStructureAnalysis_CyclicBFSFromRootToRoot() - can't find "+toString(*OtherAtom)+" on stack!"); 178 BFSStack.erase(iter); 179 } 180 } while ((!TouchedStack.empty()) && (PredecessorList[OtherAtom->getNr()] == NULL)); 181 TouchedStack.push_front(OtherAtom); // last was wrongly popped 182 OtherAtom = BackEdge->rightatom; // set to not Root 163 LOG(3, "INFO: All bonds are marked cyclic already, checking allcycles whether cycle is already present."); 164 const cycle_t currentcycle = extractCurrentCycle(BackEdge); 165 const cycles_t::const_iterator iter = 166 std::find(allcycles.begin(), allcycles.end(), currentcycle); 167 if (iter == allcycles.end()) { // not found 168 OtherAtom = Root; 169 LOG(2, "INFO: Cycle is not present."); 170 LOG(2, "INFO: We have reached Root " << *OtherAtom << " and may extract the cycle."); 171 } else { 172 LOG(2, "INFO: Cycle is already present."); 173 do { 174 ASSERT(!TouchedStack.empty(), "CyclicStructureAnalysis_CyclicBFSFromRootToRoot() - TouchedStack is empty!"); 175 OtherAtom = TouchedStack.front(); 176 TouchedStack.pop_front(); 177 if (PredecessorList[OtherAtom->getNr()] == Walker) { 178 LOG(4, "INFO: Removing " << *OtherAtom << " from lists and stacks."); 179 PredecessorList[OtherAtom->getNr()] = NULL; 180 ShortestPathList[OtherAtom->getNr()] = -1; 181 ColorList[OtherAtom->getNr()] = GraphEdge::white; 182 // rats ... deque has no find() 183 std::deque<atom *>::iterator iter = find( 184 BFSStack.begin(), 185 BFSStack.end(), 186 OtherAtom); 187 ASSERT(iter != BFSStack.end(), 188 "CyclicStructureAnalysis_CyclicBFSFromRootToRoot() - can't find "+toString(*OtherAtom)+" on stack!"); 189 BFSStack.erase(iter); 190 } 191 } while ((!TouchedStack.empty()) && (PredecessorList[OtherAtom->getNr()] == NULL)); 192 TouchedStack.push_front(OtherAtom); // last was wrongly popped 193 OtherAtom = BackEdge->rightatom; // set to not Root 194 } 183 195 } else { 184 196 OtherAtom = Root; … … 187 199 } 188 200 } while ((!BFSStack.empty()) && (OtherAtom != Root) && (OtherAtom != NULL)); // || (ShortestPathList[OtherAtom->getNr()] < MinimumRingSize[Walker->GetTrueFather()->getNr()]))); 201 } 202 203 /** Extracts cycle from BFSAccounting::PredecessorList with given \a BackEdge and current \a Root. 204 * 205 * \param BackEdge back edge of this cycle 206 */ 207 CyclicStructureAnalysis::cycle_t CyclicStructureAnalysis::extractCurrentCycle( 208 bond::ptr &BackEdge) 209 { 210 CyclicStructureAnalysis::cycle_t currentcycle; 211 atom *Walker = Root; 212 currentcycle.insert(Walker->GetTrueFather()->getId()); 213 std::stringstream output; 214 while (Walker != BackEdge->rightatom) { // leftatom is root 215 Walker = PredecessorList[Walker->getNr()]; 216 Walker->GetTrueFather()->IsCyclic = true; 217 output << Walker->getName() << " <-> "; 218 #ifndef NDEBUG 219 std::pair< cycle_t::iterator, bool > inserter = 220 #endif 221 currentcycle.insert(Walker->GetTrueFather()->getId()); 222 ASSERT( inserter.second, 223 "CyclicStructureAnalysis::RetrieveCycleMembers() - we already inserted " 224 +toString(Walker->GetTrueFather()->getId())+" into currentcycle."); 225 } 226 LOG(3, "INFO: " << output.str() << Root->getName()); 227 return currentcycle; 189 228 } 190 229 … … 208 247 // now climb back the predecessor list and thus find the cycle members 209 248 NumCycles++; 210 RingSize = 1;211 249 Root->GetTrueFather()->IsCyclic = true; 212 250 251 // exctract cycle 213 252 { 214 CyclicStructureAnalysis::cycle_t currentcycle; 215 std::stringstream output; 216 output << "Found ring contains: "; 217 Walker = Root; 218 currentcycle.insert(Walker->GetTrueFather()->getId()); 219 while (Walker != BackEdge->rightatom) { // leftatom is root 220 output << Walker->getName() << " <-> "; 221 Walker = PredecessorList[Walker->getNr()]; 222 Walker->GetTrueFather()->IsCyclic = true; 223 #ifndef NDEBUG 224 std::pair< cycle_t::iterator, bool > inserter = 225 #endif 226 currentcycle.insert(Walker->GetTrueFather()->getId()); 227 ASSERT( inserter.second, 228 "CyclicStructureAnalysis::RetrieveCycleMembers() - we already inserted " 229 +toString(Walker->GetTrueFather()->getId())+" into currentcycle."); 230 RingSize++; 231 } 232 output << Walker->getName() << " with a length of " << RingSize << "."; 233 LOG(0, "INFO: " << output.str()); 234 allcycles.push_back(currentcycle); 253 allcycles.push_back(extractCurrentCycle(BackEdge)); 254 CyclicStructureAnalysis::cycle_t &lastcycle = allcycles.back(); 255 RingSize = lastcycle.size(); 256 LOG(0, "INFO: " << "Found ring contains: " << lastcycle << " with a length of " << RingSize); 235 257 } 236 258 -
src/Graph/CyclicStructureAnalysis.hpp
r4b10fd rec7511 60 60 void CyclicBFSFromRootToRoot(atom *&OtherAtom, bond::ptr &BackEdge); 61 61 void RetrieveCycleMembers(atom *&OtherAtom, bond::ptr &BackEdge, int &MinRingSize, int &NumCycles); 62 cycle_t extractCurrentCycle(bond::ptr &BackEdge); 62 63 void BFSToNextCycle(atom *Walker); 63 64 void AssignRingSizetoNonCycleMembers(const int MinRingSize, const int NumCycles);
Note:
See TracChangeset
for help on using the changeset viewer.