Changeset 28e203
- Timestamp:
- Dec 14, 2012, 5:39:42 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:
- 91a565
- Parents:
- d058e6
- git-author:
- Frederik Heber <heber@…> (09/28/12 16:22:03)
- git-committer:
- Frederik Heber <heber@…> (12/14/12 17:39:42)
- Location:
- src/Fragmentation/Homology
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Homology/HomologyGraph.cpp
rd058e6 r28e203 108 108 nodeiter != graph.nodes.end(); 109 109 ++nodeiter) 110 ost << *nodeiter << "";110 ost << nodeiter->second << "x " << nodeiter->first << ", "; 111 111 for (HomologyGraph::edges_t::const_iterator edgeiter = graph.edges.begin(); 112 112 edgeiter != graph.edges.end(); 113 113 ++edgeiter) 114 ost << *edgeiter << "";114 ost << edgeiter->second << "x " << edgeiter->first << ", "; 115 115 return ost; 116 116 } -
src/Fragmentation/Homology/HomologyGraph.hpp
rd058e6 r28e203 16 16 17 17 #include <boost/serialization/export.hpp> 18 #include <boost/serialization/ set.hpp>18 #include <boost/serialization/map.hpp> 19 19 20 #include < set>20 #include <map> 21 21 #include <iosfwd> 22 22 … … 46 46 public: 47 47 //!> typedef for a set of nodes representing node information 48 typedef std:: set<FragmentNode> nodes_t;48 typedef std::map<FragmentNode, size_t> nodes_t; 49 49 //!> typedef for a set of nodes representing edge information 50 typedef std:: set<FragmentEdge> edges_t;50 typedef std::map<FragmentEdge, size_t> edges_t; 51 51 public: 52 52 /** Default constructor for class HomologyGraph. … … 92 92 } 93 93 94 /** Checks whether this graph contains a specific \a node. 95 * 96 * @param node node to look for 97 * @param count how often this node must occur 98 * @return true - graph contains this node at least once, false - else 99 */ 100 bool hasNode(const FragmentNode &node, const size_t count = 1) const { 101 nodes_t::const_iterator iter = nodes.find(node); 102 if (iter == nodes.end()) 103 return count == 0; 104 else 105 return (iter->second == count); 106 } 107 108 /** Checks whether this graph contains a specific \a edge. 109 * 110 * @param edge edge to look for 111 * @param count how often this edge must occur 112 * @return true - graph contains this edge at least once, false - else 113 */ 114 bool hasEdge(const FragmentEdge &edge, const size_t count = 1) const { 115 edges_t::const_iterator iter = edges.find(edge); 116 if (iter == edges.end()) 117 return count == 0; 118 else 119 return (iter->second == count); 120 } 121 94 122 /** Assignment operator for class HomologyGraph. 95 123 * -
src/Fragmentation/Homology/HomologyGraph_getFromKeyset.cpp
rd058e6 r28e203 58 58 for (typename std::set<T>::const_iterator iter = keyset.begin(); 59 59 iter != keyset.end(); ++iter) { 60 // LOG(2, "DEBUG: Current global id is " << *iter << "."); 60 61 const atom *Walker = World::getInstance().getAtom(AtomById(*iter)); 61 62 if (Walker != NULL) { 63 size_t NoBonds = 0; 62 64 const BondList& ListOfBonds = Walker->getListOfBonds(); 63 #ifndef NDEBUG 65 for (BondList::const_iterator bonditer = ListOfBonds.begin(); 66 bonditer != ListOfBonds.end(); ++bonditer) { 67 const atom *OtherWalker = (*bonditer)->GetOtherAtom(Walker); 68 if (keyset.count(OtherWalker->getId())) 69 ++NoBonds; 70 } 71 // LOG(2, "DEBUG: Adding node " << Walker->getId() << " with element " 72 // << Walker->getElementNo() << " and " << NoBonds << " bonds."); 64 73 std::pair<HomologyGraph::nodes_t::iterator,bool> inserter = 65 #endif 66 nodes.insert( FragmentNode(Walker->getElementNo(), ListOfBonds.size()) ); 74 nodes.insert( std::make_pair(FragmentNode(Walker->getElementNo(), NoBonds), (size_t)1) ); 75 if (!inserter.second) 76 inserter.first->second += (size_t)1; 67 77 } else { 68 ELOG( 0, "Id " << *iter << "is not associated with any atom.");78 ELOG(3, "Skipping id " << *iter << ", is not associated with any atom."); 69 79 } 70 80 } … … 78 88 for (typename std::set<T>::const_iterator iter = keyset.begin(); 79 89 iter != keyset.end(); ++iter) { 90 // LOG(2, "DEBUG: Current global id is " << *iter << "."); 80 91 const atom *Walker = World::getInstance().getAtom(AtomById(*iter)); 81 92 if (Walker != NULL) { … … 84 95 bonditer != ListOfBonds.end(); ++bonditer) { 85 96 const atom *OtherWalker = (*bonditer)->GetOtherAtom(Walker); 86 if (Walker->getId() < OtherWalker->getId()) 87 edges.insert( FragmentEdge( Walker->getElementNo(), OtherWalker->getElementNo()) ); 97 // LOG(2, "DEBUG: Neighbor is " << OtherWalker->getId() << "."); 98 if ((keyset.count(OtherWalker->getId())) && (Walker->getId() < OtherWalker->getId())) { 99 // LOG(1, "DEBUG: Adding edge " << Walker->getId() << " and " << OtherWalker->getId() << "."); 100 std::pair<HomologyGraph::edges_t::iterator,bool> inserter = 101 edges.insert( std::make_pair(FragmentEdge( Walker->getElementNo(), OtherWalker->getElementNo()), (size_t)1) ); 102 if (!inserter.second) 103 inserter.first->second += (size_t)1; 104 } 88 105 } 89 106 } else { 90 ELOG( 0, "Id " << *iter << "is not associated with any atom.");107 ELOG(3, "Skipping id " << *iter << ", is not associated with any atom."); 91 108 } 92 109 } -
src/Fragmentation/Homology/unittests/HomologyContainerUnitTest.cpp
rd058e6 r28e203 68 68 // add nodes 69 69 nodes += 70 FragmentNode(1,1),71 FragmentNode(1,4),72 FragmentNode(2,2),73 FragmentNode(2,4);70 std::make_pair(FragmentNode(1,1),1), 71 std::make_pair(FragmentNode(1,4),1), 72 std::make_pair(FragmentNode(2,2),1), 73 std::make_pair(FragmentNode(2,4),1); 74 74 othernodes += 75 FragmentNode(1,1),76 FragmentNode(1,4);75 std::make_pair(FragmentNode(1,1),1), 76 std::make_pair(FragmentNode(1,4),1); 77 77 78 78 // add edges 79 79 edges += 80 FragmentEdge(1,1),81 FragmentEdge(1,4),82 FragmentEdge(2,2),83 FragmentEdge(2,4);80 std::make_pair(FragmentEdge(1,1),1), 81 std::make_pair(FragmentEdge(1,4),1), 82 std::make_pair(FragmentEdge(2,2),1), 83 std::make_pair(FragmentEdge(2,4),1); 84 84 otheredges += 85 FragmentEdge(1,4),86 FragmentEdge(2,2);85 std::make_pair(FragmentEdge(1,4),1), 86 std::make_pair(FragmentEdge(2,2),1); 87 87 88 88 // construct graphs -
src/Fragmentation/Homology/unittests/HomologyGraphUnitTest.cpp
rd058e6 r28e203 71 71 72 72 // add nodes 73 nodes += FragmentNode(1,1),FragmentNode(1,4), FragmentNode(2,2), FragmentNode(2,4); 74 othernodes += FragmentNode(1,1),FragmentNode(1,4); 73 nodes += 74 std::make_pair(FragmentNode(1,1),1), 75 std::make_pair(FragmentNode(1,4),1), 76 std::make_pair(FragmentNode(2,2),1), 77 std::make_pair(FragmentNode(2,4),1); 78 othernodes += 79 std::make_pair(FragmentNode(1,1),1), 80 std::make_pair(FragmentNode(1,4),1); 75 81 76 82 // add edges 77 edges += FragmentEdge(1,1),FragmentEdge(1,4), FragmentEdge(2,2), FragmentEdge(2,4); 78 otheredges += FragmentEdge(1,4),FragmentEdge(2,2); 83 edges += 84 std::make_pair(FragmentEdge(1,1),1), 85 std::make_pair(FragmentEdge(1,4),1), 86 std::make_pair(FragmentEdge(2,2),1), 87 std::make_pair(FragmentEdge(2,4),1); 88 otheredges += 89 std::make_pair(FragmentEdge(1,4),1), 90 std::make_pair(FragmentEdge(2,2),1); 79 91 80 92 // construct graph
Note:
See TracChangeset
for help on using the changeset viewer.