本文整理汇总了C++中idxwspacefree函数的典型用法代码示例。如果您正苦于以下问题:C++ idxwspacefree函数的具体用法?C++ idxwspacefree怎么用?C++ idxwspacefree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了idxwspacefree函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Random_KWayEdgeRefine
//.........这里部分代码省略.........
continue;
/*=====================================================================
* If we got here, we can now move the vertex from 'from' to 'to'
*======================================================================*/
graph->mincut -= myedegrees[k].ed-myrinfo->id;
IFSET(ctrl->dbglvl, DBG_MOVEINFO, printf("\t\tMoving %6d to %3d. Gain: %4d. Cut: %6d\n", i, to, myedegrees[k].ed-myrinfo->id, graph->mincut));
/* Update where, weight, and ID/ED information of the vertex you moved */
where[i] = to;
INC_DEC(pwgts[to], pwgts[from], vwgt);
myrinfo->ed += myrinfo->id-myedegrees[k].ed;
SWAP(myrinfo->id, myedegrees[k].ed, j);
if (myedegrees[k].ed == 0)
myedegrees[k] = myedegrees[--myrinfo->ndegrees];
else
myedegrees[k].pid = from;
if (myrinfo->ed-myrinfo->id < 0)
BNDDelete(nbnd, bndind, bndptr, i);
/* Update the degrees of adjacent vertices */
for (j=xadj[i]; j<xadj[i+1]; j++) {
ii = adjncy[j];
me = where[ii];
myrinfo = graph->rinfo+ii;
if (myrinfo->edegrees == NULL) {
myrinfo->edegrees = ctrl->wspace.edegrees+ctrl->wspace.cdegree;
ctrl->wspace.cdegree += xadj[ii+1]-xadj[ii];
}
myedegrees = myrinfo->edegrees;
ASSERT(CheckRInfo(myrinfo));
if (me == from) {
INC_DEC(myrinfo->ed, myrinfo->id, adjwgt[j]);
if (myrinfo->ed-myrinfo->id >= 0 && bndptr[ii] == -1)
BNDInsert(nbnd, bndind, bndptr, ii);
}
else if (me == to) {
INC_DEC(myrinfo->id, myrinfo->ed, adjwgt[j]);
if (myrinfo->ed-myrinfo->id < 0 && bndptr[ii] != -1)
BNDDelete(nbnd, bndind, bndptr, ii);
}
/* Remove contribution from the .ed of 'from' */
if (me != from) {
for (k=0; k<myrinfo->ndegrees; k++) {
if (myedegrees[k].pid == from) {
if (myedegrees[k].ed == adjwgt[j])
myedegrees[k] = myedegrees[--myrinfo->ndegrees];
else
myedegrees[k].ed -= adjwgt[j];
break;
}
}
}
/* Add contribution to the .ed of 'to' */
if (me != to) {
for (k=0; k<myrinfo->ndegrees; k++) {
if (myedegrees[k].pid == to) {
myedegrees[k].ed += adjwgt[j];
break;
}
}
if (k == myrinfo->ndegrees) {
myedegrees[myrinfo->ndegrees].pid = to;
myedegrees[myrinfo->ndegrees++].ed = adjwgt[j];
}
}
ASSERT(myrinfo->ndegrees <= xadj[ii+1]-xadj[ii]);
ASSERT(CheckRInfo(myrinfo));
}
nmoves++;
}
}
graph->nbnd = nbnd;
IFSET(ctrl->dbglvl, DBG_REFINE,
printf("\t[%6d %6d], Balance: %5.3f, Nb: %6d. Nmoves: %5d, Cut: %6d, Vol: %6d\n",
pwgts[idxamin(nparts, pwgts)], pwgts[idxamax(nparts, pwgts)],
1.0*nparts*pwgts[idxamax(nparts, pwgts)]/tvwgt, graph->nbnd, nmoves, graph->mincut, ComputeVolume(graph, where)));
if (graph->mincut == oldcut)
break;
}
idxwspacefree(ctrl, nparts);
idxwspacefree(ctrl, nparts);
idxwspacefree(ctrl, nparts);
idxwspacefree(ctrl, nvtxs);
}
开发者ID:davidheryanto,项目名称:sc14,代码行数:101,代码来源:kwayfm.c
示例2: ProjectVolKWayPartition
//.........这里部分代码省略.........
**************************************************************************/
void ProjectVolKWayPartition(CtrlType *ctrl, GraphType *graph, int nparts)
{
int i, j, k, nvtxs, me, other, istart, iend, ndegrees;
idxtype *xadj, *adjncy, *adjwgt, *adjwgtsum;
idxtype *cmap, *where;
idxtype *cwhere;
GraphType *cgraph;
VRInfoType *crinfo, *rinfo, *myrinfo;
VEDegreeType *myedegrees;
idxtype *htable;
cgraph = graph->coarser;
cwhere = cgraph->where;
crinfo = cgraph->vrinfo;
nvtxs = graph->nvtxs;
cmap = graph->cmap;
xadj = graph->xadj;
adjncy = graph->adjncy;
adjwgt = graph->adjwgt;
adjwgtsum = graph->adjwgtsum;
AllocateVolKWayPartitionMemory(ctrl, graph, nparts);
where = graph->where;
rinfo = graph->vrinfo;
/* Go through and project partition and compute id/ed for the nodes */
for (i=0; i<nvtxs; i++) {
k = cmap[i];
where[i] = cwhere[k];
cmap[i] = crinfo[k].ed; /* For optimization */
}
htable = idxset(nparts, -1, idxwspacemalloc(ctrl, nparts));
ctrl->wspace.cdegree = 0;
for (i=0; i<nvtxs; i++) {
me = where[i];
myrinfo = rinfo+i;
myrinfo->id = myrinfo->ed = myrinfo->nid = myrinfo->ndegrees = 0;
myrinfo->edegrees = NULL;
myrinfo->id = adjwgtsum[i];
myrinfo->nid = xadj[i+1]-xadj[i];
if (cmap[i] > 0) { /* If it is an interface node. Note cmap[i] = crinfo[cmap[i]].ed */
istart = xadj[i];
iend = xadj[i+1];
myedegrees = myrinfo->edegrees = ctrl->wspace.vedegrees+ctrl->wspace.cdegree;
ctrl->wspace.cdegree += iend-istart;
ndegrees = 0;
for (j=istart; j<iend; j++) {
other = where[adjncy[j]];
if (me != other) {
myrinfo->ed += adjwgt[j];
myrinfo->nid--;
if ((k = htable[other]) == -1) {
htable[other] = ndegrees;
myedegrees[ndegrees].gv = 0;
myedegrees[ndegrees].pid = other;
myedegrees[ndegrees].ed = adjwgt[j];
myedegrees[ndegrees++].ned = 1;
}
else {
myedegrees[k].ed += adjwgt[j];
myedegrees[k].ned++;
}
}
}
myrinfo->id -= myrinfo->ed;
/* Remove space for edegrees if it was interior */
if (myrinfo->ed == 0) {
myrinfo->edegrees = NULL;
ctrl->wspace.cdegree -= iend-istart;
}
else {
myrinfo->ndegrees = ndegrees;
for (j=0; j<ndegrees; j++)
htable[myedegrees[j].pid] = -1;
}
}
}
ComputeKWayVolGains(ctrl, graph, nparts);
idxcopy(nparts, cgraph->pwgts, graph->pwgts);
graph->mincut = cgraph->mincut;
FreeGraph(graph->coarser);
graph->coarser = NULL;
idxwspacefree(ctrl, nparts);
}
开发者ID:AIBluefisher,项目名称:GraphCluster,代码行数:101,代码来源:kwayvolrefine.c
示例3: Bnd2WayBalance
//.........这里部分代码省略.........
pwgts = graph->pwgts;
bndptr = graph->bndptr;
bndind = graph->bndind;
moved = idxwspacemalloc(ctrl, nvtxs);
perm = idxwspacemalloc(ctrl, nvtxs);
/* Determine from which domain you will be moving data */
mindiff = abs(tpwgts[0]-pwgts[0]);
from = (pwgts[0] < tpwgts[0] ? 1 : 0);
to = (from+1)%2;
IFSET(ctrl->dbglvl, DBG_REFINE,
printf("Partitions: [%6d %6d] T[%6d %6d], Nv-Nb[%6d %6d]. ICut: %6d [B]\n",
pwgts[0], pwgts[1], tpwgts[0], tpwgts[1], graph->nvtxs, graph->nbnd, graph->mincut));
tmp = graph->adjwgtsum[idxamax(nvtxs, graph->adjwgtsum)];
PQueueInit(ctrl, &parts, nvtxs, tmp);
idxset(nvtxs, -1, moved);
ASSERT(ComputeCut(graph, where) == graph->mincut);
ASSERT(CheckBnd(graph));
/* Insert the boundary nodes of the proper partition whose size is OK in the priority queue */
nbnd = graph->nbnd;
RandomPermute(nbnd, perm, 1);
for (ii=0; ii<nbnd; ii++) {
i = perm[ii];
ASSERT(ed[bndind[i]] > 0 || id[bndind[i]] == 0);
ASSERT(bndptr[bndind[i]] != -1);
if (where[bndind[i]] == from && vwgt[bndind[i]] <= mindiff)
PQueueInsert(&parts, bndind[i], ed[bndind[i]]-id[bndind[i]]);
}
mincut = graph->mincut;
for (nswaps=0; nswaps<nvtxs; nswaps++) {
if ((higain = PQueueGetMax(&parts)) == -1)
break;
ASSERT(bndptr[higain] != -1);
if (pwgts[to]+vwgt[higain] > tpwgts[to])
break;
mincut -= (ed[higain]-id[higain]);
INC_DEC(pwgts[to], pwgts[from], vwgt[higain]);
where[higain] = to;
moved[higain] = nswaps;
IFSET(ctrl->dbglvl, DBG_MOVEINFO,
printf("Moved %6d from %d. [%3d %3d] %5d [%4d %4d]\n", higain, from, ed[higain]-id[higain], vwgt[higain], mincut, pwgts[0], pwgts[1]));
/**************************************************************
* Update the id[i]/ed[i] values of the affected nodes
***************************************************************/
SWAP(id[higain], ed[higain], tmp);
if (ed[higain] == 0 && xadj[higain] < xadj[higain+1])
BNDDelete(nbnd, bndind, bndptr, higain);
for (j=xadj[higain]; j<xadj[higain+1]; j++) {
k = adjncy[j];
oldgain = ed[k]-id[k];
kwgt = (to == where[k] ? adjwgt[j] : -adjwgt[j]);
INC_DEC(id[k], ed[k], kwgt);
/* Update its boundary information and queue position */
if (bndptr[k] != -1) { /* If k was a boundary vertex */
if (ed[k] == 0) { /* Not a boundary vertex any more */
BNDDelete(nbnd, bndind, bndptr, k);
if (moved[k] == -1 && where[k] == from && vwgt[k] <= mindiff) /* Remove it if in the queues */
PQueueDelete(&parts, k, oldgain);
}
else { /* If it has not been moved, update its position in the queue */
if (moved[k] == -1 && where[k] == from && vwgt[k] <= mindiff)
PQueueUpdate(&parts, k, oldgain, ed[k]-id[k]);
}
}
else {
if (ed[k] > 0) { /* It will now become a boundary vertex */
BNDInsert(nbnd, bndind, bndptr, k);
if (moved[k] == -1 && where[k] == from && vwgt[k] <= mindiff)
PQueueInsert(&parts, k, ed[k]-id[k]);
}
}
}
}
IFSET(ctrl->dbglvl, DBG_REFINE,
printf("\tMinimum cut: %6d, PWGTS: [%6d %6d], NBND: %6d\n", mincut, pwgts[0], pwgts[1], nbnd));
graph->mincut = mincut;
graph->nbnd = nbnd;
PQueueFree(ctrl, &parts);
idxwspacefree(ctrl, nvtxs);
idxwspacefree(ctrl, nvtxs);
}
开发者ID:dwickeroth,项目名称:covise,代码行数:101,代码来源:balance.c
示例4: MCGreedy_KWayEdgeBalanceHorizontal
//.........这里部分代码省略.........
myrinfo = graph->rinfo+ii;
if (myrinfo->edegrees == NULL) {
myrinfo->edegrees = ctrl->wspace.edegrees+ctrl->wspace.cdegree;
ctrl->wspace.cdegree += xadj[ii+1]-xadj[ii];
}
myedegrees = myrinfo->edegrees;
ASSERT(CheckRInfo(myrinfo));
oldgain = (myrinfo->ed-myrinfo->id);
if (me == from) {
INC_DEC(myrinfo->ed, myrinfo->id, adjwgt[j]);
if (myrinfo->ed > 0 && bndptr[ii] == -1)
BNDInsert(nbnd, bndind, bndptr, ii);
}
else if (me == to) {
INC_DEC(myrinfo->id, myrinfo->ed, adjwgt[j]);
if (myrinfo->ed == 0 && bndptr[ii] != -1)
BNDDelete(nbnd, bndind, bndptr, ii);
}
/* Remove contribution from the .ed of 'from' */
if (me != from) {
for (k=0; k<myrinfo->ndegrees; k++) {
if (myedegrees[k].pid == from) {
if (myedegrees[k].ed == adjwgt[j])
myedegrees[k] = myedegrees[--myrinfo->ndegrees];
else
myedegrees[k].ed -= adjwgt[j];
break;
}
}
}
/* Add contribution to the .ed of 'to' */
if (me != to) {
for (k=0; k<myrinfo->ndegrees; k++) {
if (myedegrees[k].pid == to) {
myedegrees[k].ed += adjwgt[j];
break;
}
}
if (k == myrinfo->ndegrees) {
myedegrees[myrinfo->ndegrees].pid = to;
myedegrees[myrinfo->ndegrees++].ed = adjwgt[j];
}
}
/* Update the queue */
if (me == to || me == from) {
gain = myrinfo->ed-myrinfo->id;
if (moved[ii] == 2) {
if (myrinfo->ed > 0)
PQueueUpdate(&queue, ii, oldgain, gain);
else {
PQueueDelete(&queue, ii, oldgain);
moved[ii] = -1;
}
}
else if (moved[ii] == -1 && myrinfo->ed > 0) {
PQueueInsert(&queue, ii, gain);
moved[ii] = 2;
}
}
ASSERT(myrinfo->ndegrees <= xadj[ii+1]-xadj[ii]);
ASSERT(CheckRInfo(myrinfo));
}
nmoves++;
}
graph->nbnd = nbnd;
if (ctrl->dbglvl&DBG_REFINE) {
printf("\t [%5.4f %5.4f], Nb: %6d, Nmoves: %5d, Cut: %6d, LB: ",
npwgts[samin(ncon*nparts, npwgts)], npwgts[samax(ncon*nparts, npwgts)],
nbnd, nmoves, graph->mincut);
ComputeHKWayLoadImbalance(ncon, nparts, npwgts, tvec);
for (i=0; i<ncon; i++)
printf("%.3f ", tvec[i]);
printf("\n");
}
if (nmoves == 0)
break;
}
PQueueFree(ctrl, &queue);
fwspacefree(ctrl, ncon*nparts);
fwspacefree(ctrl, ncon*nparts);
idxwspacefree(ctrl, nvtxs);
idxwspacefree(ctrl, nvtxs);
}
开发者ID:dwickeroth,项目名称:covise,代码行数:101,代码来源:mkwayfmh.c
示例5: CreateCoarseGraph_NVW
//.........这里部分代码省略.........
u = match[v];
cvwgt[cnvtxs] = 1;
cadjwgtsum[cnvtxs] = adjwgtsum[v];
nedges = 0;
istart = xadj[v];
iend = xadj[v+1];
for (j=istart; j<iend; j++) {
k = auxadj[j];
kk = k&mask;
if ((m = htable[kk]) == -1) {
cadjncy[nedges] = k;
cadjwgt[nedges] = 1;
htable[kk] = nedges++;
}
else if (cadjncy[m] == k) {
cadjwgt[m]++;
}
else {
for (jj=0; jj<nedges; jj++) {
if (cadjncy[jj] == k) {
cadjwgt[jj]++;
break;
}
}
if (jj == nedges) {
cadjncy[nedges] = k;
cadjwgt[nedges++] = 1;
}
}
}
if (v != u) {
cvwgt[cnvtxs]++;
cadjwgtsum[cnvtxs] += adjwgtsum[u];
istart = xadj[u];
iend = xadj[u+1];
for (j=istart; j<iend; j++) {
k = auxadj[j];
kk = k&mask;
if ((m = htable[kk]) == -1) {
cadjncy[nedges] = k;
cadjwgt[nedges] = 1;
htable[kk] = nedges++;
}
else if (cadjncy[m] == k) {
cadjwgt[m]++;
}
else {
for (jj=0; jj<nedges; jj++) {
if (cadjncy[jj] == k) {
cadjwgt[jj]++;
break;
}
}
if (jj == nedges) {
cadjncy[nedges] = k;
cadjwgt[nedges++] = 1;
}
}
}
/* Remove the contracted adjacency weight */
jj = htable[cnvtxs&mask];
if (jj >= 0 && cadjncy[jj] != cnvtxs) {
for (jj=0; jj<nedges; jj++) {
if (cadjncy[jj] == cnvtxs)
break;
}
}
if (jj >= 0 && cadjncy[jj] == cnvtxs) { /* This 2nd check is needed for non-adjacent matchings */
cadjwgtsum[cnvtxs] -= cadjwgt[jj];
cadjncy[jj] = cadjncy[--nedges];
cadjwgt[jj] = cadjwgt[nedges];
}
}
ASSERTP(cadjwgtsum[cnvtxs] == idxsum(nedges, cadjwgt), ("%d %d %d %d %d\n", cnvtxs, cadjwgtsum[cnvtxs], idxsum(nedges, cadjwgt), adjwgtsum[u], adjwgtsum[v]));
for (j=0; j<nedges; j++)
htable[cadjncy[j]&mask] = -1; /* Zero out the htable */
htable[cnvtxs&mask] = -1;
cnedges += nedges;
cxadj[++cnvtxs] = cnedges;
cadjncy += nedges;
cadjwgt += nedges;
}
cgraph->nedges = cnedges;
ReAdjustMemory(graph, cgraph, 0);
IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->ContractTmr));
idxwspacefree(ctrl, mask+1);
}
开发者ID:SangitaSingh,项目名称:elmerfem,代码行数:101,代码来源:ccgraph.c
示例6: MocProjectKWayPartition
/*************************************************************************
* This function projects a partition, and at the same time computes the
* parameters for refinement.
**************************************************************************/
void MocProjectKWayPartition(CtrlType *ctrl, GraphType *graph, int nparts)
{
int i, j, k, nvtxs, nbnd, me, other, istart, iend, ndegrees;
idxtype *xadj, *adjncy, *adjwgt, *adjwgtsum;
idxtype *cmap, *where, *bndptr, *bndind;
idxtype *cwhere;
GraphType *cgraph;
RInfoType *crinfo, *rinfo, *myrinfo;
EDegreeType *myedegrees;
idxtype *htable;
cgraph = graph->coarser;
cwhere = cgraph->where;
crinfo = cgraph->rinfo;
nvtxs = graph->nvtxs;
cmap = graph->cmap;
xadj = graph->xadj;
adjncy = graph->adjncy;
adjwgt = graph->adjwgt;
adjwgtsum = graph->adjwgtsum;
MocAllocateKWayPartitionMemory(ctrl, graph, nparts);
where = graph->where;
rinfo = graph->rinfo;
bndind = graph->bndind;
bndptr = idxset(nvtxs, -1, graph->bndptr);
/* Go through and project partition and compute id/ed for the nodes */
for (i=0; i<nvtxs; i++) {
k = cmap[i];
where[i] = cwhere[k];
cmap[i] = crinfo[k].ed; /* For optimization */
}
htable = idxset(nparts, -1, idxwspacemalloc(ctrl, nparts));
ctrl->wspace.cdegree = 0;
for (nbnd=0, i=0; i<nvtxs; i++) {
me = where[i];
myrinfo = rinfo+i;
myrinfo->id = myrinfo->ed = myrinfo->ndegrees = 0;
myrinfo->edegrees = NULL;
myrinfo->id = adjwgtsum[i];
if (cmap[i] > 0) { /* If it is an interface node. Note cmap[i] = crinfo[cmap[i]].ed */
istart = xadj[i];
iend = xadj[i+1];
myedegrees = myrinfo->edegrees = ctrl->wspace.edegrees+ctrl->wspace.cdegree;
ctrl->wspace.cdegree += iend-istart;
ndegrees = 0;
for (j=istart; j<iend; j++) {
other = where[adjncy[j]];
if (me != other) {
myrinfo->ed += adjwgt[j];
if ((k = htable[other]) == -1) {
htable[other] = ndegrees;
myedegrees[ndegrees].pid = other;
myedegrees[ndegrees++].ed = adjwgt[j];
}
else {
myedegrees[k].ed += adjwgt[j];
}
}
}
myrinfo->id -= myrinfo->ed;
/* Remove space for edegrees if it was interior */
if (myrinfo->ed == 0) {
myrinfo->edegrees = NULL;
ctrl->wspace.cdegree -= iend-istart;
}
else {
if (myrinfo->ed-myrinfo->id >= 0)
BNDInsert(nbnd, bndind, bndptr, i);
myrinfo->ndegrees = ndegrees;
for (j=0; j<ndegrees; j++)
htable[myedegrees[j].pid] = -1;
}
}
}
scopy(graph->ncon*nparts, cgraph->npwgts, graph->npwgts);
graph->mincut = cgraph->mincut;
graph->nbnd = nbnd;
FreeGraph(graph->coarser);
graph->coarser = NULL;
idxwspacefree(ctrl, nparts);
//.........这里部分代码省略.........
开发者ID:BijanZarif,项目名称:oomph-lib,代码行数:101,代码来源:mkwayrefine.c
示例7: SplitGraphOrderCC
/*************************************************************************
* This function takes a graph and a bisection and splits it into two graphs.
* It relies on the fact that adjwgt is all set to 1.
**************************************************************************/
int SplitGraphOrderCC(CtrlType *ctrl, GraphType *graph, GraphType *sgraphs, int ncmps, idxtype *cptr, idxtype *cind)
{
int i, ii, iii, j, k, l, istart, iend, mypart, nvtxs, snvtxs, snedges;
idxtype *xadj, *vwgt, *adjncy, *adjwgt, *adjwgtsum, *label, *where, *bndptr, *bndind;
idxtype *sxadj, *svwgt, *sadjncy, *sadjwgt, *sadjwgtsum, *slabel;
idxtype *rename;
idxtype *auxadjncy, *auxadjwgt;
IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->SplitTmr));
nvtxs = graph->nvtxs;
xadj = graph->xadj;
vwgt = graph->vwgt;
adjncy = graph->adjncy;
adjwgt = graph->adjwgt;
adjwgtsum = graph->adjwgtsum;
label = graph->label;
where = graph->where;
bndptr = graph->bndptr;
bndind = graph->bndind;
ASSERT(bndptr != NULL);
/* Go and use bndptr to also mark the boundary nodes in the two partitions */
for (ii=0; ii<graph->nbnd; ii++) {
i = bndind[ii];
for (j=xadj[i]; j<xadj[i+1]; j++)
bndptr[adjncy[j]] = 1;
}
rename = idxwspacemalloc(ctrl, nvtxs);
/* Go and split the graph a component at a time */
for (iii=0; iii<ncmps; iii++) {
RandomPermute(cptr[iii+1]-cptr[iii], cind+cptr[iii], 0);
snvtxs = snedges = 0;
for (j=cptr[iii]; j<cptr[iii+1]; j++) {
i = cind[j];
rename[i] = snvtxs++;
snedges += xadj[i+1]-xadj[i];
}
SetUpSplitGraph(graph, sgraphs+iii, snvtxs, snedges);
sxadj = sgraphs[iii].xadj;
svwgt = sgraphs[iii].vwgt;
sadjwgtsum = sgraphs[iii].adjwgtsum;
sadjncy = sgraphs[iii].adjncy;
sadjwgt = sgraphs[iii].adjwgt;
slabel = sgraphs[iii].label;
snvtxs = snedges = sxadj[0] = 0;
for (ii=cptr[iii]; ii<cptr[iii+1]; ii++) {
i = cind[ii];
istart = xadj[i];
iend = xadj[i+1];
if (bndptr[i] == -1) { /* This is an interior vertex */
auxadjncy = sadjncy + snedges - istart;
auxadjwgt = sadjwgt + snedges - istart;
for(j=istart; j<iend; j++)
auxadjncy[j] = adjncy[j];
snedges += iend-istart;
}
else {
l = snedges;
for (j=istart; j<iend; j++) {
k = adjncy[j];
if (where[k] != 2)
sadjncy[l++] = k;
}
snedges = l;
}
svwgt[snvtxs] = vwgt[i];
sadjwgtsum[snvtxs] = snedges-sxadj[snvtxs];
slabel[snvtxs] = label[i];
sxadj[++snvtxs] = snedges;
}
idxset(snedges, 1, sadjwgt);
for (i=0; i<snedges; i++)
sadjncy[i] = rename[sadjncy[i]];
sgraphs[iii].nvtxs = snvtxs;
sgraphs[iii].nedges = snedges;
sgraphs[iii].ncon = 1;
if (snvtxs < MMDSWITCH)
sgraphs[iii].adjwgt = NULL; /* A marker to call MMD on the driver */
}
IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->SplitTmr));
idxwspacefree(ctrl, nvtxs);
return ncmps;
//.........这里部分代码省略.........
开发者ID:Shallouf,项目名称:Genius-TCAD-Open,代码行数:101,代码来源:ometis.c
示例8: FM_2WayNodeRefine_OneSided
//.........这里部分代码省略.........
***********************************************************/
for (j=xadj[higain]; j<xadj[higain+1]; j++) {
k = adjncy[j];
if (where[k] == 2) { /* For the in-separator vertices modify their edegree[to] */
rinfo[k].edegrees[to] += vwgt[higain];
}
else if (where[k] == other) { /* This vertex is pulled into the separator */
ASSERTP(bndptr[k] == -1, ("%d %d %d\n", k, bndptr[k], where[k]));
BNDInsert(nbnd, bndind, bndptr, k);
mind[nmind++] = k; /* Keep track for rollback */
where[k] = 2;
pwgts[other] -= vwgt[k];
edegrees = rinfo[k].edegrees;
edegrees[0] = edegrees[1] = 0;
for (jj=xadj[k]; jj<xadj[k+1]; jj++) {
kk = adjncy[jj];
if (where[kk] != 2)
edegrees[where[kk]] += vwgt[kk];
else {
oldgain = vwgt[kk]-rinfo[kk].edegrees[other];
rinfo[kk].edegrees[other] -= vwgt[k];
/* Since the moves are one-sided this vertex has not been moved yet */
PQueueUpdateUp(&parts, kk, oldgain, oldgain+vwgt[k]);
}
}
/* Insert the new vertex into the priority queue. Safe due to one-sided moves */
PQueueInsert(&parts, k, vwgt[k]-edegrees[other]);
}
}
mptr[nswaps+1] = nmind;
IFSET(ctrl->dbglvl, DBG_MOVEINFO,
printf("Moved %6d to %3d, Gain: %5d [%5d] \t[%5d %5d %5d] [%3d %2d]\n",
higain, to, (vwgt[higain]-rinfo[higain].edegrees[other]), vwgt[higain], pwgts[0], pwgts[1], pwgts[2], nswaps, limit));
}
/****************************************************************
* Roll back computation
*****************************************************************/
for (nswaps--; nswaps>mincutorder; nswaps--) {
higain = swaps[nswaps];
ASSERT(CheckNodePartitionParams(graph));
ASSERT(where[higain] == to);
INC_DEC(pwgts[2], pwgts[to], vwgt[higain]);
where[higain] = 2;
BNDInsert(nbnd, bndind, bndptr, higain);
edegrees = rinfo[higain].edegrees;
edegrees[0] = edegrees[1] = 0;
for (j=xadj[higain]; j<xadj[higain+1]; j++) {
k = adjncy[j];
if (where[k] == 2)
rinfo[k].edegrees[to] -= vwgt[higain];
else
edegrees[where[k]] += vwgt[k];
}
/* Push nodes out of the separator */
for (j=mptr[nswaps]; j<mptr[nswaps+1]; j++) {
k = mind[j];
ASSERT(where[k] == 2);
where[k] = other;
INC_DEC(pwgts[other], pwgts[2], vwgt[k]);
BNDDelete(nbnd, bndind, bndptr, k);
for (jj=xadj[k]; jj<xadj[k+1]; jj++) {
kk = adjncy[jj];
if (where[kk] == 2)
rinfo[kk].edegrees[other] += vwgt[k];
}
}
}
ASSERT(mincut == pwgts[2]);
IFSET(ctrl->dbglvl, DBG_REFINE,
printf("\tMinimum sep: %6d at %5d, PWGTS: [%6d %6d], NBND: %6d\n", mincut, mincutorder, pwgts[0], pwgts[1], nbnd));
graph->mincut = mincut;
graph->nbnd = nbnd;
if (pass%2 == 1 && (mincutorder == -1 || mincut >= initcut))
break;
}
PQueueFree(ctrl, &parts);
idxwspacefree(ctrl, nvtxs+1);
idxwspacefree(ctrl, nvtxs);
idxwspacefree(ctrl, nvtxs);
idxwspacefree(ctrl, nvtxs);
}
开发者ID:NickDaniil,项目名称:structured,代码行数:101,代码来源:sfm.c
示例9: FM_2WayNodeBalance
//.........这里部分代码省略.........
PQueueInit(ctrl, &parts, nvtxs, ComputeMaxNodeGain(nvtxs, xadj, adjncy, vwgt));
perm = idxwspacemalloc(ctrl, nvtxs);
moved = idxset(nvtxs, -1, idxwspacemalloc(ctrl, nvtxs));
IFSET(ctrl->dbglvl, DBG_REFINE,
printf("Partitions: [%6d %6d] Nv-Nb[%6d %6d]. ISep: %6d [B]\n", pwgts[0], pwgts[1], graph->nvtxs, graph->nbnd, graph->mincut));
nbnd = graph->nbnd;
RandomPermute(nbnd, perm, 1);
for (ii=0; ii<nbnd; ii++) {
i = bndind[perm[ii]];
ASSERT(where[i] == 2);
PQueueInsert(&parts, i, vwgt[i]-rinfo[i].edegrees[other]);
}
ASSERT(CheckNodeBnd(graph, nbnd));
ASSERT(CheckNodePartitionParams(graph));
/******************************************************
* Get into the FM loop
*******************************************************/
for (nswaps=0; nswaps<nvtxs; nswaps++) {
if ((higain = PQueueGetMax(&parts)) == -1)
break;
moved[higain] = 1;
if (pwgts[other] - rinfo[higain].edegrees[other] < (pwgts[0]+pwgts[1])/2)
continue;
#ifdef XXX
if (pwgts[other] - rinfo[higain].edegrees[other] < pwgts[to]+vwgt[higain])
break;
#endif
ASSERT(bndptr[higain] != -1);
pwgts[2] -= (vwgt[higain]-rinfo[higain].edegrees[other]);
BNDDelete(nbnd, bndind, bndptr, higain);
pwgts[to] += vwgt[higain];
where[higain] = to;
IFSET(ctrl->dbglvl, DBG_MOVEINFO,
printf("Moved %6d to %3d, Gain: %3d, \t[%5d %5d %5d]\n", higain, to, vwgt[higain]-rinfo[higain].edegrees[other], pwgts[0], pwgts[1], pwgts[2]));
/**********************************************************
* Update the degrees of the affected nodes
***********************************************************/
for (j=xadj[higain]; j<xadj[higain+1]; j++) {
k = adjncy[j];
if (where[k] == 2) { /* For the in-separator vertices modify their edegree[to] */
rinfo[k].edegrees[to] += vwgt[higain];
}
else if (where[k] == other) { /* This vertex is pulled into the separator */
ASSERTP(bndptr[k] == -1, ("%d %d %d\n", k, bndptr[k], where[k]));
BNDInsert(nbnd, bndind, bndptr, k);
where[k] = 2;
pwgts[other] -= vwgt[k];
edegrees = rinfo[k].edegrees;
edegrees[0] = edegrees[1] = 0;
for (jj=xadj[k]; jj<xadj[k+1]; jj++) {
kk = adjncy[jj];
if (where[kk] != 2)
edegrees[where[kk]] += vwgt[kk];
else {
ASSERT(bndptr[kk] != -1);
oldgain = vwgt[kk]-rinfo[kk].edegrees[other];
rinfo[kk].edegrees[other] -= vwgt[k];
if (moved[kk] == -1)
PQueueUpdateUp(&parts, kk, oldgain, oldgain+vwgt[k]);
}
}
/* Insert the new vertex into the priority queue */
PQueueInsert(&parts, k, vwgt[k]-edegrees[other]);
}
}
if (pwgts[to] > pwgts[other])
break;
}
IFSET(ctrl->dbglvl, DBG_REFINE,
printf("\tBalanced sep: %6d at %4d, PWGTS: [%6d %6d], NBND: %6d\n", pwgts[2], nswaps, pwgts[0], pwgts[1], nbnd));
graph->mincut = pwgts[2];
graph->nbnd = nbnd;
PQueueFree(ctrl, &parts);
idxwspacefree(ctrl, nvtxs);
idxwspacefree(ctrl, nvtxs);
}
开发者ID:NickDaniil,项目名称:structured,代码行数:101,代码来源:sfm.c
示例10: FM_2WayNodeRefineEqWgt
//.........这里部分代码省略.........
if (moved[k] == -1 || moved[k] == -(2+other))
PQueueUpdate(&parts[other], k, oldgain, oldgain-vwgt[higain]);
}
else if (where[k] == other) { /* This vertex is pulled into the separator */
ASSERTP(bndptr[k] == -1, ("%d %d %d\n", k, bndptr[k], where[k]));
BNDInsert(nbnd, bndind, bndptr, k);
mind[nmind++] = k; /* Keep track for rollback */
where[k] = 2;
pwgts[other] -= vwgt[k];
edegrees = rinfo[k].edegrees;
edegrees[0] = edegrees[1] = 0;
for (jj=xadj[k]; jj<xadj[k+1]; jj++) {
kk = adjncy[jj];
if (where[kk] != 2)
edegrees[where[kk]] += vwgt[kk];
else {
oldgain = vwgt[kk]-rinfo[kk].edegrees[other];
rinfo[kk].edegrees[other] -= vwgt[k];
if (moved[kk] == -1 || moved[kk] == -(2+to))
PQueueUpdate(&parts[to], kk, oldgain, oldgain+vwgt[k]);
}
}
/* Insert the new vertex into the priority queue. Only one side! */
if (moved[k] == -1) {
PQueueInsert(&parts[to], k, vwgt[k]-edegrees[other]);
moved[k] = -(2+to);
}
}
}
mptr[nswaps+1] = nmind;
IFSET(ctrl->dbglvl, DBG_MOVEINFO,
printf("Moved %6d to %3d, Gain: %5d [%5d] [%4d %4d] \t[%5d %5d %5d]\n", higain, to, g[to], g[other], vwgt[u[to]], vwgt[u[other]], pwgts[0], pwgts[1], pwgts[2]));
}
/****************************************************************
* Roll back computation
*****************************************************************/
for (nswaps--; nswaps>mincutorder; nswaps--) {
higain = swaps[nswaps];
ASSERT(CheckNodePartitionParams(graph));
to = where[higain];
other = (to+1)%2;
INC_DEC(pwgts[2], pwgts[to], vwgt[higain]);
where[higain] = 2;
BNDInsert(nbnd, bndind, bndptr, higain);
edegrees = rinfo[higain].edegrees;
edegrees[0] = edegrees[1] = 0;
for (j=xadj[higain]; j<xadj[higain+1]; j++) {
k = adjncy[j];
if (where[k] == 2)
rinfo[k].edegrees[to] -= vwgt[higain];
else
edegrees[where[k]] += vwgt[k];
}
/* Push nodes out of the separator */
for (j=mptr[nswaps]; j<mptr[nswaps+1]; j++) {
k = mind[j];
ASSERT(where[k] == 2);
where[k] = other;
INC_DEC(pwgts[other], pwgts[2], vwgt[k]);
BNDDelete(nbnd, bndind, bndptr, k);
for (jj=xadj[k]; jj<xadj[k+1]; jj++) {
kk = adjncy[jj];
if (where[kk] == 2)
rinfo[kk].edegrees[other] += vwgt[k];
}
}
}
ASSERT(mincut == pwgts[2]);
IFSET(ctrl->dbglvl, DBG_REFINE,
printf("\tMinimum sep: %6d at %5d, PWGTS: [%6d %6d], NBND: %6d\n", mincut, mincutorder, pwgts[0], pwgts[1], nbnd));
graph->mincut = mincut;
graph->nbnd = nbnd;
if (mincutorder == -1 || mincut >= initcut)
break;
}
PQueueFree(ctrl, &parts[0]);
PQueueFree(ctrl, &parts[1]);
idxwspacefree(ctrl, nvtxs+1);
idxwspacefree(ctrl, nvtxs);
idxwspacefree(ctrl, nvtxs);
idxwspacefree(ctrl, nvtxs);
idxwspacefree(ctrl, nvtxs);
}
开发者ID:NickDaniil,项目名称:structured,代码行数:101,代码来源:sfm.c
示例11: FM_2WayEdgeRefine
//.........这里部分代码省略.........
mincutorder = nswaps;
}
else if (nswaps-mincutorder > limit) { /* We hit the limit, undo last move */
newcut += (ed[higain]-id[higain]);
INC_DEC(pwgts[from], pwgts[to], vwgt[higain]);
break;
}
where[higain] = to;
moved[higain] = nswaps;
swaps[nswaps] = higain;
IFSET(ctrl->dbglvl, DBG_MOVEINFO,
printf("Moved %6d from %d. [%3d %3d] %5d [%4d %4d]\n", higain, from, ed[higain]-id[higain], vwgt[higain], newcut, pwgts[0], pwgts[1]));
/**************************************************************
* Update the id[i]/ed[i] values of the affected nodes
***************************************************************/
SWAP(id[higain], ed[higain], tmp);
if (ed[higain] == 0 && xadj[higain] < xadj[higain+1])
BNDDelete(nbnd, bndind, bndptr, higain);
for (j=xadj[higain]; j<xadj[higain+1]; j++) {
k = adjncy[j];
oldgain = ed[k]-id[k];
kwgt = (to == where[k] ? adjwgt[j] : -adjwgt[j]);
INC_DEC(id[k], ed[k], kwgt);
/* Update its boundary information and queue position */
if (bndptr[k] != -1) { /* If k was a boundary vertex */
if (ed[k] == 0) { /* Not a boundary vertex any more */
BNDDelete(nbnd, bndind, bndptr, k);
if (moved[k] == -1) /* Remove it if in the queues */
PQueueDelete(&parts[where[k]], k, oldgain);
}
else { /* If it has not been moved, update its position in the queue */
if (moved[k] == -1)
PQueueUpdate(&parts[where[k]], k, oldgain, ed[k]-id[k]);
}
}
else {
if (ed[k] > 0) { /* It will now become a boundary vertex */
BNDInsert(nbnd, bndind, bndptr, k);
if (moved[k] == -1)
PQueueInsert(&parts[where[k]], k, ed[k]-id[k]);
}
}
}
}
/****************************************************************
* Roll back computations
*****************************************************************/
for (i=0; i<nswaps; i++)
moved[swaps[i]] = -1; /* reset moved array */
for (nswaps--; nswaps>mincutorder; nswaps--) {
higain = swaps[nswaps];
to = where[higain] = (where[higain]+1)%2;
SWAP(id[higain], ed[higain], tmp);
if (ed[higain] == 0 && bndptr[higain] != -1 && xadj[higain] < xadj[higain+1])
BNDDelete(nbnd, bndind, bndptr, higain);
else if (ed[higain] > 0 && bndptr[higain] == -1)
BNDInsert(nbnd, bndind, bndptr, higain);
INC_DEC(pwgts[to], pwgts[(to+1)%2], vwgt[higain]);
for (j=xadj[higain]; j<xadj[higain+1]; j++) {
k = adjncy[j];
kwgt = (to == where[k] ? adjwgt[j] : -adjwgt[j]);
INC_DEC(id[k], ed[k], kwgt);
if (bndptr[k] != -1 && ed[k] == 0)
BNDDelete(nbnd, bndind, bndptr, k);
if (bndptr[k] == -1 && ed[k] > 0)
BNDInsert(nbnd, bndind, bndptr, k);
}
}
IFSET(ctrl->dbglvl, DBG_REFINE,
printf("\tMinimum cut: %6d at %5d, PWGTS: [%6d %6d], NBND: %6d\n", mincut, mincutorder, pwgts[0], pwgts[1], nbnd));
graph->mincut = mincut;
graph->nbnd = nbnd;
if (mincutorder == -1 || mincut == initcut)
break;
}
PQueueFree(ctrl, &parts[0]);
PQueueFree(ctrl, &parts[1]);
idxwspacefree(ctrl, nvtxs);
idxwspacefree(ctrl, nvtxs);
idxwspacefree(ctrl, nvtxs);
}
开发者ID:BrainSoft,项目名称:fieldtrip,代码行数:101,代码来源:fm.c
示例12: ConstructMinCoverSeparator0
//.........这里部分代码省略.........
nvtxs = graph->nvtxs;
xadj = graph->xadj;
adjncy = graph->adjncy;
nbnd = graph->nbnd;
bndind = graph->bndind;
bndptr = graph->bndptr;
where = graph->where;
vmap = idxwspacemalloc(ctrl, nvtxs);
ivmap = idxwspacemalloc(ctrl, nbnd);
cover = idxwspacemalloc(ctrl, nbnd);
if (nbnd > 0) {
/* Go through the boundary and determine the sizes of the bipartite graph */
bnvtxs[0] = bnvtxs[1] = bnedges[0] = bnedges[1] = 0;
for (i=0; i<nbnd; i++) {
j = bndind[i];
k = where[j];
if (xadj[j+1]-xadj[j] > 0) {
bnvtxs[k]++;
bnedges[k] += xadj[j+1]-xadj[j];
}
}
bnvtxs[2] = bnvtxs[0]+bnvtxs[1];
bnvtxs[1] = bnvtxs[0];
bnvtxs[0] = 0;
bxadj = idxmalloc(bnvtxs[2]+1, "ConstructMinCoverSeparator: bxadj");
badjncy = idxmalloc(bnedges[0]+bnedges[1]+1, "ConstructMinCoverSeparator: badjncy");
/* Construct the ivmap and vmap */
ASSERT(idxset(nvtxs, -1, vmap) == vmap);
for (i=0; i<nbnd; i++) {
j = bndind[i];
k = where[j];
if (xadj[j+1]-xadj[j] > 0) {
vmap[j] = bnvtxs[k];
ivmap[bnvtxs[k]++] = j;
}
}
/* OK, go through and put the vertices of each part starting from 0 */
bnvtxs[1] = bnvtxs[0];
bnvtxs[0] = 0;
bxadj[0] = l = 0;
for (k=0; k<2; k++) {
for (ii=0; ii<nbnd; ii++) {
i = bndind[ii];
if (where[i] == k && xadj[i] < xadj[i+1]) {
for (j=xadj[i]; j<xadj[i+1]; j++) {
jj = adjncy[j];
if (where[jj] != k) {
ASSERT(bndptr[jj] != -1);
ASSERTP(vmap[jj] != -1, ("%d %d %d\n", jj, vmap[jj], graph->bndptr[jj]));
badjncy[l++] = vmap[jj];
}
}
bxadj[++bnvtxs[k]] = l;
}
}
}
ASSERT(l <= bnedges[0]+bnedges[1]);
MinCover(bxadj, badjncy, bnvtxs[0], bnvtxs[1], cover, &csize);
IFSET(ctrl->dbglvl, DBG_SEPINFO,
printf("Nvtxs: %6d, [%5d %5d], Cut: %6d, SS: [%6d %6d], Cover: %6d\n", nvtxs, graph->pwgts[0], graph->pwgts[1], graph->mincut, bnvtxs[0], bnvtxs[1]-bnvtxs[0], csize));
for (i=0; i<csize; i++) {
j = ivmap[cover[i]];
where[j] = 2;
}
GKfree(&bxadj, &badjncy, LTERM);
for (i=0; i<nbnd; i++)
bndptr[bndind[i]] = -1;
for (nbnd=i=0; i<nvtxs; i++) {
if (where[i] == 2) {
bndind[nbnd] = i;
bndptr[i] = nbnd++;
}
}
}
else {
IFSET(ctrl->dbglvl, DBG_SEPINFO,
printf("Nvtxs: %6d, [%5d %5d], Cut: %6d, SS: [%6d %6d], Cover: %6d\n", nvtxs, graph->pwgts[0], graph->pwgts[1], graph->mincut, 0, 0, 0));
}
idxwspacefree(ctrl, nvtxs);
idxwspacefree(ctrl, graph->nbnd);
idxwspacefree(ctrl, graph->nbnd);
graph->nbnd = nbnd;
ASSERT(IsSeparable(graph));
}
开发者ID:Nasrollah,项目名称:phasta,代码行数:101,代码来源:separator.c
示例13: Greedy_KWayEdgeBalance
//.........这里部分代码省略.........
if (myrinfo->ed == 0)
BNDDelete(nbnd, bndind, bndptr, i);
/* Update the degrees of adjacent vertices */
for (j=xadj[i]; j<xadj[i+1]; j++) {
ii = adjncy[j];
me = where[ii];
myrinfo = graph->rinfo+ii;
if (myrinfo->edegrees == NULL) {
myrinfo->edegrees = ctrl->wspace.edegrees+ctrl->wspace.cdegree;
ctrl->wspace.cdegree += xadj[ii+1]-xadj[ii];
}
myedegrees = myrinfo->edegrees;
ASSERT(CheckRInfo(myrinfo));
oldgain = (myrinfo->ed-myrinfo->id);
if (me == from) {
INC_DEC(myrinfo->ed, myrinfo->id, adjwgt[j]);
if (myrinfo->ed > 0 && bndptr[ii] == -1)
BNDInsert(nbnd, bndind, bndptr, ii);
}
else if (me == to) {
INC_DEC(myrinfo->id, myrinfo->ed, adjwgt[j]);
if (myrinfo->ed == 0 && bndptr[ii] != -1)
BNDDelete(nbnd, bndind, bndptr, ii);
}
/* Remove contribution from the .ed of 'from' */
if (me != from) {
for (k=0; k<myrinfo->ndegrees; k++) {
if (myedegrees[k].pid == from) {
if (myedegrees[k].ed == adjwgt[j])
myedegrees[k] = myedegrees[--myrinfo->ndegrees];
else
myedegrees[k].ed -= adjwgt[j];
break;
}
}
}
/* Add contribution to the .ed of 'to' */
if (me != to) {
for (k=0; k<myrinfo->ndegrees; k++) {
if (myedegrees[k].pid == to) {
myedegrees[k].ed += adjwgt[j];
break;
}
}
if (k == myrinfo->ndegrees) {
myedegrees[myrinfo->ndegrees].pid = to;
myedegrees[myrinfo->ndegrees++].ed = adjwgt[j];
}
}
/* Update the queue */
if (me == to || me == from) {
gain = myrinfo->ed-myrinfo->id;
if (moved[ii] == 2) {
if (myrinfo->ed > 0)
PQueueUpdate(&queue, ii, oldgain, gain);
else {
PQueueDelete(&queue, ii, oldgain);
moved[ii] = -1;
}
}
else if (moved[ii] == -1 && myrinfo->ed > 0) {
PQueueInsert(&queue, ii, gain);
moved[ii] = 2;
}
}
ASSERT(myrinfo->ndegrees <= xadj[ii+1]-xadj[ii]);
ASSERT(CheckRInfo(myrinfo));
}
nmoves++;
}
graph->nbnd = nbnd;
IFSET(ctrl->dbglvl, DBG_REFINE,
printf("\t[%6d %6d], Balance: %5.3f, Nb: %6d. Nmoves: %5d, Cut: %6d\n",
pwgts[idxamin(nparts, pwgts)], pwgts[idxamax(nparts, pwgts)],
1.0*nparts*pwgts[idxamax(nparts, pwgts)]/tvwgt, graph->nbnd, nmoves, graph->mincut));
}
PQueueFree(ctrl, &queue);
idxwspacefree(ctrl, nparts);
idxwspacefree(ctrl, nparts);
idxwspacefree(ctrl, nparts);
idxwspacefree(ctrl, nvtxs);
idxwspacefree(ctrl, nvtxs);
}
开发者ID:davidheryanto,项目名称:sc14,代码行数:101,代码来源:kwayfm.c
示例14: SplitGraphPart
//.........这里部分代码省略.........
xadj = graph->xadj;
vwgt = graph->vwgt;
nvwgt = graph->nvwgt;
adjncy = graph->adjncy;
adjwgt = graph->adjwgt;
adjwgtsum = graph->adjwgtsum;
label = graph->label;
where = graph->where;
bndptr = graph->bndptr;
npwgts = graph->npwgts;
ASSERT(bndptr != NULL);
rename = idxwspacemalloc(ctrl, nvtxs);
snvtxs[0] = snvtxs[1] = snedges[0] = snedges[1] = 0;
for (i=0; i<nvtxs; i++) {
k = where[i];
rename[i] = snvtxs[k]++;
snedges[k] += xadj[i+1]-xadj[i];
}
SetUpSplitGraph(graph, lgraph, snvtxs[0], snedges[0]);
sxadj[0] = lgraph->xadj;
svwgt[0] = lgraph->vwgt;
snvwgt[0] = lgraph->nvwgt;
sadjwgtsum[0] = lgraph->adjwgtsum;
sadjncy[0] = lgraph->adjncy;
sadjwgt[0] = lgraph->adjwgt;
slabel[0] = lgraph->label;
SetUpSplitGraph(graph, rgraph, snvtxs[1], snedges[1]);
sxadj[1] = rgraph->xadj;
svwgt[1] = rgraph->vwgt;
snvwgt[1] = rgraph->nvwgt;
sadjwgtsum[1] = rgraph->adjwgtsum;
sadjncy[1] = rgraph->adjncy;
sadjwgt[1] = rgraph->adjwgt;
slabel[1] = rgraph->label;
snvtxs[0] = snvtxs[1] = snedges[0] = snedges[1] = 0;
sxadj[0][0] = sxadj[1][0] = 0;
for (i=0; i<nvtxs; i++) {
mypart = where[i];
sum = adjwgtsum[i];
istart = xadj[i];
iend = xadj[i+1];
if (bndptr[i] == -1) { /* This is an interior vertex */
auxadjncy = sadjncy[mypart] + snedges[mypart] - istart;
auxadjwgt = sadjwgt[mypart] + snedges[mypart] - istart;
for(j=istart; j<iend; j++) {
auxadjncy[j] = adjncy[j];
auxadjwgt[j] = adjwgt[j];
}
snedges[mypart] += iend-istart;
}
else {
auxadjncy = sadjncy[mypart];
auxadjwgt = sadjwgt[mypart];
l = snedges[mypart];
for (j=istart; j<iend; j++) {
k = adjncy[j];
if (where[k] == mypart) {
auxadjncy[l] = k;
auxadjwgt[l++] = adjwgt[j];
}
else {
sum -= adjwgt[j];
}
}
snedges[mypart] = l;
}
if (ncon == 1)
svwgt[mypart][snvtxs[mypart]] = vwgt[i];
else {
for (kk=0; kk<ncon; kk++)
snvwgt[mypart][snvtxs[mypart]*ncon+kk] = nvwgt[i*ncon+kk]/npwgts[mypart*ncon+kk];
}
sadjwgtsum[mypart][snvtxs[mypart]] = sum;
slabel[mypart][snvtxs[mypart]] = label[i];
sxadj[mypart][++snvtxs[mypart]] = snedges[mypart];
}
for (mypart=0; mypart<2; mypart++) {
iend = sxadj[mypart][snvtxs[mypart]];
auxadjncy = sadjncy[mypart];
for (i=0; i<iend; i++)
auxadjncy[i] = rename[auxadjncy[i]];
}
lgraph->nedges = snedges[0];
rgraph->nedges = snedges[1];
IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->SplitTmr));
idxwspacefree(ctrl, nvtxs);
|
请发表评论