Changeset 3ccc3e
- Timestamp:
- Oct 9, 2008, 6:29:03 PM (17 years ago)
- 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:
- 1e8243
- Parents:
- 18913c
- git-author:
- Frederik Heber <heber@…> (10/09/08 18:27:56)
- git-committer:
- Frederik Heber <heber@…> (10/09/08 18:29:03)
- Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/builder.cpp
r18913c r3ccc3e 952 952 cout << Verbose(1) << "Depth-First-Search Analysis." << endl; 953 953 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 954 int *MinimumRingSize = NULL; 954 int *MinimumRingSize = new int[mol->AtomCount]; 955 atom ***ListOfLocalAtoms = NULL; 956 int FragmentCounter = 0; 957 class StackClass<bond *> *BackEdgeStack = NULL; 958 class StackClass<bond *> *LocalBackEdgeStack = NULL; 955 959 mol->CreateAdjacencyList((ofstream *)&cout, atof(argv[argptr]), configuration.GetIsAngstroem()); 956 960 mol->CreateListOfBondsPerAtom((ofstream *)&cout); 957 Subgraphs = mol->DepthFirstSearchAnalysis((ofstream *)&cout, MinimumRingSize); 958 delete[](MinimumRingSize); 961 Subgraphs = mol->DepthFirstSearchAnalysis((ofstream *)&cout, BackEdgeStack); 959 962 if (Subgraphs != NULL) { 963 Subgraphs->next->FillBondStructureFromReference((ofstream *)&cout, mol, (FragmentCounter = 0), ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms 960 964 while (Subgraphs->next != NULL) { 961 965 Subgraphs = Subgraphs->next; 966 LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount); 967 Subgraphs->Leaf->PickLocalBackEdges((ofstream *)&cout, ListOfLocalAtoms[FragmentCounter++], BackEdgeStack, LocalBackEdgeStack); 968 Subgraphs->Leaf->CyclicStructureAnalysis((ofstream *)&cout, BackEdgeStack, MinimumRingSize); 969 delete(LocalBackEdgeStack); 962 970 delete(Subgraphs->previous); 963 971 } 964 972 delete(Subgraphs); 973 for (int i=0;i<FragmentCounter;i++) 974 Free((void **)&ListOfLocalAtoms[FragmentCounter], "ParseCommandLineOptions: **ListOfLocalAtoms[]"); 975 Free((void **)&ListOfLocalAtoms, "ParseCommandLineOptions: ***ListOfLocalAtoms"); 965 976 } 977 delete(BackEdgeStack); 978 delete[](MinimumRingSize); 966 979 } 967 980 argptr+=1; … … 1240 1253 int Z; 1241 1254 int j, axis, count, faktor; 1242 int *MinimumRingSize = NULL; 1255 clock_t start,end; 1256 // int *MinimumRingSize = NULL; 1243 1257 MoleculeLeafClass *Subgraphs = NULL; 1244 clock_t start,end;1258 // class StackClass<bond *> *BackEdgeStack = NULL; 1245 1259 element **Elements; 1246 1260 Vector **vectors; … … 1408 1422 1409 1423 case 'o': // create the connection matrix 1410 cout << Verbose(0) << "What's the maximum bond distance: "; 1411 cin >> tmp1; 1412 start = clock(); 1413 mol->CreateAdjacencyList((ofstream *)&cout, tmp1, configuration.GetIsAngstroem()); 1414 //mol->CreateListOfBondsPerAtom((ofstream *)&cout); 1415 Subgraphs = mol->DepthFirstSearchAnalysis((ofstream *)&cout, MinimumRingSize); 1416 while (Subgraphs->next != NULL) { 1417 Subgraphs = Subgraphs->next; 1418 delete(Subgraphs->previous); 1424 { 1425 cout << Verbose(0) << "What's the maximum bond distance: "; 1426 cin >> tmp1; 1427 start = clock(); 1428 mol->CreateAdjacencyList((ofstream *)&cout, tmp1, configuration.GetIsAngstroem()); 1429 mol->CreateListOfBondsPerAtom((ofstream *)&cout); 1430 // Subgraphs = mol->DepthFirstSearchAnalysis((ofstream *)&cout, BackEdgeStack); 1431 // while (Subgraphs->next != NULL) { 1432 // Subgraphs = Subgraphs->next; 1433 // Subgraphs->Leaf->CyclicStructureAnalysis((ofstream *)&cout, BackEdgeStack, MinimumRingSize); 1434 // delete(Subgraphs->previous); 1435 // } 1436 // delete(Subgraphs); // we don't need the list here, so free everything 1437 // delete[](MinimumRingSize); 1438 // Subgraphs = NULL; 1439 end = clock(); 1440 cout << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl; 1419 1441 } 1420 delete(Subgraphs); // we don't need the list here, so free everything1421 delete[](MinimumRingSize);1422 Subgraphs = NULL;1423 end = clock();1424 cout << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;1425 1442 break; 1426 1443 -
src/helpers.hpp
r18913c r3ccc3e 100 100 status = false; 101 101 } else { 102 for (int i=0;i<count;i++) 103 LookupTable[i] = NULL; 102 104 Walker = start; 103 105 while (Walker->next != end) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron -
src/moleculelist.cpp
r18913c r3ccc3e 584 584 while (Walker->next != Leaf->end) { 585 585 Walker = Walker->next; 586 AtomNo = Walker-> father->nr; // global id of the current walker586 AtomNo = Walker->GetTrueFather()->nr; // global id of the current walker 587 587 for(int i=0;i<reference->NumberOfBondsPerAtom[AtomNo];i++) { // go through father's bonds and copy them all 588 588 Binder = reference->ListOfBondsPerAtom[AtomNo][i]; 589 OtherWalker = ListOfLocalAtoms[FragmentCounter][Binder->GetOtherAtom(Walker-> father)->nr]; // local copy of current bond partner of walker589 OtherWalker = ListOfLocalAtoms[FragmentCounter][Binder->GetOtherAtom(Walker->GetTrueFather())->nr]; // local copy of current bond partner of walker 590 590 if (OtherWalker != NULL) { 591 591 if (OtherWalker->nr > Walker->nr) 592 592 Leaf->AddBond(Walker, OtherWalker, Binder->BondDegree); 593 593 } else { 594 *out << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << Binder->GetOtherAtom(Walker-> father)->nr << "] is NULL!" << endl;594 *out << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << Binder->GetOtherAtom(Walker->GetTrueFather())->nr << "] is NULL!" << endl; 595 595 status = false; 596 596 } … … 603 603 } 604 604 605 FragmentCounter--; 605 606 if (FreeList) { 606 607 // free the index lookup list 607 608 Free((void **)&ListOfLocalAtoms[FragmentCounter], "MoleculeLeafClass::FillBondStructureFromReference - **ListOfLocalAtoms[]"); 608 if ( ListOfLocalAtoms[FragmentCounter] == NULL)609 if (FragmentCounter == 0) // first fragments frees the initial pointer to list 609 610 Free((void **)&ListOfLocalAtoms, "MoleculeLeafClass::FillBondStructureFromReference - ***ListOfLocalAtoms"); 610 611 } … … 656 657 * \param *out output stream fro debugging 657 658 * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled 658 * \param &FragmentCounter counts the fragments as we move along the list659 * \param FragmentCounter counts the fragments as we move along the list 659 660 * \param GlobalAtomCount number of atoms in the complete molecule 660 661 * \param &FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not 661 662 * \return true - succes, false - failure 662 663 */ 663 bool MoleculeLeafClass::FillListOfLocalAtoms(ofstream *out, atom ***&ListOfLocalAtoms, int &FragmentCounter,int GlobalAtomCount, bool &FreeList)664 bool MoleculeLeafClass::FillListOfLocalAtoms(ofstream *out, atom ***&ListOfLocalAtoms, const int FragmentCounter, const int GlobalAtomCount, bool &FreeList) 664 665 { 665 666 bool status = true; … … 721 722 KeySet *TempSet = new KeySet; 722 723 for(Graph::iterator runner = KeySetList->begin();runner != KeySetList->end(); runner++) { // key sets contain global numbers! 723 if ( ListOfLocalAtoms[FragmentCounter][reference->FindAtom(*((*runner).first.begin()))->nr] ->nr != -1) {// as we may assume that that bond structure is unchanged, we only test the first key in each set724 if ( ListOfLocalAtoms[FragmentCounter][reference->FindAtom(*((*runner).first.begin()))->nr] != NULL) {// as we may assume that that bond structure is unchanged, we only test the first key in each set 724 725 // translate keyset to local numbers 725 726 for(KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++) … … 739 740 if (next != NULL) 740 741 next->AssignKeySetsToFragment(out, reference, KeySetList, ListOfLocalAtoms, FragmentList, FragmentCounter, FreeList); 741 FragmentCounter--;742 742 } else 743 743 *out << Verbose(1) << "KeySetList is NULL or empty." << endl; 744 744 745 FragmentCounter--; 746 if (FreeList) { 747 // free the index lookup list 748 Free((void **)&ListOfLocalAtoms[FragmentCounter], "MoleculeLeafClass::AssignKeySetsToFragment - **ListOfLocalAtoms[]"); 749 if (FragmentCounter == 0) // first fragments frees the initial pointer to list 750 Free((void **)&ListOfLocalAtoms, "MoleculeLeafClass::AssignKeySetsToFragment - ***ListOfLocalAtoms"); 751 } 745 752 return status; 746 753 }; -
src/molecules.cpp
r18913c r3ccc3e 1603 1603 int *MinimumRingSize = NULL; 1604 1604 MoleculeLeafClass *Subgraphs = NULL; 1605 class StackClass<bond *> *BackEdgeStack = NULL; 1605 1606 bond *Binder = first; 1606 1607 if ((Binder->next != last) && (Binder->next->Type == Undetermined)) { 1607 1608 *out << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl; 1608 Subgraphs = DepthFirstSearchAnalysis(out, MinimumRingSize);1609 Subgraphs = DepthFirstSearchAnalysis(out, BackEdgeStack); 1609 1610 while (Subgraphs->next != NULL) { 1610 1611 Subgraphs = Subgraphs->next; … … 1619 1620 No++; 1620 1621 } 1622 delete(BackEdgeStack); 1621 1623 return No; 1622 1624 }; … … 1700 1702 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 1701 1703 Vector x; 1704 int FalseBondDegree = 0; 1702 1705 1703 1706 BondDistance = bonddistance; // * ((IsAngstroem) ? 1. : 1./AtomicLengthToAngstroem); … … 1718 1721 j += i+1; 1719 1722 divisor[i] = (int)floor(cell_size[j]/bonddistance); // take smaller value such that size of linked cell is at least bonddistance 1720 *out << Verbose(1) << "divisor[" << i << "] = " << divisor[i] << "." << endl;1723 //*out << Verbose(1) << "divisor[" << i << "] = " << divisor[i] << "." << endl; 1721 1724 } 1722 1725 // 2a. allocate memory for the cell list … … 1743 1746 } 1744 1747 index = n[2] + (n[1] + n[0] * divisor[1]) * divisor[2]; 1745 *out << Verbose(1) << "Atom " << *Walker << " goes into cell number [" << n[0] << "," << n[1] << "," << n[2] << "] = " << index << "." << endl;1748 //*out << Verbose(1) << "Atom " << *Walker << " goes into cell number [" << n[0] << "," << n[1] << "," << n[2] << "] = " << index << "." << endl; 1746 1749 // add copy atom to this cell 1747 1750 if (CellList[index] == NULL) // allocate molecule if not done … … 1785 1788 distance = OtherWalker->x.PeriodicDistance(&(Walker->x), cell_size); 1786 1789 if ((OtherWalker->father->nr > Walker->father->nr) && (distance <= MaxDistance*MaxDistance) && (distance >= MinDistance*MinDistance)) { // create bond if distance is smaller 1787 *out << Verbose(0) << "Adding Bond between " << *Walker << " and " << *OtherWalker << "." << endl;1790 //*out << Verbose(0) << "Adding Bond between " << *Walker << " and " << *OtherWalker << "." << endl; 1788 1791 AddBond(Walker->father, OtherWalker->father, 1); // also increases molecule::BondCount 1789 1792 BondCount++; … … 1844 1847 ListOfBondsPerAtom[Walker->nr][CandidateBondNo]->BondDegree++; 1845 1848 *out << Verbose(2) << "Increased bond degree for bond " << *ListOfBondsPerAtom[Walker->nr][CandidateBondNo] << "." << endl; 1846 } 1849 } else 1850 *out << Verbose(2) << "Could not find correct degree for bond " << *ListOfBondsPerAtom[Walker->nr][CandidateBondNo] << "." << endl; 1851 FalseBondDegree++; 1847 1852 } 1848 1853 } … … 1851 1856 } else 1852 1857 *out << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl; 1853 *out << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << bonddistance << " ." << endl;1858 *out << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << bonddistance << ", " << FalseBondDegree << " bonds could not be corrected." << endl; 1854 1859 1855 1860 // output bonds for debugging (if bond chain list was correctly installed) … … 1872 1877 * We use the algorithm from [Even, Graph Algorithms, p.62]. 1873 1878 * \param *out output stream for debugging 1874 * \param *& MinimumRingSize contains smallest ring size in molecular structure on return or -1 if no rings were found1879 * \param *&BackEdgeStack NULL pointer to StackClass with all the found back edges, allocated and filled on return 1875 1880 * \return list of each disconnected subgraph as an individual molecule class structure 1876 1881 */ 1877 MoleculeLeafClass * molecule::DepthFirstSearchAnalysis(ofstream *out, int *&MinimumRingSize) 1878 { 1879 class StackClass<atom *> *AtomStack; 1880 AtomStack = new StackClass<atom *>(AtomCount); 1881 class StackClass<bond *> *BackEdgeStack = new StackClass<bond *> (BondCount); 1882 MoleculeLeafClass * molecule::DepthFirstSearchAnalysis(ofstream *out, class StackClass<bond *> *&BackEdgeStack) 1883 { 1884 class StackClass<atom *> *AtomStack = new StackClass<atom *>(AtomCount); 1885 BackEdgeStack = new StackClass<bond *> (BondCount); 1882 1886 MoleculeLeafClass *SubGraphs = new MoleculeLeafClass(NULL); 1883 1887 MoleculeLeafClass *LeafWalker = SubGraphs; … … 2011 2015 LeafWalker->Leaf->Output(out); 2012 2016 *out << endl; 2013 2017 2014 2018 // step on to next root 2015 2019 while ((Root != end) && (Root->GraphNr != -1)) { … … 2029 2033 } 2030 2034 2031 // analysis of the cycles (print rings, get minimum cycle length)2032 CyclicStructureAnalysis(out, BackEdgeStack, MinimumRingSize);2033 2035 2034 2036 *out << Verbose(1) << "Final graph info for each atom is:" << endl; … … 2068 2070 * as cyclic and print out the cycles. 2069 2071 * \param *out output stream for debugging 2070 * \param *BackEdgeStack stack with all back edges found during DFS scan 2072 * \param *BackEdgeStack stack with all back edges found during DFS scan. Beware: This stack contains the bonds from the total molecule, not from the subgraph! 2071 2073 * \param *&MinimumRingSize contains smallest ring size in molecular structure on return or -1 if no rings were found, if set is maximum search distance 2072 2074 * \todo BFS from the not-same-LP to find back to starting point of tributary cycle over more than one bond … … 2089 2091 ColorList[i] = white; 2090 2092 } 2091 MinimumRingSize = new int[AtomCount];2092 for(int i=AtomCount;i--;)2093 MinimumRingSize[i] = AtomCount;2094 2095 2093 2096 2094 *out << Verbose(1) << "Back edge list - "; … … 2894 2892 MoleculeListClass *BondFragments = NULL; 2895 2893 int *SortIndex = NULL; 2896 int *MinimumRingSize = NULL;2894 int *MinimumRingSize = new int[AtomCount]; 2897 2895 int FragmentCounter; 2898 2896 MoleculeLeafClass *MolecularWalker = NULL; … … 2900 2898 fstream File; 2901 2899 bool FragmentationToDo = true; 2900 class StackClass<bond *> *BackEdgeStack = NULL, *LocalBackEdgeStack = NULL; 2902 2901 bool CheckOrder = false; 2903 2902 Graph **FragmentList = NULL; … … 2931 2930 2932 2931 // ===== 2. perform a DFS analysis to gather info on cyclic structure and a list of disconnected subgraphs ===== 2933 Subgraphs = DepthFirstSearchAnalysis(out, MinimumRingSize);2932 Subgraphs = DepthFirstSearchAnalysis(out, BackEdgeStack); 2934 2933 // fill the bond structure of the individually stored subgraphs 2935 2934 Subgraphs->next->FillBondStructureFromReference(out, this, (FragmentCounter = 0), ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms 2936 2935 // analysis of the cycles (print rings, get minimum cycle length) for each subgraph 2936 for(int i=AtomCount;i--;) 2937 MinimumRingSize[i] = AtomCount; 2938 MolecularWalker = Subgraphs; 2939 FragmentCounter = 0; 2940 while (MolecularWalker->next != NULL) { 2941 MolecularWalker = MolecularWalker->next; 2942 *out << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl; 2943 LocalBackEdgeStack = new StackClass<bond *> (MolecularWalker->Leaf->BondCount); 2944 // // check the list of local atoms for debugging 2945 // *out << Verbose(0) << "ListOfLocalAtoms for this subgraph is:" << endl; 2946 // for (int i=0;i<AtomCount;i++) 2947 // if (ListOfLocalAtoms[FragmentCounter][i] == NULL) 2948 // *out << "\tNULL"; 2949 // else 2950 // *out << "\t" << ListOfLocalAtoms[FragmentCounter][i]->Name; 2951 MolecularWalker->Leaf->PickLocalBackEdges(out, ListOfLocalAtoms[FragmentCounter++], BackEdgeStack, LocalBackEdgeStack); 2952 MolecularWalker->Leaf->CyclicStructureAnalysis(out, LocalBackEdgeStack, MinimumRingSize); 2953 delete(LocalBackEdgeStack); 2954 } 2955 2937 2956 // ===== 3. if structure still valid, parse key set file and others ===== 2938 2957 FragmentationToDo = FragmentationToDo && ParseKeySetFile(out, configuration->configpath, ParsedFragmentList); … … 2943 2962 // =================================== Begin of FRAGMENTATION =============================== 2944 2963 // ===== 6a. assign each keyset to its respective subgraph ===== 2945 Subgraphs->next->AssignKeySetsToFragment(out, this, ParsedFragmentList, ListOfLocalAtoms, FragmentList, (FragmentCounter = 0), false);2964 Subgraphs->next->AssignKeySetsToFragment(out, this, ParsedFragmentList, ListOfLocalAtoms, FragmentList, (FragmentCounter = 0), true); 2946 2965 2947 2966 // ===== 6b. prepare and go into the adaptive (Order<0), single-step (Order==0) or incremental (Order>0) cycle … … 2980 2999 delete[](MinimumRingSize); 2981 3000 2982 // free the index lookup list2983 for (int i=FragmentCounter;i--;)2984 Free((void **)&ListOfLocalAtoms[i], "molecule::FragmentMolecule - *ListOfLocalAtoms[]");2985 Free((void **)&ListOfLocalAtoms, "molecule::FragmentMolecule - **ListOfLocalAtoms");2986 3001 2987 3002 // ==================================== End of FRAGMENTATION ============================================ … … 3057 3072 }; 3058 3073 3074 3075 /** Picks from a global stack with all back edges the ones in the fragment. 3076 * \param *out output stream for debugging 3077 * \param **ListOfLocalAtoms array of father atom::nr to local atom::nr (reverse of atom::father) 3078 * \param *ReferenceStack stack with all the back egdes 3079 * \param *LocalStack stack to be filled 3080 * \return true - everything ok, false - ReferenceStack was empty 3081 */ 3082 bool molecule::PickLocalBackEdges(ofstream *out, atom **ListOfLocalAtoms, class StackClass<bond *> *&ReferenceStack, class StackClass<bond *> *&LocalStack) 3083 { 3084 bool status = true; 3085 if (ReferenceStack->IsEmpty()) { 3086 cerr << "ReferenceStack is empty!" << endl; 3087 return false; 3088 } 3089 bond *Binder = ReferenceStack->PopFirst(); 3090 bond *FirstBond = Binder; // mark the first bond, so that we don't loop through the stack indefinitely 3091 atom *Walker = NULL, *OtherAtom = NULL; 3092 ReferenceStack->Push(Binder); 3093 3094 do { // go through all bonds and push local ones 3095 Walker = ListOfLocalAtoms[Binder->leftatom->nr]; // get one atom in the reference molecule 3096 if (Walker == NULL) // if this Walker exists in the subgraph ... 3097 continue; 3098 for(int i=0;i<NumberOfBondsPerAtom[Walker->nr];i++) { // go through the local list of bonds 3099 OtherAtom = ListOfBondsPerAtom[Walker->nr][i]->GetOtherAtom(Walker); 3100 if (OtherAtom == ListOfLocalAtoms[Binder->rightatom->nr]) { // found the bond 3101 LocalStack->Push(ListOfBondsPerAtom[Walker->nr][i]); 3102 break; 3103 } 3104 } 3105 Binder = ReferenceStack->PopFirst(); // loop the stack for next item 3106 ReferenceStack->Push(Binder); 3107 } while (FirstBond != Binder); 3108 3109 return status; 3110 }; 3111 3059 3112 /** Stores pairs (Atom::nr, Atom::AdaptiveOrder) into file. 3060 3113 * Atoms not present in the file get "-1". … … 3199 3252 while (Walker->next != end) { 3200 3253 Walker = Walker->next; 3201 *out << Verbose(4) << "Atom " << Walker->Name << " with " << NumberOfBondsPerAtom[Walker->nr] << " bonds: ";3254 *out << Verbose(4) << "Atom " << Walker->Name << "/" << Walker->nr << " with " << NumberOfBondsPerAtom[Walker->nr] << " bonds: "; 3202 3255 TotalDegree = 0; 3203 3256 for (int j=0;j<NumberOfBondsPerAtom[Walker->nr];j++) { -
src/molecules.hpp
r18913c r3ccc3e 269 269 270 270 // Graph analysis 271 MoleculeLeafClass * DepthFirstSearchAnalysis(ofstream *out, int *&MinimumRingSize);271 MoleculeLeafClass * DepthFirstSearchAnalysis(ofstream *out, class StackClass<bond *> *&BackEdgeStack); 272 272 void CyclicStructureAnalysis(ofstream *out, class StackClass<bond *> *BackEdgeStack, int *&MinimumRingSize); 273 bool PickLocalBackEdges(ofstream *out, atom **ListOfLocalAtoms, class StackClass<bond *> *&ReferenceStack, class StackClass<bond *> *&LocalStack); 273 274 bond * FindNextUnused(atom *vertex); 274 275 void SetNextComponentNumber(atom *vertex, int nr); … … 363 364 bool FillRootStackForSubgraphs(ofstream *out, KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter); 364 365 bool AssignKeySetsToFragment(ofstream *out, molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList = false); 365 bool FillListOfLocalAtoms(ofstream *out, atom ***&ListOfLocalAtoms, int &FragmentCounter,int GlobalAtomCount, bool &FreeList);366 bool FillListOfLocalAtoms(ofstream *out, atom ***&ListOfLocalAtoms, const int FragmentCounter, const int GlobalAtomCount, bool &FreeList); 366 367 void TranslateIndicesToGlobalIDs(ofstream *out, Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph); 367 368 int Count() const;
Note:
See TracChangeset
for help on using the changeset viewer.