graphchk.c
Go to the documentation of this file.
1 /*
2  * Copyright 1997, Regents of the University of Minnesota
3  *
4  * graphchk.c
5  *
6  * This file checks the validity of a graph
7  *
8  * Started 8/28/94
9  * George
10  *
11  * $Id: graphchk.c 9982 2011-05-25 17:18:00Z karypis $
12  *
13  */
14 
15 #include "metisbin.h"
16 
17 
18 
19 /*************************************************************************/
21 /*************************************************************************/
22 int main(int argc, char *argv[])
23 {
24  graph_t *graph, *fgraph;
25  char filename[256];
26  idx_t wgtflag;
28 
29  if (argc != 2 && argc != 3) {
30  printf("Usage: %s <GraphFile> [FixedGraphFile (for storing the fixed graph)]\n", argv[0]);
31  exit(0);
32  }
33 
34  memset((void *)&params, 0, sizeof(params_t));
35  params.filename = gk_strdup(argv[1]);
36 
37  graph = ReadGraph(&params);
38  if (graph->nvtxs == 0) {
39  printf("Empty graph!\n");
40  exit(0);
41  }
42 
43  printf("**********************************************************************\n");
44  printf("%s", METISTITLE);
45  printf(" (HEAD: %s, Built on: %s, %s)\n", SVNINFO, __DATE__, __TIME__);
46  printf(" size of idx_t: %zubits, real_t: %zubits, idx_t *: %zubits\n",
47  8*sizeof(idx_t), 8*sizeof(real_t), 8*sizeof(idx_t *));
48  printf("\n");
49  printf("Graph Information ---------------------------------------------------\n");
50  printf(" Name: %s, #Vertices: %"PRIDX", #Edges: %"PRIDX"\n\n",
51  params.filename, graph->nvtxs, graph->nedges/2);
52  printf("Checking Graph... ---------------------------------------------------\n");
53 
54  if (CheckGraph(graph, 1, 1)) {
55  printf(" The format of the graph is correct!\n");
56  }
57  else {
58  printf(" The format of the graph is incorrect!\n");
59  if (argc == 3) {
60  fgraph = FixGraph(graph);
61  WriteGraph(fgraph, argv[2]);
62  FreeGraph(&fgraph);
63  printf(" A corrected version was stored at %s\n", argv[2]);
64  }
65  }
66 
67  printf("\n**********************************************************************\n");
68 
69 
70  FreeGraph(&graph);
71  gk_free((void **)&params.filename, &params.tpwgtsfile, &params.tpwgts, LTERM);
72 }
73 
74 
Definition: fis.c:15
#define FreeGraph
Definition: rename.h:98
char * filename
Definition: fis.c:18
#define FixGraph
Definition: rename.h:32
real_t * tpwgts
idx_t nvtxs
#define METISTITLE
Definition: libmetis/defs.h:18
NonlinearFactorGraph graph
#define PRIDX
idx_t nedges
#define CheckGraph
Definition: rename.h:30
int32_t idx_t
char * tpwgtsfile
static SmartStereoProjectionParams params
float real_t
char * gk_strdup(char *orgstr)
Duplicates a string.
Definition: string.c:372
graph_t * ReadGraph(params_t *params)
Definition: programs/io.c:22
void gk_free(void **ptr1,...)
Definition: memory.c:202
void WriteGraph(graph_t *graph, char *filename)
Definition: programs/io.c:497
int main(int argc, char *argv[])
Definition: graphchk.c:22
#define LTERM
Definition: gk_defs.h:14


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:09