| 197 | // vrtices are in. Returns -1 if options are not set, -2 if metis failed. |
| 198 | |
| 199 | int |
| 200 | Metis::partition(Graph &theGraph, int numPart) |
| 201 | { |
| 202 | // first we check that the options are valid |
| 203 | if (checkOptions() == false) |
| 204 | return -1; |
| 205 | |
| 206 | // now we get room for the data structures metis needs |
| 207 | |
| 208 | int numVertex = theGraph.getNumVertex(); |
| 209 | int numEdge = theGraph.getNumEdge(); |
| 210 | // opserr << " Metis::partition --- numVertex: " << numVertex << " numEdge: "<< numEdge << "\n"; |
| 211 | int *options = new int [5]; |
| 212 | int *partition = new int [numVertex + 1]; |
| 213 | int *xadj = new int [numVertex + 2]; |
| 214 | int *adjncy = new int [2 * numEdge]; |
| 215 | int *vwgts = 0; |
| 216 | int *ewgts = 0; |
| 217 | int numbering = 0; |
| 218 | int weightflag = 0; // no weights on our graphs yet |
| 219 | |
| 220 | if (START_VERTEX_NUM == 0) |
| 221 | numbering = 0; |
| 222 | else if (START_VERTEX_NUM == 1) |
| 223 | numbering = 1; |
| 224 | else { |
| 225 | opserr << "WARNING Metis::partition - No partitioning done"; |
| 226 | opserr << " vertex numbering must start at 0 or 1\n"; |
| 227 | return (-2); |
| 228 | } |
| 229 | int edgecut; |
| 230 | |
| 231 | if ((options == 0) || (partition == 0) || (xadj == 0) || (adjncy == 0)) { |
| 232 | opserr << "WARNING Metis::partition - No partitioning done"; |
| 233 | opserr << " as ran out of memory\n"; |
| 234 | return (-2); |
| 235 | } |
| 236 | |
| 237 | |
| 238 | // we build these data structures |
| 239 | |
| 240 | int indexEdge = 0; |
| 241 | xadj[0] = 0; |
| 242 | |
| 243 | Vertex *vertexPtr; |
| 244 | for (int vertex = 0; vertex < numVertex; vertex++) { |
| 245 | vertexPtr = theGraph.getVertexPtr(vertex + START_VERTEX_NUM); |
| 246 | |
| 247 | // check we don't have an invalid vertex numbering scheme |
| 248 | // if so WARNING message, clean up and return -2 |
| 249 | |
| 250 | if (vertexPtr == 0) { |
| 251 | opserr << "WARNING Metis::partition - No partitioning done"; |
| 252 | opserr << " Metis requires consecutive Vertex Numbering\n"; |
| 253 | |
| 254 | delete [] options; |
| 255 | delete [] partition; |
| 256 | delete [] xadj; |
nothing calls this directly
no test coverage detected