Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_graph.cpp

    r68f03d re5ad5c  
    1717#include "memoryallocator.hpp"
    1818#include "molecule.hpp"
    19 #include "World.hpp"
    20 #include "Helpers/fast_functions.hpp"
    2119
    2220struct BFSAccounting
     
    6058
    6159  if (!input) {
    62     DoLog(1) && (Log() << Verbose(1) << "Opening silica failed \n");
     60    Log() << Verbose(1) << "Opening silica failed \n";
    6361  };
    6462
    6563  *input >> ws >> atom1;
    6664  *input >> ws >> atom2;
    67   DoLog(1) && (Log() << Verbose(1) << "Scanning file\n");
     65  Log() << Verbose(1) << "Scanning file\n";
    6866  while (!input->eof()) // Check whether we read everything already
    6967  {
     
    108106  LinkedCell *LC = NULL;
    109107  bool free_BG = false;
    110   double * const cell_size = World::getInstance().getDomain();
    111108
    112109  if (BG == NULL) {
     
    116113
    117114  BondDistance = bonddistance; // * ((IsAngstroem) ? 1. : 1./AtomicLengthToAngstroem);
    118   DoLog(0) && (Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl);
     115  Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl;
    119116  // remove every bond from the list
    120117  bond *Binder = NULL;
     
    129126  // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering)
    130127  CountAtoms();
    131   DoLog(1) && (Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl);
     128  Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl;
    132129
    133130  if ((AtomCount > 1) && (bonddistance > 1.)) {
    134     DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl);
     131    Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl;
    135132    LC = new LinkedCell(this, bonddistance);
    136133
    137134    // create a list to map Tesselpoint::nr to atom *
    138     DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl);
     135    Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl;
    139136    AtomMap = Calloc<atom *> (AtomCount, "molecule::CreateAdjacencyList - **AtomCount");
    140137    Walker = start;
     
    145142
    146143    // 3a. go through every cell
    147     DoLog(2) && (Log() << Verbose(2) << "Celling ... " << endl);
     144    Log() << Verbose(2) << "Celling ... " << endl;
    148145    for (LC->n[0] = 0; LC->n[0] < LC->N[0]; LC->n[0]++)
    149146      for (LC->n[1] = 0; LC->n[1] < LC->N[1]; LC->n[1]++)
    150147        for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) {
    151           const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
     148          const LinkedNodes *List = LC->GetCurrentCell();
    152149//          Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
    153150          if (List != NULL) {
    154             for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     151            for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    155152              Walker = AtomMap[(*Runner)->nr];
    156153//              Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
     
    159156                for (n[1] = -1; n[1] <= 1; n[1]++)
    160157                  for (n[2] = -1; n[2] <= 1; n[2]++) {
    161                     const LinkedCell::LinkedNodes *OtherList = LC->GetRelativeToCurrentCell(n);
     158                    const LinkedNodes *OtherList = LC->GetRelativeToCurrentCell(n);
    162159//                    Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
    163160                    if (OtherList != NULL) {
    164                       for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
     161                      for (LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
    165162                        if ((*OtherRunner)->nr > Walker->nr) {
    166163                          OtherWalker = AtomMap[(*OtherRunner)->nr];
    167164//                          Log() << Verbose(0) << "Current other Atom is " << *OtherWalker << "." << endl;
    168                           const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x, cell_size);
     165                          const double distance = OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size);
    169166//                          Log() << Verbose(1) << "Checking distance " << distance << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
    170167                          (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
     
    190187    Free(&AtomMap);
    191188    delete (LC);
    192     DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl);
     189    Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl;
    193190
    194191    // correct bond degree by comparing valence and bond degree
    195     DoLog(2) && (Log() << Verbose(2) << "Correcting bond degree ... " << endl);
     192    Log() << Verbose(2) << "Correcting bond degree ... " << endl;
    196193    CorrectBondDegree();
    197194
     
    199196    ActOnAllAtoms( &atom::OutputBondOfAtom );
    200197  } else
    201     DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl);
    202   DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl);
     198    Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl;
     199  Log() << Verbose(0) << "End of CreateAdjacencyList." << endl;
    203200  if (free_BG)
    204201    delete(BG);
     
    211208void molecule::OutputBondsList() const
    212209{
    213   DoLog(1) && (Log() << Verbose(1) << endl << "From contents of bond chain list:");
     210  Log() << Verbose(1) << endl << "From contents of bond chain list:";
    214211  bond *Binder = first;
    215212  while (Binder->next != last) {
    216213    Binder = Binder->next;
    217     DoLog(0) && (Log() << Verbose(0) << *Binder << "\t" << endl);
    218   }
    219   DoLog(0) && (Log() << Verbose(0) << endl);
     214    Log() << Verbose(0) << *Binder << "\t" << endl;
     215  }
     216  Log() << Verbose(0) << endl;
    220217}
    221218;
     
    234231
    235232  if (BondCount != 0) {
    236     DoLog(1) && (Log() << Verbose(1) << "Correcting Bond degree of each bond ... " << endl);
     233    Log() << Verbose(1) << "Correcting Bond degree of each bond ... " << endl;
    237234    do {
    238235      OldNo = No;
    239236      No = SumPerAtom( &atom::CorrectBondDegree );
    240237    } while (OldNo != No);
    241     DoLog(0) && (Log() << Verbose(0) << " done." << endl);
     238    Log() << Verbose(0) << " done." << endl;
    242239  } else {
    243     DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl);
    244   }
    245   DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl);
     240    Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl;
     241  }
     242  Log() << Verbose(0) << No << " bonds could not be corrected." << endl;
    246243
    247244  return (No);
     
    262259  bond *Binder = first;
    263260  if ((Binder->next != last) && (Binder->next->Type == Undetermined)) {
    264     DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl);
     261    Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl;
    265262    Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack);
    266263    while (Subgraphs->next != NULL) {
     
    317314    Walker->GraphNr = DFS.CurrentGraphNr;
    318315    Walker->LowpointNr = DFS.CurrentGraphNr;
    319     DoLog(1) && (Log() << Verbose(1) << "Setting Walker[" << Walker->getName() << "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl);
     316    Log() << Verbose(1) << "Setting Walker[" << Walker->Name << "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl;
    320317    DFS.AtomStack->Push(Walker);
    321318    DFS.CurrentGraphNr++;
     
    344341    if (Binder == NULL)
    345342      break;
    346     DoLog(2) && (Log() << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl);
     343    Log() << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl;
    347344    // (4) Mark Binder used, ...
    348345    Binder->MarkUsed(black);
    349346    OtherAtom = Binder->GetOtherAtom(Walker);
    350     DoLog(2) && (Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->getName() << "." << endl);
     347    Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->Name << "." << endl;
    351348    if (OtherAtom->GraphNr != -1) {
    352349      // (4a) ... if "other" atom has been visited (GraphNr != 0), set lowpoint to minimum of both, go to (3)
     
    354351      DFS.BackEdgeStack->Push(Binder);
    355352      Walker->LowpointNr = (Walker->LowpointNr < OtherAtom->GraphNr) ? Walker->LowpointNr : OtherAtom->GraphNr;
    356       DoLog(3) && (Log() << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->getName() << "] to " << Walker->LowpointNr << "." << endl);
     353      Log() << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->Name << "] to " << Walker->LowpointNr << "." << endl;
    357354    } else {
    358355      // (4b) ... otherwise set OtherAtom as Ancestor of Walker and Walker as OtherAtom, go to (2)
     
    360357      OtherAtom->Ancestor = Walker;
    361358      Walker = OtherAtom;
    362       DoLog(3) && (Log() << Verbose(3) << "(4b) Not Visited: OtherAtom[" << OtherAtom->getName() << "]'s Ancestor is now " << OtherAtom->Ancestor->getName() << ", Walker is OtherAtom " << OtherAtom->getName() << "." << endl);
     359      Log() << Verbose(3) << "(4b) Not Visited: OtherAtom[" << OtherAtom->Name << "]'s Ancestor is now " << OtherAtom->Ancestor->Name << ", Walker is OtherAtom " << OtherAtom->Name << "." << endl;
    363360      break;
    364361    }
     
    382379
    383380  // (5) if Ancestor of Walker is ...
    384   DoLog(1) && (Log() << Verbose(1) << "(5) Number of Walker[" << Walker->getName() << "]'s Ancestor[" << Walker->Ancestor->getName() << "] is " << Walker->Ancestor->GraphNr << "." << endl);
     381  Log() << Verbose(1) << "(5) Number of Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "] is " << Walker->Ancestor->GraphNr << "." << endl;
    385382
    386383  if (Walker->Ancestor->GraphNr != DFS.Root->GraphNr) {
     
    389386      // (6a) set Ancestor's Lowpoint number to minimum of of its Ancestor and itself, go to Step(8)
    390387      Walker->Ancestor->LowpointNr = (Walker->Ancestor->LowpointNr < Walker->LowpointNr) ? Walker->Ancestor->LowpointNr : Walker->LowpointNr;
    391       DoLog(2) && (Log() << Verbose(2) << "(6) Setting Walker[" << Walker->getName() << "]'s Ancestor[" << Walker->Ancestor->getName() << "]'s Lowpoint to " << Walker->Ancestor->LowpointNr << "." << endl);
     388      Log() << Verbose(2) << "(6) Setting Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s Lowpoint to " << Walker->Ancestor->LowpointNr << "." << endl;
    392389    } else {
    393390      // (7) (Ancestor of Walker is a separating vertex, remove all from stack till Walker (including), these and Ancestor form a component
    394391      Walker->Ancestor->SeparationVertex = true;
    395       DoLog(2) && (Log() << Verbose(2) << "(7) Walker[" << Walker->getName() << "]'s Ancestor[" << Walker->Ancestor->getName() << "]'s is a separating vertex, creating component." << endl);
     392      Log() << Verbose(2) << "(7) Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s is a separating vertex, creating component." << endl;
    396393      mol->SetNextComponentNumber(Walker->Ancestor, DFS.ComponentNumber);
    397       DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->getName() << "]'s Ancestor's Compont is " << DFS.ComponentNumber << "." << endl);
     394      Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Ancestor's Compont is " << DFS.ComponentNumber << "." << endl;
    398395      mol->SetNextComponentNumber(Walker, DFS.ComponentNumber);
    399       DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->getName() << "]'s Compont is " << DFS.ComponentNumber << "." << endl);
     396      Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl;
    400397      do {
    401398        OtherAtom = DFS.AtomStack->PopLast();
    402399        LeafWalker->Leaf->AddCopyAtom(OtherAtom);
    403400        mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber);
    404         DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->getName() << "]'s Compont is " << DFS.ComponentNumber << "." << endl);
     401        Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl;
    405402      } while (OtherAtom != Walker);
    406403      DFS.ComponentNumber++;
    407404    }
    408405    // (8) Walker becomes its Ancestor, go to (3)
    409     DoLog(2) && (Log() << Verbose(2) << "(8) Walker[" << Walker->getName() << "] is now its Ancestor " << Walker->Ancestor->getName() << ", backstepping. " << endl);
     406    Log() << Verbose(2) << "(8) Walker[" << Walker->Name << "] is now its Ancestor " << Walker->Ancestor->Name << ", backstepping. " << endl;
    410407    Walker = Walker->Ancestor;
    411408    DFS.BackStepping = true;
     
    431428    //DFS.AtomStack->Output(out);
    432429    mol->SetNextComponentNumber(DFS.Root, DFS.ComponentNumber);
    433     DoLog(3) && (Log() << Verbose(3) << "(9) Root[" << DFS.Root->getName() << "]'s Component is " << DFS.ComponentNumber << "." << endl);
     430    Log() << Verbose(3) << "(9) Root[" << DFS.Root->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl;
    434431    mol->SetNextComponentNumber(Walker, DFS.ComponentNumber);
    435     DoLog(3) && (Log() << Verbose(3) << "(9) Walker[" << Walker->getName() << "]'s Component is " << DFS.ComponentNumber << "." << endl);
     432    Log() << Verbose(3) << "(9) Walker[" << Walker->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl;
    436433    do {
    437434      OtherAtom = DFS.AtomStack->PopLast();
    438435      LeafWalker->Leaf->AddCopyAtom(OtherAtom);
    439436      mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber);
    440       DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->getName() << "]'s Compont is " << DFS.ComponentNumber << "." << endl);
     437      Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl;
    441438    } while (OtherAtom != Walker);
    442439    DFS.ComponentNumber++;
     
    445442    Walker = DFS.Root;
    446443    Binder = mol->FindNextUnused(Walker);
    447     DoLog(1) && (Log() << Verbose(1) << "(10) Walker is Root[" << DFS.Root->getName() << "], next Unused Bond is " << Binder << "." << endl);
     444    Log() << Verbose(1) << "(10) Walker is Root[" << DFS.Root->Name << "], next Unused Bond is " << Binder << "." << endl;
    448445    if (Binder != NULL) { // Root is separation vertex
    449       DoLog(1) && (Log() << Verbose(1) << "(11) Root is a separation vertex." << endl);
     446      Log() << Verbose(1) << "(11) Root is a separation vertex." << endl;
    450447      Walker->SeparationVertex = true;
    451448    }
     
    502499  bond *Binder = NULL;
    503500
    504   if (AtomCount == 0)
    505     return SubGraphs;
    506   DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl);
     501  Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl;
    507502  DepthFirstSearchAnalysis_Init(DFS, this);
    508503
     
    514509    // put into new subgraph molecule and add this to list of subgraphs
    515510    LeafWalker = new MoleculeLeafClass(LeafWalker);
    516     LeafWalker->Leaf = World::getInstance().createMolecule();
     511    LeafWalker->Leaf = new molecule(elemente);
    517512    LeafWalker->Leaf->AddCopyAtom(DFS.Root);
    518513
     
    526521
    527522        if (Binder == NULL) {
    528           DoLog(2) && (Log() << Verbose(2) << "No more Unused Bonds." << endl);
     523          Log() << Verbose(2) << "No more Unused Bonds." << endl;
    529524          break;
    530525        } else
     
    543538
    544539    // From OldGraphNr to CurrentGraphNr ranges an disconnected subgraph
    545     DoLog(0) && (Log() << Verbose(0) << "Disconnected subgraph ranges from " << OldGraphNr << " to " << DFS.CurrentGraphNr << "." << endl);
     540    Log() << Verbose(0) << "Disconnected subgraph ranges from " << OldGraphNr << " to " << DFS.CurrentGraphNr << "." << endl;
    546541    LeafWalker->Leaf->Output((ofstream *)&cout);
    547     DoLog(0) && (Log() << Verbose(0) << endl);
     542    Log() << Verbose(0) << endl;
    548543
    549544    // step on to next root
     
    563558  // free all and exit
    564559  DepthFirstSearchAnalysis_Finalize(DFS);
    565   DoLog(0) && (Log() << Verbose(0) << "End of DepthFirstSearchAnalysis" << endl);
     560  Log() << Verbose(0) << "End of DepthFirstSearchAnalysis" << endl;
    566561  return SubGraphs;
    567562}
     
    589584void molecule::OutputGraphInfoPerAtom() const
    590585{
    591   DoLog(1) && (Log() << Verbose(1) << "Final graph info for each atom is:" << endl);
     586  Log() << Verbose(1) << "Final graph info for each atom is:" << endl;
    592587  ActOnAllAtoms( &atom::OutputGraphInfo );
    593588}
     
    599594void molecule::OutputGraphInfoPerBond() const
    600595{
    601   DoLog(1) && (Log() << Verbose(1) << "Final graph info for each bond is:" << endl);
     596  Log() << Verbose(1) << "Final graph info for each bond is:" << endl;
    602597  bond *Binder = first;
    603598  while (Binder->next != last) {
    604599    Binder = Binder->next;
    605     DoLog(2) && (Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <");
    606     DoLog(0) && (Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp.");
     600    Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <";
     601    Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp.";
    607602    Binder->leftatom->OutputComponentNumber();
    608     DoLog(0) && (Log() << Verbose(0) << " ===  ");
    609     DoLog(0) && (Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp.");
     603    Log() << Verbose(0) << " ===  ";
     604    Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp.";
    610605    Binder->rightatom->OutputComponentNumber();
    611     DoLog(0) && (Log() << Verbose(0) << ">." << endl);
     606    Log() << Verbose(0) << ">." << endl;
    612607    if (Binder->Cyclic) // cyclic ??
    613       DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl);
     608      Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl;
    614609  }
    615610}
     
    685680  do { // look for Root
    686681    Walker = BFS.BFSStack->PopFirst();
    687     DoLog(2) && (Log() << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *BFS.Root << "." << endl);
     682    Log() << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *BFS.Root << "." << endl;
    688683    for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    689684      if ((*Runner) != BackEdge) { // only walk along DFS spanning tree (otherwise we always find SP of one being backedge Binder)
     
    692687        if (OtherAtom->type->Z != 1) {
    693688#endif
    694         DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << "." << endl);
     689        Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl;
    695690        if (BFS.ColorList[OtherAtom->nr] == white) {
    696691          BFS.TouchedStack->Push(OtherAtom);
     
    698693          BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor
    699694          BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1;
    700           DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->getName() << " lightgray, its predecessor is " << Walker->getName() << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl);
     695          Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " lightgray, its predecessor is " << Walker->Name << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl;
    701696          //if (BFS.ShortestPathList[OtherAtom->nr] < MinimumRingSize[Walker->GetTrueFather()->nr]) { // Check for maximum distance
    702           DoLog(3) && (Log() << Verbose(3) << "Putting OtherAtom into queue." << endl);
     697          Log() << Verbose(3) << "Putting OtherAtom into queue." << endl;
    703698          BFS.BFSStack->Push(OtherAtom);
    704699          //}
    705700        } else {
    706           DoLog(3) && (Log() << Verbose(3) << "Not Adding, has already been visited." << endl);
     701          Log() << Verbose(3) << "Not Adding, has already been visited." << endl;
    707702        }
    708703        if (OtherAtom == BFS.Root)
     
    710705#ifdef ADDHYDROGEN
    711706      } else {
    712         DoLog(2) && (Log() << Verbose(2) << "Skipping hydrogen atom " << *OtherAtom << "." << endl);
     707        Log() << Verbose(2) << "Skipping hydrogen atom " << *OtherAtom << "." << endl;
    713708        BFS.ColorList[OtherAtom->nr] = black;
    714709      }
    715710#endif
    716711      } else {
    717         DoLog(2) && (Log() << Verbose(2) << "Bond " << *(*Runner) << " not Visiting, is the back edge." << endl);
     712        Log() << Verbose(2) << "Bond " << *(*Runner) << " not Visiting, is the back edge." << endl;
    718713      }
    719714    }
    720715    BFS.ColorList[Walker->nr] = black;
    721     DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->getName() << " black." << endl);
     716    Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl;
    722717    if (OtherAtom == BFS.Root) { // if we have found the root, check whether this cycle wasn't already found beforehand
    723718      // step through predecessor list
     
    729724      }
    730725      if (OtherAtom == BackEdge->rightatom) { // if each atom in found cycle is cyclic, loop's been found before already
    731         DoLog(3) && (Log() << Verbose(3) << "This cycle was already found before, skipping and removing seeker from search." << endl);
     726        Log() << Verbose(3) << "This cycle was already found before, skipping and removing seeker from search." << endl;
    732727        do {
    733728          OtherAtom = BFS.TouchedStack->PopLast();
    734729          if (BFS.PredecessorList[OtherAtom->nr] == Walker) {
    735             DoLog(4) && (Log() << Verbose(4) << "Removing " << *OtherAtom << " from lists and stacks." << endl);
     730            Log() << Verbose(4) << "Removing " << *OtherAtom << " from lists and stacks." << endl;
    736731            BFS.PredecessorList[OtherAtom->nr] = NULL;
    737732            BFS.ShortestPathList[OtherAtom->nr] = -1;
     
    767762    RingSize = 1;
    768763    BFS.Root->GetTrueFather()->IsCyclic = true;
    769     DoLog(1) && (Log() << Verbose(1) << "Found ring contains: ");
     764    Log() << Verbose(1) << "Found ring contains: ";
    770765    Walker = BFS.Root;
    771766    while (Walker != BackEdge->rightatom) {
    772       DoLog(0) && (Log() << Verbose(0) << Walker->getName() << " <-> ");
     767      Log() << Verbose(0) << Walker->Name << " <-> ";
    773768      Walker = BFS.PredecessorList[Walker->nr];
    774769      Walker->GetTrueFather()->IsCyclic = true;
    775770      RingSize++;
    776771    }
    777     DoLog(0) && (Log() << Verbose(0) << Walker->getName() << "  with a length of " << RingSize << "." << endl << endl);
     772    Log() << Verbose(0) << Walker->Name << "  with a length of " << RingSize << "." << endl << endl;
    778773    // walk through all and set MinimumRingSize
    779774    Walker = BFS.Root;
     
    787782      MinRingSize = RingSize;
    788783  } else {
    789     DoLog(1) && (Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[Walker->GetTrueFather()->nr] << " found." << endl);
     784    Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[Walker->GetTrueFather()->nr] << " found." << endl;
    790785  }
    791786};
     
    865860
    866861      }
    867       DoLog(1) && (Log() << Verbose(1) << "Minimum ring size of " << *Root << " is " << MinimumRingSize[Root->GetTrueFather()->nr] << "." << endl);
    868     }
    869     DoLog(1) && (Log() << Verbose(1) << "Minimum ring size is " << MinRingSize << ", over " << NumCycles << " cycles total." << endl);
     862      Log() << Verbose(1) << "Minimum ring size of " << *Root << " is " << MinimumRingSize[Root->GetTrueFather()->nr] << "." << endl;
     863    }
     864    Log() << Verbose(1) << "Minimum ring size is " << MinRingSize << ", over " << NumCycles << " cycles total." << endl;
    870865  } else
    871     DoLog(1) && (Log() << Verbose(1) << "No rings were detected in the molecular structure." << endl);
     866    Log() << Verbose(1) << "No rings were detected in the molecular structure." << endl;
    872867}
    873868;
     
    897892  //BackEdgeStack->Output(out);
    898893
    899   DoLog(1) && (Log() << Verbose(1) << "Analysing cycles ... " << endl);
     894  Log() << Verbose(1) << "Analysing cycles ... " << endl;
    900895  NumCycles = 0;
    901896  while (!BackEdgeStack->IsEmpty()) {
     
    908903    ResetBFSAccounting(Walker, BFS);
    909904
    910     DoLog(1) && (Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl);
     905    Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl;
    911906    OtherAtom = NULL;
    912907    CyclicStructureAnalysis_CyclicBFSFromRootToRoot(BackEdge, BFS);
     
    937932        break; // breaking here will not cause error!
    938933    }
    939     if (i == vertex->ListOfBonds.size()) {
    940       DoeLog(0) && (eLog()<< Verbose(0) << "Error: All Component entries are already occupied!" << endl);
    941       performCriticalExit();
    942     }
    943   } else {
    944     DoeLog(0) && (eLog()<< Verbose(0) << "Error: Given vertex is NULL!" << endl);
    945     performCriticalExit();
    946   }
     934    if (i == vertex->ListOfBonds.size())
     935      eLog() << Verbose(0) << "Error: All Component entries are already occupied!" << endl;
     936  } else
     937    eLog() << Verbose(0) << "Error: Given vertex is NULL!" << endl;
    947938}
    948939;
     
    980971void OutputAlreadyVisited(int *list)
    981972{
    982   DoLog(4) && (Log() << Verbose(4) << "Already Visited Bonds:\t");
     973  Log() << Verbose(4) << "Already Visited Bonds:\t";
    983974  for (int i = 1; i <= list[0]; i++)
    984     DoLog(0) && (Log() << Verbose(0) << list[i] << "  ");
    985   DoLog(0) && (Log() << Verbose(0) << endl);
     975    Log() << Verbose(0) << list[i] << "  ";
     976  Log() << Verbose(0) << endl;
    986977}
    987978;
     
    989980/** Storing the bond structure of a molecule to file.
    990981 * Simply stores Atom::nr and then the Atom::nr of all bond partners per line.
     982 * \param *out output stream for debugging
    991983 * \param *path path to file
    992  * \param *filename name of file
    993984 * \return true - file written successfully, false - writing failed
    994985 */
    995 bool molecule::StoreAdjacencyToFile(char *path, char *filename)
     986bool molecule::StoreAdjacencyToFile(char *path)
    996987{
    997988  ofstream AdjacencyFile;
     
    999990  bool status = true;
    1000991
    1001   if (path != NULL)
    1002     line << path << "/" << filename;
    1003   else
    1004     line << filename;
     992  line << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;
    1005993  AdjacencyFile.open(line.str().c_str(), ios::out);
    1006   DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... ");
     994  Log() << Verbose(1) << "Saving adjacency list ... ";
    1007995  if (AdjacencyFile != NULL) {
    1008     AdjacencyFile << "m\tn" << endl;
    1009996    ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile);
    1010997    AdjacencyFile.close();
    1011     DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     998    Log() << Verbose(1) << "done." << endl;
    1012999  } else {
    1013     DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
    1014     status = false;
    1015   }
    1016 
    1017   return status;
    1018 }
    1019 ;
    1020 
    1021 /** Storing the bond structure of a molecule to file.
    1022  * Simply stores Atom::nr and then the Atom::nr of all bond partners, one per line.
    1023  * \param *path path to file
    1024  * \param *filename name of file
    1025  * \return true - file written successfully, false - writing failed
    1026  */
    1027 bool molecule::StoreBondsToFile(char *path, char *filename)
    1028 {
    1029   ofstream BondFile;
    1030   stringstream line;
    1031   bool status = true;
    1032 
    1033   if (path != NULL)
    1034     line << path << "/" << filename;
    1035   else
    1036     line << filename;
    1037   BondFile.open(line.str().c_str(), ios::out);
    1038   DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... ");
    1039   if (BondFile != NULL) {
    1040     BondFile << "m\tn" << endl;
    1041     ActOnAllAtoms(&atom::OutputBonds, &BondFile);
    1042     BondFile.close();
    1043     DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    1044   } else {
    1045     DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
     1000    Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;
    10461001    status = false;
    10471002  }
     
    10561011  filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;
    10571012  File.open(filename.str().c_str(), ios::out);
    1058   DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... ");
     1013  Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... ";
    10591014  if (File == NULL)
    10601015    return false;
     
    10971052    //Log() << Verbose(0) << endl;
    10981053  } else {
    1099     DoLog(0) && (Log() << Verbose(0) << "Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << Walker->ListOfBonds.size() << "." << endl);
     1054    Log() << Verbose(0) << "Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << Walker->ListOfBonds.size() << "." << endl;
    11001055    status = false;
    11011056  }
     
    11201075
    11211076  if (!CheckAdjacencyFileAgainstMolecule_Init(path, File, CurrentBonds)) {
    1122     DoLog(1) && (Log() << Verbose(1) << "Adjacency file not found." << endl);
     1077    Log() << Verbose(1) << "Adjacency file not found." << endl;
    11231078    return true;
    11241079  }
     
    11461101
    11471102  if (status) { // if equal we parse the KeySetFile
    1148     DoLog(1) && (Log() << Verbose(1) << "done: Equal." << endl);
     1103    Log() << Verbose(1) << "done: Equal." << endl;
    11491104  } else
    1150     DoLog(1) && (Log() << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl);
     1105    Log() << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl;
    11511106  return status;
    11521107}
     
    11641119  bool status = true;
    11651120  if (ReferenceStack->IsEmpty()) {
    1166     DoLog(1) && (Log() << Verbose(1) << "ReferenceStack is empty!" << endl);
     1121    eLog() << Verbose(0) << "ReferenceStack is empty!" << endl;
    11671122    return false;
    11681123  }
     
    11791134        if (OtherAtom == ListOfLocalAtoms[(*Runner)->rightatom->nr]) { // found the bond
    11801135          LocalStack->Push((*Runner));
    1181           DoLog(3) && (Log() << Verbose(3) << "Found local edge " << *(*Runner) << "." << endl);
     1136          Log() << Verbose(3) << "Found local edge " << *(*Runner) << "." << endl;
    11821137          break;
    11831138        }
    11841139      }
    11851140    Binder = ReferenceStack->PopFirst(); // loop the stack for next item
    1186     DoLog(3) && (Log() << Verbose(3) << "Current candidate edge " << Binder << "." << endl);
     1141    Log() << Verbose(3) << "Current candidate edge " << Binder << "." << endl;
    11871142    ReferenceStack->Push(Binder);
    11881143  } while (FirstBond != Binder);
     
    12331188  BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor
    12341189  BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1;
    1235   DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->getName() << " " << ((BFS.ColorList[OtherAtom->nr] == white) ? "white" : "lightgray") << ", its predecessor is " << Walker->getName() << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl);
     1190  Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " " << ((BFS.ColorList[OtherAtom->nr] == white) ? "white" : "lightgray") << ", its predecessor is " << Walker->Name << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl;
    12361191  if ((((BFS.ShortestPathList[OtherAtom->nr] < BFS.BondOrder) && (Binder != Bond)))) { // Check for maximum distance
    1237     DoLog(3) && (Log() << Verbose(3));
     1192    Log() << Verbose(3);
    12381193    if (AddedAtomList[OtherAtom->nr] == NULL) { // add if it's not been so far
    12391194      AddedAtomList[OtherAtom->nr] = Mol->AddCopyAtom(OtherAtom);
    1240       DoLog(0) && (Log() << Verbose(0) << "Added OtherAtom " << OtherAtom->getName());
     1195      Log() << Verbose(0) << "Added OtherAtom " << OtherAtom->Name;
    12411196      AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder);
    1242       DoLog(0) && (Log() << Verbose(0) << " and bond " << *(AddedBondList[Binder->nr]) << ", ");
     1197      Log() << Verbose(0) << " and bond " << *(AddedBondList[Binder->nr]) << ", ";
    12431198    } else { // this code should actually never come into play (all white atoms are not yet present in BondMolecule, that's why they are white in the first place)
    1244       DoLog(0) && (Log() << Verbose(0) << "Not adding OtherAtom " << OtherAtom->getName());
     1199      Log() << Verbose(0) << "Not adding OtherAtom " << OtherAtom->Name;
    12451200      if (AddedBondList[Binder->nr] == NULL) {
    12461201        AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder);
    1247         DoLog(0) && (Log() << Verbose(0) << ", added Bond " << *(AddedBondList[Binder->nr]));
     1202        Log() << Verbose(0) << ", added Bond " << *(AddedBondList[Binder->nr]);
    12481203      } else
    1249         DoLog(0) && (Log() << Verbose(0) << ", not added Bond ");
    1250     }
    1251     DoLog(0) && (Log() << Verbose(0) << ", putting OtherAtom into queue." << endl);
     1204        Log() << Verbose(0) << ", not added Bond ";
     1205    }
     1206    Log() << Verbose(0) << ", putting OtherAtom into queue." << endl;
    12521207    BFS.BFSStack->Push(OtherAtom);
    12531208  } else { // out of bond order, then replace
     
    12551210      BFS.ColorList[OtherAtom->nr] = white; // unmark if it has not been queued/added, to make it available via its other bonds (cyclic)
    12561211    if (Binder == Bond)
    1257       DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is the Root bond");
     1212      Log() << Verbose(3) << "Not Queueing, is the Root bond";
    12581213    else if (BFS.ShortestPathList[OtherAtom->nr] >= BFS.BondOrder)
    1259       DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is out of Bond Count of " << BFS.BondOrder);
     1214      Log() << Verbose(3) << "Not Queueing, is out of Bond Count of " << BFS.BondOrder;
    12601215    if (!Binder->Cyclic)
    1261       DoLog(0) && (Log() << Verbose(0) << ", is not part of a cyclic bond, saturating bond with Hydrogen." << endl);
     1216      Log() << Verbose(0) << ", is not part of a cyclic bond, saturating bond with Hydrogen." << endl;
    12621217    if (AddedBondList[Binder->nr] == NULL) {
    12631218      if ((AddedAtomList[OtherAtom->nr] != NULL)) { // .. whether we add or saturate
     
    12761231void BreadthFirstSearchAdd_VisitedNode(molecule *Mol, struct BFSAccounting &BFS, atom *&Walker, atom *&OtherAtom, bond *&Binder, bond *&Bond, atom **&AddedAtomList, bond **&AddedBondList, bool IsAngstroem)
    12771232{
    1278   DoLog(3) && (Log() << Verbose(3) << "Not Adding, has already been visited." << endl);
     1233  Log() << Verbose(3) << "Not Adding, has already been visited." << endl;
    12791234  // This has to be a cyclic bond, check whether it's present ...
    12801235  if (AddedBondList[Binder->nr] == NULL) {
     
    13221277    // followed by n+1 till top of stack.
    13231278    Walker = BFS.BFSStack->PopFirst(); // pop oldest added
    1324     DoLog(1) && (Log() << Verbose(1) << "Current Walker is: " << Walker->getName() << ", and has " << Walker->ListOfBonds.size() << " bonds." << endl);
     1279    Log() << Verbose(1) << "Current Walker is: " << Walker->Name << ", and has " << Walker->ListOfBonds.size() << " bonds." << endl;
    13251280    for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    13261281      if ((*Runner) != NULL) { // don't look at bond equal NULL
    13271282        Binder = (*Runner);
    13281283        OtherAtom = (*Runner)->GetOtherAtom(Walker);
    1329         DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << "." << endl);
     1284        Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl;
    13301285        if (BFS.ColorList[OtherAtom->nr] == white) {
    13311286          BreadthFirstSearchAdd_UnvisitedNode(Mol, BFS, Walker, OtherAtom, Binder, Bond, AddedAtomList, AddedBondList, IsAngstroem);
     
    13361291    }
    13371292    BFS.ColorList[Walker->nr] = black;
    1338     DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->getName() << " black." << endl);
     1293    Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl;
    13391294  }
    13401295  BreadthFirstSearchAdd_Free(BFS);
     
    13611316  // reset parent list
    13621317  ParentList = Calloc<atom*> (AtomCount, "molecule::BuildInducedSubgraph_Init: **ParentList");
    1363   DoLog(3) && (Log() << Verbose(3) << "Resetting ParentList." << endl);
     1318  Log() << Verbose(3) << "Resetting ParentList." << endl;
    13641319}
    13651320;
     
    13681323{
    13691324  // fill parent list with sons
    1370   DoLog(3) && (Log() << Verbose(3) << "Filling Parent List." << endl);
     1325  Log() << Verbose(3) << "Filling Parent List." << endl;
    13711326  atom *Walker = mol->start;
    13721327  while (Walker->next != mol->end) {
     
    13741329    ParentList[Walker->father->nr] = Walker;
    13751330    // Outputting List for debugging
    1376     DoLog(4) && (Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl);
     1331    Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl;
    13771332  }
    13781333
     
    13921347  atom *OtherAtom = NULL;
    13931348  // check each entry of parent list and if ok (one-to-and-onto matching) create bonds
    1394   DoLog(3) && (Log() << Verbose(3) << "Creating bonds." << endl);
     1349  Log() << Verbose(3) << "Creating bonds." << endl;
    13951350  Walker = Father->start;
    13961351  while (Walker->next != Father->end) {
     
    14031358          OtherAtom = (*Runner)->GetOtherAtom(Walker);
    14041359          if (ParentList[OtherAtom->nr] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond
    1405             DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[Walker->nr]->getName() << " and " << ParentList[OtherAtom->nr]->getName() << "." << endl);
     1360            Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[Walker->nr]->Name << " and " << ParentList[OtherAtom->nr]->Name << "." << endl;
    14061361            mol->AddBond(ParentList[Walker->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);
    14071362          }
     
    14281383  atom **ParentList = NULL;
    14291384
    1430   DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl);
     1385  Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl;
    14311386  BuildInducedSubgraph_Init(ParentList, Father->AtomCount);
    14321387  BuildInducedSubgraph_FillParentList(this, Father, ParentList);
    14331388  status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList);
    14341389  BuildInducedSubgraph_Finalize(ParentList);
    1435   DoLog(2) && (Log() << Verbose(2) << "End of BuildInducedSubgraph." << endl);
     1390  Log() << Verbose(2) << "End of BuildInducedSubgraph." << endl;
    14361391  return status;
    14371392}
     
    14501405  int size;
    14511406
    1452   DoLog(1) && (Log() << Verbose(1) << "Begin of CheckForConnectedSubgraph" << endl);
    1453   DoLog(2) && (Log() << Verbose(2) << "Disconnected atom: ");
     1407  Log() << Verbose(1) << "Begin of CheckForConnectedSubgraph" << endl;
     1408  Log() << Verbose(2) << "Disconnected atom: ";
    14541409
    14551410  // count number of atoms in graph
     
    14731428      }
    14741429      if (!BondStatus) {
    1475         DoLog(0) && (Log() << Verbose(0) << (*Walker) << endl);
     1430        Log() << Verbose(0) << (*Walker) << endl;
    14761431        return false;
    14771432      }
    14781433    }
    14791434  else {
    1480     DoLog(0) && (Log() << Verbose(0) << "none." << endl);
     1435    Log() << Verbose(0) << "none." << endl;
    14811436    return true;
    14821437  }
    1483   DoLog(0) && (Log() << Verbose(0) << "none." << endl);
    1484 
    1485   DoLog(1) && (Log() << Verbose(1) << "End of CheckForConnectedSubgraph" << endl);
     1438  Log() << Verbose(0) << "none." << endl;
     1439
     1440  Log() << Verbose(1) << "End of CheckForConnectedSubgraph" << endl;
    14861441
    14871442  return true;
Note: See TracChangeset for help on using the changeset viewer.