Debian Codegraph @

tests/2356.c

raw
1 /// \file
2 /// \brief test case from Gitlab #2356 ported to C
3
4 #include <graphviz/cgraph.h>
5 #include <graphviz/gvc.h>
6 #include <stdio.h>
7
8 static void GraphProc(void) {
9 Agraph_t *g;
10 Agnode_t *n, *m;
11 GVC_t *gvc;
12 // set up a graphviz context
13 gvc = gvContext();
14 // Create a simple digraph
15 Agdesc_t dir = {
16 // graph descriptor
17 1, // if edges are asymmetric
18 1, // if multi-edges forbidden
19 0, // if no loops
20 1, // if this is the top level graph
21 0, // if a temporary subgraph
22 1, // if string attr tables should be initialized
23 1 // if may contain collapsed nodes
24 };
25 g = agopen("g", dir, 0);
26 agattr_text(g, AGRAPH, "mindist", "0.3"); //!!!!!!the line causing the error
27 n = agnode(g, "n", 1);
28 m = agnode(g, "m", 1);
29 (void)agedge(g, n, m, 0, 1);
30 gvLayout(gvc, g, "circo"); //!!!!!crashes here
31 // Free layout data
32 gvFreeLayout(gvc, g);
33 // Free graph structures
34 agclose(g);
35 // close output file, free context, and return number of errors
36 gvFreeContext(gvc);
37 }
38
39 int main(void) {
40 for (int i = 0; i < 1000; i++) {
41 GraphProc();
42 printf("i = %d\n", i);
43 }
44 return 0;
45 }