# SCM Repository

[matrix] View of /pkg/src/Metis/debug.c
 [matrix] / pkg / src / Metis / debug.c

# View of /pkg/src/Metis/debug.c

Mon Mar 22 20:20:05 2004 UTC (16 years ago) by bates
File size: 6581 byte(s)
`Initial import`
```/*
* Copyright 1997, Regents of the University of Minnesota
*
* debug.c
*
* This file contains code that performs self debuging
*
* Started 7/24/97
* George
*
* \$Id: debug.c,v 1.1 2003/12/31 21:32:30 bates Exp \$
*
*/

#include <metis.h>

/*************************************************************************
* This function computes the cut given the graph and a where vector
**************************************************************************/
int ComputeCut(GraphType *graph, idxtype *where)
{
int i, j, cut;

for (cut=0, i=0; i<graph->nvtxs; i++) {
cut++;
}
}
else {
for (cut=0, i=0; i<graph->nvtxs; i++) {
}
}

return cut/2;
}

/*************************************************************************
* This function checks whether or not the boundary information is correct
**************************************************************************/
int CheckBnd(GraphType *graph)
{
int i, j, nvtxs, nbnd;

nvtxs = graph->nvtxs;
where = graph->where;
bndptr = graph->bndptr;
bndind = graph->bndind;

for (nbnd=0, i=0; i<nvtxs; i++) {
nbnd++;   /* Islands are considered to be boundary vertices */

nbnd++;
ASSERT(bndptr[i] != -1);
ASSERT(bndind[bndptr[i]] == i);
break;
}
}
}

ASSERTP(nbnd == graph->nbnd, ("%d %d\n", nbnd, graph->nbnd));

return 1;
}

/*************************************************************************
* This function checks whether or not the boundary information is correct
**************************************************************************/
int CheckBnd2(GraphType *graph)
{
int i, j, nvtxs, nbnd, id, ed;

nvtxs = graph->nvtxs;
where = graph->where;
bndptr = graph->bndptr;
bndind = graph->bndind;

for (nbnd=0, i=0; i<nvtxs; i++) {
id = ed = 0;
else
}
nbnd++;
ASSERTP(bndptr[i] != -1, ("%d %d %d\n", i, id, ed));
ASSERT(bndind[bndptr[i]] == i);
}
}

ASSERTP(nbnd == graph->nbnd, ("%d %d\n", nbnd, graph->nbnd));

return 1;
}

/*************************************************************************
* This function checks whether or not the boundary information is correct
**************************************************************************/
int CheckNodeBnd(GraphType *graph, int onbnd)
{
int i, j, nvtxs, nbnd;

nvtxs = graph->nvtxs;
where = graph->where;
bndptr = graph->bndptr;
bndind = graph->bndind;

for (nbnd=0, i=0; i<nvtxs; i++) {
if (where[i] == 2)
nbnd++;
}

ASSERTP(nbnd == onbnd, ("%d %d\n", nbnd, onbnd));

for (i=0; i<nvtxs; i++) {
if (where[i] != 2) {
ASSERTP(bndptr[i] == -1, ("%d %d\n", i, bndptr[i]));
}
else {
ASSERTP(bndptr[i] != -1, ("%d %d\n", i, bndptr[i]));
}
}

return 1;
}

/*************************************************************************
* This function checks whether or not the rinfo of a vertex is consistent
**************************************************************************/
int CheckRInfo(RInfoType *rinfo)
{
int i, j;

for (i=0; i<rinfo->ndegrees; i++) {
for (j=i+1; j<rinfo->ndegrees; j++)
ASSERTP(rinfo->edegrees[i].pid != rinfo->edegrees[j].pid, ("%d %d %d %d\n", i, j, rinfo->edegrees[i].pid, rinfo->edegrees[j].pid));
}

return 1;
}

/*************************************************************************
* This function checks the correctness of the NodeFM data structures
**************************************************************************/
int CheckNodePartitionParams(GraphType *graph)
{
int i, j, k, l, nvtxs, me, other;
idxtype edegrees[2], pwgts[3];

nvtxs = graph->nvtxs;
vwgt = graph->vwgt;

where = graph->where;

/*------------------------------------------------------------
/ Compute now the separator external degrees
/------------------------------------------------------------*/
pwgts[0] = pwgts[1] = pwgts[2] = 0;
for (i=0; i<nvtxs; i++) {
me = where[i];
pwgts[me] += vwgt[i];

if (me == 2) { /* If it is on the separator do some computations */
edegrees[0] = edegrees[1] = 0;

if (other != 2)
}
if (edegrees[0] != graph->nrinfo[i].edegrees[0] || edegrees[1] != graph->nrinfo[i].edegrees[1]) {
printf("Something wrong with edegrees: %d %d %d %d %d\n", i, edegrees[0], edegrees[1], graph->nrinfo[i].edegrees[0], graph->nrinfo[i].edegrees[1]);
return 0;
}
}
}

if (pwgts[0] != graph->pwgts[0] || pwgts[1] != graph->pwgts[1] || pwgts[2] != graph->pwgts[2])
printf("Something wrong with part-weights: %d %d %d %d %d %d\n", pwgts[0], pwgts[1], pwgts[2], graph->pwgts[0], graph->pwgts[1], graph->pwgts[2]);

return 1;
}

/*************************************************************************
* This function checks if the separator is indeed a separator
**************************************************************************/
int IsSeparable(GraphType *graph)
{
int i, j, nvtxs, other;

nvtxs = graph->nvtxs;
where = graph->where;

for (i=0; i<nvtxs; i++) {
if (where[i] == 2)
continue;
other = (where[i]+1)%2;