Debian Codegraph @

extern/metis/libmetis/ometis.c

raw
1 /*
2 * Copyright 1997, Regents of the University of Minnesota
3 *
4 * ometis.c
5 *
6 * This file contains the top level routines for the multilevel recursive
7 * bisection algorithm PMETIS.
8 *
9 * Started 7/24/97
10 * George
11 *
12 * $Id: ometis.c 10513 2011-07-07 22:06:03Z karypis $
13 *
14 */
15
16 #include "metislib.h"
17
18
19 /*************************************************************************/
20 /*! This function is the entry point for the multilevel nested dissection
21 ordering code. At each bisection, a node-separator is computed using
22 a node-based refinement approach.
23
24 \param nvtxs is the number of vertices in the graph.
25 \param xadj is of length nvtxs+1 marking the start of the adjancy
26 list of each vertex in adjncy.
27 \param adjncy stores the adjacency lists of the vertices. The adjnacy
28 list of a vertex should not contain the vertex itself.
29 \param vwgt is an array of size nvtxs storing the weight of each
30 vertex. If vwgt is NULL, then the vertices are considered
31 to have unit weight.
32 \param numflag is either 0 or 1 indicating that the numbering of
33 the vertices starts from 0 or 1, respectively.
34 \param options is an array of size METIS_NOPTIONS used to pass
35 various options impacting the of the algorithm. A NULL
36 value indicates use of default options.
37 \param perm is an array of size nvtxs such that if A and A' are
38 the original and permuted matrices, then A'[i] = A[perm[i]].
39 \param iperm is an array of size nvtxs such that if A and A' are
40 the original and permuted matrices, then A[i] = A'[iperm[i]].
41 */
42 /*************************************************************************/
43 int Highs_METIS_NodeND(idx_t *nvtxs, const idx_t *xadj, const idx_t *adjncy, idx_t *vwgt,
44 idx_t *options, idx_t *perm, idx_t *iperm)
45 {
46 idx_t i, ii, j, l, nnvtxs=0;
47 graph_t *graph=NULL;
48 ctrl_t *ctrl;
49 idx_t *cptr, *cind, *piperm;
50
51 /* set up the run time parameters */
52 ctrl = SetupCtrl(METIS_OP_OMETIS, options, 1, 3, NULL, NULL);
53 if (!ctrl) {
54 return METIS_ERROR_INPUT;
55 }
56
57 /* prune the dense columns */
58 if (ctrl->pfactor > 0.0) {
59 piperm = imalloc(*nvtxs);
60
61 graph = PruneGraph(ctrl, *nvtxs, xadj, adjncy, vwgt, piperm, ctrl->pfactor);
62 if (graph == NULL) {
63 /* if there was no prunning, cleanup the pfactor */
64 gk_free((void **)&piperm);
65 ctrl->pfactor = 0.0;
66 }
67 else {
68 nnvtxs = graph->nvtxs;
69 ctrl->compress = 0; /* disable compression if prunning took place */
70 }
71 }
72
73 /* compress the graph; note that compression only happens if not prunning
74 has taken place. */
75 if (ctrl->compress) {
76 cptr = imalloc(*nvtxs+1);
77 cind = imalloc(*nvtxs);
78
79 graph = CompressGraph(ctrl, *nvtxs, xadj, adjncy, vwgt, cptr, cind);
80 if (graph == NULL) {
81 /* if there was no compression, cleanup the compress flag */
82 gk_free((void **)&cptr);
83 gk_free((void**)&cind);
84 ctrl->compress = 0;
85 }
86 else {
87 nnvtxs = graph->nvtxs;
88 ctrl->cfactor = 1.0*(*nvtxs)/nnvtxs;
89 if (ctrl->cfactor > 1.5 && ctrl->nseps == 1)
90 ctrl->nseps = 2;
91 //ctrl->nseps = (idx_t)(ctrl->cfactor*ctrl->nseps);
92 }
93 }
94
95 /* if no prunning and no compression, setup the graph in the normal way. */
96 if (ctrl->pfactor == 0.0 && ctrl->compress == 0)
97 graph = SetupGraph(ctrl, *nvtxs, 1, xadj, adjncy, vwgt, NULL, NULL);
98
99
100 /* allocate workspace memory */
101 AllocateWorkSpace(ctrl, graph);
102
103 /* do the nested dissection ordering */
104 if (ctrl->ccorder)
105 MlevelNestedDissectionCC(ctrl, graph, iperm, graph->nvtxs);
106 else
107 MlevelNestedDissection(ctrl, graph, iperm, graph->nvtxs);
108
109
110 if (ctrl->pfactor > 0.0) { /* Order any prunned vertices */
111 icopy(nnvtxs, iperm, perm); /* Use perm as an auxiliary array */
112 for (i=0; i<nnvtxs; i++)
113 iperm[piperm[i]] = perm[i];
114 for (i=nnvtxs; i<*nvtxs; i++)
115 iperm[piperm[i]] = i;
116
117 gk_free((void **)&piperm);
118 }
119 else if (ctrl->compress) { /* Uncompress the ordering */
120 /* construct perm from iperm */
121 for (i=0; i<nnvtxs; i++)
122 perm[iperm[i]] = i;
123 for (l=ii=0; ii<nnvtxs; ii++) {
124 i = perm[ii];
125 for (j=cptr[i]; j<cptr[i+1]; j++)
126 iperm[cind[j]] = l++;
127 }
128
129 gk_free((void **)&cptr);
130 gk_free((void**)&cind);
131 }
132
133 for (i=0; i<*nvtxs; i++)
134 perm[iperm[i]] = i;
135
136 /* clean up */
137 FreeCtrl(&ctrl);
138
139 return METIS_OK;
140 }
141
142
143 /*************************************************************************/
144 /*! This is the driver for the recursive tri-section of a graph into the
145 left, separator, and right partitions. The graphs correspond to the
146 left and right parts are further tri-sected in a recursive fashion.
147 The nodes in the separator are ordered at the end of the left & right
148 nodes.
149 */
150 /*************************************************************************/
151 void MlevelNestedDissection(ctrl_t *ctrl, graph_t *graph, idx_t *order,
152 idx_t lastvtx)
153 {
154 idx_t i, j, nvtxs, nbnd;
155 idx_t *label, *bndind;
156 graph_t *lgraph, *rgraph;
157
158 nvtxs = graph->nvtxs;
159
160 MlevelNodeBisectionMultiple(ctrl, graph);
161
162 IFSET(ctrl->dbglvl, METIS_DBG_SEPINFO,
163 HIGHS_ORDERING_PRINT("Nvtxs: %6"PRIDX", [%6"PRIDX" %6"PRIDX" %6"PRIDX"]\n",
164 graph->nvtxs, graph->pwgts[0], graph->pwgts[1], graph->pwgts[2]));
165
166
167 /* Order the nodes in the separator */
168 nbnd = graph->nbnd;
169 bndind = graph->bndind;
170 label = graph->label;
171 for (i=0; i<nbnd; i++)
172 order[label[bndind[i]]] = --lastvtx;
173
174 SplitGraphOrder(ctrl, graph, &lgraph, &rgraph);
175
176 /* Free the memory of the top level graph */
177 FreeGraph(&graph);
178
179 /* Recurse on lgraph first, as its lastvtx depends on rgraph->nvtxs, which
180 will not be defined upon return from MlevelNestedDissection. */
181 if (lgraph->nvtxs > MMDSWITCH && lgraph->nedges > 0)
182 MlevelNestedDissection(ctrl, lgraph, order, lastvtx-rgraph->nvtxs);
183 else {
184 MMDOrder(ctrl, lgraph, order, lastvtx-rgraph->nvtxs);
185 FreeGraph(&lgraph);
186 }
187 if (rgraph->nvtxs > MMDSWITCH && rgraph->nedges > 0)
188 MlevelNestedDissection(ctrl, rgraph, order, lastvtx);
189 else {
190 MMDOrder(ctrl, rgraph, order, lastvtx);
191 FreeGraph(&rgraph);
192 }
193 }
194
195
196 /*************************************************************************/
197 /*! This routine is similar to its non 'CC' counterpart. The difference is
198 that after each tri-section, the connected components of the original
199 graph that result after removing the separator vertises are ordered
200 independently (i.e., this may lead to more than just the left and
201 the right subgraphs).
202 */
203 /*************************************************************************/
204 void MlevelNestedDissectionCC(ctrl_t *ctrl, graph_t *graph, idx_t *order,
205 idx_t lastvtx)
206 {
207 idx_t i, j, nvtxs, nbnd, ncmps, rnvtxs, snvtxs;
208 idx_t *label, *bndind;
209 idx_t *cptr, *cind;
210 graph_t **sgraphs;
211
212 nvtxs = graph->nvtxs;
213
214 MlevelNodeBisectionMultiple(ctrl, graph);
215
216 IFSET(ctrl->dbglvl, METIS_DBG_SEPINFO,
217 HIGHS_ORDERING_PRINT("Nvtxs: %6"PRIDX", [%6"PRIDX" %6"PRIDX" %6"PRIDX"]\n",
218 graph->nvtxs, graph->pwgts[0], graph->pwgts[1], graph->pwgts[2]));
219
220 /* Order the nodes in the separator */
221 nbnd = graph->nbnd;
222 bndind = graph->bndind;
223 label = graph->label;
224 for (i=0; i<nbnd; i++)
225 order[label[bndind[i]]] = --lastvtx;
226
227 WCOREPUSH;
228 cptr = iwspacemalloc(ctrl, nvtxs+1);
229 cind = iwspacemalloc(ctrl, nvtxs);
230 ncmps = FindSepInducedComponents(ctrl, graph, cptr, cind);
231
232 if (ctrl->dbglvl&METIS_DBG_INFO) {
233 if (ncmps > 2)
234 HIGHS_ORDERING_PRINT(" Bisection resulted in %"PRIDX" connected components\n", ncmps);
235 }
236
237 sgraphs = SplitGraphOrderCC(ctrl, graph, ncmps, cptr, cind);
238
239 WCOREPOP;
240
241 /* Free the memory of the top level graph */
242 FreeGraph(&graph);
243
244 /* Go and process the subgraphs */
245 for (rnvtxs=i=0; i<ncmps; i++) {
246 /* Save the number of vertices in sgraphs[i] because sgraphs[i] is freed
247 inside MlevelNestedDissectionCC, and as such it will be undefined. */
248 snvtxs = sgraphs[i]->nvtxs;
249
250 if (sgraphs[i]->nvtxs > MMDSWITCH && sgraphs[i]->nedges > 0) {
251 MlevelNestedDissectionCC(ctrl, sgraphs[i], order, lastvtx-rnvtxs);
252 }
253 else {
254 MMDOrder(ctrl, sgraphs[i], order, lastvtx-rnvtxs);
255 FreeGraph(&sgraphs[i]);
256 }
257 rnvtxs += snvtxs;
258 }
259
260 gk_free((void **)&sgraphs);
261 }
262
263
264 /*************************************************************************/
265 /*! This function performs multilevel node bisection (i.e., tri-section).
266 It performs multiple bisections and selects the best. */
267 /*************************************************************************/
268 void MlevelNodeBisectionMultiple(ctrl_t *ctrl, graph_t *graph)
269 {
270 idx_t i, mincut;
271 idx_t *bestwhere;
272
273 /* if the graph is small, just find a single vertex separator */
274 if (ctrl->nseps == 1 || graph->nvtxs < (ctrl->compress ? 1000 : 2000)) {
275 MlevelNodeBisectionL2(ctrl, graph, LARGENIPARTS);
276 return;
277 }
278
279 WCOREPUSH;
280
281 bestwhere = iwspacemalloc(ctrl, graph->nvtxs);
282
283 mincut = graph->tvwgt[0];
284 for (i=0; i<ctrl->nseps; i++) {
285 MlevelNodeBisectionL2(ctrl, graph, LARGENIPARTS);
286
287 if (i == 0 || graph->mincut < mincut) {
288 mincut = graph->mincut;
289 if (i < ctrl->nseps-1)
290 icopy(graph->nvtxs, graph->where, bestwhere);
291 }
292
293 if (mincut == 0)
294 break;
295
296 if (i < ctrl->nseps-1)
297 FreeRData(graph);
298 }
299
300 if (mincut != graph->mincut) {
301 icopy(graph->nvtxs, bestwhere, graph->where);
302 Compute2WayNodePartitionParams(ctrl, graph);
303 }
304
305 WCOREPOP;
306 }
307
308
309 /*************************************************************************/
310 /*! This function performs multilevel node bisection (i.e., tri-section).
311 It performs multiple bisections and selects the best. */
312 /*************************************************************************/
313 void MlevelNodeBisectionL2(ctrl_t *ctrl, graph_t *graph, idx_t niparts)
314 {
315 idx_t i, mincut, nruns=5;
316 graph_t *cgraph;
317 idx_t *bestwhere;
318
319 /* if the graph is small, just find a single vertex separator */
320 if (graph->nvtxs < 5000) {
321 MlevelNodeBisectionL1(ctrl, graph, niparts);
322 return;
323 }
324
325 WCOREPUSH;
326
327 ctrl->CoarsenTo = gk_max(100, graph->nvtxs/30);
328
329 cgraph = CoarsenGraphNlevels(ctrl, graph, 4);
330
331 bestwhere = iwspacemalloc(ctrl, cgraph->nvtxs);
332
333 mincut = graph->tvwgt[0];
334 for (i=0; i<nruns; i++) {
335 MlevelNodeBisectionL1(ctrl, cgraph, 0.7*niparts);
336
337 if (i == 0 || cgraph->mincut < mincut) {
338 mincut = cgraph->mincut;
339 if (i < nruns-1)
340 icopy(cgraph->nvtxs, cgraph->where, bestwhere);
341 }
342
343 if (mincut == 0)
344 break;
345
346 if (i < nruns-1)
347 FreeRData(cgraph);
348 }
349
350 if (mincut != cgraph->mincut)
351 icopy(cgraph->nvtxs, bestwhere, cgraph->where);
352
353 WCOREPOP;
354
355 Refine2WayNode(ctrl, graph, cgraph);
356
357 }
358
359
360 /*************************************************************************/
361 /*! The top-level routine of the actual multilevel node bisection */
362 /*************************************************************************/
363 void MlevelNodeBisectionL1(ctrl_t *ctrl, graph_t *graph, idx_t niparts)
364 {
365 graph_t *cgraph;
366
367 ctrl->CoarsenTo = graph->nvtxs/8;
368 if (ctrl->CoarsenTo > 100)
369 ctrl->CoarsenTo = 100;
370 else if (ctrl->CoarsenTo < 40)
371 ctrl->CoarsenTo = 40;
372
373 cgraph = CoarsenGraph(ctrl, graph);
374
375 niparts = gk_max(1, (cgraph->nvtxs <= ctrl->CoarsenTo ? niparts/2: niparts));
376 /*niparts = (cgraph->nvtxs <= ctrl->CoarsenTo ? SMALLNIPARTS : LARGENIPARTS);*/
377 InitSeparator(ctrl, cgraph, niparts);
378
379 Refine2WayNode(ctrl, graph, cgraph);
380 }
381
382
383 /*************************************************************************/
384 /*! This function takes a graph and a tri-section (left, right, separator)
385 and splits it into two graphs.
386
387 This function relies on the fact that adjwgt is all equal to 1.
388 */
389 /*************************************************************************/
390 void SplitGraphOrder(ctrl_t *ctrl, graph_t *graph, graph_t **r_lgraph,
391 graph_t **r_rgraph)
392 {
393 idx_t i, ii, j, k, l, istart, iend, mypart, nvtxs, snvtxs[3], snedges[3];
394 const idx_t *xadj, *adjncy;
395 idx_t *vwgt, *adjwgt, *label, *where, *bndptr, *bndind;
396 idx_t *sxadj[2], *svwgt[2], *sadjncy[2], *sadjwgt[2], *slabel[2];
397 idx_t *rename;
398 idx_t *auxadjncy;
399 graph_t *lgraph, *rgraph;
400
401 WCOREPUSH;
402
403 nvtxs = graph->nvtxs;
404 xadj = graph->xadj_orig ? graph->xadj_orig : graph->xadj;
405 vwgt = graph->vwgt;
406 adjncy = graph->adjncy_orig ? graph->adjncy_orig : graph->adjncy;
407 adjwgt = graph->adjwgt;
408 label = graph->label;
409 where = graph->where;
410 bndptr = graph->bndptr;
411 bndind = graph->bndind;
412
413 rename = iwspacemalloc(ctrl, nvtxs);
414
415 snvtxs[0] = snvtxs[1] = snvtxs[2] = snedges[0] = snedges[1] = snedges[2] = 0;
416 for (i=0; i<nvtxs; i++) {
417 k = where[i];
418 rename[i] = snvtxs[k]++;
419 snedges[k] += xadj[i+1]-xadj[i];
420 }
421
422 lgraph = SetupSplitGraph(graph, snvtxs[0], snedges[0]);
423 sxadj[0] = lgraph->xadj;
424 svwgt[0] = lgraph->vwgt;
425 sadjncy[0] = lgraph->adjncy;
426 sadjwgt[0] = lgraph->adjwgt;
427 slabel[0] = lgraph->label;
428
429 rgraph = SetupSplitGraph(graph, snvtxs[1], snedges[1]);
430 sxadj[1] = rgraph->xadj;
431 svwgt[1] = rgraph->vwgt;
432 sadjncy[1] = rgraph->adjncy;
433 sadjwgt[1] = rgraph->adjwgt;
434 slabel[1] = rgraph->label;
435
436 /* Go and use bndptr to also mark the boundary nodes in the two partitions */
437 for (ii=0; ii<graph->nbnd; ii++) {
438 i = bndind[ii];
439 for (j=xadj[i]; j<xadj[i+1]; j++)
440 bndptr[adjncy[j]] = 1;
441 }
442
443 snvtxs[0] = snvtxs[1] = snedges[0] = snedges[1] = 0;
444 sxadj[0][0] = sxadj[1][0] = 0;
445 for (i=0; i<nvtxs; i++) {
446 if ((mypart = where[i]) == 2)
447 continue;
448
449 istart = xadj[i];
450 iend = xadj[i+1];
451 if (bndptr[i] == -1) { /* This is an interior vertex */
452 auxadjncy = sadjncy[mypart] + snedges[mypart] - istart;
453 for(j=istart; j<iend; j++)
454 auxadjncy[j] = adjncy[j];
455 snedges[mypart] += iend-istart;
456 }
457 else {
458 auxadjncy = sadjncy[mypart];
459 l = snedges[mypart];
460 for (j=istart; j<iend; j++) {
461 k = adjncy[j];
462 if (where[k] == mypart)
463 auxadjncy[l++] = k;
464 }
465 snedges[mypart] = l;
466 }
467
468 svwgt[mypart][snvtxs[mypart]] = vwgt[i];
469 slabel[mypart][snvtxs[mypart]] = label[i];
470 sxadj[mypart][++snvtxs[mypart]] = snedges[mypart];
471 }
472
473 for (mypart=0; mypart<2; mypart++) {
474 iend = snedges[mypart];
475 iset(iend, 1, sadjwgt[mypart]);
476
477 auxadjncy = sadjncy[mypart];
478 for (i=0; i<iend; i++)
479 auxadjncy[i] = rename[auxadjncy[i]];
480 }
481
482 lgraph->nvtxs = snvtxs[0];
483 lgraph->nedges = snedges[0];
484 rgraph->nvtxs = snvtxs[1];
485 rgraph->nedges = snedges[1];
486
487 SetupGraph_tvwgt(lgraph);
488 SetupGraph_tvwgt(rgraph);
489
490 *r_lgraph = lgraph;
491 *r_rgraph = rgraph;
492
493 WCOREPOP;
494 }
495
496
497 /*************************************************************************/
498 /*! This function takes a graph and generates a set of graphs, each of
499 which is a connected component in the original graph.
500
501 This function relies on the fact that adjwgt is all equal to 1.
502
503 \param ctrl stores run state info.
504 \param graph is the graph to be split.
505 \param ncmps is the number of connected components.
506 \param cptr is an array of size ncmps+1 that marks the start and end
507 locations of the vertices in cind that make up the respective
508 components (i.e., cptr, cind is in CSR format).
509 \param cind is an array of size equal to the number of vertices in
510 the original graph and stores the vertices that belong to each
511 connected component.
512
513 \returns an array of subgraphs corresponding to the extracted subgraphs.
514 */
515 /*************************************************************************/
516 graph_t **SplitGraphOrderCC(ctrl_t *ctrl, graph_t *graph, idx_t ncmps,
517 idx_t *cptr, idx_t *cind)
518 {
519 idx_t i, ii, iii, j, k, l, istart, iend, mypart, nvtxs, snvtxs, snedges;
520 const idx_t *xadj, *adjncy;
521 idx_t *vwgt, *adjwgt, *label, *where, *bndptr, *bndind;
522 idx_t *sxadj, *svwgt, *sadjncy, *sadjwgt, *slabel;
523 idx_t *rename;
524 idx_t *auxadjncy;
525 graph_t **sgraphs;
526
527 WCOREPUSH;
528
529 nvtxs = graph->nvtxs;
530 xadj = graph->xadj_orig ? graph->xadj_orig : graph->xadj;
531 vwgt = graph->vwgt;
532 adjncy = graph->adjncy_orig ? graph->adjncy_orig : graph->adjncy;
533 adjwgt = graph->adjwgt;
534 label = graph->label;
535 where = graph->where;
536 bndptr = graph->bndptr;
537 bndind = graph->bndind;
538
539 /* Go and use bndptr to also mark the boundary nodes in the two partitions */
540 for (ii=0; ii<graph->nbnd; ii++) {
541 i = bndind[ii];
542 for (j=xadj[i]; j<xadj[i+1]; j++)
543 bndptr[adjncy[j]] = 1;
544 }
545
546 rename = iwspacemalloc(ctrl, nvtxs);
547
548 sgraphs = (graph_t **)malloc(sizeof(graph_t *)*ncmps);
549
550 /* Go and split the graph a component at a time */
551 for (iii=0; iii<ncmps; iii++) {
552 irandArrayPermute(cptr[iii+1]-cptr[iii], cind+cptr[iii], cptr[iii+1]-cptr[iii], 0, &ctrl->rng_state);
553 snvtxs = snedges = 0;
554 for (j=cptr[iii]; j<cptr[iii+1]; j++) {
555 i = cind[j];
556 rename[i] = snvtxs++;
557 snedges += xadj[i+1]-xadj[i];
558 }
559
560 sgraphs[iii] = SetupSplitGraph(graph, snvtxs, snedges);
561
562 sxadj = sgraphs[iii]->xadj;
563 svwgt = sgraphs[iii]->vwgt;
564 sadjncy = sgraphs[iii]->adjncy;
565 sadjwgt = sgraphs[iii]->adjwgt;
566 slabel = sgraphs[iii]->label;
567
568 snvtxs = snedges = sxadj[0] = 0;
569 for (ii=cptr[iii]; ii<cptr[iii+1]; ii++) {
570 i = cind[ii];
571
572 istart = xadj[i];
573 iend = xadj[i+1];
574 if (bndptr[i] == -1) { /* This is an interior vertex */
575 auxadjncy = sadjncy + snedges - istart;
576 for(j=istart; j<iend; j++)
577 auxadjncy[j] = adjncy[j];
578 snedges += iend-istart;
579 }
580 else {
581 l = snedges;
582 for (j=istart; j<iend; j++) {
583 k = adjncy[j];
584 if (where[k] != 2)
585 sadjncy[l++] = k;
586 }
587 snedges = l;
588 }
589
590 svwgt[snvtxs] = vwgt[i];
591 slabel[snvtxs] = label[i];
592 sxadj[++snvtxs] = snedges;
593 }
594
595 iset(snedges, 1, sadjwgt);
596 for (i=0; i<snedges; i++)
597 sadjncy[i] = rename[sadjncy[i]];
598
599 sgraphs[iii]->nvtxs = snvtxs;
600 sgraphs[iii]->nedges = snedges;
601
602 SetupGraph_tvwgt(sgraphs[iii]);
603 }
604
605 WCOREPOP;
606
607 return sgraphs;
608 }
609
610
611 /*************************************************************************/
612 /*! This function uses MMD to order the graph. The vertices are numbered
613 from lastvtx downwards. */
614 /*************************************************************************/
615 void MMDOrder(ctrl_t *ctrl, graph_t *graph, idx_t *order, idx_t lastvtx)
616 {
617 idx_t i, j, k, nvtxs, nofsub, firstvtx;
618 idx_t *xadj, *adjncy, *label;
619 idx_t *perm, *iperm, *head, *qsize, *list, *marker;
620
621 WCOREPUSH;
622
623 nvtxs = graph->nvtxs;
624 xadj = graph->xadj;
625 adjncy = graph->adjncy;
626
627 /* Relabel the vertices so that it starts from 1 */
628 k = xadj[nvtxs];
629 for (i=0; i<k; i++)
630 adjncy[i]++;
631 for (i=0; i<nvtxs+1; i++)
632 xadj[i]++;
633
634 perm = iwspacemalloc(ctrl, nvtxs+5);
635 iperm = iwspacemalloc(ctrl, nvtxs+5);
636 head = iwspacemalloc(ctrl, nvtxs+5);
637 qsize = iwspacemalloc(ctrl, nvtxs+5);
638 list = iwspacemalloc(ctrl, nvtxs+5);
639 marker = iwspacemalloc(ctrl, nvtxs+5);
640
641 genmmd(nvtxs, xadj, adjncy, iperm, perm, 1, head, qsize, list, marker, IDX_MAX, &nofsub);
642
643 label = graph->label;
644 firstvtx = lastvtx-nvtxs;
645 for (i=0; i<nvtxs; i++)
646 order[label[i]] = firstvtx+iperm[i]-1;
647
648 /* Relabel the vertices so that it starts from 0 */
649 for (i=0; i<nvtxs+1; i++)
650 xadj[i]--;
651 k = xadj[nvtxs];
652 for (i=0; i<k; i++)
653 adjncy[i]--;
654
655 WCOREPOP;
656 }
657
658
659
660
661