Changeset cc6dfb for molecuilder


Ignore:
Timestamp:
May 9, 2008, 2:38:27 PM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
0e348e
Parents:
0716ff4
Message:

CyclicStructureAnalysis(): forget to check whether we actually have found rings or not (only then MinimumRingSize needs to be checked for non-set neighbours also)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified molecuilder/src/molecules.cpp

    r0716ff4 rcc6dfb  
    17351735    }
    17361736  }
    1737   // go over all atoms
    1738   Root = start;
    1739   while(Root->next != end) {
    1740     Root = Root->next;
     1737  if (MinRingSize != -1) {
     1738    // go over all atoms
     1739    Root = start;
     1740    while(Root->next != end) {
     1741      Root = Root->next;
     1742     
     1743      if (MinimumRingSize[Root->GetTrueFather()->nr] == AtomCount) { // check whether MinimumRingSize is set, if not BFS to next where it is
     1744        ShortestPathList[Walker->nr] = 0;
     1745        BFSStack->ClearStack();  // start with empty BFS stack
     1746        BFSStack->Push(Walker);
     1747        TouchedStack->Push(Walker);
     1748        //*out << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl;
     1749        OtherAtom = Walker;
     1750        while ((Walker != Root) && (OtherAtom != NULL)) {  // look for Root
     1751          Walker = BFSStack->PopFirst();
     1752          //*out << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *Root << "." << endl;
     1753          for(int i=0;i<NumberOfBondsPerAtom[Walker->nr];i++) {
     1754            Binder = ListOfBondsPerAtom[Walker->nr][i];
     1755            if (Binder != BackEdge) { // only walk along DFS spanning tree (otherwise we always find SP of one being backedge Binder)
     1756              OtherAtom = Binder->GetOtherAtom(Walker);
     1757              //*out << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *Binder << "." << endl;
     1758              if (ColorList[OtherAtom->nr] == white) {
     1759                TouchedStack->Push(OtherAtom);
     1760                ColorList[OtherAtom->nr] = lightgray;
     1761                PredecessorList[OtherAtom->nr] = Walker;  // Walker is the predecessor
     1762                ShortestPathList[OtherAtom->nr] = ShortestPathList[Walker->nr]+1;
     1763                //*out << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " lightgray, its predecessor is " << Walker->Name << " and its Shortest Path is " << ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl;
     1764                if (MinimumRingSize[OtherAtom->GetTrueFather()->nr] != AtomCount) { // if the other atom is connected to a ring
     1765                  MinimumRingSize[Root->GetTrueFather()->nr] = ShortestPathList[OtherAtom->nr]+MinimumRingSize[OtherAtom->GetTrueFather()->nr];
     1766                  OtherAtom = NULL; //break;
     1767                  break;
     1768                } else
     1769                  BFSStack->Push(OtherAtom);
     1770              } else {
     1771                //*out << Verbose(3) << "Not Adding, has already been visited." << endl;
     1772              }
     1773            } else {
     1774              //*out << Verbose(3) << "Not Visiting, is a back edge." << endl;
     1775            }
     1776          }
     1777          ColorList[Walker->nr] = black;
     1778          //*out << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl;
     1779        }
    17411780   
    1742     if (MinimumRingSize[Root->GetTrueFather()->nr] == AtomCount) { // check whether MinimumRingSize is set, if not BFS to next where it is
    1743       ShortestPathList[Walker->nr] = 0;
    1744       BFSStack->ClearStack();  // start with empty BFS stack
    1745       BFSStack->Push(Walker);
    1746       TouchedStack->Push(Walker);
    1747       //*out << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl;
    1748       OtherAtom = Walker;
    1749       while ((Walker != Root) && (OtherAtom != NULL)) {  // look for Root
    1750         Walker = BFSStack->PopFirst();
    1751         //*out << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *Root << "." << endl;
    1752         for(int i=0;i<NumberOfBondsPerAtom[Walker->nr];i++) {
    1753           Binder = ListOfBondsPerAtom[Walker->nr][i];
    1754           if (Binder != BackEdge) { // only walk along DFS spanning tree (otherwise we always find SP of one being backedge Binder)
    1755             OtherAtom = Binder->GetOtherAtom(Walker);
    1756             //*out << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *Binder << "." << endl;
    1757             if (ColorList[OtherAtom->nr] == white) {
    1758               TouchedStack->Push(OtherAtom);
    1759               ColorList[OtherAtom->nr] = lightgray;
    1760               PredecessorList[OtherAtom->nr] = Walker;  // Walker is the predecessor
    1761               ShortestPathList[OtherAtom->nr] = ShortestPathList[Walker->nr]+1;
    1762               //*out << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " lightgray, its predecessor is " << Walker->Name << " and its Shortest Path is " << ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl;
    1763               if (MinimumRingSize[OtherAtom->GetTrueFather()->nr] != AtomCount) { // if the other atom is connected to a ring
    1764                 MinimumRingSize[Root->GetTrueFather()->nr] = ShortestPathList[OtherAtom->nr]+MinimumRingSize[OtherAtom->GetTrueFather()->nr];
    1765                 OtherAtom = NULL; //break;
    1766                 break;
    1767               } else
    1768                 BFSStack->Push(OtherAtom);
    1769             } else {
    1770               //*out << Verbose(3) << "Not Adding, has already been visited." << endl;
    1771             }
    1772           } else {
    1773             //*out << Verbose(3) << "Not Visiting, is a back edge." << endl;
    1774           }
     1781        // now clean the lists
     1782        while (!TouchedStack->IsEmpty()){
     1783          Walker = TouchedStack->PopFirst();
     1784          PredecessorList[Walker->nr] = NULL;
     1785          ShortestPathList[Walker->nr] = -1;
     1786          ColorList[Walker->nr] = white;
    17751787        }
    1776         ColorList[Walker->nr] = black;
    1777         //*out << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl;
    1778       }
    1779 
    1780       // now clean the lists
    1781       while (!TouchedStack->IsEmpty()){
    1782         Walker = TouchedStack->PopFirst();
    1783         PredecessorList[Walker->nr] = NULL;
    1784         ShortestPathList[Walker->nr] = -1;
    1785         ColorList[Walker->nr] = white;
    1786       }
    1787     }
    1788     *out << Verbose(1) << "Minimum ring size of " << *Root << " is " << MinimumRingSize[Root->GetTrueFather()->nr] << "." << endl;
    1789   }
    1790  
    1791        
    1792   if (MinRingSize != -1)
     1788      }
     1789      *out << Verbose(1) << "Minimum ring size of " << *Root << " is " << MinimumRingSize[Root->GetTrueFather()->nr] << "." << endl;
     1790    }
    17931791    *out << Verbose(1) << "Minimum ring size is " << MinRingSize << ", over " << NumCycles << " cycles total." << endl;
    1794   else
     1792  } else
    17951793    *out << Verbose(1) << "No rings were detected in the molecular structure." << endl;
    17961794
Note: See TracChangeset for help on using the changeset viewer.