/* * 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 1998/11/27 17:59:13 karypis Exp $ * */ #include /************************************************************************* * This function computes the cut given the graph and a where vector **************************************************************************/ int ComputeCut(GraphType *graph, idxtype *where) { int i, j, cut; if (graph->adjwgt == NULL) { for (cut=0, i=0; invtxs; i++) { for (j=graph->xadj[i]; jxadj[i+1]; j++) if (where[i] != where[graph->adjncy[j]]) cut++; } } else { for (cut=0, i=0; invtxs; i++) { for (j=graph->xadj[i]; jxadj[i+1]; j++) if (where[i] != where[graph->adjncy[j]]) cut += graph->adjwgt[j]; } } return cut/2; } /************************************************************************* * This function checks whether or not the boundary information is correct **************************************************************************/ int CheckBnd(GraphType *graph) { int i, j, nvtxs, nbnd; idxtype *xadj, *adjncy, *where, *bndptr, *bndind; nvtxs = graph->nvtxs; xadj = graph->xadj; adjncy = graph->adjncy; where = graph->where; bndptr = graph->bndptr; bndind = graph->bndind; for (nbnd=0, i=0; inbnd, ("%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; idxtype *xadj, *adjncy, *where, *bndptr, *bndind; nvtxs = graph->nvtxs; xadj = graph->xadj; adjncy = graph->adjncy; where = graph->where; bndptr = graph->bndptr; bndind = graph->bndind; for (nbnd=0, i=0; iadjwgt[j]; else id += graph->adjwgt[j]; } if (ed - id >= 0 && xadj[i] < xadj[i+1]) { 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; idxtype *xadj, *adjncy, *where, *bndptr, *bndind; nvtxs = graph->nvtxs; xadj = graph->xadj; adjncy = graph->adjncy; where = graph->where; bndptr = graph->bndptr; bndind = graph->bndind; for (nbnd=0, i=0; indegrees; i++) { for (j=i+1; jndegrees; 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 *xadj, *adjncy, *adjwgt, *vwgt, *where; idxtype edegrees[2], pwgts[3]; nvtxs = graph->nvtxs; xadj = graph->xadj; vwgt = graph->vwgt; adjncy = graph->adjncy; adjwgt = graph->adjwgt; where = graph->where; /*------------------------------------------------------------ / Compute now the separator external degrees /------------------------------------------------------------*/ pwgts[0] = pwgts[1] = pwgts[2] = 0; for (i=0; inrinfo[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; idxtype *xadj, *adjncy, *where; nvtxs = graph->nvtxs; xadj = graph->xadj; adjncy = graph->adjncy; where = graph->where; for (i=0; i