Graphviz  2.41.20171026.1811
main2.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <cgraph.h>
3 #include "bla.h"
4 
5 int main(int argc, char **argv)
6 {
7  Agraph_t *g;
8  Agnode_t *n, *n0;
9  Agsubnode_t *sn;
10  int sum = 0, i, sum1;
11  int sz = (argc > 1) ? atoi(argv[1]) : 1;
12  int run, nruns = (argc > 2) ? atoi(argv[2]) : 1;
13  int opt = (argc > 3)? atoi(argv[3]) : 0;
14  Agnode_t *N[sz];
15 
16  if (argc == 1) fprintf(stderr,"%s nnodes nruns opt\n\topt = 0 for agfstnode/agnxtnode\n\topt = 1 for dtflatten/dtlink\n\topt = 2 for flat array\n",argv[0]);
17  g = agopen("g",Agdirected,0);
18  for (i = 0; i < sz; i++) {
19  n = agnode(g,0,TRUE);
20  N[i] = n;
21  sum = sum + AGSEQ(n);
22  }
23  switch(opt) {
24  default:
25  case 0:
26  for (run = 0; run < nruns; run++) {
27  sum1 = 0;
28  for (n = agfstnode(g); n; n = agnxtnode(g,n)) {
29  sum1 = sum1 + AGSEQ(n);
30  }
31  if (sum != sum1) fprintf(stderr,"error\n");
32  }
33  break;
34  case 1:
35  for (run = 0; run < nruns; run++) {
36  Agnoderef_t *nref;
37  sum1 = 0;
38  for (nref = FIRSTNREF(g); nref;
39  nref = NEXTNREF(nref)) {
40  n = NODEOF(nref);
41  sum1 = sum1 + AGSEQ(n);
42  n0 = agnxtnode(g,n);
43  }
44  if (sum != sum1) fprintf(stderr,"error %x %x\n", sum, sum1);
45  }
46  break;
47  case 2:
48  for (run = 0; run < nruns; run++) {
49  sum1 = 0;
50  for (i = 0; i < sz; i++) {
51  n = N[i];
52  sum1 = sum1 + AGSEQ(n);
53  }
54  if (sum != sum1) fprintf(stderr,"error\n");
55  }
56  break;
57  }
58  return 1;
59 }
#define AGSEQ(obj)
Definition: cgraph.h:115
CGRAPH_API Agnode_t * agnode(Agraph_t *g, char *name, int createflag)
Definition: node.c:142
CGRAPH_API Agraph_t * agopen(char *name, Agdesc_t desc, Agdisc_t *disc)
Definition: graph.c:44
CGRAPH_API Agdesc_t Agdirected
Definition: cgraph.h:418
#define FIRSTNREF(g)
Definition: cgraph.h:432
CGRAPH_API Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Definition: node.c:45
CGRAPH_API Agnode_t * agfstnode(Agraph_t *g)
Definition: node.c:38
#define NEXTNREF(g, rep)
Definition: cgraph.h:434
int main(int argc, char **argv)
Definition: dot.c:95
#define NODEOF(rep)
Definition: cgraph.h:439
#define TRUE
Definition: cgraph.h:38