/* * Copyright 1997, Regents of the University of Minnesota * * mtest.c * * This file is a comprehensive tester for all the graph partitioning/ordering * routines of METIS * * Started 9/18/98 * George * * $Id: mtest.c,v 1.1 2002/08/10 04:34:53 karypis Exp $ * */ #include #include "../libmetis/proto.h" #include "proto.h" /************************************************************************* * Let the game begin **************************************************************************/ int main(int argc, char *argv[]) { graph_t *graph; if (argc != 2) { printf("Usage: %s \n",argv[0]); exit(0); } graph = ReadGraph(argv[1], &wgtflag); printf("**********************************************************************\n"); printf("%s", METISTITLE); printf("Graph Information ---------------------------------------------------\n"); printf(" Name: %s, #Vertices: %"PRIDX", #Edges: %"PRIDX"\n", argv[1], graph.nvtxs, graph.nedges/2); Test_PartGraph(graph.nvtxs, graph.xadj, graph.adjncy); Test_PartGraphV(graph.nvtxs, graph.xadj, graph.adjncy); Test_PartGraphmC(graph.nvtxs, graph.xadj, graph.adjncy); Test_ND(graph.nvtxs, graph.xadj, graph.adjncy); printf("\n---------------------------------------------------------------------\n"); printf(" Testing completed.\n"); printf("**********************************************************************\n"); gk_free((void **)&graph.xadj, &graph.adjncy, &graph.vwgt, &graph.adjwgt, LTERM); } /************************************************************************* * This function tests the regular graph partitioning routines **************************************************************************/ void Test_PartGraph(idx_t nvtxs, idx_t *xadj, idx_t *adjncy) { idx_t i, j, jj, k, tstnum, rcode; idx_t nparts, numflag, wgtflag, edgecut, options[METIS_NOPTIONS]; idx_t *part, *vwgt, *adjwgt; real_t tpwgts[256]; vwgt = imalloc(nvtxs, "vwgt"); for (i=0; i 1.10*isum(nparts, pwgts, 1)) rcode = 3; if (vfree) gk_free((void **)&vwgt, LTERM); if (efree) gk_free((void **)&adjwgt, LTERM); gk_free((void **)&pwgts, LTERM); MALLOC_CHECK(NULL); return rcode; } /************************************************************************* * This function verifies that the partitioning was computed correctly **************************************************************************/ int VerifyWPart(idx_t nvtxs, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, idx_t *adjwgt, idx_t nparts, real_t *tpwgts, idx_t edgecut, idx_t *part) { idx_t i, j, k, tvwgt, cut, vfree=0, efree=0, rcode=0; idx_t *pwgts; if (part[iargmax(nvtxs, part)] != nparts-1) return 1; /* the total number of partitions is different than nparts */ /* compute the cut and the pwgts */ if (vwgt == NULL) { vfree = 1; vwgt = ismalloc(nvtxs, 1, "vwgt"); } if (adjwgt == NULL) { efree = 1; adjwgt = ismalloc(xadj[nvtxs], 1, "adjwgt"); } pwgts = ismalloc(nparts, 0, "pwgts"); for (cut=0, i=0; i 1.10*tpwgts[i]*tvwgt) { rcode = 3; break; } } if (vfree) gk_free((void **)&vwgt, LTERM); if (efree) gk_free((void **)&adjwgt, LTERM); gk_free((void **)&pwgts, LTERM); MALLOC_CHECK(NULL); return rcode; } /************************************************************************* * This function tests the regular graph partitioning routines **************************************************************************/ void Test_PartGraphV(idx_t nvtxs, idx_t *xadj, idx_t *adjncy) { idx_t i, j, jj, k, tstnum, rcode; idx_t nparts, numflag, wgtflag, totalv, options[10]; idx_t *part, *vwgt, *vsize; real_t tpwgts[256]; vwgt = imalloc(nvtxs, "vwgt"); for (i=0; i 1.05*isum(nparts, pwgts, 1)) rcode = 3; if (vfree) gk_free((void **)&vwgt, LTERM); if (efree) gk_free((void **)&vsize, LTERM); gk_free((void **)&pwgts, &marker, LTERM); MALLOC_CHECK(NULL); return rcode; } /************************************************************************* * This function verifies that the partitioning was computed correctly **************************************************************************/ int VerifyWPartV(idx_t nvtxs, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, idx_t *vsize, idx_t nparts, real_t *tpwgts, idx_t totalv, idx_t *part) { idx_t i, j, k, tvwgt, ttlv, vfree=0, efree=0, rcode=0; idx_t *pwgts, *marker; if (part[iargmax(nvtxs, part)] != nparts-1) return 1; /* the total number of partitions is different than nparts */ /* compute the cut and the pwgts */ if (vwgt == NULL) { vfree = 1; vwgt = ismalloc(nvtxs, 1, "vwgt"); } if (vsize == NULL) { efree = 1; vsize = ismalloc(nvtxs, 1, "vsize"); } pwgts = ismalloc(nparts, 0, "pwgts"); marker = ismalloc(nparts, -1, "htable"); for (ttlv=0, i=0; i 1.05*tpwgts[i]*tvwgt) { rcode = 3; break; } } if (vfree) gk_free((void **)&vwgt, LTERM); if (efree) gk_free((void **)&vsize, LTERM); gk_free((void **)&pwgts, &marker, LTERM); MALLOC_CHECK(NULL); return rcode; } /************************************************************************* * This function tests the regular graph partitioning routines **************************************************************************/ void Test_PartGraphmC(idx_t nvtxs, idx_t *xadj, idx_t *adjncy) { idx_t i, j, jj, k, tstnum, rcode; idx_t nparts, ncon, numflag, wgtflag, edgecut, options[10]; idx_t *part, *vwgt, *adjwgt; real_t ubvec[MAXNCON]; ncon = 3; vwgt = imalloc(nvtxs*ncon, "vwgt"); for (i=0; i ubvec[i]) rcode = 3; } if (efree) gk_free((void **)&adjwgt, LTERM); gk_free((void **)&pwgts, LTERM); MALLOC_CHECK(NULL); return rcode; } /************************************************************************* * This function tests the regular graph partitioning routines **************************************************************************/ void Test_ND(idx_t nvtxs, idx_t *xadj, idx_t *adjncy) { idx_t i, j, jj, k, tstnum, rcode; idx_t numflag, wgtflag, options[10]; idx_t *perm, *iperm, *vwgt; vwgt = imalloc(nvtxs, "vwgt"); for (i=0; i