/*------------------------------------------------------------------- Header file for Input/Output routines for graphs. This program was developed for the course MTH 607 - Graph Theory. Released under the GNU public license. (c) Peter Danziger -------------------------------------------------------------------*/ #include #include /* The maximum number of vertices we can handle. Up this for larger graphs. */ #ifndef MAX_N #define MAX_N 100 #endif /*------------------------------------------------------------------- The top level routine is called parse_args() and should be called from main. It will read in a graph file specified on the command line: graph [ []] If no input name is given inputs from stdin, if no output name given defaults to stdout It also sets the file handle "file_out" for the output file. The graph is stored internally as a weighted adjacency matrix in the array "graph" The are also two low level routines, read_graph and write_graph which read and write graphs to and from the array "graph" to the file pointed to by the handle fhandle. -------------------------------------------------------------------*/ int parse_args(int argc, char *argv[]); int read_graph(FILE *fhandle, int graph[][MAX_N]); void write_graph(FILE *fhandle, int graph[][MAX_N], int v); /* The number of vertices */ int n; int source, sink; /*------------------------------------------------------------------- The array "graph" holds the initial graph adjacency[i][j] = weight of edge from i to j, graph[i][j] = 0 means no edge ij -------------------------------------------------------------------*/ /* Note that this should really be done with malloc */ int graph[MAX_N][MAX_N]; /* File handles for i/o files set by parse_args() */ FILE *file_in, *file_out;