{
SCOTCH_Num baseval;
const SCOTCH_Num * vwgt2;
const SCOTCH_Num * vsize2;
SCOTCH_Num vsizval;
SCOTCH_Num vertnbr;
SCOTCH_Num vertnum;
SCOTCH_Num edgenum;
const SCOTCH_Num * edgetax;
const SCOTCH_Num * parttax;
SCOTCH_Num * nghbtab;
SCOTCH_Num commvol;
vsize2 = ((*wgtflag & 1) != 0) ? vsize : NULL;
vwgt2 = ((*wgtflag & 2) != 0) ? vwgt : NULL;
baseval = *numflag;
vertnbr = *n;
edgetax = adjncy - baseval;
if (vsize2 == NULL) {
if (
PartGraph2 (n, xadj, adjncy, vwgt2, NULL, numflag, nparts,
part, SCOTCH_STRATDEFAULT, 0.01) != 0)
return;
}
else {
const SCOTCH_Num * vsiztax;
SCOTCH_Num edgenbr;
SCOTCH_Num * edlotax;
int o;
edgenbr = xadj[vertnbr] - baseval;
if ((edlotax =
(SCOTCH_Num*) malloc (edgenbr * sizeof (SCOTCH_Num))) == NULL)
{
return;
}
edlotax -= baseval;
vsiztax = vsize2 - baseval;
for (vertnum = 0, edgenum = baseval;
vertnum < vertnbr; vertnum ++) {
SCOTCH_Num vsizval;
SCOTCH_Num edgennd;
vsizval = vsize2[vertnum];
for (edgennd = xadj[vertnum + 1];
edgenum < edgennd;
edgenum ++) {
SCOTCH_Num vertend;
vertend = edgetax[edgenum];
edlotax[edgenum] = vsizval + vsiztax[vertend];
}
}
o =
PartGraph2 (n, xadj, adjncy, vwgt2, edlotax + baseval, numflag,
nparts, part, SCOTCH_STRATDEFAULT, 0.01);
free (edlotax + baseval);
if (o != 0)
return;
}
if ((nghbtab =
(SCOTCH_Num*) malloc (*nparts * sizeof (SCOTCH_Num))) == NULL)
{
return;
}
memset (nghbtab, ~0, *nparts * sizeof (SCOTCH_Num));
parttax = part - baseval;
vsizval = 1;
for (vertnum = 0, edgenum = baseval, commvol = 0;
vertnum < vertnbr; vertnum ++) {
SCOTCH_Num partval;
SCOTCH_Num edgennd;
partval = part[vertnum];
nghbtab[partval] = vertnum;
if (vsize2 != NULL)
vsizval = vsize2[vertnum];
for (edgennd = xadj[vertnum + 1]; edgenum < edgennd; edgenum ++) {
SCOTCH_Num vertend;
SCOTCH_Num partend;
vertend = edgetax[edgenum];
partend = parttax[vertend];
if (nghbtab[partend] != vertnum) {
nghbtab[partend] = vertnum;
commvol += vsizval;
}
}
}
*volume = commvol;
free (nghbtab);
}