Changeset 920c70 for src/molecule_graph.cpp
- Timestamp:
- May 31, 2010, 1:09:58 PM (15 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:
- 42af9e
- Parents:
- 87b597
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_graph.cpp
r87b597 r920c70 143 143 // create a list to map Tesselpoint::nr to atom * 144 144 DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl); 145 AtomMap = Calloc<atom *> (AtomCount, "molecule::CreateAdjacencyList - **AtomCount"); 145 AtomMap = new atom *[AtomCount]; 146 for (int i=0;i<AtomCount;i++) 147 AtomMap[i] = NULL; 146 148 Walker = start; 147 149 while (Walker->next != end) { … … 194 196 } 195 197 } 196 Free(&AtomMap);198 delete[](AtomMap); 197 199 delete (LC); 198 200 DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl); … … 630 632 { 631 633 BFS.AtomCount = AtomCount; 632 BFS.PredecessorList = Calloc<atom*> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: **PredecessorList");633 BFS.ShortestPathList = Malloc<int> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ShortestPathList");634 BFS.ColorList = Calloc<enum Shading> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ColorList");634 BFS.PredecessorList = new atom*[AtomCount]; 635 BFS.ShortestPathList = new int[AtomCount]; 636 BFS.ColorList = new enum Shading[AtomCount]; 635 637 BFS.BFSStack = new StackClass<atom *> (AtomCount); 636 638 637 for (int i = AtomCount; i--;) 639 for (int i = AtomCount; i--;) { 638 640 BFS.ShortestPathList[i] = -1; 641 BFS.PredecessorList[i] = 0; 642 } 639 643 }; 640 644 … … 645 649 void FinalizeBFSAccounting(struct BFSAccounting &BFS) 646 650 { 647 Free(&BFS.PredecessorList);648 Free(&BFS.ShortestPathList);649 Free(&BFS.ColorList);651 delete[](BFS.PredecessorList); 652 delete[](BFS.ShortestPathList); 653 delete[](BFS.ColorList); 650 654 delete (BFS.BFSStack); 651 655 BFS.AtomCount = 0; … … 1067 1071 1068 1072 // allocate storage structure 1069 CurrentBonds = Calloc<int> (8, "molecule::CheckAdjacencyFileAgainstMolecule - CurrentBonds"); // contains parsed bonds of current atom 1073 CurrentBonds = new int[8]; // contains parsed bonds of current atom 1074 for(int i=0;i<8;i++) 1075 CurrentBonds[i] = 0; 1070 1076 return true; 1071 1077 } … … 1076 1082 File.close(); 1077 1083 File.clear(); 1078 Free(&CurrentBonds);1084 delete[](CurrentBonds); 1079 1085 } 1080 1086 ; … … 1120 1126 bool status = true; 1121 1127 atom *Walker = NULL; 1122 char *buffer = NULL;1123 1128 int *CurrentBonds = NULL; 1124 1129 int NonMatchNumber = 0; // will number of atoms with differing bond structure … … 1130 1135 } 1131 1136 1132 buffer = Malloc<char> (MAXSTRINGSIZE, "molecule::CheckAdjacencyFileAgainstMolecule: *buffer");1137 char buffer[MAXSTRINGSIZE]; 1133 1138 // Parse the file line by line and count the bonds 1134 1139 while (!File.eof()) { … … 1148 1153 } 1149 1154 } 1150 Free(&buffer);1151 1155 CheckAdjacencyFileAgainstMolecule_Finalize(File, CurrentBonds); 1152 1156 … … 1202 1206 BFS.AtomCount = AtomCount; 1203 1207 BFS.BondOrder = BondOrder; 1204 BFS.PredecessorList = Calloc<atom*> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: **PredecessorList");1205 BFS.ShortestPathList = Calloc<int> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ShortestPathList");1206 BFS.ColorList = Malloc<enum Shading> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ColorList");1208 BFS.PredecessorList = new atom*[AtomCount]; 1209 BFS.ShortestPathList = new int[AtomCount]; 1210 BFS.ColorList = new enum Shading[AtomCount]; 1207 1211 BFS.BFSStack = new StackClass<atom *> (AtomCount); 1208 1212 … … 1213 1217 // initialise each vertex as white with no predecessor, empty queue, color Root lightgray 1214 1218 for (int i = AtomCount; i--;) { 1219 BFS.PredecessorList[i] = NULL; 1215 1220 BFS.ShortestPathList[i] = -1; 1216 1221 if ((AddedAtomList != NULL) && (AddedAtomList[i] != NULL)) // mark already present atoms (i.e. Root and maybe others) as visited … … 1219 1224 BFS.ColorList[i] = white; 1220 1225 } 1221 //BFS.ShortestPathList[Root->nr] = 0; // is set due to Calloc()1226 //BFS.ShortestPathList[Root->nr] = 0; // done by Calloc 1222 1227 } 1223 1228 ; … … 1225 1230 void BreadthFirstSearchAdd_Free(struct BFSAccounting &BFS) 1226 1231 { 1227 Free(&BFS.PredecessorList);1228 Free(&BFS.ShortestPathList);1229 Free(&BFS.ColorList);1232 delete[](BFS.PredecessorList); 1233 delete[](BFS.ShortestPathList); 1234 delete[](BFS.ColorList); 1230 1235 delete (BFS.BFSStack); 1231 1236 BFS.AtomCount = 0; … … 1366 1371 { 1367 1372 // reset parent list 1368 ParentList = Calloc<atom*> (AtomCount, "molecule::BuildInducedSubgraph_Init: **ParentList"); 1373 ParentList = new atom*[AtomCount]; 1374 for (int i=0;i<AtomCount;i++) 1375 ParentList[i] = NULL; 1369 1376 DoLog(3) && (Log() << Verbose(3) << "Resetting ParentList." << endl); 1370 1377 } … … 1388 1395 void BuildInducedSubgraph_Finalize(atom **&ParentList) 1389 1396 { 1390 Free(&ParentList);1397 delete[](ParentList); 1391 1398 } 1392 1399 ;
Note:
See TracChangeset
for help on using the changeset viewer.