1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
/*
* Copyright 1997, Regents of the University of Minnesota
*
* mgrsetup.c
*
* This file contain various graph setting up routines
*
* Started 10/19/96
* George
*
* $Id: renumber.c 10531 2011-07-09 21:58:13Z karypis $
*
*/
#include <parmetislib.h>
/*************************************************************************
* This function changes the numbering from 1 to 0 or 0 to 1
**************************************************************************/
void ChangeNumbering(idx_t *vtxdist, idx_t *xadj, idx_t *adjncy, idx_t *part, idx_t npes, idx_t mype, idx_t from)
{
idx_t i, nvtxs;
nvtxs = vtxdist[mype+1]-vtxdist[mype];
if (from == 1) { /* Change it from 1 to 0 */
for (i=0; i<npes+1; i++)
vtxdist[i]--;
for (i=0; i<nvtxs+1; i++)
xadj[i]--;
for (i=0; i<xadj[nvtxs]; i++)
adjncy[i]--;
}
else { /* Change it from 0 to 1 */
for (i=0; i<npes+1; i++)
vtxdist[i]++;
for (i=0; i<xadj[nvtxs]; i++)
adjncy[i]++;
for (i=0; i<nvtxs+1; i++)
xadj[i]++;
for (i=0; i<nvtxs; i++)
part[i]++;
}
}
/*************************************************************************
* This function changes the numbering from 1 to 0 or 0 to 1
**************************************************************************/
void ChangeNumberingMesh(idx_t *elmdist, idx_t *eptr, idx_t *eind,
idx_t *xadj, idx_t *adjncy, idx_t *part,
idx_t npes, idx_t mype, idx_t from)
{
idx_t i, nelms;
nelms = elmdist[mype+1]-elmdist[mype];
if (from == 1) { /* Change it from 1 to 0 */
for (i=0; i<npes+1; i++)
elmdist[i]--;
for (i=0; i<nelms+1; i++)
eptr[i]--;
for (i=0; i<eptr[nelms]; i++)
eind[i]--;
}
else { /* Change it from 0 to 1 */
for (i=0; i<npes+1; i++)
elmdist[i]++;
for (i=0; i<eptr[nelms]; i++)
eind[i]++;
for (i=0; i<nelms+1; i++)
eptr[i]++;
for (i=0; i<xadj[nelms]; i++)
adjncy[i]++;
for (i=0; i<nelms+1; i++)
xadj[i]++;
if (part != NULL)
for (i=0; i<nelms; i++)
part[i]++;
}
}
|