本文整理汇总了C++中idxcopy函数的典型用法代码示例。如果您正苦于以下问题:C++ idxcopy函数的具体用法?C++ idxcopy怎么用?C++ idxcopy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了idxcopy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: METIS_NodeRefine
void METIS_NodeRefine(int nvtxs, idxtype *xadj, idxtype *vwgt, idxtype *adjncy,
idxtype *adjwgt, idxtype *where, idxtype *hmarker, float ubfactor)
{
GraphType *graph;
CtrlType ctrl;
ctrl.dbglvl = ONMETIS_DBGLVL;
ctrl.optype = OP_ONMETIS;
graph = CreateGraph();
SetUpGraph(graph, OP_ONMETIS, nvtxs, 1, xadj, adjncy, vwgt, adjwgt, 3);
AllocateWorkSpace(&ctrl, graph, 2);
Allocate2WayNodePartitionMemory(&ctrl, graph);
idxcopy(nvtxs, where, graph->where);
Compute2WayNodePartitionParams(&ctrl, graph);
FM_2WayNodeRefine_OneSidedP(&ctrl, graph, hmarker, ubfactor, 10);
/* FM_2WayNodeRefine_TwoSidedP(&ctrl, graph, hmarker, ubfactor, 10); */
FreeWorkSpace(&ctrl, graph);
idxcopy(nvtxs, graph->where, where);
FreeGraph(graph);
}
示例2: ConstructSeparator
/*************************************************************************
* This function takes a bisection and constructs a minimum weight vertex
* separator out of it. It uses the node-based separator refinement for it.
**************************************************************************/
void ConstructSeparator(CtrlType *ctrl, GraphType *graph, float ubfactor)
{
int i, j, k, nvtxs, nbnd;
idxtype *xadj, *where, *bndind;
nvtxs = graph->nvtxs;
xadj = graph->xadj;
nbnd = graph->nbnd;
bndind = graph->bndind;
where = idxcopy(nvtxs, graph->where, idxwspacemalloc(ctrl, nvtxs));
/* Put the nodes in the boundary into the separator */
for (i=0; i<nbnd; i++) {
j = bndind[i];
if (xadj[j+1]-xadj[j] > 0) /* Ignore islands */
where[j] = 2;
}
GKfree(&graph->rdata, LTERM);
Allocate2WayNodePartitionMemory(ctrl, graph);
idxcopy(nvtxs, where, graph->where);
idxwspacefree(ctrl, nvtxs);
ASSERT(IsSeparable(graph));
Compute2WayNodePartitionParams(ctrl, graph);
ASSERT(CheckNodePartitionParams(graph));
FM_2WayNodeRefine(ctrl, graph, ubfactor, 8);
ASSERT(IsSeparable(graph));
}
示例3: ComputeRealCut2
/******************************************************************************
* This function takes a partition vector that is distributed and reads in
* the original graph and computes the edgecut
*******************************************************************************/
int ComputeRealCut2(idxtype *vtxdist, idxtype *mvtxdist, idxtype *part, idxtype *mpart, char *filename, MPI_Comm comm)
{
int i, j, nvtxs, mype, npes, cut;
idxtype *xadj, *adjncy, *gpart, *gmpart, *perm, *sizes;
MPI_Status status;
MPI_Comm_size(comm, &npes);
MPI_Comm_rank(comm, &mype);
if (mype != 0) {
MPI_Send((void *)part, vtxdist[mype+1]-vtxdist[mype], IDX_DATATYPE, 0, 1, comm);
MPI_Send((void *)mpart, mvtxdist[mype+1]-mvtxdist[mype], IDX_DATATYPE, 0, 1, comm);
}
else { /* Processor 0 does all the rest */
gpart = idxmalloc(vtxdist[npes], "ComputeRealCut: gpart");
idxcopy(vtxdist[1], part, gpart);
gmpart = idxmalloc(mvtxdist[npes], "ComputeRealCut: gmpart");
idxcopy(mvtxdist[1], mpart, gmpart);
for (i=1; i<npes; i++) {
MPI_Recv((void *)(gpart+vtxdist[i]), vtxdist[i+1]-vtxdist[i], IDX_DATATYPE, i, 1, comm, &status);
MPI_Recv((void *)(gmpart+mvtxdist[i]), mvtxdist[i+1]-mvtxdist[i], IDX_DATATYPE, i, 1, comm, &status);
}
/* OK, now go and reconstruct the permutation to go from the graph to mgraph */
perm = idxmalloc(vtxdist[npes], "ComputeRealCut: perm");
sizes = idxsmalloc(npes+1, 0, "ComputeRealCut: sizes");
for (i=0; i<vtxdist[npes]; i++)
sizes[gpart[i]]++;
MAKECSR(i, npes, sizes);
for (i=0; i<vtxdist[npes]; i++)
perm[i] = sizes[gpart[i]]++;
/* Ok, now read the graph from the file */
ReadMetisGraph(filename, &nvtxs, &xadj, &adjncy);
/* OK, now compute the cut */
for (cut=0, i=0; i<nvtxs; i++) {
for (j=xadj[i]; j<xadj[i+1]; j++) {
if (gmpart[perm[i]] != gmpart[perm[adjncy[j]]])
cut++;
}
}
cut = cut/2;
GKfree(&gpart, &gmpart, &perm, &sizes, &xadj, &adjncy, LTERM);
return cut;
}
return 0;
}
示例4: setupCanonicalMatrix
Matrix* setupCanonicalMatrix(int nvtxs, int nedges, idxtype* xadj,
idxtype* adjncy, idxtype* adjwgt, int ncutify)
{
int i,j;
Matrix* ret;
if ( ncutify )
ret=allocMatrix(nvtxs,nedges,1,0,0);
else
ret=allocMatrix(nvtxs,nedges,0,0,0);
idxcopy(nvtxs+1, xadj, ret->xadj);
idxcopy(nedges, adjncy, ret->adjncy);
if ( adjwgt != NULL )
{
if ( ncutify )
{
for(i=0;i<ret->nvtxs;i++)
{
ret->adjwgtsum[i]=0;
for(j=ret->xadj[i];j<ret->xadj[i+1];j++)
{
ret->adjwgt[j]=(wgttype)adjwgt[j];
ret->adjwgtsum[i]+=ret->adjwgt[j];
}
}
//ncutifyWeights(ret,1,ncutify); //YK removed
}
else
{
for(i=0;i<nedges;i++)
ret->adjwgt[i]=(wgttype)adjwgt[i];
}
normalizeColumns(ret,1,0);
}
else
{
if ( ncutify )
ncutifyWeights(ret,0,ncutify);
normalizeColumns(ret,0,0);
}
// sort each column in ascending order. This is necessary for
// getDprAdjMatrix.
for(i=0;i<nvtxs;i++)
{
ParallelQSort(ret->adjncy,ret->adjwgt,ret->xadj[i],ret->xadj[i+1]-1);
}
return ret;
}
示例5: AllocateNodePartitionParams
void AllocateNodePartitionParams(CtrlType *ctrl, GraphType *graph, WorkSpaceType *wspace)
{
int nparts, nvtxs;
idxtype *vwgt;
NRInfoType *rinfo, *myrinfo;
IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->KWayInitTmr));
nvtxs = graph->nvtxs;
nparts = ctrl->nparts;
graph->nrinfo = (NRInfoType *)GKmalloc(sizeof(NRInfoType)*nvtxs, "AllocateNodePartitionParams: rinfo");
graph->lpwgts = idxmalloc(2*nparts, "AllocateNodePartitionParams: lpwgts");
graph->gpwgts = idxmalloc(2*nparts, "AllocateNodePartitionParams: gpwgts");
graph->sepind = idxmalloc(nvtxs, "AllocateNodePartitionParams: sepind");
graph->hmarker = idxmalloc(nvtxs, "AllocateNodePartitionParams: hmarker");
/* Allocate additional memory for graph->vwgt in order to store the weights
of the remote vertices */
vwgt = graph->vwgt;
graph->vwgt = idxmalloc(nvtxs+graph->nrecv, "AllocateNodePartitionParams: graph->vwgt");
idxcopy(nvtxs, vwgt, graph->vwgt);
GKfree((void **)&vwgt, LTERM);
IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->KWayInitTmr));
}
示例6: MlevelKWayPartitioning
/*************************************************************************
* This function takes a graph and produces a bisection of it
**************************************************************************/
int MlevelKWayPartitioning(CtrlType *ctrl, GraphType *graph, int nparts, idxtype *part, float *tpwgts, float ubfactor)
{
int i, j, nvtxs, tvwgt, tpwgts2[2];
GraphType *cgraph;
int wgtflag=3, numflag=0, options[10], edgecut;
cgraph = Coarsen2Way(ctrl, graph);
IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->InitPartTmr));
AllocateKWayPartitionMemory(ctrl, cgraph, nparts);
options[0] = 1;
options[OPTION_CTYPE] = MATCH_SHEMKWAY;
options[OPTION_ITYPE] = IPART_GGPKL;
options[OPTION_RTYPE] = RTYPE_FM;
options[OPTION_DBGLVL] = 0;
METIS_WPartGraphRecursive(&cgraph->nvtxs, cgraph->xadj, cgraph->adjncy, cgraph->vwgt,
cgraph->adjwgt, &wgtflag, &numflag, &nparts, tpwgts, options,
&edgecut, cgraph->where);
IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->InitPartTmr));
IFSET(ctrl->dbglvl, DBG_IPART, printf("Initial %d-way partitioning cut: %d\n", nparts, edgecut));
IFSET(ctrl->dbglvl, DBG_KWAYPINFO, ComputePartitionInfo(cgraph, nparts, cgraph->where));
RefineKWay(ctrl, graph, cgraph, nparts, tpwgts, ubfactor);
idxcopy(graph->nvtxs, graph->where, part);
GKfree(&graph->gdata, &graph->rdata, LTERM);
return graph->mincut;
}
示例7: ParMETIS_V3_PartGeom
/***********************************************************************************
* This function is the entry point of the parallel ordering algorithm.
* This function assumes that the graph is already nice partitioned among the
* processors and then proceeds to perform recursive bisection.
************************************************************************************/
void ParMETIS_V3_PartGeom(idxtype *vtxdist, int *ndims, float *xyz, idxtype *part, MPI_Comm *comm)
{
int i, npes, mype, nvtxs, firstvtx, dbglvl;
idxtype *xadj, *adjncy;
CtrlType ctrl;
WorkSpaceType wspace;
GraphType *graph;
int zeroflg = 0;
MPI_Comm_size(*comm, &npes);
MPI_Comm_rank(*comm, &mype);
if (npes == 1) {
idxset(vtxdist[mype+1]-vtxdist[mype], 0, part);
return;
}
/* Setup a fake graph to allow the rest of the code to work unchanged */
dbglvl = 0;
nvtxs = vtxdist[mype+1]-vtxdist[mype];
firstvtx = vtxdist[mype];
xadj = idxmalloc(nvtxs+1, "ParMETIS_PartGeom: xadj");
adjncy = idxmalloc(nvtxs, "ParMETIS_PartGeom: adjncy");
for (i=0; i<nvtxs; i++) {
xadj[i] = i;
adjncy[i] = firstvtx + (i+1)%nvtxs;
}
xadj[nvtxs] = nvtxs;
/* Proceed with the rest of the code */
SetUpCtrl(&ctrl, npes, dbglvl, *comm);
ctrl.seed = mype;
ctrl.CoarsenTo = amin(vtxdist[npes]+1, 25*npes);
graph = Moc_SetUpGraph(&ctrl, 1, vtxdist, xadj, NULL, adjncy, NULL, &zeroflg);
PreAllocateMemory(&ctrl, graph, &wspace);
/*=======================================================
* Compute the initial geometric partitioning
=======================================================*/
IFSET(ctrl.dbglvl, DBG_TIME, InitTimers(&ctrl));
IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm));
IFSET(ctrl.dbglvl, DBG_TIME, starttimer(ctrl.TotalTmr));
Coordinate_Partition(&ctrl, graph, *ndims, xyz, 0, &wspace);
idxcopy(graph->nvtxs, graph->where, part);
IFSET(ctrl.dbglvl, DBG_TIME, MPI_Barrier(ctrl.gcomm));
IFSET(ctrl.dbglvl, DBG_TIME, stoptimer(ctrl.TotalTmr));
IFSET(ctrl.dbglvl, DBG_TIME, PrintTimingInfo(&ctrl));
FreeInitialGraphAndRemap(graph, 0);
FreeWSpace(&wspace);
FreeCtrl(&ctrl);
GKfree((void **)&xadj, (void **)&adjncy, LTERM);
}
示例8: ReAdjustMemory
/*************************************************************************
* This function re-adjusts the amount of memory that was allocated if
* it will lead to significant savings
**************************************************************************/
void ReAdjustMemory(GraphType *graph, GraphType *cgraph, int dovsize)
{
if (cgraph->nedges > 100000 && graph->nedges < 0.7*graph->nedges) {
idxcopy(cgraph->nedges, cgraph->adjwgt, cgraph->adjncy+cgraph->nedges);
if (graph->ncon == 1) {
if (dovsize) {
cgraph->gdata = realloc(cgraph->gdata, (5*cgraph->nvtxs+1 + 2*cgraph->nedges)*sizeof(idxtype));
/* Do this, in case everything was copied into new space */
cgraph->xadj = cgraph->gdata;
cgraph->vwgt = cgraph->gdata + cgraph->nvtxs+1;
cgraph->vsize = cgraph->gdata + 2*cgraph->nvtxs+1;
cgraph->adjwgtsum = cgraph->gdata + 3*cgraph->nvtxs+1;
cgraph->cmap = cgraph->gdata + 4*cgraph->nvtxs+1;
cgraph->adjncy = cgraph->gdata + 5*cgraph->nvtxs+1;
cgraph->adjwgt = cgraph->gdata + 5*cgraph->nvtxs+1 + cgraph->nedges;
}
else {
cgraph->gdata = realloc(cgraph->gdata, (4*cgraph->nvtxs+1 + 2*cgraph->nedges)*sizeof(idxtype));
/* Do this, in case everything was copied into new space */
cgraph->xadj = cgraph->gdata;
cgraph->vwgt = cgraph->gdata + cgraph->nvtxs+1;
cgraph->adjwgtsum = cgraph->gdata + 2*cgraph->nvtxs+1;
cgraph->cmap = cgraph->gdata + 3*cgraph->nvtxs+1;
cgraph->adjncy = cgraph->gdata + 4*cgraph->nvtxs+1;
cgraph->adjwgt = cgraph->gdata + 4*cgraph->nvtxs+1 + cgraph->nedges;
}
}
else {
if (dovsize) {
cgraph->gdata = realloc(cgraph->gdata, (4*cgraph->nvtxs+1 + 2*cgraph->nedges)*sizeof(idxtype));
/* Do this, in case everything was copied into new space */
cgraph->xadj = cgraph->gdata;
cgraph->vsize = cgraph->gdata + cgraph->nvtxs+1;
cgraph->adjwgtsum = cgraph->gdata + 2*cgraph->nvtxs+1;
cgraph->cmap = cgraph->gdata + 3*cgraph->nvtxs+1;
cgraph->adjncy = cgraph->gdata + 4*cgraph->nvtxs+1;
cgraph->adjwgt = cgraph->gdata + 4*cgraph->nvtxs+1 + cgraph->nedges;
}
else {
cgraph->gdata = realloc(cgraph->gdata, (3*cgraph->nvtxs+1 + 2*cgraph->nedges)*sizeof(idxtype));
/* Do this, in case everything was copied into new space */
cgraph->xadj = cgraph->gdata;
cgraph->adjwgtsum = cgraph->gdata + cgraph->nvtxs+1;
cgraph->cmap = cgraph->gdata + 2*cgraph->nvtxs+1;
cgraph->adjncy = cgraph->gdata + 3*cgraph->nvtxs+1;
cgraph->adjwgt = cgraph->gdata + 3*cgraph->nvtxs+1 + cgraph->nedges;
}
}
}
}
示例9: MocGrowBisection
/*************************************************************************
* This function takes a graph and produces a bisection by using a region
* growing algorithm. The resulting partition is returned in
* graph->where
**************************************************************************/
void MocGrowBisection(CtrlType *ctrl, GraphType *graph, float *tpwgts, float ubfactor)
{
int i, j, k, nvtxs, ncon, from, bestcut, mincut, nbfs;
idxtype *bestwhere, *where;
nvtxs = graph->nvtxs;
MocAllocate2WayPartitionMemory(ctrl, graph);
where = graph->where;
bestwhere = idxmalloc(nvtxs, "BisectGraph: bestwhere");
nbfs = 2*(nvtxs <= ctrl->CoarsenTo ? SMALLNIPARTS : LARGENIPARTS);
bestcut = idxsum(graph->nedges, graph->adjwgt);
for (; nbfs>0; nbfs--) {
idxset(nvtxs, 1, where);
where[RandomInRange(nvtxs)] = 0;
MocCompute2WayPartitionParams(ctrl, graph);
MocInit2WayBalance(ctrl, graph, tpwgts);
MocFM_2WayEdgeRefine(ctrl, graph, tpwgts, 4);
MocBalance2Way(ctrl, graph, tpwgts, 1.02);
MocFM_2WayEdgeRefine(ctrl, graph, tpwgts, 4);
if (bestcut >= graph->mincut) {
bestcut = graph->mincut;
idxcopy(nvtxs, where, bestwhere);
if (bestcut == 0)
break;
}
}
graph->mincut = bestcut;
idxcopy(nvtxs, bestwhere, where);
/*GKfree(&bestwhere, LTERM);*/
GKfree1((void**)&bestwhere);
}
示例10: MocGrowBisection2
/*************************************************************************
* This function takes a graph and produces a bisection by using a region
* growing algorithm. The resulting partition is returned in
* graph->where
**************************************************************************/
void MocGrowBisection2(CtrlType *ctrl, GraphType *graph, float *tpwgts, float *ubvec)
{
int /*i, j, k,*/ nvtxs, /*ncon, from,*/ bestcut, /*mincut,*/ nbfs;
idxtype *bestwhere, *where;
nvtxs = graph->nvtxs;
MocAllocate2WayPartitionMemory(ctrl, graph);
where = graph->where;
bestwhere = idxmalloc(nvtxs, "BisectGraph: bestwhere");
nbfs = 2*(nvtxs <= ctrl->CoarsenTo ? SMALLNIPARTS : LARGENIPARTS);
bestcut = idxsum(graph->nedges, graph->adjwgt);
for (; nbfs>0; nbfs--) {
idxset(nvtxs, 1, where);
where[RandomInRange(nvtxs)] = 0;
MocCompute2WayPartitionParams(ctrl, graph);
MocBalance2Way2(ctrl, graph, tpwgts, ubvec);
MocFM_2WayEdgeRefine2(ctrl, graph, tpwgts, ubvec, 4);
MocBalance2Way2(ctrl, graph, tpwgts, ubvec);
MocFM_2WayEdgeRefine2(ctrl, graph, tpwgts, ubvec, 4);
if (bestcut > graph->mincut) {
bestcut = graph->mincut;
idxcopy(nvtxs, where, bestwhere);
if (bestcut == 0)
break;
}
}
graph->mincut = bestcut;
idxcopy(nvtxs, bestwhere, where);
GKfree((void**)&bestwhere, LTERM);
}
示例11: METIS_NodeComputeSeparator
/*************************************************************************
* This function is the entry point for ONWMETIS. It requires weights on the
* vertices. It is for the case that the matrix has been pre-compressed.
**************************************************************************/
void METIS_NodeComputeSeparator(int *nvtxs, idxtype *xadj, idxtype *adjncy, idxtype *vwgt,
idxtype *adjwgt, float *ubfactor, int *options, int *sepsize, idxtype *part)
{
int i, j, tvwgt, tpwgts[2];
GraphType graph;
CtrlType ctrl;
SetUpGraph(&graph, OP_ONMETIS, *nvtxs, 1, xadj, adjncy, vwgt, adjwgt, 3);
tvwgt = idxsum(*nvtxs, graph.vwgt);
if (options[0] == 0) { /* Use the default parameters */
ctrl.CType = ONMETIS_CTYPE;
ctrl.IType = ONMETIS_ITYPE;
ctrl.RType = ONMETIS_RTYPE;
ctrl.dbglvl = ONMETIS_DBGLVL;
}
else {
ctrl.CType = options[OPTION_CTYPE];
ctrl.IType = options[OPTION_ITYPE];
ctrl.RType = options[OPTION_RTYPE];
ctrl.dbglvl = options[OPTION_DBGLVL];
}
ctrl.oflags = OFLAG_COMPRESS; /* For by-passing the pre-coarsening for multiple runs */
ctrl.RType = 2; /* Standard 1-sided node refinement code */
ctrl.pfactor = 0;
ctrl.nseps = 5; /* This should match NUM_INIT_MSECTIONS in ParMETISLib/defs.h */
ctrl.optype = OP_ONMETIS;
InitRandom(options[7]);
AllocateWorkSpace(&ctrl, &graph, 2);
/*============================================================
* Perform the bisection
*============================================================*/
tpwgts[0] = tvwgt/2;
tpwgts[1] = tvwgt-tpwgts[0];
MlevelNodeBisectionMultiple(&ctrl, &graph, tpwgts, *ubfactor*.95);
*sepsize = graph.pwgts[2];
idxcopy(*nvtxs, graph.where, part);
GKfree((void **)&graph.gdata, &graph.rdata, &graph.label, LTERM);
FreeWorkSpace(&ctrl, &graph);
}
示例12: METIS_NodeComputeSeparator
/*************************************************************************
* This function is the entry point for ONWMETIS. It requires weights on the
* vertices. It is for the case that the matrix has been pre-compressed.
**************************************************************************/
void METIS_NodeComputeSeparator(idxtype *nvtxs, idxtype *xadj, idxtype *adjncy, idxtype *vwgt,
idxtype *adjwgt, idxtype *options, idxtype *sepsize, idxtype *part)
{
idxtype i, j, tvwgt, tpwgts[2];
GraphType graph;
CtrlType ctrl;
SetUpGraph(&graph, OP_ONMETIS, *nvtxs, 1, xadj, adjncy, vwgt, adjwgt, 3);
tvwgt = idxsum(*nvtxs, graph.vwgt, 1);
if (options[0] == 0) { /* Use the default parameters */
ctrl.CType = ONMETIS_CTYPE;
ctrl.IType = ONMETIS_ITYPE;
ctrl.RType = ONMETIS_RTYPE;
ctrl.dbglvl = ONMETIS_DBGLVL;
}
else {
ctrl.CType = options[OPTION_CTYPE];
ctrl.IType = options[OPTION_ITYPE];
ctrl.RType = options[OPTION_RTYPE];
ctrl.dbglvl = options[OPTION_DBGLVL];
}
ctrl.oflags = 0;
ctrl.pfactor = 0;
ctrl.nseps = 3;
ctrl.optype = OP_ONMETIS;
ctrl.CoarsenTo = amin(100, *nvtxs-1);
ctrl.maxvwgt = 1.5*tvwgt/ctrl.CoarsenTo;
InitRandom(options[7]);
AllocateWorkSpace(&ctrl, &graph, 2);
/*============================================================
* Perform the bisection
*============================================================*/
tpwgts[0] = tvwgt/2;
tpwgts[1] = tvwgt-tpwgts[0];
MlevelNodeBisectionMultiple(&ctrl, &graph, tpwgts, 1.02);
*sepsize = graph.pwgts[2];
idxcopy(*nvtxs, graph.where, part);
FreeGraph(&graph, 0);
FreeWorkSpace(&ctrl, &graph);
}
示例13: MocGrowBisectionNew2
/*************************************************************************
* This function takes a graph and produces a bisection by using a region
* growing algorithm. The resulting partition is returned in
* graph->where
**************************************************************************/
void MocGrowBisectionNew2(CtrlType *ctrl, GraphType *graph, float *tpwgts, float *ubvec)
{
idxtype i, j, k, nvtxs, ncon, from, bestcut, mincut, nbfs, inbfs;
idxtype *bestwhere, *where;
nvtxs = graph->nvtxs;
MocAllocate2WayPartitionMemory(ctrl, graph);
where = graph->where;
bestwhere = idxmalloc(nvtxs, "BisectGraph: bestwhere");
nbfs = 2*(nvtxs <= ctrl->CoarsenTo ? SMALLNIPARTS : LARGENIPARTS);
for (inbfs=0; inbfs<nbfs; inbfs++) {
idxset(nvtxs, 1, where);
where[RandomInRange(nvtxs)] = 0;
MocCompute2WayPartitionParams(ctrl, graph);
MocInit2WayBalance2(ctrl, graph, tpwgts, ubvec);
MocFM_2WayEdgeRefine2(ctrl, graph, tpwgts, ubvec, 4);
if (inbfs == 0 || bestcut > graph->mincut) {
bestcut = graph->mincut;
idxcopy(nvtxs, where, bestwhere);
if (bestcut == 0)
break;
}
}
graph->mincut = bestcut;
idxcopy(nvtxs, bestwhere, where);
gk_free((void **)&bestwhere, LTERM);
}
示例14: MCMlevelKWayPartitioning
/*************************************************************************
* This function takes a graph and produces a bisection of it
**************************************************************************/
int MCMlevelKWayPartitioning(CtrlType *ctrl, GraphType *graph, int nparts, idxtype *part,
float *rubvec)
{
int i, j, nvtxs;
GraphType *cgraph;
int options[10], edgecut;
cgraph = MCCoarsen2Way(ctrl, graph);
IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->InitPartTmr));
MocAllocateKWayPartitionMemory(ctrl, cgraph, nparts);
options[0] = 1;
options[OPTION_CTYPE] = MATCH_SBHEM_INFNORM;
options[OPTION_ITYPE] = IPART_RANDOM;
options[OPTION_RTYPE] = RTYPE_FM;
options[OPTION_DBGLVL] = 0;
/* Determine what you will use as the initial partitioner, based on tolerances */
for (i=0; i<graph->ncon; i++) {
if (rubvec[i] > 1.2)
break;
}
if (i == graph->ncon)
METIS_mCPartGraphRecursiveInternal(&cgraph->nvtxs, &cgraph->ncon,
cgraph->xadj, cgraph->adjncy, cgraph->nvwgt, cgraph->adjwgt, &nparts,
options, &edgecut, cgraph->where);
else
METIS_mCHPartGraphRecursiveInternal(&cgraph->nvtxs, &cgraph->ncon,
cgraph->xadj, cgraph->adjncy, cgraph->nvwgt, cgraph->adjwgt, &nparts,
rubvec, options, &edgecut, cgraph->where);
IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->InitPartTmr));
IFSET(ctrl->dbglvl, DBG_IPART, printf("Initial %d-way partitioning cut: %d\n", nparts, edgecut));
IFSET(ctrl->dbglvl, DBG_KWAYPINFO, ComputePartitionInfo(cgraph, nparts, cgraph->where));
MocRefineKWayHorizontal(ctrl, graph, cgraph, nparts, rubvec);
idxcopy(graph->nvtxs, graph->where, part);
GKfree(&graph->nvwgt, &graph->npwgts, &graph->gdata, &graph->rdata, LTERM);
return graph->mincut;
}
示例15: ParMETIS_RepartLDiffusion
/***********************************************************************************
* This function is the entry point of the parallel multilevel local diffusion
* algorithm. It uses parallel undirected diffusion followed by adaptive k-way
* refinement. This function utilizes local coarsening.
************************************************************************************/
void ParMETIS_RepartLDiffusion(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy,
idxtype *vwgt, realtype *adjwgt, int *wgtflag, int *numflag, int *options,
int *edgecut, idxtype *part, MPI_Comm *comm)
{
int npes, mype;
CtrlType ctrl;
WorkSpaceType wspace;
GraphType *graph;
MPI_Comm_size(*comm, &npes);
MPI_Comm_rank(*comm, &mype);
if (npes == 1) { /* Take care the npes = 1 case */
idxset(vtxdist[1], 0, part);
*edgecut = 0;
return;
}
if (*numflag == 1)
ChangeNumbering(vtxdist, xadj, adjncy, part, npes, mype, 1);
SetUpCtrl(&ctrl, npes, options, *comm);
ctrl.CoarsenTo = amin(vtxdist[npes]+1, 70*npes);
graph = SetUpGraph(&ctrl, vtxdist, xadj, vwgt, adjncy, adjwgt, *wgtflag);
graph->vsize = idxsmalloc(graph->nvtxs, 1, "Par_KMetis: vsize");
PreAllocateMemory(&ctrl, graph, &wspace);
IFSET(ctrl.dbglvl, DBG_TRACK, printf("%d ParMETIS_RepartLDiffusion about to call AdaptiveUndirected_Partition\n",mype));
AdaptiveUndirected_Partition(&ctrl, graph, &wspace);
IFSET(ctrl.dbglvl, DBG_TRACK, printf("%d ParMETIS_RepartLDiffusion about to call ReMapGraph\n",mype));
ReMapGraph(&ctrl, graph, 0, &wspace);
idxcopy(graph->nvtxs, graph->where, part);
*edgecut = graph->mincut;
IMfree((void**)&graph->vsize, LTERM);
FreeInitialGraphAndRemap(graph, *wgtflag);
FreeWSpace(&wspace);
FreeCtrl(&ctrl);
if (*numflag == 1)
ChangeNumbering(vtxdist, xadj, adjncy, part, npes, mype, 0);
}