Changeset 49c059


Ignore:
Timestamp:
Mar 2, 2011, 9:53:08 PM (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:
2fa1dc
Parents:
1a4d4fe
git-author:
Frederik Heber <heber@…> (02/25/11 22:15:31)
git-committer:
Frederik Heber <heber@…> (03/02/11 21:53:08)
Message:

Moved DepthFirstSearchAnalysis into functor in Graph/.

Smaller fixes:

TESTFIXES:

Files:
2 added
13 edited
2 moved

Legend:

Unmodified
Added
Removed
  • src/Actions/FragmentationAction/DepthFirstSearchAction.cpp

    r1a4d4fe r49c059  
    2626#include "CodePatterns/Verbose.hpp"
    2727#include "Graph/CyclicStructureAnalysis.hpp"
     28#include "Graph/DepthFirstSearchAnalysis.hpp"
    2829#include "molecule.hpp"
    2930#include "Descriptors/MoleculeDescriptor.hpp"
     
    4748
    4849  DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
    49   molecule * const mol = World::getInstance().getMolecule(MoleculeById(0));
    50   MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
    5150  atom **ListOfAtoms = NULL;
    52   std::deque<bond *> *BackEdgeStack = NULL;
    5351  std::deque<bond *> *LocalBackEdgeStack = NULL;
    54   Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
     52  DepthFirstSearchAnalysis DFS;
     53  DFS();
     54  DFS.UpdateMoleculeStructure();
     55  MoleculeLeafClass *Subgraphs = DFS.getMoleculeStructure();
    5556  if (Subgraphs != NULL) {
    5657    int FragmentCounter = 0;
     
    5859      Subgraphs = Subgraphs->next;
    5960      ListOfAtoms = NULL;
    60       Subgraphs->Leaf->FillBondStructureFromReference(mol, ListOfAtoms, false);  // we want to keep the created ListOfLocalAtoms
     61      Subgraphs->Leaf->FillListOfLocalAtoms(ListOfAtoms, Subgraphs->Leaf->getAtomCount());
    6162      LocalBackEdgeStack = new std::deque<bond *>; // no need to have it Subgraphs->Leaf->BondCount size
    62       Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack);
     63      DFS.PickLocalBackEdges(ListOfAtoms, LocalBackEdgeStack);
    6364      CyclicStructureAnalysis CycleAnalysis;
    6465      CycleAnalysis(LocalBackEdgeStack);
    6566      delete(LocalBackEdgeStack);
     67      Subgraphs->Leaf = NULL;
    6668      delete(Subgraphs->previous);
    67       delete[](ListOfAtoms);  // and here we remove it
     69      delete[](ListOfAtoms);  // allocated by FillListOfLocalAtoms
    6870      FragmentCounter++;
    6971    }
     72    Subgraphs->Leaf = NULL;
    7073    delete(Subgraphs);
    7174  }
    72   delete(BackEdgeStack);
    7375  return Action::success;
    7476}
  • src/Actions/FragmentationAction/FragmentationAction.cpp

    r1a4d4fe r49c059  
    2525#include "CodePatterns/Log.hpp"
    2626#include "CodePatterns/Verbose.hpp"
     27#include "Graph/DepthFirstSearchAnalysis.hpp"
    2728#include "molecule.hpp"
    2829#include "Descriptors/MoleculeDescriptor.hpp"
     
    4849  getParametersfromValueStorage();
    4950
     51  DepthFirstSearchAnalysis DFS;
    5052  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
    5153    mol = iter->second;
    5254    ASSERT(mol != NULL, "No molecule has been picked for fragmentation.");
    53     DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with bond distance " << params.distance << " angstroem, order of " << params.order << "." << endl);
    54     DoLog(0) && (Log() << Verbose(0) << "Creating connection matrix..." << endl);
     55    LOG(2, "INFO: Fragmenting molecule with bond distance " << params.distance << " angstroem, order of " << params.order << ".");
    5556    start = clock();
    56     DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
    5757    if (mol->hasBondStructure()) {
    58       ExitFlag = mol->FragmentMolecule(params.order, params.path);
     58      LOG(1, "STAUS: Fragmenting molecule with current connection matrix ...");
     59      ExitFlag = mol->FragmentMolecule(params.order, params.path, DFS);
    5960    }
    6061    World::getInstance().setExitFlag(ExitFlag);
    6162    end = clock();
    62     DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
     63    LOG(0, "STATUS: Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s.");
    6364  }
    6465  return Action::success;
  • src/Actions/FragmentationAction/SubgraphDissectionAction.cpp

    r1a4d4fe r49c059  
    2929#include "CodePatterns/Verbose.hpp"
    3030#include "Graph/BondGraph.hpp"
     31#include "Graph/DepthFirstSearchAnalysis.hpp"
    3132#include "molecule.hpp"
    3233#include "World.hpp"
     
    102103
    103104  // 2. scan for connected subgraphs
    104   LOG(0, "STATUS: Analysing adjacency graph.");
    105   MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
    106   std::deque<bond *> *BackEdgeStack = NULL;
    107   Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
    108   delete(BackEdgeStack);
    109   if ((Subgraphs == NULL) || (Subgraphs->next == NULL)) {
     105  DepthFirstSearchAnalysis DFS;
     106  DFS();
     107  DFS.UpdateMoleculeStructure();
     108  if (!World::getInstance().numMolecules()) {
    110109    //World::getInstance().destroyMolecule(mol);
    111110    DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms." << endl);
     
    113112  }
    114113
    115   //int FragmentCounter = Subgraphs->next->Count();
    116 
    117   // TODO: When DepthFirstSearchAnalysis does not use AddCopyAtom() anymore, we don't need to delete all original atoms
    118   LOG(0, "STATUS: Creating molecules as connected subgraphs.");
    119   {
    120     {
    121       atom **ListOfAtoms = NULL;
    122       // 3a. re-create bond structure and insert molecules into general MoleculeListClass
    123       MoleculeLeafClass *MoleculeWalker = Subgraphs->next;
    124       while (MoleculeWalker->next != NULL) {
    125         ListOfAtoms = NULL;
    126         MoleculeWalker->Leaf->FillBondStructureFromReference(mol, ListOfAtoms, true);  // we want to keep the created ListOfLocalAtoms
    127         molecules->insert(MoleculeWalker->Leaf);
    128         MoleculeWalker = MoleculeWalker->next;
    129       }
    130       molecules->insert(MoleculeWalker->Leaf);
    131       ListOfAtoms = NULL;
    132       MoleculeWalker->Leaf->FillBondStructureFromReference(mol, ListOfAtoms, true);  // we want to keep the created ListOfLocalAtoms
    133     }
    134 
    135     // 3b. store map from new to old ids for 3d
    136     vector <atom *> allatoms = World::getInstance().getAllAtoms();
    137     AtomAtomList newtooldlist;
    138     for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner)
    139       if ((*AtomRunner)->father != (*AtomRunner))
    140         newtooldlist.insert( std::pair<atomId_t, atomId_t> ((*AtomRunner)->getId(),(*AtomRunner)->father->getId()) );
    141 
    142     {
    143       // 3c. destroy the original molecule
    144       for (molecule::iterator AtomRunner = mol->begin(); !mol->empty(); AtomRunner = mol->begin())
    145         World::getInstance().destroyAtom(*AtomRunner);
    146       World::getInstance().destroyMolecule(mol);
    147     }
    148 
    149     {
    150       // 3d. convert to old Ids and correct fathers (AddCopyAtom sets father to original atom, which has been destroyed).
    151       vector <atom *> allatoms = World::getInstance().getAllAtoms();
    152       for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
    153         World::getInstance().changeAtomId((*AtomRunner)->getId(), newtooldlist[(*AtomRunner)->getId()]);
    154         (*AtomRunner)->father = *AtomRunner;
    155       }
    156     }
    157   }
    158 
    159   // 4. free Leafs
    160   LOG(0, "STATUS: Done.");
    161   MoleculeLeafClass *MolecularWalker = Subgraphs;
    162   while (MolecularWalker->next != NULL) {
    163     MolecularWalker->Leaf = NULL;
    164     MolecularWalker = MolecularWalker->next;
    165     delete(MolecularWalker->previous);
    166   }
    167   MolecularWalker->Leaf = NULL;
    168   delete(MolecularWalker);
    169   DoLog(1) && (Log() << Verbose(1) << "I scanned " << molecules->ListOfMolecules.size() << " molecules." << endl);
     114  DoLog(1) && (Log() << Verbose(1) << "I scanned " << World::getInstance().numMolecules() << " molecules." << endl);
    170115
    171116  return Action::state_ptr(UndoState);
  • src/Graph/Makefile.am

    r1a4d4fe r49c059  
    1010        BreadthFirstSearchAdd.cpp \
    1111        ConnectedSubgraph.cpp \
    12         CyclicStructureAnalysis.cpp
     12        CyclicStructureAnalysis.cpp \
     13        DepthFirstSearchAnalysis.cpp
    1314                                 
    1415GRAPHHEADER = \
    1516        BreadthFirstSearchAdd.hpp \
    1617        ConnectedSubgraph.hpp \
    17         CyclicStructureAnalysis.hpp
     18        CyclicStructureAnalysis.hpp \
     19        DepthFirstSearchAnalysis.hpp
    1820
    1921
  • src/molecule.hpp

    r1a4d4fe r49c059  
    3939class BondedParticle;
    4040class BondGraph;
     41class DepthFirstSearchAnalysis;
    4142class element;
    4243class ForceMatrix;
     
    204205  /// Initialising routines in fragmentation
    205206  void OutputBondsList() const;
    206   void CyclicBondAnalysis() const;
    207   void OutputGraphInfoPerAtom() const;
    208   void OutputGraphInfoPerBond() const;
    209 
    210   // Graph analysis
    211   MoleculeLeafClass * DepthFirstSearchAnalysis(std::deque<bond *> *&BackEdgeStack) const;
    212   bool PickLocalBackEdges(atom **ListOfLocalAtoms, std::deque<bond *> *&ReferenceStack, std::deque<bond *> *&LocalStack) const;
    213   bond * FindNextUnused(atom *vertex) const;
    214   void SetNextComponentNumber(atom *vertex, int nr) const;
    215   void ResetAllBondsToUnused() const;
    216   int CountCyclicBonds();
    217   bool CheckForConnectedSubgraph(KeySet *Fragment);
     207
    218208  bond * CopyBond(atom *left, atom *right, bond *CopyBond);
    219209
     
    222212
    223213  /// Fragment molecule by two different approaches:
    224   int FragmentMolecule(int Order, std::string &prefix);
     214  int FragmentMolecule(int Order, std::string &prefix, DepthFirstSearchAnalysis &DFS);
    225215  bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, std::string path = "");
    226216  bool StoreBondsToFile(std::string filename, std::string path = "");
     
    259249
    260250private:
    261   void init_DFS(struct DFSAccounting&) const;
    262251  int last_atom; //!< number given to last atom
    263252};
  • src/molecule_fragmentation.cpp

    r1a4d4fe r49c059  
    3131#include "Graph/BondGraph.hpp"
    3232#include "Graph/CyclicStructureAnalysis.hpp"
     33#include "Graph/DepthFirstSearchAnalysis.hpp"
    3334#include "Helpers/helpers.hpp"
    3435#include "LinearAlgebra/RealSpaceMatrix.hpp"
     
    623624 * \param Order up to how many neighbouring bonds a fragment contains in BondOrderScheme::BottumUp scheme
    624625 * \param &prefix path and prefix of the bond order configs to be written
     626 * \param &DFS contains bond structure analysis data
    625627 * \return 1 - continue, 2 - stop (no fragmentation occured)
    626628 */
    627 int molecule::FragmentMolecule(int Order, std::string &prefix)
     629int molecule::FragmentMolecule(int Order, std::string &prefix, DepthFirstSearchAnalysis &DFS)
    628630{
    629631  MoleculeListClass *BondFragments = NULL;
     
    633635  fstream File;
    634636  bool FragmentationToDo = true;
    635   std::deque<bond *> *BackEdgeStack = NULL, *LocalBackEdgeStack = NULL;
    636637  bool CheckOrder = false;
    637638  Graph **FragmentList = NULL;
     
    671672
    672673  // ===== 2. perform a DFS analysis to gather info on cyclic structure and a list of disconnected subgraphs =====
    673   Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack);
    674 
    675   // analysis of the cycles (print rings, get minimum cycle length) for each subgraph
    676   MolecularWalker = Subgraphs;
    677   const int LeafCount = Subgraphs->next->Count();
    678   FragmentCounter = 0;
    679   while (MolecularWalker->next != NULL) {
    680     MolecularWalker = MolecularWalker->next;
    681     // fill the bond structure of the individually stored subgraphs
    682     ListOfAtoms = NULL;
    683     MolecularWalker->Leaf->FillBondStructureFromReference(this, ListOfAtoms, false);  // we want to keep the created ListOfLocalAtoms
    684     DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    685     LocalBackEdgeStack = new std::deque<bond *>; // (MolecularWalker->Leaf->BondCount);
    686 //    // check the list of local atoms for debugging
    687 //    Log() << Verbose(0) << "ListOfLocalAtoms for this subgraph is:" << endl;
    688 //    for (int i=0;i<getAtomCount();i++)
    689 //      if (ListOfLocalAtoms[FragmentCounter][i] == NULL)
    690 //        Log() << Verbose(0) << "\tNULL";
    691 //      else
    692 //        Log() << Verbose(0) << "\t" << ListOfLocalAtoms[FragmentCounter][i]->Name;
    693     DoLog(0) && (Log() << Verbose(0) << "Gathering local back edges for subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    694     MolecularWalker->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack);
    695     DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    696     CyclicStructureAnalysis CycleAnalysis;
    697     CycleAnalysis(LocalBackEdgeStack);
    698     CycleAnalysis.getMinimumRingSize();
    699     DoLog(0) && (Log() << Verbose(0) << "Done with Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    700     delete(LocalBackEdgeStack);
    701     delete(ListOfAtoms);
    702     FragmentCounter++;
    703   }
    704   delete(BackEdgeStack);
     674  // NOTE: We assume here that DFS has been performed and molecule structure is current.
     675  Subgraphs = DFS.getMoleculeStructure();
    705676
    706677  // ===== 3. if structure still valid, parse key set file and others =====
     
    712683  // =================================== Begin of FRAGMENTATION ===============================
    713684  // ===== 6a. assign each keyset to its respective subgraph =====
    714   ListOfLocalAtoms = new atom **[LeafCount];
    715   for (int i=0;i<LeafCount;i++)
     685  const int MolCount = World::getInstance().numMolecules();
     686  ListOfLocalAtoms = new atom **[MolCount];
     687  for (int i=0;i<MolCount;i++)
    716688    ListOfLocalAtoms[i] = NULL;
    717689  FragmentCounter = 0;
     
    762734    // remove subgraph fragment
    763735    MolecularWalker = Subgraphs->next;
     736    Subgraphs->Leaf = NULL;
    764737    delete(Subgraphs);
    765738    Subgraphs = MolecularWalker;
     
    770743  delete[](FragmentList);
    771744
    772   DoLog(0) && (Log() << Verbose(0) << FragmentCounter-1 << " subgraph fragments have been removed." << std::endl);
     745  DoLog(0) && (Log() << Verbose(0) << FragmentCounter << " subgraph fragments have been removed." << std::endl);
    773746
    774747  // ===== 8b. gather keyset lists (graphs) from all subgraphs and transform into MoleculeListClass =====
     
    12621235          DoLog(0) && (Log() << Verbose(0) << (*runner) << " ");
    12631236        DoLog(0) && (Log() << Verbose(0) << endl);
    1264         //if (!CheckForConnectedSubgraph(FragmentSearch->FragmentSet))
    1265           //DoeLog(1) && (eLog()<< Verbose(1) << "The found fragment is not a connected subgraph!" << endl);
    12661237        InsertFragmentIntoGraph(FragmentSearch);
    12671238      }
  • src/molecule_graph.cpp

    r1a4d4fe r49c059  
    3030#include "CodePatterns/Verbose.hpp"
    3131#include "config.hpp"
     32#include "Graph/DepthFirstSearchAnalysis.hpp"
    3233#include "element.hpp"
    3334#include "Graph/BondGraph.hpp"
     
    4445#define MAXBONDS 8
    4546
    46 
    47 /** Accounting data for Depth First Search.
    48  */
    49 struct DFSAccounting
    50 {
    51   std::deque<atom *> *AtomStack;
    52   std::deque<bond *> *BackEdgeStack;
    53   int CurrentGraphNr;
    54   int ComponentNumber;
    55   atom *Root;
    56   bool BackStepping;
    57 };
    58 
    59 /************************************* Functions for class molecule *********************************/
    6047
    6148/** Fills the bond structure of this chain list subgraphs that are derived from a complete \a *reference molecule.
     
    146133;
    147134
    148 
    149 /** Counts all cyclic bonds and returns their number.
    150  * \note Hydrogen bonds can never by cyclic, thus no check for that
    151  * \return number of cyclic bonds
    152  */
    153 int molecule::CountCyclicBonds()
    154 {
    155   NoCyclicBonds = 0;
    156   int *MinimumRingSize = NULL;
    157   MoleculeLeafClass *Subgraphs = NULL;
    158   std::deque<bond *> *BackEdgeStack = NULL;
    159   for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
    160     const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
    161     if ((!ListOfBonds.empty()) && ((*ListOfBonds.begin())->Type == GraphEdge::Undetermined)) {
    162       DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl);
    163       Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack);
    164       while (Subgraphs->next != NULL) {
    165         Subgraphs = Subgraphs->next;
    166         delete (Subgraphs->previous);
    167       }
    168       delete (Subgraphs);
    169       delete[] (MinimumRingSize);
    170       break;
    171     }
    172   }
    173   for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
    174     const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
    175     for(BondList::const_iterator BondRunner = ListOfBonds.begin();
    176         BondRunner != ListOfBonds.end();
    177         ++BondRunner)
    178       if ((*BondRunner)->leftatom == *AtomRunner)
    179         if ((*BondRunner)->Cyclic)
    180           NoCyclicBonds++;
    181   }
    182   delete (BackEdgeStack);
    183   return NoCyclicBonds;
    184 }
    185 ;
    186 
    187 
    188 /** Sets atom::GraphNr and atom::LowpointNr to DFSAccounting::CurrentGraphNr.
    189  * \param *Walker current node
    190  * \param &BFS structure with accounting data for BFS
    191  */
    192 void DepthFirstSearchAnalysis_SetWalkersGraphNr(atom *&Walker, struct DFSAccounting &DFS)
    193 {
    194   if (!DFS.BackStepping) { // if we don't just return from (8)
    195     Walker->GraphNr = DFS.CurrentGraphNr;
    196     Walker->LowpointNr = DFS.CurrentGraphNr;
    197     DoLog(1) && (Log() << Verbose(1) << "Setting Walker[" << Walker->getName() << "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl);
    198     DFS.AtomStack->push_front(Walker);
    199     DFS.CurrentGraphNr++;
    200   }
    201 }
    202 ;
    203 
    204 /** During DFS goes along unvisited bond and touches other atom.
    205  * Sets bond::type, if
    206  *  -# BackEdge: set atom::LowpointNr and push on \a BackEdgeStack
    207  *  -# TreeEgde: set atom::Ancestor and continue with Walker along this edge
    208  * Continue until molecule::FindNextUnused() finds no more unused bonds.
    209  * \param *mol molecule with atoms and finding unused bonds
    210  * \param *&Binder current edge
    211  * \param &DFS DFS accounting data
    212  */
    213 void DepthFirstSearchAnalysis_ProbeAlongUnusedBond(const molecule * const mol, atom *&Walker, bond *&Binder, struct DFSAccounting &DFS)
    214 {
    215   atom *OtherAtom = NULL;
    216 
    217   do { // (3) if Walker has no unused egdes, go to (5)
    218     DFS.BackStepping = false; // reset backstepping flag for (8)
    219     if (Binder == NULL) // if we don't just return from (11), Binder is already set to next unused
    220       Binder = mol->FindNextUnused(Walker);
    221     if (Binder == NULL)
    222       break;
    223     DoLog(2) && (Log() << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl);
    224     // (4) Mark Binder used, ...
    225     Binder->MarkUsed(GraphEdge::black);
    226     OtherAtom = Binder->GetOtherAtom(Walker);
    227     DoLog(2) && (Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->getName() << "." << endl);
    228     if (OtherAtom->GraphNr != -1) {
    229       // (4a) ... if "other" atom has been visited (GraphNr != 0), set lowpoint to minimum of both, go to (3)
    230       Binder->Type = GraphEdge::BackEdge;
    231       DFS.BackEdgeStack->push_front(Binder);
    232       Walker->LowpointNr = (Walker->LowpointNr < OtherAtom->GraphNr) ? Walker->LowpointNr : OtherAtom->GraphNr;
    233       DoLog(3) && (Log() << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->getName() << "] to " << Walker->LowpointNr << "." << endl);
    234     } else {
    235       // (4b) ... otherwise set OtherAtom as Ancestor of Walker and Walker as OtherAtom, go to (2)
    236       Binder->Type = GraphEdge::TreeEdge;
    237       OtherAtom->Ancestor = Walker;
    238       Walker = OtherAtom;
    239       DoLog(3) && (Log() << Verbose(3) << "(4b) Not Visited: OtherAtom[" << OtherAtom->getName() << "]'s Ancestor is now " << OtherAtom->Ancestor->getName() << ", Walker is OtherAtom " << OtherAtom->getName() << "." << endl);
    240       break;
    241     }
    242     Binder = NULL;
    243   } while (1); // (3)
    244 }
    245 ;
    246 
    247 /** Checks whether we have a new component.
    248  * if atom::LowpointNr of \a *&Walker is greater than atom::GraphNr of its atom::Ancestor, we have a new component.
    249  * Meaning that if we touch upon a node who suddenly has a smaller atom::LowpointNr than its ancestor, then we
    250  * have a found a new branch in the graph tree.
    251  * \param *mol molecule with atoms and finding unused bonds
    252  * \param *&Walker current node
    253  * \param &DFS DFS accounting data
    254  */
    255 void DepthFirstSearchAnalysis_CheckForaNewComponent(const molecule * const mol, atom *&Walker, struct DFSAccounting &DFS, MoleculeLeafClass *&LeafWalker)
    256 {
    257   atom *OtherAtom = NULL;
    258 
    259   // (5) if Ancestor of Walker is ...
    260   DoLog(1) && (Log() << Verbose(1) << "(5) Number of Walker[" << Walker->getName() << "]'s Ancestor[" << Walker->Ancestor->getName() << "] is " << Walker->Ancestor->GraphNr << "." << endl);
    261 
    262   if (Walker->Ancestor->GraphNr != DFS.Root->GraphNr) {
    263     // (6)  (Ancestor of Walker is not Root)
    264     if (Walker->LowpointNr < Walker->Ancestor->GraphNr) {
    265       // (6a) set Ancestor's Lowpoint number to minimum of of its Ancestor and itself, go to Step(8)
    266       Walker->Ancestor->LowpointNr = (Walker->Ancestor->LowpointNr < Walker->LowpointNr) ? Walker->Ancestor->LowpointNr : Walker->LowpointNr;
    267       DoLog(2) && (Log() << Verbose(2) << "(6) Setting Walker[" << Walker->getName() << "]'s Ancestor[" << Walker->Ancestor->getName() << "]'s Lowpoint to " << Walker->Ancestor->LowpointNr << "." << endl);
    268     } else {
    269       // (7) (Ancestor of Walker is a separating vertex, remove all from stack till Walker (including), these and Ancestor form a component
    270       Walker->Ancestor->SeparationVertex = true;
    271       DoLog(2) && (Log() << Verbose(2) << "(7) Walker[" << Walker->getName() << "]'s Ancestor[" << Walker->Ancestor->getName() << "]'s is a separating vertex, creating component." << endl);
    272       mol->SetNextComponentNumber(Walker->Ancestor, DFS.ComponentNumber);
    273       DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->getName() << "]'s Ancestor's Compont is " << DFS.ComponentNumber << "." << endl);
    274       mol->SetNextComponentNumber(Walker, DFS.ComponentNumber);
    275       DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->getName() << "]'s Compont is " << DFS.ComponentNumber << "." << endl);
    276       do {
    277         ASSERT(!DFS.AtomStack->empty(), "DepthFirstSearchAnalysis_CheckForaNewComponent() - DFS.AtomStack is empty!");
    278         OtherAtom = DFS.AtomStack->front();
    279         DFS.AtomStack->pop_front();
    280         LeafWalker->Leaf->AddCopyAtom(OtherAtom);
    281         mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber);
    282         DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->getName() << "]'s Compont is " << DFS.ComponentNumber << "." << endl);
    283       } while (OtherAtom != Walker);
    284       DFS.ComponentNumber++;
    285     }
    286     // (8) Walker becomes its Ancestor, go to (3)
    287     DoLog(2) && (Log() << Verbose(2) << "(8) Walker[" << Walker->getName() << "] is now its Ancestor " << Walker->Ancestor->getName() << ", backstepping. " << endl);
    288     Walker = Walker->Ancestor;
    289     DFS.BackStepping = true;
    290   }
    291 }
    292 ;
    293 
    294 /** Cleans the root stack when we have found a component.
    295  * If we are not DFSAccounting::BackStepping, then we clear the root stack by putting everything into a
    296  * component down till we meet DFSAccounting::Root.
    297  * \param *mol molecule with atoms and finding unused bonds
    298  * \param *&Walker current node
    299  * \param *&Binder current edge
    300  * \param &DFS DFS accounting data
    301  */
    302 void DepthFirstSearchAnalysis_CleanRootStackDownTillWalker(const molecule * const mol, atom *&Walker, bond *&Binder, struct DFSAccounting &DFS, MoleculeLeafClass *&LeafWalker)
    303 {
    304   atom *OtherAtom = NULL;
    305 
    306   if (!DFS.BackStepping) { // coming from (8) want to go to (3)
    307     // (9) remove all from stack till Walker (including), these and Root form a component
    308     //DFS.AtomStack->Output(out);
    309     mol->SetNextComponentNumber(DFS.Root, DFS.ComponentNumber);
    310     DoLog(3) && (Log() << Verbose(3) << "(9) Root[" << DFS.Root->getName() << "]'s Component is " << DFS.ComponentNumber << "." << endl);
    311     mol->SetNextComponentNumber(Walker, DFS.ComponentNumber);
    312     DoLog(3) && (Log() << Verbose(3) << "(9) Walker[" << Walker->getName() << "]'s Component is " << DFS.ComponentNumber << "." << endl);
    313     do {
    314       ASSERT(!DFS.AtomStack->empty(), "DepthFirstSearchAnalysis_CleanRootStackDownTillWalker() - DFS.AtomStack is empty!");
    315       OtherAtom = DFS.AtomStack->front();
    316       DFS.AtomStack->pop_front();
    317       LeafWalker->Leaf->AddCopyAtom(OtherAtom);
    318       mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber);
    319       DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->getName() << "]'s Component is " << DFS.ComponentNumber << "." << endl);
    320     } while (OtherAtom != Walker);
    321     DFS.ComponentNumber++;
    322 
    323     // (11) Root is separation vertex,  set Walker to Root and go to (4)
    324     Walker = DFS.Root;
    325     Binder = mol->FindNextUnused(Walker);
    326     DoLog(1) && (Log() << Verbose(1) << "(10) Walker is Root[" << DFS.Root->getName() << "], next Unused Bond is " << Binder << "." << endl);
    327     if (Binder != NULL) { // Root is separation vertex
    328       DoLog(1) && (Log() << Verbose(1) << "(11) Root is a separation vertex." << endl);
    329       Walker->SeparationVertex = true;
    330     }
    331   }
    332 }
    333 ;
    334 
    335 /** Initializes DFSAccounting structure.
    336  * \param &DFS accounting structure to allocate
    337  * \param *mol molecule with AtomCount, BondCount and all atoms
    338  */
    339 void DepthFirstSearchAnalysis_Init(struct DFSAccounting &DFS, const molecule * const mol)
    340 {
    341   DFS.AtomStack = new std::deque<atom *> (mol->getAtomCount());
    342   DFS.CurrentGraphNr = 0;
    343   DFS.ComponentNumber = 0;
    344   DFS.BackStepping = false;
    345   mol->ResetAllBondsToUnused();
    346   DFS.BackEdgeStack->clear();
    347 }
    348 ;
    349 
    350 /** Free's DFSAccounting structure.
    351  * \param &DFS accounting structure to free
    352  */
    353 void DepthFirstSearchAnalysis_Finalize(struct DFSAccounting &DFS)
    354 {
    355   delete (DFS.AtomStack);
    356   // delete (DFS.BackEdgeStack); // DON'T free, see DepthFirstSearchAnalysis(), is returned as allocated
    357 }
    358 ;
    359 
    360 void molecule::init_DFS(struct DFSAccounting &DFS) const{
    361   DepthFirstSearchAnalysis_Init(DFS, this);
    362   for_each(atoms.begin(),atoms.end(),mem_fun(&atom::resetGraphNr));
    363   for_each(atoms.begin(),atoms.end(),mem_fun(&atom::InitComponentNr));
    364 }
    365 
    366 /** Performs a Depth-First search on this molecule.
    367  * Marks bonds in molecule as cyclic, bridge, ... and atoms as
    368  * articulations points, ...
    369  * We use the algorithm from [Even, Graph Algorithms, p.62].
    370  * \param *&BackEdgeStack NULL pointer to std::deque<bond *> with all the found back edges, allocated and filled on return
    371  * \return list of each disconnected subgraph as an individual molecule class structure
    372  */
    373 MoleculeLeafClass * molecule::DepthFirstSearchAnalysis(std::deque<bond *> *&BackEdgeStack) const
    374 {
    375   struct DFSAccounting DFS;
    376   BackEdgeStack = new std::deque<bond *> (getBondCount());
    377   DFS.BackEdgeStack = BackEdgeStack;
    378   MoleculeLeafClass *SubGraphs = new MoleculeLeafClass(NULL);
    379   MoleculeLeafClass *LeafWalker = SubGraphs;
    380   int OldGraphNr = 0;
    381   atom *Walker = NULL;
    382   bond *Binder = NULL;
    383 
    384   if (getAtomCount() == 0)
    385     return SubGraphs;
    386   DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl);
    387   init_DFS(DFS);
    388 
    389   for (molecule::const_iterator iter = begin(); iter != end();) {
    390     DFS.Root = *iter;
    391     // (1) mark all edges unused, empty stack, set atom->GraphNr = -1 for all
    392     DFS.AtomStack->clear();
    393 
    394     // put into new subgraph molecule and add this to list of subgraphs
    395     LeafWalker = new MoleculeLeafClass(LeafWalker);
    396     LeafWalker->Leaf = World::getInstance().createMolecule();
    397     LeafWalker->Leaf->AddCopyAtom(DFS.Root);
    398 
    399     OldGraphNr = DFS.CurrentGraphNr;
    400     Walker = DFS.Root;
    401     do { // (10)
    402       do { // (2) set number and Lowpoint of Atom to i, increase i, push current atom
    403         DepthFirstSearchAnalysis_SetWalkersGraphNr(Walker, DFS);
    404 
    405         DepthFirstSearchAnalysis_ProbeAlongUnusedBond(this, Walker, Binder, DFS);
    406 
    407         if (Binder == NULL) {
    408           DoLog(2) && (Log() << Verbose(2) << "No more Unused Bonds." << endl);
    409           break;
    410         } else
    411           Binder = NULL;
    412       } while (1); // (2)
    413 
    414       // if we came from backstepping, yet there were no more unused bonds, we end up here with no Ancestor, because Walker is Root! Then we are finished!
    415       if ((Walker == DFS.Root) && (Binder == NULL))
    416         break;
    417 
    418       DepthFirstSearchAnalysis_CheckForaNewComponent(this, Walker, DFS, LeafWalker);
    419 
    420       DepthFirstSearchAnalysis_CleanRootStackDownTillWalker(this, Walker, Binder, DFS, LeafWalker);
    421 
    422     } while ((DFS.BackStepping) || (Binder != NULL)); // (10) halt only if Root has no unused edges
    423 
    424     // From OldGraphNr to CurrentGraphNr ranges an disconnected subgraph
    425     DoLog(0) && (Log() << Verbose(0) << "Disconnected subgraph ranges from " << OldGraphNr << " to " << DFS.CurrentGraphNr << "." << endl);
    426     LeafWalker->Leaf->Output((ofstream *)&(Log() << Verbose(0)));
    427     DoLog(0) && (Log() << Verbose(0) << endl);
    428 
    429     // step on to next root
    430     while ((iter != end()) && ((*iter)->GraphNr != -1)) {
    431       //Log() << Verbose(1) << "Current next subgraph root candidate is " << (*iter)->Name << "." << endl;
    432       if ((*iter)->GraphNr != -1) // if already discovered, step on
    433         iter++;
    434     }
    435   }
    436   // set cyclic bond criterium on "same LP" basis
    437   CyclicBondAnalysis();
    438 
    439   OutputGraphInfoPerAtom();
    440 
    441   OutputGraphInfoPerBond();
    442 
    443   // free all and exit
    444   DepthFirstSearchAnalysis_Finalize(DFS);
    445   DoLog(0) && (Log() << Verbose(0) << "End of DepthFirstSearchAnalysis" << endl);
    446   return SubGraphs;
    447 }
    448 ;
    449 
    450 /** Scans through all bonds and set bond::Cyclic to true where atom::LowpointNr of both ends is equal: LP criterion.
    451  */
    452 void molecule::CyclicBondAnalysis() const
    453 {
    454   NoCyclicBonds = 0;
    455   for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
    456     const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
    457     for(BondList::const_iterator BondRunner = ListOfBonds.begin();
    458         BondRunner != ListOfBonds.end();
    459         ++BondRunner)
    460       if ((*BondRunner)->leftatom == *AtomRunner)
    461         if ((*BondRunner)->rightatom->LowpointNr == (*BondRunner)->leftatom->LowpointNr) { // cyclic ??
    462           (*BondRunner)->Cyclic = true;
    463           NoCyclicBonds++;
    464         }
    465   }
    466 }
    467 ;
    468 
    469 /** Output graph information per atom.
    470  */
    471 void molecule::OutputGraphInfoPerAtom() const
    472 {
    473   DoLog(1) && (Log() << Verbose(1) << "Final graph info for each atom is:" << endl);
    474   for_each(atoms.begin(),atoms.end(),mem_fun(&atom::OutputGraphInfo));
    475 }
    476 ;
    477 
    478 /** Output graph information per bond.
    479  */
    480 void molecule::OutputGraphInfoPerBond() const
    481 {
    482   DoLog(1) && (Log() << Verbose(1) << "Final graph info for each bond is:" << endl);
    483   for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
    484     const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
    485     for(BondList::const_iterator BondRunner = ListOfBonds.begin();
    486         BondRunner != ListOfBonds.end();
    487         ++BondRunner)
    488       if ((*BondRunner)->leftatom == *AtomRunner) {
    489         const bond *Binder = *BondRunner;
    490         if (DoLog(2)) {
    491           ostream &out = (Log() << Verbose(2));
    492           out << ((Binder->Type == GraphEdge::TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <";
    493           out << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp.";
    494           Binder->leftatom->OutputComponentNumber(&out);
    495           out << " ===  ";
    496           out << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp.";
    497           Binder->rightatom->OutputComponentNumber(&out);
    498           out << ">." << endl;
    499         }
    500         if (Binder->Cyclic) // cyclic ??
    501           DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl);
    502       }
    503   }
    504 }
    505 ;
    506 
    507 /** Sets the next component number.
    508  * This is O(N) as the number of bonds per atom is bound.
    509  * \param *vertex atom whose next atom::*ComponentNr is to be set
    510  * \param Nr number to use
    511  */
    512 void molecule::SetNextComponentNumber(atom *vertex, int nr) const
    513 {
    514   size_t i = 0;
    515   if (vertex != NULL) {
    516     const BondList& ListOfBonds = vertex->getListOfBonds();
    517     for (; i < ListOfBonds.size(); i++) {
    518       if (vertex->ComponentNr[i] == -1) { // check if not yet used
    519         vertex->ComponentNr[i] = nr;
    520         break;
    521       } else if (vertex->ComponentNr[i] == nr) // if number is already present, don't add another time
    522         break; // breaking here will not cause error!
    523     }
    524     if (i == ListOfBonds.size()) {
    525       DoeLog(0) && (eLog()<< Verbose(0) << "Error: All Component entries are already occupied!" << endl);
    526       performCriticalExit();
    527     }
    528   } else {
    529     DoeLog(0) && (eLog()<< Verbose(0) << "Error: Given vertex is NULL!" << endl);
    530     performCriticalExit();
    531   }
    532 }
    533 ;
    534 
    535 /** Returns next unused bond for this atom \a *vertex or NULL of none exists.
    536  * \param *vertex atom to regard
    537  * \return bond class or NULL
    538  */
    539 bond * molecule::FindNextUnused(atom *vertex) const
    540 {
    541   const BondList& ListOfBonds = vertex->getListOfBonds();
    542   for (BondList::const_iterator Runner = ListOfBonds.begin();
    543       Runner != ListOfBonds.end();
    544       ++Runner)
    545     if ((*Runner)->IsUsed() == GraphEdge::white)
    546       return ((*Runner));
    547   return NULL;
    548 }
    549 ;
    550 
    551 /** Resets bond::Used flag of all bonds in this molecule.
    552  * \return true - success, false - -failure
    553  */
    554 void molecule::ResetAllBondsToUnused() const
    555 {
    556   for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
    557     const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
    558     for(BondList::const_iterator BondRunner = ListOfBonds.begin();
    559         BondRunner != ListOfBonds.end();
    560         ++BondRunner)
    561       if ((*BondRunner)->leftatom == *AtomRunner)
    562         (*BondRunner)->ResetUsed();
    563   }
    564 }
    565 ;
    566 
    567 /** Output a list of flags, stating whether the bond was visited or not.
    568  * \param *list list to print
    569  */
    570 void OutputAlreadyVisited(int *list)
    571 {
    572   DoLog(4) && (Log() << Verbose(4) << "Already Visited Bonds:\t");
    573   for (int i = 1; i <= list[0]; i++)
    574     DoLog(0) && (Log() << Verbose(0) << list[i] << "  ");
    575   DoLog(0) && (Log() << Verbose(0) << endl);
    576 }
    577 ;
    578135
    579136/** Storing the bond structure of a molecule to file.
     
    755312;
    756313
    757 /** Picks from a global stack with all back edges the ones in the fragment.
    758  * \param **ListOfLocalAtoms array of father atom::Nr to local atom::Nr (reverse of atom::father)
    759  * \param *ReferenceStack stack with all the back egdes
    760  * \param *LocalStack stack to be filled
    761  * \return true - everything ok, false - ReferenceStack was empty
    762  */
    763 bool molecule::PickLocalBackEdges(atom **ListOfLocalAtoms, std::deque<bond *> *&ReferenceStack, std::deque<bond *> *&LocalStack) const
    764 {
    765   bool status = true;
    766   if (ReferenceStack->empty()) {
    767     DoLog(1) && (Log() << Verbose(1) << "ReferenceStack is empty!" << endl);
    768     return false;
    769   }
    770   bond *Binder = ReferenceStack->front();
    771   ReferenceStack->pop_front();
    772   bond *FirstBond = Binder; // mark the first bond, so that we don't loop through the stack indefinitely
    773   atom *Walker = NULL, *OtherAtom = NULL;
    774   ReferenceStack->push_front(Binder);
    775 
    776   do { // go through all bonds and push local ones
    777     Walker = ListOfLocalAtoms[Binder->leftatom->getNr()]; // get one atom in the reference molecule
    778     if (Walker != NULL) { // if this Walker exists in the subgraph ...
    779       const BondList& ListOfBonds = Walker->getListOfBonds();
    780       for (BondList::const_iterator Runner = ListOfBonds.begin();
    781           Runner != ListOfBonds.end();
    782           ++Runner) {
    783         OtherAtom = (*Runner)->GetOtherAtom(Walker);
    784         if (OtherAtom == ListOfLocalAtoms[(*Runner)->rightatom->getNr()]) { // found the bond
    785           LocalStack->push_front((*Runner));
    786           DoLog(3) && (Log() << Verbose(3) << "Found local edge " << *(*Runner) << "." << endl);
    787           break;
    788         }
    789       }
    790     }
    791     ASSERT(!ReferenceStack->empty(), "molecule::PickLocalBackEdges() - ReferenceStack is empty!");
    792     Binder = ReferenceStack->front(); // loop the stack for next item
    793     ReferenceStack->pop_front();
    794     DoLog(3) && (Log() << Verbose(3) << "Current candidate edge " << Binder << "." << endl);
    795     ReferenceStack->push_front(Binder);
    796   } while (FirstBond != Binder);
    797 
    798   return status;
    799 }
    800 ;
    801 
    802314/** Adds a bond as a copy to a given one
    803315 * \param *left leftatom of new bond
     
    891403;
    892404
    893 /** For a given keyset \a *Fragment, checks whether it is connected in the current molecule.
    894  * \param *Fragment Keyset of fragment's vertices
    895  * \return true - connected, false - disconnected
    896  * \note this is O(n^2) for it's just a bug checker not meant for permanent use!
    897  */
    898 bool molecule::CheckForConnectedSubgraph(KeySet *Fragment)
    899 {
    900   atom *Walker = NULL, *Walker2 = NULL;
    901   bool BondStatus = false;
    902   int size;
    903 
    904   DoLog(1) && (Log() << Verbose(1) << "Begin of CheckForConnectedSubgraph" << endl);
    905   DoLog(2) && (Log() << Verbose(2) << "Disconnected atom: ");
    906 
    907   // count number of atoms in graph
    908   size = 0;
    909   for (KeySet::iterator runner = Fragment->begin(); runner != Fragment->end(); runner++)
    910     size++;
    911   if (size > 1)
    912     for (KeySet::iterator runner = Fragment->begin(); runner != Fragment->end(); runner++) {
    913       Walker = FindAtom(*runner);
    914       BondStatus = false;
    915       for (KeySet::iterator runners = Fragment->begin(); runners != Fragment->end(); runners++) {
    916         Walker2 = FindAtom(*runners);
    917         const BondList& ListOfBonds = Walker->getListOfBonds();
    918         for (BondList::const_iterator Runner = ListOfBonds.begin();
    919             Runner != ListOfBonds.end();
    920             ++Runner) {
    921           if ((*Runner)->GetOtherAtom(Walker) == Walker2) {
    922             BondStatus = true;
    923             break;
    924           }
    925           if (BondStatus)
    926             break;
    927         }
    928       }
    929       if (!BondStatus) {
    930         DoLog(0) && (Log() << Verbose(0) << (*Walker) << endl);
    931         return false;
    932       }
    933     }
    934   else {
    935     DoLog(0) && (Log() << Verbose(0) << "none." << endl);
    936     return true;
    937   }
    938   DoLog(0) && (Log() << Verbose(0) << "none." << endl);
    939 
    940   DoLog(1) && (Log() << Verbose(1) << "End of CheckForConnectedSubgraph" << endl);
    941 
    942   return true;
    943 }
    944 
    945 /** Fills a lookup list of father's Atom::Nr -> atom for each subgraph.
    946  * \param *out output stream from debugging
     405/** Fills a lookup list of father's Atom::nr -> atom for each subgraph.
    947406 * \param **&ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
    948407 * \param GlobalAtomCount number of atoms in the complete molecule
  • tests/Fragmentations/defs.in

    r1a4d4fe r49c059  
    5757        echo "Current dir is `pwd`, calling $MOLECUILDER $mol.conf --select-molecule-by-id 0 -f $FILENAME --order $ORDER --distance $DISTANCE."
    5858        if [ -e $mol.dbond ]; then
    59                 $MOLECUILDER -i ../$mol.xyz -A $mol.dbond --select-all-atoms --create-adjacency --select-molecule-by-id 0 -f $FILENAME --order $ORDER --distance $DISTANCE &>stdout || exitcode=$?
     59                $MOLECUILDER -i ../$mol.xyz -A $mol.dbond -I --select-molecule-by-id 0 -f $FILENAME --order $ORDER --distance $DISTANCE &>stdout || exitcode=$?
    6060        else
    61                 $MOLECUILDER -i ../$mol.xyz --select-all-atoms --create-adjacency --select-molecule-by-id 0 -f $FILENAME --order $ORDER --distance $DISTANCE $>stdout || exitcode=$?
     61                $MOLECUILDER -i ../$mol.xyz -I --select-molecule-by-id 0 -f $FILENAME --order $ORDER --distance $DISTANCE $>stdout || exitcode=$?
    6262        fi
    6363        cat <stdout
  • tests/regression/Analysis/SurfaceCorrelation/testsuite-analysis-surface-correlation.at

    r1a4d4fe r49c059  
    44AT_KEYWORDS([analysis,correlation])
    55AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/SurfaceCorrelation/pre/test.conf .], 0)
    6 AT_CHECK([../../molecuilder -i test.conf  -v 3 -I --select-all-molecules --unselect-molecules-by-formula C3H8 --surface-correlation --elements 1 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-width 1. --bin-end 20 --molecule-by-id 1], 0, [stdout], [stderr])
     6AT_CHECK([../../molecuilder -i test.conf  -v 3 -I --select-all-molecules --unselect-molecules-by-formula C3H8 --surface-correlation --elements 1 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-width 1. --bin-end 20 --molecule-by-id 0], 0, [stdout], [stderr])
    77AT_CHECK([fgrep "Begin of CorrelationToSurface" stdout], 0, [ignore], [ignore])
    88#AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/SurfaceCorrelation/post/$file], 0, [ignore], [ignore])
  • tests/regression/Fragmentation/FragmentMolecule/testsuite-fragmentation-fragment-molecule.at

    r1a4d4fe r49c059  
    22
    33AT_SETUP([Fragmentation - Fragmentation])
     4AT_KEYWORDS([fragmentation])
    45AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/FragmentMolecule/pre/test.conf .], 0)
    5 AT_CHECK([../../molecuilder -i test.conf  -v 1 --select-all-atoms --create-adjacency --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], 0, [ignore], [ignore])
     6AT_CHECK([../../molecuilder -i test.conf  -v 1 -I --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], 0, [ignore], [ignore])
     7#AT_CHECK([diff BondFragment0.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/FragmentMolecule/post/BondFragment0.conf], 0, [ignore], [ignore])
     8#AT_CHECK([diff BondFragment1.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/FragmentMolecule/post/BondFragment1.conf], 0, [ignore], [ignore])
     9#AT_CHECK([diff BondFragment2.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/FragmentMolecule/post/BondFragment2.conf], 0, [ignore], [ignore])
     10#AT_CHECK([diff BondFragment3.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/FragmentMolecule/post/BondFragment3.conf], 0, [ignore], [ignore])
     11#AT_CHECK([diff BondFragment4.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/FragmentMolecule/post/BondFragment4.conf], 0, [ignore], [ignore])
    612AT_CHECK([ls -l BondFragment*.conf | wc -l], 0, [5
    713], [ignore])
  • tests/regression/Selection/Atoms/AllAtomsOfMolecule/testsuite-selection-all-atoms-of-molecule.at

    r1a4d4fe r49c059  
    44AT_KEYWORDS([selection])
    55file=molecule1.xyz
     6AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/pre/test.xyz $file], 0)
     7AT_CHECK([../../molecuilder -i $file -v 3 -I --select-molecule-by-id 0 --select-molecules-atoms -r], 0, [stdout], [stderr])
     8AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/post/$file], 0, [ignore], [ignore])
     9AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/pre/test.xyz $file], 0)
     10AT_CHECK([../../molecuilder -i $file -v 3 -I --select-molecule-by-id 0 --select-molecules-atoms --undo -r], 0, [stdout], [stderr])
     11AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/pre/test.xyz], 0, [ignore], [ignore])
     12AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/pre/test.xyz $file], 0)
     13AT_CHECK([../../molecuilder -i $file -v 3 -I --select-molecule-by-id 0 --select-molecules-atoms --undo --redo -r], 0, [stdout], [stderr])
     14AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/post/$file], 0, [ignore], [ignore])
     15file=molecule0.xyz
    616AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/pre/test.xyz $file], 0)
    717AT_CHECK([../../molecuilder -i $file -v 3 -I --select-molecule-by-id 1 --select-molecules-atoms -r], 0, [stdout], [stderr])
     
    1323AT_CHECK([../../molecuilder -i $file -v 3 -I --select-molecule-by-id 1 --select-molecules-atoms --undo --redo -r], 0, [stdout], [stderr])
    1424AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/post/$file], 0, [ignore], [ignore])
    15 file=molecule0.xyz
    16 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/pre/test.xyz $file], 0)
    17 AT_CHECK([../../molecuilder -i $file -v 3 -I --select-molecule-by-id 2 --select-molecules-atoms -r], 0, [stdout], [stderr])
    18 AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/post/$file], 0, [ignore], [ignore])
    19 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/pre/test.xyz $file], 0)
    20 AT_CHECK([../../molecuilder -i $file -v 3 -I --select-molecule-by-id 2 --select-molecules-atoms --undo -r], 0, [stdout], [stderr])
    21 AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/pre/test.xyz], 0, [ignore], [ignore])
    22 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/pre/test.xyz $file], 0)
    23 AT_CHECK([../../molecuilder -i $file -v 3 -I --select-molecule-by-id 2 --select-molecules-atoms --undo --redo -r], 0, [stdout], [stderr])
    24 AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/post/$file], 0, [ignore], [ignore])
    2525AT_CLEANUP
    2626
     
    2828AT_KEYWORDS([selection])
    2929file=molecule0.xyz
     30AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/pre/test.xyz $file], 0)
     31AT_CHECK([../../molecuilder -i $file -v 3 -I --select-all-atoms --select-molecule-by-id 0 --unselect-molecules-atoms -r], 0, [stdout], [stderr])
     32AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/post/$file], 0, [ignore], [ignore])
     33AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/pre/test.xyz $file], 0)
     34AT_CHECK([../../molecuilder -i $file -v 3 -I --select-all-atoms --select-molecule-by-id 0 --unselect-molecules-atoms --undo -r], 0, [stdout], [stderr])
     35AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/post/empty.xyz], 0, [ignore], [ignore])
     36AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/pre/test.xyz $file], 0)
     37AT_CHECK([../../molecuilder -i $file -v 3 -I --select-all-atoms --select-molecule-by-id 0 --unselect-molecules-atoms --undo --redo -r], 0, [stdout], [stderr])
     38AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/post/$file], 0, [ignore], [ignore])
     39file=molecule1.xyz
    3040AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/pre/test.xyz $file], 0)
    3141AT_CHECK([../../molecuilder -i $file -v 3 -I --select-all-atoms --select-molecule-by-id 1 --unselect-molecules-atoms -r], 0, [stdout], [stderr])
     
    3747AT_CHECK([../../molecuilder -i $file -v 3 -I --select-all-atoms --select-molecule-by-id 1 --unselect-molecules-atoms --undo --redo -r], 0, [stdout], [stderr])
    3848AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/post/$file], 0, [ignore], [ignore])
    39 file=molecule1.xyz
    40 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/pre/test.xyz $file], 0)
    41 AT_CHECK([../../molecuilder -i $file -v 3 -I --select-all-atoms --select-molecule-by-id 2 --unselect-molecules-atoms -r], 0, [stdout], [stderr])
    42 AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/post/$file], 0, [ignore], [ignore])
    43 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/pre/test.xyz $file], 0)
    44 AT_CHECK([../../molecuilder -i $file -v 3 -I --select-all-atoms --select-molecule-by-id 2 --unselect-molecules-atoms --undo -r], 0, [stdout], [stderr])
    45 AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/post/empty.xyz], 0, [ignore], [ignore])
    46 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/pre/test.xyz $file], 0)
    47 AT_CHECK([../../molecuilder -i $file -v 3 -I --select-all-atoms --select-molecule-by-id 2 --unselect-molecules-atoms --undo --redo -r], 0, [stdout], [stderr])
    48 AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Selection/Atoms/AllAtomsOfMolecule/post/$file], 0, [ignore], [ignore])
    4949AT_CLEANUP
  • tests/regression/Selection/Molecules/MoleculeById/testsuite-selection-molecule-by-id.at

    r1a4d4fe r49c059  
    99m4_include(CheckCommand.sh)
    1010# the tests
    11 check_command_output $srcpath $srcfile "water_id5.xyz" "-I --select-molecule-by-id 5 -s water_id5.xyz"
    12 mv water_id5.xyz water_id5_a.xyz
    13 check_command_output $srcpath $srcfile "empty.xyz" "-I --select-molecule-by-id 5 --undo -s empty.xyz"
    14 check_command_output $srcpath $srcfile "water_id5.xyz" "-I --select-molecule-by-id 5 --undo --redo -s water_id5.xyz"
    15 mv water_id5.xyz water_id5_b.xyz
    16 AT_CHECK([diff -I '.*Created by molecuilder.*' water_id5_a.xyz water_id5_b.xyz], 0, [ignore], [ignore])
     11check_command_output $srcpath $srcfile "water_id4.xyz" "-I --select-molecule-by-id 4 -s water_id4.xyz"
     12mv water_id4.xyz water_id4_a.xyz
     13check_command_output $srcpath $srcfile "empty.xyz" "-I --select-molecule-by-id 4 --undo -s empty.xyz"
     14check_command_output $srcpath $srcfile "water_id4.xyz" "-I --select-molecule-by-id 4 --undo --redo -s water_id4.xyz"
     15mv water_id4.xyz water_id4_b.xyz
     16AT_CHECK([diff -I '.*Created by molecuilder.*' water_id4_a.xyz water_id4_b.xyz], 0, [ignore], [ignore])
    1717AT_CLEANUP
    1818
     
    2424m4_include(CheckCommand.sh)
    2525# the tests
    26 check_command_output $srcpath $srcfile "id5_missing.xyz" "-I --select-all-molecules --unselect-molecule-by-id 5 -s id5_missing.xyz"
    27 mv id5_missing.xyz id5_missing_a.xyz
    28 check_command_output $srcpath $srcfile "box.xyz" "-I --select-all-molecules --unselect-molecule-by-id 5 --undo -s box.xyz"
    29 check_command_output $srcpath $srcfile "id5_missing.xyz" "-I --select-all-molecules --unselect-molecule-by-id 5 --undo --redo -s id5_missing.xyz"
    30 mv id5_missing.xyz id5_missing_b.xyz
    31 AT_CHECK([diff -I '.*Created by molecuilder.*' id5_missing_a.xyz id5_missing_b.xyz], 0, [ignore], [ignore])
     26check_command_output $srcpath $srcfile "id4_missing.xyz" "-I --select-all-molecules --unselect-molecule-by-id 4 -s id4_missing.xyz"
     27mv id4_missing.xyz id4_missing_a.xyz
     28check_command_output $srcpath $srcfile "box.xyz" "-I --select-all-molecules --unselect-molecule-by-id 4 --undo -s box.xyz"
     29check_command_output $srcpath $srcfile "id4_missing.xyz" "-I --select-all-molecules --unselect-molecule-by-id 4 --undo --redo -s id4_missing.xyz"
     30mv id4_missing.xyz id4_missing_b.xyz
     31AT_CHECK([diff -I '.*Created by molecuilder.*' id4_missing_a.xyz id4_missing_b.xyz], 0, [ignore], [ignore])
    3232AT_CLEANUP
  • tests/regression/Selection/Molecules/MoleculeByName/testsuite-selection-molecules-by-name.at

    r1a4d4fe r49c059  
    88m4_include(CheckCommand.sh)
    99# the tests
    10 check_command_output $srcpath $srcfile "water.xyz" "-I --select-molecule-by-id 1 --change-molname \"water\" --unselect-molecule-by-id 1 --select-molecules-by-name water -s water.xyz"
     10check_command_output $srcpath $srcfile "water.xyz" "-I --select-molecule-by-id 0 --change-molname \"water\" --unselect-molecule-by-id 0 --select-molecules-by-name water -s water.xyz"
    1111mv water.xyz water_a.xyz
    12 check_command_output $srcpath $srcfile "empty.xyz" "-I --select-molecule-by-id 1 --change-molname \"water\" --unselect-molecule-by-id 1 --select-molecules-by-name water --undo -s empty.xyz"
    13 check_command_output $srcpath $srcfile "water.xyz" "-I --select-molecule-by-id 1 --change-molname \"water\" --unselect-molecule-by-id 1 --select-molecules-by-name water --undo --redo -s water.xyz"
     12check_command_output $srcpath $srcfile "empty.xyz" "-I --select-molecule-by-id 0 --change-molname \"water\" --unselect-molecule-by-id 0 --select-molecules-by-name water --undo -s empty.xyz"
     13check_command_output $srcpath $srcfile "water.xyz" "-I --select-molecule-by-id 0 --change-molname \"water\" --unselect-molecule-by-id 0 --select-molecules-by-name water --undo --redo -s water.xyz"
    1414mv water.xyz water_b.xyz
    1515AT_CHECK([diff -I '.*Created by molecuilder.*' water_a.xyz water_b.xyz], 0, [ignore], [ignore])
     
    2323m4_include(CheckCommand.sh)
    2424# the tests
    25 check_command_output $srcpath $srcfile "empty.xyz" "-I --select-molecule-by-id 1 --change-molname \"water\" --unselect-molecules-by-name water -s empty.xyz"
     25check_command_output $srcpath $srcfile "empty.xyz" "-I --select-molecule-by-id 0 --change-molname \"water\" --unselect-molecules-by-name water -s empty.xyz"
    2626mv empty.xyz empty_a.xyz
    27 check_command_output $srcpath $srcfile "water.xyz" "-I --select-molecule-by-id 1 --change-molname \"water\" --unselect-molecules-by-name water --undo -s water.xyz"
    28 check_command_output $srcpath $srcfile "empty.xyz" "-I --select-molecule-by-id 1 --change-molname \"water\" --unselect-molecules-by-name water --undo --redo -s empty.xyz"
     27check_command_output $srcpath $srcfile "water.xyz" "-I --select-molecule-by-id 0 --change-molname \"water\" --unselect-molecules-by-name water --undo -s water.xyz"
     28check_command_output $srcpath $srcfile "empty.xyz" "-I --select-molecule-by-id 0 --change-molname \"water\" --unselect-molecules-by-name water --undo --redo -s empty.xyz"
    2929mv empty.xyz empty_b.xyz
    3030AT_CHECK([diff -I '.*Created by molecuilder.*' empty_a.xyz empty_b.xyz], 0, [ignore], [ignore])
Note: See TracChangeset for help on using the changeset viewer.