Changeset 8dbcaf


Ignore:
Timestamp:
Oct 14, 2013, 11:42:03 PM (11 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:
fe0cb8
Parents:
fb9f6d
git-author:
Frederik Heber <heber@…> (09/24/13 12:32:02)
git-committer:
Frederik Heber <heber@…> (10/14/13 23:42:03)
Message:

FIX: CyclicStructureAnalysis did not work correctly.

  • many errors with local variables that probably should have been in the class.
  • we use OtherAtom in subsequent RetrieveCycleMembers() but we have not given CyclicBFSFromRootToRoot() its ref.
  • the idea now is to use first get all cycles (CyclicBFSFromRootToRoot(). RetrieveCycleMembers()) and then to assign all remaining atoms via AssignRingSizetoNonCycleMembers() with BFSToNextCycle() where we make use of locality property of BFS.
Location:
src/Graph
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Graph/CyclicStructureAnalysis.cpp

    rfb9f6d r8dbcaf  
    9999
    100100/** Performs a BFS from \a *Root, trying to find the same node and hence a cycle.
     101 * \param OtherAtom pointing to Root on return indicating found cycle
    101102 * \param *&BackEdge the edge from root that we don't want to move along
    102  * \param &BFS accounting structure
    103  */
    104 void CyclicStructureAnalysis::CyclicBFSFromRootToRoot(bond::ptr &BackEdge)
     103 */
     104void CyclicStructureAnalysis::CyclicBFSFromRootToRoot(atom *&OtherAtom, bond::ptr &BackEdge)
    105105{
    106106  atom *Walker = NULL;
    107   atom *OtherAtom = NULL;
    108107  do { // look for Root
    109108    ASSERT(!BFSStack.empty(), "CyclicStructureAnalysis_CyclicBFSFromRootToRoot() - BFSStack is empty!");
    110109    Walker = BFSStack.front();
    111110    BFSStack.pop_front();
    112     LOG(2, "INFO: Current Walker is " << *Walker << ", we look for SP to Root " << *Root << "." << endl);
     111    LOG(2, "INFO: Current Walker is " << *Walker << ", we look for SP to Root " << *Root << ".");
    113112    const BondList& ListOfBonds = Walker->getListOfBonds();
    114113    for (BondList::const_iterator Runner = ListOfBonds.begin();
     
    118117        OtherAtom = (*Runner)->GetOtherAtom(Walker);
    119118        if ((treatment == IncludeHydrogen) || (OtherAtom->getType()->getAtomicNumber() != 1)) {
    120           LOG(2, "INFO: Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << "." << endl);
     119          LOG(2, "INFO: Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << ".");
    121120          if (ColorList[OtherAtom->getNr()] == GraphEdge::white) {
    122121            TouchedStack.push_front(OtherAtom);
     
    124123            PredecessorList[OtherAtom->getNr()] = Walker; // Walker is the predecessor
    125124            ShortestPathList[OtherAtom->getNr()] = ShortestPathList[Walker->getNr()] + 1;
    126             LOG(2, "INFO: Coloring OtherAtom " << OtherAtom->getName() << " lightgray, its predecessor is " << Walker->getName() << " and its Shortest Path is " << ShortestPathList[OtherAtom->getNr()] << " egde(s) long." << endl);
     125            LOG(2, "INFO: Coloring OtherAtom " << OtherAtom->getName() << " lightgray, its predecessor is " << Walker->getName() << " and its Shortest Path is " << ShortestPathList[OtherAtom->getNr()] << " egde(s) long.");
    127126            //if (ShortestPathList[OtherAtom->getNr()] < MinimumRingSize[Walker->GetTrueFather()->getNr()]) { // Check for maximum distance
    128             LOG(3, "ACCEPT: Putting OtherAtom into queue." << endl);
     127            LOG(3, "ACCEPT: Putting OtherAtom " << OtherAtom->getName() << " into queue.");
    129128            BFSStack.push_front(OtherAtom);
    130129            //}
    131130          } else {
    132             LOG(3, "REJECT: Not Adding, has already been visited." << endl);
     131            LOG(3, "REJECT: Not Adding, has already been visited.");
    133132          }
    134133          if (OtherAtom == Root)
    135134            break;
    136135        } else {
    137           LOG(2, "INFO: Skipping hydrogen atom " << *OtherAtom << "." << endl);
     136          LOG(2, "INFO: Skipping hydrogen atom " << *OtherAtom << ".");
    138137          ColorList[OtherAtom->getNr()] = GraphEdge::black;
    139138        }
    140139      } else {
    141         LOG(2, "REJECT: Bond " << *(*Runner) << " not Visiting, is the back edge." << endl);
     140        LOG(2, "REJECT: Bond " << *(*Runner) << " not Visiting, is the back edge.");
    142141      }
    143142    }
    144143    ColorList[Walker->getNr()] = GraphEdge::black;
    145     LOG(1, "INFO: Coloring Walker " << Walker->getName() << " " << GraphEdge::getColorName(ColorList[Walker->getNr()]) << "." << endl);
     144    LOG(1, "INFO: Coloring Walker " << Walker->getName() << " " << GraphEdge::getColorName(ColorList[Walker->getNr()]) << ".");
    146145    if (OtherAtom == Root) { // if we have found the root, check whether this cycle wasn't already found beforehand
    147146      // step through predecessor list
    148       while (OtherAtom != BackEdge->rightatom) {
    149         if (!OtherAtom->GetTrueFather()->IsCyclic) // if one bond in the loop is not marked as cyclic, we haven't found this cycle yet
     147      LOG(4, "DEBUG: Checking whether all predecessors are already marked cyclic ...");
     148      while (OtherAtom != BackEdge->rightatom) {  // Note that leftatom is Root itself
     149        if (!OtherAtom->GetTrueFather()->IsCyclic) { // if one bond in the loop is not marked as cyclic, we haven't found this cycle yet
     150          LOG(4, "\tDEBUG: OtherAtom " << *OtherAtom << " is not cyclic, breaking.");
    150151          break;
    151         else
     152        } else
    152153          OtherAtom = PredecessorList[OtherAtom->getNr()];
    153154      }
    154       if (OtherAtom == BackEdge->rightatom) { // if each atom in found cycle is cyclic, loop's been found before already
    155         LOG(3, "INFO This cycle was already found before, skipping and removing seeker from search." << endl);
     155      LOG(4, "DEBUG: Checking done.");
     156      // if each atom in found cycle is cyclic, loop's been found before already
     157      if (OtherAtom == BackEdge->rightatom) { // loop got round completely
     158        LOG(3, "INFO: This cycle was already found before, skipping and removing seeker from search.");
    156159        do {
    157160          ASSERT(!TouchedStack.empty(), "CyclicStructureAnalysis_CyclicBFSFromRootToRoot() - TouchedStack is empty!");
     
    159162          TouchedStack.pop_front();
    160163          if (PredecessorList[OtherAtom->getNr()] == Walker) {
    161             LOG(4, "INFO: Removing " << *OtherAtom << " from lists and stacks." << endl);
     164            LOG(4, "INFO: Removing " << *OtherAtom << " from lists and stacks.");
    162165            PredecessorList[OtherAtom->getNr()] = NULL;
    163166            ShortestPathList[OtherAtom->getNr()] = -1;
     
    175178        TouchedStack.push_front(OtherAtom); // last was wrongly popped
    176179        OtherAtom = BackEdge->rightatom; // set to not Root
    177       } else
     180      } else {
    178181        OtherAtom = Root;
     182        LOG(2, "INFO: We have reached Root " << *OtherAtom << " and may extract the cycle.");
     183      }
    179184    }
    180185  } while ((!BFSStack.empty()) && (OtherAtom != Root) && (OtherAtom != NULL)); // || (ShortestPathList[OtherAtom->getNr()] < MinimumRingSize[Walker->GetTrueFather()->getNr()])));
     
    186191 * \param &BFS accounting structure
    187192 * \param &MinRingSize global minimum distance from one node without encountering oneself, set on return
    188  */
    189 void CyclicStructureAnalysis::RetrieveCycleMembers(atom *&OtherAtom, bond::ptr &BackEdge, int &MinRingSize)
     193 * \param &NumCyles number of cycles in graph
     194 */
     195void CyclicStructureAnalysis::RetrieveCycleMembers(
     196    atom *&OtherAtom,
     197    bond::ptr &BackEdge,
     198    int &MinRingSize,
     199    int &NumCycles)
    190200{
    191201  atom *Walker = NULL;
    192   int NumCycles = 0;
    193202  int RingSize = -1;
    194203
     
    213222    // walk through all and set MinimumRingSize
    214223    Walker = Root;
    215     ASSERT(!MinimumRingSize.count(Walker->GetTrueFather()->getNr()),
    216         "CyclicStructureAnalysis::RetrieveCycleMembers() - setting MinimumRingSize of "
    217         +toString(*(Walker->GetTrueFather()))+" to "
    218         +toString(RingSize)+" which is already set to "
    219         +toString(MinimumRingSize[Walker->GetTrueFather()->getNr()])+".");
    220     MinimumRingSize[Walker->GetTrueFather()->getNr()] = RingSize;
    221     while (Walker != BackEdge->rightatom) {
     224    if ((MinimumRingSize.count(Walker->GetTrueFather()->getNr()) == 0)
     225        || (RingSize < MinimumRingSize[Walker->GetTrueFather()->getNr()])) {
     226      MinimumRingSize[Walker->GetTrueFather()->getNr()] = RingSize;
     227    } else {
     228      LOG(3, "INFO: Not setting MinimumRingSize of "<< *(Walker->GetTrueFather())
     229          << " to " << RingSize << " which is already set to "
     230          << MinimumRingSize[Walker->GetTrueFather()->getNr()] << ".");
     231    }
     232    while (Walker != BackEdge->rightatom) { // note that Root is leftatom
    222233      Walker = PredecessorList[Walker->getNr()];
    223       if (RingSize < MinimumRingSize[Walker->GetTrueFather()->getNr()])
     234      if ((MinimumRingSize.count(Walker->GetTrueFather()->getNr()) == 0)
     235          || (RingSize < MinimumRingSize[Walker->GetTrueFather()->getNr()]))
    224236        MinimumRingSize[Walker->GetTrueFather()->getNr()] = RingSize;
    225237    }
     
    227239      MinRingSize = RingSize;
    228240  } else {
    229     LOG(1, "INFO: No ring containing " << *Root << " with length equal to or smaller than " << MinimumRingSize[Root->GetTrueFather()->getNr()] << " found." << endl);
     241    LOG(1, "INFO: No ring containing " << *Root << " with length equal to or smaller than " << MinimumRingSize[Root->GetTrueFather()->getNr()] << " found.");
    230242  }
    231243}
    232244
    233245/** From a given node performs a BFS to touch the next cycle, for whose nodes \a MinimumRingSize is set and set it accordingly.
    234  * \param *&Root node to look for closest cycle from, i.e. \a MinimumRingSize is set for this node
     246 * \param *&Walker node to look for closest cycle from, i.e. \a MinimumRingSize is set for this node
    235247 * \param AtomCount number of nodes in graph
    236248 */
    237 void CyclicStructureAnalysis::BFSToNextCycle(atom *&Root, atom *&Walker)
    238 {
     249void CyclicStructureAnalysis::BFSToNextCycle(atom *Walker)
     250{
     251  atom *Root = Walker;
    239252  atom *OtherAtom = Walker;
    240253
     
    246259    Walker = BFSStack.front();
    247260    BFSStack.pop_front();
    248     LOG(2, "INFO: Current Walker is " << *Walker << ", we look for SP to Root " << *Root << ".");
     261    LOG(2, "INFO: Current Walker is " << *Walker << ", BFS-stepping away from Root " << *Root << ".");
    249262    const BondList& ListOfBonds = Walker->getListOfBonds();
    250263    for (BondList::const_iterator Runner = ListOfBonds.begin();
     
    252265        ++Runner) {
    253266      // "removed (*Runner) != BackEdge) || " from next if, is u
    254       if ((ListOfBonds.size() == 1)) { // only walk along DFS spanning tree (otherwise we always find SP of 1 being backedge Binder), but terminal hydrogens may be connected via backedge, hence extra check
     267
     268      // only walk along DFS spanning tree (otherwise we always find SP of 1
     269      // being backedge Binder), but terminal hydrogens may be connected via
     270      // backedge, hence extra check
     271//      if ((ListOfBonds.size() != 1)) {
    255272        OtherAtom = (*Runner)->GetOtherAtom(Walker);
    256         LOG(2, "INFO: Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << ".");
    257         if (ColorList[OtherAtom->getNr()] == GraphEdge::white) {
    258           TouchedStack.push_front(OtherAtom);
    259           ColorList[OtherAtom->getNr()] = GraphEdge::lightgray;
    260           PredecessorList[OtherAtom->getNr()] = Walker; // Walker is the predecessor
    261           ShortestPathList[OtherAtom->getNr()] = ShortestPathList[Walker->getNr()] + 1;
    262           LOG(2, "ACCEPT: Coloring OtherAtom " << OtherAtom->getName() << " lightgray, its predecessor is " << Walker->getName() << " and its Shortest Path is " << ShortestPathList[OtherAtom->getNr()] << " egde(s) long.");
    263           if (OtherAtom->GetTrueFather()->IsCyclic) { // if the other atom is connected to a ring
    264             ASSERT(!MinimumRingSize.count(Root->GetTrueFather()->getNr()),
    265                 "CyclicStructureAnalysis::BFSToNextCycle() - setting MinimumRingSize of "
    266                 +toString(*(Root->GetTrueFather()))+" to "+
    267                 toString(ShortestPathList[OtherAtom->getNr()] + MinimumRingSize[OtherAtom->GetTrueFather()->getNr()])
    268                 +" which is already set to "
    269                 +toString(MinimumRingSize[Root->GetTrueFather()->getNr()])+".");
    270             MinimumRingSize[Root->GetTrueFather()->getNr()] = ShortestPathList[OtherAtom->getNr()] + MinimumRingSize[OtherAtom->GetTrueFather()->getNr()];
    271             OtherAtom = NULL; //break;
    272             break;
    273           } else
    274             BFSStack.push_front(OtherAtom);
     273        if ((treatment == IncludeHydrogen) || (OtherAtom->getType()->getAtomicNumber() != 1)) {
     274          LOG(2, "INFO: Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << ".");
     275          if (ColorList[OtherAtom->getNr()] == GraphEdge::white) {
     276            TouchedStack.push_front(OtherAtom);
     277            ColorList[OtherAtom->getNr()] = GraphEdge::lightgray;
     278            PredecessorList[OtherAtom->getNr()] = Walker; // Walker is the predecessor
     279            ShortestPathList[OtherAtom->getNr()] = ShortestPathList[Walker->getNr()] + 1;
     280            LOG(2, "ACCEPT: Coloring OtherAtom "
     281                << OtherAtom->getName() << " lightgray, its predecessor is "
     282                << Walker->getName() << " and its Shortest Path is "
     283                << ShortestPathList[OtherAtom->getNr()] << " egde(s) long.");
     284            // distance is a locally optimal criterion (we have eliminated all
     285            // cycles already). Hence, we may assume that all set MinimumRingSize
     286            // correspond to shortest distances to cycles. I.e., as soon as we reach
     287            // as set MinimumRingSize we may use it and the current shortest path
     288            // distance to it
     289            if (MinimumRingSize.count(OtherAtom->GetTrueFather()->getNr())) {
     290              LOG(2, "SUCCESS: Found set MinimumRingSize at " << *OtherAtom
     291                  << ", walking back to Root " << *Root << ".");
     292              // set all predecessors
     293              const unsigned int shorttestpath = ShortestPathList[OtherAtom->getNr()];
     294              atom *Backwalker = OtherAtom;
     295              while (Backwalker != Root) {
     296                Backwalker = PredecessorList[Backwalker->getNr()];
     297                MinimumRingSize[Backwalker->GetTrueFather()->getNr()] =
     298                    (shorttestpath - ShortestPathList[Backwalker->getNr()])
     299                    + MinimumRingSize[OtherAtom->GetTrueFather()->getNr()];
     300                LOG(2, "Setting MinimumRingSize of " << *Backwalker << " to "
     301                    << MinimumRingSize[Backwalker->GetTrueFather()->getNr()] << ".");
     302              }
     303              OtherAtom = NULL; //break;
     304              break;
     305            } else
     306              BFSStack.push_front(OtherAtom);
     307          } else {
     308            LOG(3, "REJECT: Not Adding, has already been visited.");
     309          }
    275310        } else {
    276           LOG(3, "REJECT: Not Adding, has already been visited.");
     311          LOG(3, "REJECT: Not Visiting, is a back edge to hydrogen.");
    277312        }
    278       } else {
    279         LOG(3, "REJECT: Not Visiting, is a back edge.");
    280       }
     313//      }
    281314    }
    282315    ColorList[Walker->getNr()] = GraphEdge::black;
     
    285318}
    286319
    287 /** All nodes that are not in cycles get assigned a \a *&MinimumRingSizeby BFS to next cycle.
    288  * \param *&MinimumRingSize array with minimum distance without encountering onself for each atom
    289  * \param &MinRingSize global minium distance
    290  * \param &NumCyles number of cycles in graph
    291  */
    292 void CyclicStructureAnalysis::AssignRingSizetoNonCycleMembers(int &MinRingSize, int &NumCycles)
    293 {
    294   atom *Root = NULL;
     320/** All nodes that are not in cycles get assigned a \a *&MinimumRingSize by BFS to next cycle.
     321 * \param *&MinimumRingSize array with minimum distance without encountering oneself for each atom
     322 * \param MinRingSize global minium distance
     323 * \param NumCyles number of cycles in graph
     324 */
     325void CyclicStructureAnalysis::AssignRingSizetoNonCycleMembers(const int MinRingSize, const int NumCycles)
     326{
    295327  atom *Walker = NULL;
    296328  if (MinRingSize != -1) { // if rings are present
     
    300332        iter != allatoms.end();
    301333        ++iter) {
    302       Root = *iter;
    303 
    304       if (MinimumRingSize.find(Root->GetTrueFather()->getNr()) != MinimumRingSize.end()) { // check whether MinimumRingSize is set, if not BFS to next where it is
    305         Walker = Root;
    306 
     334      Walker = *iter;
     335
     336      if (MinimumRingSize.find(Walker->GetTrueFather()->getNr()) == MinimumRingSize.end()) { // check whether MinimumRingSize is set, if not BFS to next where it is
    307337        LOG(1, "---------------------------------------------------------------------------------------------------------");
    308         BFSToNextCycle(Root, Walker);
    309 
     338        BFSToNextCycle(Walker);
    310339      }
    311       ASSERT(MinimumRingSize.find(Root->GetTrueFather()->getNr()) != MinimumRingSize.end(),
     340      ASSERT(MinimumRingSize.find(Walker->GetTrueFather()->getNr()) != MinimumRingSize.end(),
    312341          "CyclicStructureAnalysis::AssignRingSizetoNonCycleMembers() - BFSToNextCycle did not set MinimumRingSize of "
    313           +toString(*(Root->GetTrueFather()))+".");
    314       LOG(1, "INFO: Minimum ring size of " << *Root << " is " << MinimumRingSize[Root->GetTrueFather()->getNr()] << "." << endl);
    315     }
    316     LOG(1, "INFO: Minimum ring size is " << MinRingSize << ", over " << NumCycles << " cycles total." << endl);
     342          +toString(*(Walker->GetTrueFather()))+".");
     343      LOG(1, "INFO: Minimum ring size of " << *Walker << " is " << MinimumRingSize[Walker->GetTrueFather()->getNr()] << ".");
     344    }
     345    LOG(1, "INFO: Minimum ring size is " << MinRingSize << ", over " << NumCycles << " cycle(s) total.");
    317346  } else
    318     LOG(1, "INFO: No rings were detected in the molecular structure." << endl);
     347    LOG(1, "INFO: No rings were detected in the molecular structure.");
    319348}
    320349
     
    336365  int MinRingSize = -1;
    337366
    338   //std::stringstream output;
    339   //output << "Back edge list - ";
    340   //BackEdgeStack->Output(output);
    341   //LOG(0, output.str());
    342 
    343   LOG(1, "STATUS: Analysing cycles ... " << endl);
     367  {
     368    std::stringstream output;
     369    output << "Back edge list - ";
     370    for (std::deque<bond::ptr >::const_iterator iter = BackEdgeStack->begin();
     371        iter != BackEdgeStack->end(); ++iter)
     372      output << **iter << " ";
     373    LOG(0, output.str());
     374  }
     375
     376  LOG(1, "STATUS: Analysing cycles ... ");
    344377  NumCycles = 0;
    345378  while (!BackEdgeStack->empty()) {
     
    353386    InitializeToRoot(Walker);
    354387
    355     LOG(1, "---------------------------------------------------------------------------------------------------------" << endl);
     388    LOG(1, "---------------------------------------------------------------------------------------------------------");
    356389    OtherAtom = NULL;
    357390    // go to next cycle via BFS
    358     CyclicBFSFromRootToRoot(BackEdge);
     391    CyclicBFSFromRootToRoot(OtherAtom, BackEdge);
    359392    // get all member nodes of this cycle
    360     RetrieveCycleMembers(OtherAtom, BackEdge, MinRingSize);
     393    RetrieveCycleMembers(OtherAtom, BackEdge, MinRingSize, NumCycles);
    361394
    362395    CleanAllTouched();
  • src/Graph/CyclicStructureAnalysis.hpp

    rfb9f6d r8dbcaf  
    4343  void InitializeToRoot(atom *&Walker);
    4444  // performing tasks
    45   void CyclicBFSFromRootToRoot(bond::ptr &BackEdge);
    46   void RetrieveCycleMembers(atom *&OtherAtom, bond::ptr &BackEdge, int &MinRingSize);
    47   void BFSToNextCycle(atom *&Root, atom *&Walker);
    48   void AssignRingSizetoNonCycleMembers(int &MinRingSize, int &NumCycles);
     45  void CyclicBFSFromRootToRoot(atom *&OtherAtom, bond::ptr &BackEdge);
     46  void RetrieveCycleMembers(atom *&OtherAtom, bond::ptr &BackEdge, int &MinRingSize, int &NumCycles);
     47  void BFSToNextCycle(atom *Walker);
     48  void AssignRingSizetoNonCycleMembers(const int MinRingSize, const int NumCycles);
    4949  // output
    5050  void OutputAlreadyVisited(int *list);
  • src/Graph/DepthFirstSearchAnalysis.cpp

    rfb9f6d r8dbcaf  
    130130    return false;
    131131  }
    132   bond::ptr Binder = BackEdgeStack.front();
    133   bond::ptr FirstBond = Binder; // mark the first bond, so that we don't loop through the stack indefinitely
    134   atom *Walker = NULL, *OtherAtom = NULL;
     132  std::deque<bond::ptr > MyBackEdgeStack = BackEdgeStack;
    135133
    136134  do { // go through all bonds and push local ones
     135    const bond::ptr &Binder = MyBackEdgeStack.front(); // loop the stack for next item
     136    MyBackEdgeStack.pop_front();
     137    LOG(3, "INFO: Current candidate edge " << *Binder << ".");
    137138    const ListOfLocalAtoms_t::const_iterator leftiter = ListOfLocalAtoms.find(Binder->leftatom->getNr());
    138139    ASSERT( leftiter != ListOfLocalAtoms.end(),
    139140        "DepthFirstSearchAnalysis::PickLocalBackEdges() - could not find atom id "
    140141        +toString(Binder->leftatom->getNr())+" in ListOfLocalAtoms.");
    141     Walker = leftiter->second; // get one atom in the reference molecule
     142    atom * const Walker = leftiter->second; // get one atom in the reference molecule
    142143    if (Walker != NULL) { // if this Walker exists in the subgraph ...
    143144      const BondList& ListOfBonds = Walker->getListOfBonds();
     
    145146          Runner != ListOfBonds.end();
    146147          ++Runner) {
    147         OtherAtom = (*Runner)->GetOtherAtom(Walker);
     148        atom * const OtherAtom = (*Runner)->GetOtherAtom(Walker);
    148149        const ListOfLocalAtoms_t::const_iterator rightiter = ListOfLocalAtoms.find((*Runner)->rightatom->getNr());
    149150        if (OtherAtom == rightiter->second) { // found the bond
     
    154155      }
    155156    }
    156     ASSERT(!BackEdgeStack.empty(), "DepthFirstSearchAnalysis::PickLocalBackEdges() - ReferenceStack is empty!");
    157     Binder = BackEdgeStack.front(); // loop the stack for next item
    158     LOG(3, "Current candidate edge " << Binder << ".");
    159   } while (FirstBond != Binder);
     157  } while (!MyBackEdgeStack.empty());
    160158
    161159  return status;
Note: See TracChangeset for help on using the changeset viewer.