From: Matthew Fernandez Date: Sun, 16 Jan 2022 18:15:01 +0000 (-0800) Subject: dot.demo/example.c: [nfc] align with C99 style and clang-format X-Git-Tag: 3.0.0~57^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7a081019fc965e5870d814cd59ed9b40374e7d1f;p=graphviz dot.demo/example.c: [nfc] align with C99 style and clang-format --- diff --git a/dot.demo/example.c b/dot.demo/example.c index 21a441b2b..2f36d1d8e 100644 --- a/dot.demo/example.c +++ b/dot.demo/example.c @@ -1,44 +1,38 @@ #include +#include +#include #define NO_LAYOUT_OR_RENDERING -int main(int argc, char **argv) -{ - Agraph_t *g; - Agnode_t *n, *m; - Agedge_t *e; - +int main(void) { #ifndef NO_LAYOUT_OR_RENDERING - /* set up a graphviz context - but only once even for multiple graphs */ - static GVC_t *gvc; - - if (!gvc) - gvc = gvContext(); + // set up a graphviz context - but only once even for multiple graphs + GVC_t *gvc = gvContext(); #endif - /* Create a simple digraph */ - g = agopen("g", Agdirected, 0); - n = agnode(g, "n", 1); - m = agnode(g, "m", 1); - e = agedge(g, n, m, 0, 1); + // Create a simple digraph + Agraph_t *g = agopen("g", Agdirected, 0); + Agnode_t *n = agnode(g, "n", 1); + Agnode_t *m = agnode(g, "m", 1); + Agedge_t *e = agedge(g, n, m, 0, 1); + + // Set an attribute - in this case one that affects the visible rendering + agsafeset(n, "color", "red", ""); - /* Set an attribute - in this case one that affects the visible rendering */ - agsafeset(n, "color", "red", ""); - #ifdef NO_LAYOUT_OR_RENDERING - /* Just write the graph without layout */ - agwrite(g, stdout); + // Just write the graph without layout + agwrite(g, stdout); #else - /* Use the directed graph layout engine */ - gvLayout(gvc, g, "dot"); + // Use the directed graph layout engine + gvLayout(gvc, g, "dot"); - /* Output in .dot format */ - gvRender(gvc, g, "dot", stdout); + // Output in .dot format + gvRender(gvc, g, "dot", stdout); - gvFreeLayout(gvc, g); + gvFreeLayout(gvc, g); #endif - agclose(g); + agclose(g); - return 0; + return EXIT_SUCCESS; }