Path: blob/devel/elmergrid/src/metis-5.1.0/programs/graphchk.c
3206 views
/*1* Copyright 1997, Regents of the University of Minnesota2*3* graphchk.c4*5* This file checks the validity of a graph6*7* Started 8/28/948* George9*10* $Id: graphchk.c 9982 2011-05-25 17:18:00Z karypis $11*12*/1314#include "metisbin.h"15161718/*************************************************************************/19/*! Let entry point of the checker */20/*************************************************************************/21int main(int argc, char *argv[])22{23graph_t *graph, *fgraph;24char filename[256];25idx_t wgtflag;26params_t params;2728if (argc != 2 && argc != 3) {29printf("Usage: %s <GraphFile> [FixedGraphFile (for storing the fixed graph)]\n", argv[0]);30exit(0);31}3233memset((void *)¶ms, 0, sizeof(params_t));34params.filename = gk_strdup(argv[1]);3536graph = ReadGraph(¶ms);37if (graph->nvtxs == 0) {38printf("Empty graph!\n");39exit(0);40}4142printf("**********************************************************************\n");43printf("%s", METISTITLE);44printf(" (HEAD: %s, Built on: %s, %s)\n", SVNINFO, __DATE__, __TIME__);45printf(" size of idx_t: %zubits, real_t: %zubits, idx_t *: %zubits\n",468*sizeof(idx_t), 8*sizeof(real_t), 8*sizeof(idx_t *));47printf("\n");48printf("Graph Information ---------------------------------------------------\n");49printf(" Name: %s, #Vertices: %"PRIDX", #Edges: %"PRIDX"\n\n",50params.filename, graph->nvtxs, graph->nedges/2);51printf("Checking Graph... ---------------------------------------------------\n");5253if (CheckGraph(graph, 1, 1)) {54printf(" The format of the graph is correct!\n");55}56else {57printf(" The format of the graph is incorrect!\n");58if (argc == 3) {59fgraph = FixGraph(graph);60WriteGraph(fgraph, argv[2]);61FreeGraph(&fgraph);62printf(" A corrected version was stored at %s\n", argv[2]);63}64}6566printf("\n**********************************************************************\n");676869FreeGraph(&graph);70gk_free((void **)¶ms.filename, ¶ms.tpwgtsfile, ¶ms.tpwgts, LTERM);71}7273747576