Graphviz  2.41.20171026.1811
main1.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <cgraph.h>
3 
4 int main(int argc, char **argv)
5 {
6  Agraph_t *g;
7  Agnode_t *n;
8  Agsubnode_t *sn;
9  int sum = 0, i, sum1;
10  int sz = (argc > 1) ? atoi(argv[1]) : 1;
11  int run, nruns = (argc > 2) ? atoi(argv[2]) : 1;
12  int opt = (argc > 3)? atoi(argv[3]) : 0;
13  Agnode_t *N[sz];
14 
15  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]);
16  g = agopen("g",Agdirected,0);
17  for (i = 0; i < sz; i++) {
18  n = agnode(g,0,TRUE);
19  N[i] = n;
20  sum = sum + AGSEQ(n);
21  }
22  switch(opt) {
23  default:
24  case 0:
25  for (run = 0; run < nruns; run++) {
26  sum1 = 0;
27  for (n = agfstnode(g); n; n = agnxtnode(g,n)) {
28  sum1 = sum1 + AGSEQ(n);
29  }
30  if (sum != sum1) fprintf(stderr,"error\n");
31  }
32  break;
33  case 1:
34  for (run = 0; run < nruns; run++) {
35  Dtlink_t *link;
36  sum1 = 0;
37  for (link = dtflatten(g->n_seq); link; link = dtlink(g->n_seq,link)) {
38  sn = (Agsubnode_t*)dtobj(g->n_seq,link);
39  n = sn->node;
40  sum1 = sum1 + AGSEQ(n);
41  }
42  if (sum != sum1) fprintf(stderr,"error\n");
43  }
44  break;
45  case 2:
46  for (run = 0; run < nruns; run++) {
47  sum1 = 0;
48  for (i = 0; i < sz; i++) {
49  n = N[i];
50  sum1 = sum1 + AGSEQ(n);
51  }
52  if (sum != sum1) fprintf(stderr,"error\n");
53  }
54  break;
55  }
56  return 1;
57 }
#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
CDT_API Dtlink_t * dtflatten(Dt_t *)
Definition: dtflatten.c:9
Dict_t * n_seq
Definition: cgraph.h:243
CGRAPH_API Agdesc_t Agdirected
Definition: cgraph.h:418
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 dtobj(d, e)
Definition: cdt.h:251
Agnode_t * node
Definition: cgraph.h:128
#define dtlink(d, e)
Definition: cdt.h:250
int main(int argc, char **argv)
Definition: dot.c:95
#define TRUE
Definition: cgraph.h:38