Changeset 28e203


Ignore:
Timestamp:
Dec 14, 2012, 5:39:42 PM (12 years ago)
Author:
Frederik Heber <heber@…>
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)
Message:

FIX: nodes_t and edges_t in HomologyGraph must be a map.

  • there may be multiples of the same node or edge. Hence, now we store the count in a map.
  • changed operator<<() accordingly.
Location:
src/Fragmentation/Homology
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Homology/HomologyGraph.cpp

    rd058e6 r28e203  
    108108      nodeiter != graph.nodes.end();
    109109      ++nodeiter)
    110     ost << *nodeiter << " ";
     110    ost << nodeiter->second << "x " << nodeiter->first << ", ";
    111111  for (HomologyGraph::edges_t::const_iterator edgeiter = graph.edges.begin();
    112112      edgeiter != graph.edges.end();
    113113      ++edgeiter)
    114     ost << *edgeiter << " ";
     114    ost << edgeiter->second << "x " << edgeiter->first << ", ";
    115115  return ost;
    116116}
  • src/Fragmentation/Homology/HomologyGraph.hpp

    rd058e6 r28e203  
    1616
    1717#include <boost/serialization/export.hpp>
    18 #include <boost/serialization/set.hpp>
     18#include <boost/serialization/map.hpp>
    1919
    20 #include <set>
     20#include <map>
    2121#include <iosfwd>
    2222
     
    4646public:
    4747  //!> 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;
    4949  //!> 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;
    5151public:
    5252  /** Default constructor for class HomologyGraph.
     
    9292  }
    9393
     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
    94122  /** Assignment operator for class HomologyGraph.
    95123   *
  • src/Fragmentation/Homology/HomologyGraph_getFromKeyset.cpp

    rd058e6 r28e203  
    5858  for (typename std::set<T>::const_iterator iter = keyset.begin();
    5959      iter != keyset.end(); ++iter) {
     60//    LOG(2, "DEBUG: Current global id is " << *iter << ".");
    6061    const atom *Walker = World::getInstance().getAtom(AtomById(*iter));
    6162    if (Walker != NULL) {
     63      size_t NoBonds = 0;
    6264      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.");
    6473    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;
    6777    } else {
    68       ELOG(0, "Id " << *iter << " is not associated with any atom.");
     78      ELOG(3, "Skipping id " << *iter << ", is not associated with any atom.");
    6979    }
    7080  }
     
    7888  for (typename std::set<T>::const_iterator iter = keyset.begin();
    7989      iter != keyset.end(); ++iter) {
     90//    LOG(2, "DEBUG: Current global id is " << *iter << ".");
    8091    const atom *Walker = World::getInstance().getAtom(AtomById(*iter));
    8192    if (Walker != NULL) {
     
    8495          bonditer != ListOfBonds.end(); ++bonditer) {
    8596        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        }
    88105      }
    89106    } else {
    90       ELOG(0, "Id " << *iter << " is not associated with any atom.");
     107      ELOG(3, "Skipping id " << *iter << ", is not associated with any atom.");
    91108    }
    92109  }
  • src/Fragmentation/Homology/unittests/HomologyContainerUnitTest.cpp

    rd058e6 r28e203  
    6868  // add nodes
    6969  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);
    7474  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);
    7777
    7878  // add edges
    7979  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);
    8484  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);
    8787
    8888  // construct graphs
  • src/Fragmentation/Homology/unittests/HomologyGraphUnitTest.cpp

    rd058e6 r28e203  
    7171
    7272  // 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);
    7581
    7682  // 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);
    7991
    8092  // construct graph
Note: See TracChangeset for help on using the changeset viewer.