26 int sigrval=0, renumber=0, ptype;
57 nparts, tpwgts,
NULL, options, objval, npart);
60 nparts, tpwgts,
NULL, options, objval, npart);
95 int sigrval=0, renumber=0, ptype;
120 rstatus =
METIS_MeshToDual(ne, nn, eptr, eind, ncommon, &pnumflag, &xadj, &adjncy);
127 nparts, tpwgts,
NULL, options, objval, epart);
130 nparts, tpwgts,
NULL, options, objval, epart);
137 nptr =
ismalloc(*nn+1, 0,
"METIS_PartMeshDual: nptr");
138 nind =
imalloc(eptr[*ne],
"METIS_PartMeshDual: nind");
140 for (i=0; i<*ne; i++) {
141 for (j=eptr[i]; j<eptr[i+1]; j++)
146 for (i=0; i<*ne; i++) {
147 for (j=eptr[i]; j<eptr[i+1]; j++)
148 nind[nptr[eind[j]]++] = i;
183 idx_t nnbrs, *pwgts, *nbrdom, *nbrwgt, *nbrmrk;
186 pwgts =
ismalloc(nparts, 0,
"InduceRowPartFromColumnPart: pwgts");
187 nbrdom =
ismalloc(nparts, 0,
"InduceRowPartFromColumnPart: nbrdom");
188 nbrwgt =
ismalloc(nparts, 0,
"InduceRowPartFromColumnPart: nbrwgt");
189 nbrmrk =
ismalloc(nparts, -1,
"InduceRowPartFromColumnPart: nbrmrk");
191 iset(nrows, -1, rpart);
194 itpwgts =
imalloc(nparts,
"InduceRowPartFromColumnPart: itpwgts");
195 if (tpwgts ==
NULL) {
196 iset(nparts, 1+nrows/nparts, itpwgts);
200 itpwgts[i] = 1+nrows*tpwgts[i];
205 for (i=0; i<nrows; i++) {
206 if (rowptr[i+1]-rowptr[i] == 0) {
211 me = cpart[rowind[rowptr[
i]]];
212 for (j=rowptr[i]+1; j<rowptr[i+1]; j++) {
213 if (cpart[rowind[j]] != me)
216 if (j == rowptr[i+1]) {
224 for (i=0; i<nrows; i++) {
225 if (rpart[i] == -1) {
226 for (nnbrs=0, j=rowptr[i]; j<rowptr[i+1]; j++) {
227 me = cpart[rowind[
j]];
228 if (nbrmrk[me] == -1) {
231 nbrmrk[me] = nnbrs++;
234 nbrwgt[nbrmrk[me]]++;
240 rpart[
i] = nbrdom[
iargmax(nnbrs, nbrwgt)];
243 if (pwgts[rpart[i]] > itpwgts[rpart[i]]) {
244 for (j=0; j<nnbrs; j++) {
245 if (pwgts[nbrdom[j]] < itpwgts[nbrdom[j]] ||
246 pwgts[nbrdom[j]]-itpwgts[nbrdom[j]] < pwgts[rpart[i]]-itpwgts[rpart[i]]) {
247 rpart[
i] = nbrdom[
j];
255 for (j=0; j<nnbrs; j++)
256 nbrmrk[nbrdom[j]] = -1;
260 gk_free((
void **)&pwgts, &nbrdom, &nbrwgt, &nbrmrk, &itpwgts,
LTERM);
idx_t idx_t idx_t idx_t * vwgt
idx_t idx_t idx_t idx_t * ncommon
int METIS_Free(void *ptr)
idx_t idx_t idx_t idx_t idx_t idx_t real_t idx_t idx_t idx_t * epart
idx_t idx_t idx_t idx_t idx_t idx_t idx_t * nparts
idx_t idx_t idx_t idx_t idx_t * vsize
#define ASSERT(expression)
int METIS_PartMeshDual(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, idx_t *vwgt, idx_t *vsize, idx_t *ncommon, idx_t *nparts, real_t *tpwgts, idx_t *options, idx_t *objval, idx_t *epart, idx_t *npart)
int METIS_PartMeshNodal(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, idx_t *vwgt, idx_t *vsize, idx_t *nparts, real_t *tpwgts, idx_t *options, idx_t *objval, idx_t *epart, idx_t *npart)
idx_t idx_t idx_t idx_t idx_t idx_t real_t idx_t idx_t * objval
#define ChangeMesh2FNumbering2
idx_t idx_t idx_t idx_t idx_t idx_t real_t idx_t idx_t idx_t idx_t * npart
void gk_malloc_cleanup(int showstats)
int METIS_MeshToNodal(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, idx_t *numflag, idx_t **r_xadj, idx_t **r_adjncy)
idx_t idx_t idx_t idx_t idx_t idx_t idx_t real_t * tpwgts
#define SHIFTCSR(i, n, a)
void gk_free(void **ptr1,...)
void InduceRowPartFromColumnPart(idx_t nrows, idx_t *rowptr, idx_t *rowind, idx_t *rpart, idx_t *cpart, idx_t nparts, real_t *tpwgts)
int METIS_PartGraphKway(idx_t *nvtxs, idx_t *ncon, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, idx_t *vsize, idx_t *adjwgt, idx_t *nparts, real_t *tpwgts, real_t *ubvec, idx_t *options, idx_t *objval, idx_t *part)
idx_t idx_t idx_t * adjncy
int METIS_PartGraphRecursive(idx_t *nvtxs, idx_t *ncon, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, idx_t *vsize, idx_t *adjwgt, idx_t *nparts, real_t *tpwgts, real_t *ubvec, idx_t *options, idx_t *objval, idx_t *part)
Recursive partitioning routine.
int METIS_MeshToDual(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, idx_t *ncommon, idx_t *numflag, idx_t **r_xadj, idx_t **r_adjncy)
#define ChangeMesh2CNumbering
#define GETOPTION(options, idx, defval)