- Timestamp:
- Apr 17, 2013, 6:56:55 PM (12 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:
- 4f04ab8
- Parents:
- 378fc6b
- git-author:
- Frederik Heber <heber@…> (03/19/13 13:32:21)
- git-committer:
- Frederik Heber <heber@…> (04/17/13 18:56:55)
- Location:
- src/Graph
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Graph/BondGraph.cpp
r378fc6b r326000 35 35 #include "CodePatterns/MemDebug.hpp" 36 36 37 #include <deque> 37 38 #include <iostream> 38 39 … … 49 50 #include "Element/periodentafel.hpp" 50 51 #include "Fragmentation/MatrixContainer.hpp" 52 #include "Graph/DepthFirstSearchAnalysis.hpp" 51 53 #include "LinearAlgebra/Vector.hpp" 52 54 #include "World.hpp" … … 226 228 227 229 /** Corrects the bond degree by one at most if necessary. 230 * 231 * We are constraint to bonds in \a egdes, if the candidate bond is in edges, we 232 * just don't increment its bond degree. We do not choose an alternative for this 233 * atom. 234 * 235 * \param edges only these edges can be updated 228 236 * \return number of corrections done 229 237 */ 230 int BondGraph::CorrectBondDegree(atom *_atom ) const238 int BondGraph::CorrectBondDegree(atom *_atom, const std::set<bond::ptr>& edges) const 231 239 { 232 240 int NoBonds = 0; … … 260 268 } 261 269 if ((CandidateBond != NULL)) { 262 CandidateBond->setDegree(CandidateBond->getDegree()+1); 263 LOG(2, "Increased bond degree for bond " << *CandidateBond << "."); 270 if (edges.find(CandidateBond) != edges.end()) { 271 CandidateBond->setDegree(CandidateBond->getDegree()+1); 272 LOG(2, "Increased bond degree for bond " << *CandidateBond << "."); 273 } else 274 LOG(2, "Bond " << *CandidateBond << " is not in edges."); 264 275 } else { 265 276 ELOG(2, "Could not find correct degree for atom " << *_atom << "."); … … 268 279 } 269 280 return FalseBondDegree; 270 } ;281 } 271 282 272 283 /** Sets the weight of all connected bonds to one. … … 279 290 ++BondRunner) 280 291 (*BondRunner)->setDegree(1); 281 }; 282 292 } 293 294 std::set<bond::ptr> BondGraph::getBackEdges() const 295 { 296 DepthFirstSearchAnalysis DFS; 297 DFS(); 298 299 const std::deque<bond::ptr>& backedgestack = DFS.getBackEdgeStack(); 300 std::set<bond::ptr> backedges(backedgestack.begin(), backedgestack.end()); 301 302 return backedges; 303 } 304 305 std::set<bond::ptr> BondGraph::getTreeEdges() const 306 { 307 const std::set<bond::ptr> backedges = getBackEdges(); 308 std::set<bond::ptr> alledges; 309 const World& world = World::getInstance(); 310 for(World::AtomConstIterator iter = world.getAtomIter(); 311 iter != world.atomEnd(); ++iter) { 312 const BondList &ListOfBonds = (*iter)->getListOfBonds(); 313 alledges.insert(ListOfBonds.begin(), ListOfBonds.end()); 314 } 315 std::set<bond::ptr> treeedges; 316 std::set_difference( 317 alledges.begin(), alledges.end(), 318 backedges.begin(), backedges.end(), 319 std::inserter(treeedges, treeedges.begin())); 320 return treeedges; 321 } -
src/Graph/BondGraph.hpp
r378fc6b r326000 473 473 class iterator_type, 474 474 class const_iterator_type> 475 void resetBondDegree (475 void resetBondDegree ( 476 476 AtomSetMixin<container_type,iterator_type,const_iterator_type> &Set) const 477 477 { … … 493 493 AtomSetMixin<container_type,iterator_type,const_iterator_type> &Set) const 494 494 { 495 const std::set<bond::ptr> backedges = getBackEdges(); 496 const std::set<bond::ptr> treeedges = getTreeEdges(); 497 495 498 //LOG(1, "Correcting Bond degree of each bond ... "); 496 499 int No = 0, OldNo = -1; … … 499 502 No=0; 500 503 for(iterator_type AtomRunner = Set.begin(); AtomRunner != Set.end(); ++AtomRunner) { 501 No+=CorrectBondDegree(*AtomRunner); 504 No+=CorrectBondDegree(*AtomRunner, backedges); 505 } 506 for(iterator_type AtomRunner = Set.begin(); AtomRunner != Set.end(); ++AtomRunner) { 507 No+=CorrectBondDegree(*AtomRunner, treeedges); 502 508 } 503 509 } while (OldNo != No); … … 512 518 } 513 519 514 int CorrectBondDegree(atom *_atom) const; 520 std::set<bond::ptr> getBackEdges() const; 521 std::set<bond::ptr> getTreeEdges() const; 522 523 int CorrectBondDegree(atom *_atom, const std::set<bond::ptr>& skipedges) const; 515 524 516 525 void resetBondDegree(atom *_atom) const;
Note:
See TracChangeset
for help on using the changeset viewer.