From: John Ellson Date: Tue, 13 Oct 2015 00:43:08 +0000 (-0400) Subject: fix errors in example in cgraph man page X-Git-Tag: TRAVIS_CI_BUILD_EXPERIMENTAL~101 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0c413389817de206f739f894ad9e8abc497cc6da;p=graphviz fix errors in example in cgraph man page --- diff --git a/lib/cgraph/cgraph.3 b/lib/cgraph/cgraph.3 index 81d86bba8..990e2e02c 100644 --- a/lib/cgraph/cgraph.3 +++ b/lib/cgraph/cgraph.3 @@ -592,29 +592,31 @@ can be retreived by calling \fBaglasterr\fP. The function \fBagerrors\fP returns non-zero if errors have been reported. .SH "EXAMPLE PROGRAM" .P0 +#include #include + typedef struct {Agrec_t hdr; int x,y,z;} mydata; -main(int argc, char **argv) +void main(int argc, char **argv) { - Agraph_t *g; + Agraph_t *g, *h; Agnode_t *v; Agedge_t *e; Agsym_t *attr; - Dict_t *d + Dict_t *d; int cnt; mydata *p; if (g = agread(stdin,NIL(Agdisc_t*))) { cnt = 0; attr = 0; while (attr = agnxtattr(g, AGNODE, attr)) cnt++; - printf("The graph %s has %d attributes\n",agnameof(g),cnt); + printf("The graph %s has %d attributes\\n",agnameof(g),cnt); /* make the graph have a node color attribute, default is blue */ attr = agattr(g,AGNODE,"color","blue"); /* create a new graph of the same kind as g */ - h = agopen("tmp",g->desc); + h = agopen("tmp",g->desc, NULL); /* this is a way of counting all the edges of the graph */ cnt = 0; @@ -624,20 +626,21 @@ main(int argc, char **argv) /* attach records to edges */ for (v = agfstnode(g); v; v = agnxtnode(g,v)) - for (e = agfstout(g,v); e; e; = agnxtout(g,e)) { - p = (mydata*) agbindrec(g,e,"mydata",sizeof(mydata),TRUE); + for (e = agfstout(g,v); e; e = agnxtout(g,e)) { + p = (mydata*) agbindrec(e,"mydata",sizeof(mydata),TRUE); p->x = 27; /* meaningless data access example */ ((mydata*)(AGDATA(e)))->y = 999; /* another example */ } } } + .P1 .SH "EXAMPLE GRAPH FILES" .P0 digraph G { a -> b; c [shape=box]; - a -> c [weight=29,label="some text]; + a -> c [weight=29,label="some text"]; subgraph anything { /* the following affects only x,y,z */ node [shape=circle];