| 172 | // returned.\\ |
| 173 | |
| 174 | Vertex * |
| 175 | ArrayGraph::getVertexPtr(int vertexTag) |
| 176 | { |
| 177 | // check first to see if it's in a nice position |
| 178 | if ((vertexTag >= 0) && (vertexTag < sizeVertices) && |
| 179 | (theVertices[vertexTag] != 0) && |
| 180 | (theVertices[vertexTag]->getTag() == vertexTag)) { |
| 181 | |
| 182 | return theVertices[vertexTag]; |
| 183 | } |
| 184 | // it's not nicely positioned, we have to search |
| 185 | // through theVertices until we find it |
| 186 | |
| 187 | else |
| 188 | for (int i=0; i<sizeVertices; i++) |
| 189 | if ((theVertices[i] != 0) && |
| 190 | (theVertices[i]->getTag() == vertexTag)){ |
| 191 | |
| 192 | return theVertices[i]; |
| 193 | } |
| 194 | |
| 195 | // else the vertex is not there |
| 196 | |
| 197 | return 0; |
| 198 | } |
| 199 | |
| 200 | // int addEdge(int vertexTag, int otherVertexTag); |
| 201 | // Causes the Graph to add an edge {\em (vertexTag,otherVertexTag)} to |