23 idx_t nads=0, *vadids, *vadwgts;
42 for (pid=0; pid<
nparts; pid++) {
49 rinfo =
graph->ckrinfo;
50 for (nads=0, ii=pptr[pid]; ii<pptr[pid+1]; ii++) {
54 if (rinfo[
i].ed > 0) {
58 for (
j=0;
j<nnbrs;
j++) {
60 if (vadwgts[
other] == 0)
61 vadids[nads++] =
other;
74 rinfo =
graph->vkrinfo;
75 for (nads=0, ii=pptr[pid]; ii<pptr[pid+1]; ii++) {
79 if (rinfo[
i].ned > 0) {
83 for (
j=0;
j<nnbrs;
j++) {
85 if (vadwgts[
other] == 0)
86 vadids[nads++] =
other;
99 if (ctrl->
maxnads[pid] < nads) {
102 "ComputeSubDomainGraph: adids[pid]");
104 "ComputeSubDomainGraph: adids[pid]");
107 ctrl->
nads[pid] = nads;
108 for (
j=0;
j<nads;
j++) {
109 ctrl->
adids[pid][
j] = vadids[
j];
110 ctrl->
adwgts[pid][
j] = vadwgts[vadids[
j]];
112 vadwgts[vadids[
j]] = 0;
142 for (
i=0;
i<2;
i++) {
143 nads = ctrl->
nads[u];
145 for (
j=0;
j<nads;
j++) {
155 if (ctrl->
maxnads[u] == nads) {
158 "IncreaseEdgeSubDomainGraph: adids[pid]");
160 "IncreaseEdgeSubDomainGraph: adids[pid]");
163 ctrl->
adwgts[u][nads] = ewgt;
165 if (r_maxndoms !=
NULL && nads > *r_maxndoms) {
166 printf(
"You just increased the maxndoms: %"PRIDX" %"PRIDX"\n",
178 if (r_maxndoms !=
NULL && nads+1 == *r_maxndoms)
182 ctrl->
nads[u] = nads;
194 idx_t i, ii,
j, k,
ncon,
nparts, scheme, pid_from, pid_to, me,
other, nvtxs,
195 total,
max, avg, totalout, nind=0, ncand=0, ncand2, target, target2,
199 *mypmat, *otherpmat, *kpmat, *
ind;
200 idx_t *nads, **adids, **adwgts;
209 nvtxs =
graph->nvtxs;
217 pwgts =
graph->pwgts;
268 printf(
"Adjacent Subdomain Stats: Total: %3"PRIDX", "
272 if (
max < badfactor*avg)
278 if (nads[
i] >= avg + (
max-avg)/2)
284 totalout =
isum(nads[me], adwgts[me], 1);
286 for (ncand2=0,
i=0;
i<nads[me];
i++) {
287 mypmat[adids[me][
i]] = adwgts[me][
i];
290 if (2*nads[me]*adwgts[me][
i] < totalout) {
291 cand2[ncand2].val = adids[me][
i];
292 cand2[ncand2++].key = adwgts[me][
i];
298 me, nads[me], totalout));
310 target = target2 = -1;
311 for (scheme=0; scheme<2; scheme++) {
328 for (nind=0, ii=pptr[pid_from]; ii<pptr[pid_from+1]; ii++) {
342 for (ncand=0, ii=0; ii<nind; ii++) {
349 if (otherpmat[k] == 0)
350 cand[ncand++].val = k;
355 for (
i=0;
i<ncand;
i++) {
356 cand[
i].key = otherpmat[cand[
i].val];
369 for (
i=0;
i<ncand;
i++) {
378 for (
j=0;
j<nads[k];
j++)
379 kpmat[adids[k][
j]] = adwgts[k][
j];
385 if (otherpmat[
j] > 0 && kpmat[
j] == 0 && nads[
j]+1 >= nads[me])
393 if (otherpmat[
j] > 0 && kpmat[
j] == 0)
398 printf(
"\t\tto=%"PRIDX", nadd=%"PRIDX", %"PRIDX"\n", k, nadd, nads[k]));
400 if (nads[k]+nadd < nads[me]) {
401 if (target2 == -1 || nads[target2]+bestnadd > nads[k]+nadd ||
402 (nads[target2]+bestnadd == nads[k]+nadd && bestnadd > nadd)) {
413 for (
j=0;
j<nads[k];
j++)
414 kpmat[adids[k][
j]] = 0;
422 for (
i=0;
i<ncand;
i++)
423 otherpmat[cand[
i].val] = 0;
425 if (target == -1 && target2 != -1)
430 printf(
"\t\tScheme: %"PRIDX". Moving to %"PRIDX"\n", scheme, target));
441 for (
i=0;
i<nads[me];
i++)
442 mypmat[adids[me][
i]] = 0;
480 idx_t i, ii,
j, jj, k,
l, nvtxs, nbnd, from, me;
485 nvtxs =
graph->nvtxs;
491 bndptr =
graph->bndptr;
492 bndind =
graph->bndind;
500 myrinfo =
graph->ckrinfo+
i;
501 if (myrinfo->
inbr == -1) {
508 for (k=0; k<myrinfo->
nnbrs; k++) {
509 if (mynbrs[k].pid == to)
512 if (k == myrinfo->
nnbrs) {
524 graph->mincut -= mynbrs[k].
ed-myrinfo->
id;
537 myrinfo =
graph->ckrinfo+ii;
544 if (me != from && me != to) {
564 idx_t i, ii,
j, jj, k,
l, nvtxs, from, me,
other, xgain, ewgt;
569 nvtxs =
graph->nvtxs;
579 myrinfo =
graph->vkrinfo+
i;
580 if (myrinfo->
inbr == -1) {
586 xgain = (myrinfo->
nid == 0 && myrinfo->
ned > 0 ?
vsize[
i] : 0);
592 for (k=0; k<myrinfo->
nnbrs; k++) {
593 if (mynbrs[k].pid == to)
597 if (k == myrinfo->
nnbrs) {
600 if (myrinfo->
nid > 0)
607 orinfo =
graph->vkrinfo+ii;
616 if (onbrs[
l].pid == to)
625 if (onbrs[
l].pid == to)
633 if (onbrs[
l].pid == from && onbrs[
l].ned == 1) {
640 graph->minvol -= xgain;
645 graph->minvol -= (xgain + mynbrs[k].
gv);
647 ewgt = myrinfo->
nid-mynbrs[k].
ned;
661 if (me != from && me != to) {
688 nvtxs =
graph->nvtxs;
695 for (
i=0;
i<nvtxs;
i++) {
724 printf(
"Total adjacent subdomains: %"PRIDX", Max: %"PRIDX"\n", total,
max);