#include #include #include int main(){ Agraph_t *g; g = agopen("G", Agdirected, 0); Agnode_t *a = agnode(g, "Apple", 1); Agnode_t *b = agnode(g, "B", 1); Agnode_t *c = agnode(g, "C", 1); Agnode_t *d = agnode(g, "D", 1); Agnode_t *e = agnode(g, "E", 1); Agnode_t *f = agnode(g, "F", 1); agedge(g, a, b, "Bob", 1); agedge(g, a, c, "", 1); agedge(g, c, f, "", 1); agedge(g, b, d, "", 1); agedge(g, b, e, "", 1); agwrite(g, stdout); GVC_t* gvc = gvContext(); gvLayout(gvc, g, "dot"); gvRenderFilename(gvc, g, "png", "out.png"); gvFreeLayout(gvc, g); agclose(g); return 0; } /* To build this program: gcc graph_demo.c -lcgraph -lgvc If there's an error about missing header files, maybe libgraphviz-dev isn't installed: sudo apt install libgraphviz-dev */