Simple graph I/O operations

This example shows how one can read graph from a file and save graph in a file.
The input file is assumed to be in GraphViz DOT language.

 1 #pragma package ".."
 2 
 3 #include <chagraph.h>
 4 #include <stdlib.h>
 5 
 6 int main(int argc, char *argv[])
 7 {
 8   if (argc != 3) {
 9     printf(_stderr, "Usage: %s infile outfile");
10     exit(EXIT_FAILURE);
11   }
12 
13   Agraph_t *g;
14   FILE *inf = fopen(argv[1], "r");
15   FILE *outf = fopen(argv[2], "w");
16 g = agread(inf, 0);
17 
18   agwrite(g, outf);
19 
20 agclose(g);
21 
22   fclose(inf);
23   fclose(outf);
24 }

Copyright 2006 Roman Putanowicz

Email: putanowr at twins.pk.edu.pl

Last Modified: Thu, 29 Jun 2006 18:03:04 CEST

Made with PubTal 3.1.3