Changeset 2d4334


Ignore:
Timestamp:
Mar 7, 2011, 11:40:27 AM (14 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:
13a953
Parents:
dda246
git-author:
Frederik Heber <heber@…> (03/03/11 00:11:14)
git-committer:
Frederik Heber <heber@…> (03/07/11 11:40:27)
Message:

Moved BuildInducedSubgraph from molecule into functor in Graph/.

  • BuildInducedSubgraph::ParentList has been reworked into map<atom*,atom*>.
Location:
src
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/Graph/Makefile.am

    rdda246 r2d4334  
    99GRAPHSOURCE = \
    1010        BreadthFirstSearchAdd.cpp \
     11        BuildInducedSubgraph.cpp \
    1112        ConnectedSubgraph.cpp \
    1213        CyclicStructureAnalysis.cpp \
     
    1516GRAPHHEADER = \
    1617        BreadthFirstSearchAdd.hpp \
     18        BuildInducedSubgraph.hpp \
    1719        ConnectedSubgraph.hpp \
    1820        CyclicStructureAnalysis.hpp \
  • TabularUnified src/molecule.hpp

    rdda246 r2d4334  
    226226  void FragmentBOSSANOVA(Graph *&FragmentList, KeyStack &RootStack);
    227227  int PowerSetGenerator(int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet);
    228   bool BuildInducedSubgraph(const molecule *Father);
    229228  molecule * StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem);
    230229  void SPFragmentGenerator(struct UniqueFragments *FragmentSearch, int RootDistance, std::vector<bond *> &BondsSet, int SetDimension, int SubOrder);
  • TabularUnified src/molecule_graph.cpp

    rdda246 r2d4334  
    327327;
    328328
    329 void BuildInducedSubgraph_Init(atom **&ParentList, int AtomCount)
    330 {
    331   // reset parent list
    332   ParentList = new atom*[AtomCount];
    333   for (int i=0;i<AtomCount;i++)
    334     ParentList[i] = NULL;
    335   DoLog(3) && (Log() << Verbose(3) << "Resetting ParentList." << endl);
    336 }
    337 ;
    338 
    339 void BuildInducedSubgraph_FillParentList(const molecule *mol, const molecule *Father, atom **&ParentList)
    340 {
    341   // fill parent list with sons
    342   DoLog(3) && (Log() << Verbose(3) << "Filling Parent List." << endl);
    343   for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    344     ParentList[(*iter)->father->getNr()] = (*iter);
    345     // Outputting List for debugging
    346     DoLog(4) && (Log() << Verbose(4) << "Son[" << (*iter)->father->getNr() << "] of " << (*iter)->father << " is " << ParentList[(*iter)->father->getNr()] << "." << endl);
    347   }
    348 };
    349 
    350 void BuildInducedSubgraph_Finalize(atom **&ParentList)
    351 {
    352   delete[](ParentList);
    353 }
    354 ;
    355 
    356 bool BuildInducedSubgraph_CreateBondsFromParent(molecule *mol, const molecule *Father, atom **&ParentList)
    357 {
    358   bool status = true;
    359   atom *OtherAtom = NULL;
    360   // check each entry of parent list and if ok (one-to-and-onto matching) create bonds
    361   DoLog(3) && (Log() << Verbose(3) << "Creating bonds." << endl);
    362   for (molecule::const_iterator iter = Father->begin(); iter != Father->end(); ++iter) {
    363     if (ParentList[(*iter)->getNr()] != NULL) {
    364       if (ParentList[(*iter)->getNr()]->father != (*iter)) {
    365         status = false;
    366       } else {
    367         const BondList& ListOfBonds = (*iter)->getListOfBonds();
    368         for (BondList::const_iterator Runner = ListOfBonds.begin();
    369             Runner != ListOfBonds.end();
    370             ++Runner) {
    371           OtherAtom = (*Runner)->GetOtherAtom((*iter));
    372           if (ParentList[OtherAtom->getNr()] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond
    373             DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[(*iter)->getNr()]->getName() << " and " << ParentList[OtherAtom->getNr()]->getName() << "." << endl);
    374             mol->AddBond(ParentList[(*iter)->getNr()], ParentList[OtherAtom->getNr()], (*Runner)->BondDegree);
    375           }
    376         }
    377       }
    378     }
    379   }
    380   return status;
    381 }
    382 ;
    383 
    384 /** Adds bond structure to this molecule from \a Father molecule.
    385  * This basically causes this molecule to become an induced subgraph of the \a Father, i.e. for every bond in Father
    386  * with end points present in this molecule, bond is created in this molecule.
    387  * Special care was taken to ensure that this is of complexity O(N), where N is the \a Father's molecule::AtomCount.
    388  * \param *Father father molecule
    389  * \return true - is induced subgraph, false - there are atoms with fathers not in \a Father
    390  * \todo not checked, not fully working probably
    391  */
    392 bool molecule::BuildInducedSubgraph(const molecule *Father){
    393   bool status = true;
    394   atom **ParentList = NULL;
    395   DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl);
    396   BuildInducedSubgraph_Init(ParentList, Father->getAtomCount());
    397   BuildInducedSubgraph_FillParentList(this, Father, ParentList);
    398   status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList);
    399   BuildInducedSubgraph_Finalize(ParentList);
    400   DoLog(2) && (Log() << Verbose(2) << "End of BuildInducedSubgraph." << endl);
    401   return status;
    402 }
    403 ;
    404 
    405329/** Fills a lookup list of father's Atom::nr -> atom for each subgraph.
    406330 * \param **&ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
Note: See TracChangeset for help on using the changeset viewer.