1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#include <graphviz/gvc.h>
int main(int argc, char *argv[])
{
Agnode_t *node1, *node2;
Agedge_t *edge1;
Agraph_t *graph;
GVC_t *gvc;
gvc = gvContext ();
graph = agopen ("graph", Agdirected, NULL);
node1 = agnode(graph, "node1", TRUE);
agsafeset (node1, "width", "1", "");
agsafeset (node1, "height", "1", "");
node2 = agnode(graph, "node2", TRUE);
agsafeset (node2, "width", "1", "");
agsafeset (node2, "height", "1", "");
edge1 = agedge(graph, node1, node2, "edge1", TRUE);
puts ("---------- initially ----------");
agwrite (graph, stdout);
gvLayout (gvc, graph, "dot");
gvRender(gvc, graph, "dot", NULL);
gvFreeLayout(gvc, graph);
puts ("---------- after first layouting ----------");
agwrite (graph, stdout);
agsafeset (node2, "height", "2", "");
gvLayout (gvc, graph, "dot");
gvRender(gvc, graph, "dot", NULL);
gvFreeLayout(gvc, graph);
puts ("---------- after second layouting ----------");
agwrite (graph, stdout);
agclose (graph);
gvFreeContext(gvc);
return 0;
}
|