void MoveGroupContigForCut(ctrl_t *ctrl, graph_t *graph, idx_t to, idx_t gid, idx_t *ptr, idx_t *ind) { idx_t i, ii, iii, j, jj, k, l, nvtxs, nbnd, from, me; idx_t *xadj, *adjncy, *adjwgt, *where, *bndptr, *bndind; ckrinfo_t *myrinfo; cnbr_t *mynbrs; nvtxs = graph->nvtxs; xadj = graph->xadj; adjncy = graph->adjncy; adjwgt = graph->adjwgt; where = graph->where; bndptr = graph->bndptr; bndind = graph->bndind; nbnd = graph->nbnd; for (iii = ptr[gid]; iii < ptr[gid + 1]; iii++) { i = ind[iii]; from = where[i]; myrinfo = graph->ckrinfo + i; if (myrinfo->inbr == -1) { myrinfo->inbr = cnbrpoolGetNext(ctrl, xadj[i + 1] - xadj[i] + 1); myrinfo->nnbrs = 0; } mynbrs = ctrl->cnbrpool + myrinfo->inbr; /* find the location of 'to' in myrinfo or create it if it is not there */ for (k = 0; k < myrinfo->nnbrs; k++) { if (mynbrs[k].pid == to) { break; } } if (k == myrinfo->nnbrs) { mynbrs[k].pid = to; mynbrs[k].ed = 0; myrinfo->nnbrs++; } graph->mincut -= mynbrs[k].ed - myrinfo->id; /* Update ID/ED and BND related information for the moved vertex */ iaxpy(graph->ncon, 1, graph->vwgt + i * graph->ncon, 1, graph->pwgts + to * graph->ncon, 1); iaxpy(graph->ncon, -1, graph->vwgt + i * graph->ncon, 1, graph->pwgts + from * graph->ncon, 1); UpdateMovedVertexInfoAndBND(i, from, k, to, myrinfo, mynbrs, where, nbnd, bndptr, bndind, BNDTYPE_REFINE); /* Update the degrees of adjacent vertices */ for (j = xadj[i]; j < xadj[i + 1]; j++) { ii = adjncy[j]; me = where[ii]; myrinfo = graph->ckrinfo + ii; UpdateAdjacentVertexInfoAndBND(ctrl, ii, xadj[ii + 1] - xadj[ii], me, from, to, myrinfo, adjwgt[j], nbnd, bndptr, bndind, BNDTYPE_REFINE); } ASSERT(CheckRInfo(ctrl, graph->ckrinfo + i)); } graph->nbnd = nbnd; }
void MoveGroupMinConnForCut(ctrl_t *ctrl, graph_t *graph, idx_t to, idx_t nind, idx_t *ind) { idx_t i, ii, j, jj, k, l, nvtxs, nbnd, from, me; idx_t *xadj, *adjncy, *adjwgt, *where, *bndptr, *bndind; ckrinfo_t *myrinfo; cnbr_t *mynbrs; nvtxs = graph->nvtxs; xadj = graph->xadj; adjncy = graph->adjncy; adjwgt = graph->adjwgt; where = graph->where; bndptr = graph->bndptr; bndind = graph->bndind; nbnd = graph->nbnd; while (--nind>=0) { i = ind[nind]; from = where[i]; myrinfo = graph->ckrinfo+i; if (myrinfo->inbr == -1) { myrinfo->inbr = cnbrpoolGetNext(ctrl, xadj[i+1]-xadj[i]+1); myrinfo->nnbrs = 0; } mynbrs = ctrl->cnbrpool + myrinfo->inbr; /* find the location of 'to' in myrinfo or create it if it is not there */ for (k=0; k<myrinfo->nnbrs; k++) { if (mynbrs[k].pid == to) break; } if (k == myrinfo->nnbrs) { ASSERT(k < xadj[i+1]-xadj[i]); mynbrs[k].pid = to; mynbrs[k].ed = 0; myrinfo->nnbrs++; } /* Update pwgts */ iaxpy(graph->ncon, 1, graph->vwgt+i*graph->ncon, 1, graph->pwgts+to*graph->ncon, 1); iaxpy(graph->ncon, -1, graph->vwgt+i*graph->ncon, 1, graph->pwgts+from*graph->ncon, 1); /* Update mincut */ graph->mincut -= mynbrs[k].ed-myrinfo->id; /* Update subdomain connectivity graph to reflect the move of 'i' */ UpdateEdgeSubDomainGraph(ctrl, from, to, myrinfo->id-mynbrs[k].ed, NULL); /* Update ID/ED and BND related information for the moved vertex */ UpdateMovedVertexInfoAndBND(i, from, k, to, myrinfo, mynbrs, where, nbnd, bndptr, bndind, BNDTYPE_REFINE); /* Update the degrees of adjacent vertices */ for (j=xadj[i]; j<xadj[i+1]; j++) { ii = adjncy[j]; me = where[ii]; myrinfo = graph->ckrinfo+ii; UpdateAdjacentVertexInfoAndBND(ctrl, ii, xadj[ii+1]-xadj[ii], me, from, to, myrinfo, adjwgt[j], nbnd, bndptr, bndind, BNDTYPE_REFINE); /* Update subdomain graph to reflect the move of 'i' for domains other than 'from' and 'to' */ if (me != from && me != to) { UpdateEdgeSubDomainGraph(ctrl, from, me, -adjwgt[j], NULL); UpdateEdgeSubDomainGraph(ctrl, to, me, adjwgt[j], NULL); } } } ASSERT(ComputeCut(graph, where) == graph->mincut); graph->nbnd = nbnd; }