E
entropy123
Hey all,
In an effort to solve a sticky - for me - problem I've picked up
Sedgewick's 'Algorithm's in C'. I've tried working through the first
few problems but am a little stumped when he refers to #include
"Graph.h" in the header file of the first program.
The style he uses to make his declarations is a little unfamiliar to
me, but here is my best guess at a "Graph.h" header file:
#ifndef FILE_H
#define FILE_H
typedef struct { int v; int w; } Edge;
Edge EDGE( int, int);
typedef struct graph *Graph;
Graph GRAPHinit(int);
void GRAPHinsertE(Graph, Edge );
void GRAPHremoveE(Graph, Edge );
int GRAPHedges( Edge[], Graph G );
Graph GRAPHcopy(Graph);
void GRAPHdestroy(Graph);
Graph GRAPHrand( int V, int E );
void GRAPHshow( Graph G );
void dfsRcc( Graph G, int v, int id );
int GRAPHcc(Graph G);
#endif
And here is main:
main (int argc, char * argv[] ) {
int V = atoi( argv[1] ), E = atoi( argv[2] );
Graph G = GRAPHrand(V,E);
if ( V < 20 )
GRAPHshow(G);
else printf("%d vertices, %d edges, ", V, E );
printf( "%d component(s)\n", GRAPHcc(G));
}
Judging by main I would call "Graph.h" but it looks like its been
sorta done already...
typdef struct Graph {
int E; /*Edges*/
int G; /*Verticies/
}
Any help would be much appreciated...
Thanks,
entropy
In an effort to solve a sticky - for me - problem I've picked up
Sedgewick's 'Algorithm's in C'. I've tried working through the first
few problems but am a little stumped when he refers to #include
"Graph.h" in the header file of the first program.
The style he uses to make his declarations is a little unfamiliar to
me, but here is my best guess at a "Graph.h" header file:
#ifndef FILE_H
#define FILE_H
typedef struct { int v; int w; } Edge;
Edge EDGE( int, int);
typedef struct graph *Graph;
Graph GRAPHinit(int);
void GRAPHinsertE(Graph, Edge );
void GRAPHremoveE(Graph, Edge );
int GRAPHedges( Edge[], Graph G );
Graph GRAPHcopy(Graph);
void GRAPHdestroy(Graph);
Graph GRAPHrand( int V, int E );
void GRAPHshow( Graph G );
void dfsRcc( Graph G, int v, int id );
int GRAPHcc(Graph G);
#endif
And here is main:
main (int argc, char * argv[] ) {
int V = atoi( argv[1] ), E = atoi( argv[2] );
Graph G = GRAPHrand(V,E);
if ( V < 20 )
GRAPHshow(G);
else printf("%d vertices, %d edges, ", V, E );
printf( "%d component(s)\n", GRAPHcc(G));
}
Judging by main I would call "Graph.h" but it looks like its been
sorta done already...
typdef struct Graph {
int E; /*Edges*/
int G; /*Verticies/
}
Any help would be much appreciated...
Thanks,
entropy