Changeset 8bc524 for molecuilder/src/molecule_graph.cpp
- Timestamp:
- Nov 3, 2009, 12:37:55 PM (16 years ago)
- Children:
- 5f9f8b
- Parents:
- df0520
- git-author:
- Frederik Heber <heber@…> (11/03/09 08:41:45)
- git-committer:
- Frederik Heber <heber@…> (11/03/09 12:37:55)
- File:
-
- 1 edited
-
molecuilder/src/molecule_graph.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/molecule_graph.cpp
rdf0520 r8bc524 126 126 127 127 // create a list to map Tesselpoint::nr to atom * 128 AtomMap = Malloc<atom *> (AtomCount, "molecule::CreateAdjacencyList - **AtomCount");128 AtomMap = Calloc<atom *> (AtomCount, "molecule::CreateAdjacencyList - **AtomCount"); 129 129 Walker = start; 130 130 while (Walker->next != end) { … … 437 437 * \param *out output stream for debugging 438 438 * \param &DFS accounting structure to allocate 439 * \param AtomCount number of nodes in graph 440 * \param BondCount number of edges in graph 441 */ 442 void DepthFirstSearchAnalysis_Init(ofstream *out, struct DFSAccounting &DFS, int AtomCount, int BondCount) 443 { 444 DFS.AtomStack = new StackClass<atom *> (AtomCount); 439 * \param *mol molecule with AtomCount, BondCount and all atoms 440 */ 441 void DepthFirstSearchAnalysis_Init(ofstream *out, struct DFSAccounting &DFS, const molecule * const mol) 442 { 443 DFS.AtomStack = new StackClass<atom *> (mol->AtomCount); 445 444 DFS.CurrentGraphNr = 0; 446 445 DFS.ComponentNumber = 0; 447 446 DFS.BackStepping = false; 447 mol->ResetAllBondsToUnused(); 448 mol->SetAtomValueToValue(-1, &atom::GraphNr); 449 mol->ActOnAllAtoms(&atom::InitComponentNr); 450 DFS.BackEdgeStack->ClearStack(); 448 451 } 449 452 ; … … 456 459 { 457 460 delete (DFS.AtomStack); 461 // delete (DFS.BackEdgeStack); // DON'T free, see DepthFirstSearchAnalysis(), is returned as allocated 458 462 } 459 463 ; … … 479 483 480 484 *out << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl; 481 DepthFirstSearchAnalysis_Init(out, DFS, AtomCount, BondCount); 485 DepthFirstSearchAnalysis_Init(out, DFS, this); 486 482 487 DFS.Root = start->next; 483 484 ResetAllBondsToUnused();485 SetAtomValueToValue(-1, &atom::GraphNr);486 ActOnAllAtoms(&atom::InitComponentNr);487 DFS.BackEdgeStack->ClearStack();488 488 while (DFS.Root != end) { // if there any atoms at all 489 // (1) mark all edges unused, empty stack, set atom->GraphNr = 0for all489 // (1) mark all edges unused, empty stack, set atom->GraphNr = -1 for all 490 490 DFS.AtomStack->ClearStack(); 491 491 … … 602 602 { 603 603 BFS.AtomCount = AtomCount; 604 BFS.PredecessorList = Malloc<atom*> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: **PredecessorList");604 BFS.PredecessorList = Calloc<atom*> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: **PredecessorList"); 605 605 BFS.ShortestPathList = Malloc<int> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ShortestPathList"); 606 BFS.ColorList = Malloc<enum Shading> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ColorList");606 BFS.ColorList = Calloc<enum Shading> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ColorList"); 607 607 BFS.BFSStack = new StackClass<atom *> (AtomCount); 608 608 609 for (int i = AtomCount; i--;) { 610 BFS.PredecessorList[i] = NULL; 609 for (int i = AtomCount; i--;) 611 610 BFS.ShortestPathList[i] = -1; 612 BFS.ColorList[i] = white;613 }614 611 }; 615 612 … … 1002 999 1003 1000 // allocate storage structure 1004 CurrentBonds = Malloc<int> (8, "molecule::CheckAdjacencyFileAgainstMolecule - CurrentBonds"); // contains parsed bonds of current atom1001 CurrentBonds = Calloc<int> (8, "molecule::CheckAdjacencyFileAgainstMolecule - CurrentBonds"); // contains parsed bonds of current atom 1005 1002 return true; 1006 1003 } … … 1137 1134 BFS.AtomCount = AtomCount; 1138 1135 BFS.BondOrder = BondOrder; 1139 BFS.PredecessorList = Malloc<atom*> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: **PredecessorList");1140 BFS.ShortestPathList = Malloc<int> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ShortestPathList");1136 BFS.PredecessorList = Calloc<atom*> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: **PredecessorList"); 1137 BFS.ShortestPathList = Calloc<int> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ShortestPathList"); 1141 1138 BFS.ColorList = Malloc<enum Shading> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ColorList"); 1142 1139 BFS.BFSStack = new StackClass<atom *> (AtomCount); … … 1148 1145 // initialise each vertex as white with no predecessor, empty queue, color Root lightgray 1149 1146 for (int i = AtomCount; i--;) { 1150 BFS.PredecessorList[i] = NULL;1151 1147 BFS.ShortestPathList[i] = -1; 1152 1148 if ((AddedAtomList != NULL) && (AddedAtomList[i] != NULL)) // mark already present atoms (i.e. Root and maybe others) as visited … … 1155 1151 BFS.ColorList[i] = white; 1156 1152 } 1157 BFS.ShortestPathList[Root->nr] = 0;1153 //BFS.ShortestPathList[Root->nr] = 0; //is set due to Calloc() 1158 1154 } 1159 1155 ; … … 1302 1298 { 1303 1299 // reset parent list 1304 ParentList = Malloc<atom*> (AtomCount, "molecule::BuildInducedSubgraph_Init: **ParentList");1300 ParentList = Calloc<atom*> (AtomCount, "molecule::BuildInducedSubgraph_Init: **ParentList"); 1305 1301 *out << Verbose(3) << "Resetting ParentList." << endl; 1306 for (int i = AtomCount; i--;)1307 ParentList[i] = NULL;1308 1302 } 1309 1303 ;
Note:
See TracChangeset
for help on using the changeset viewer.
