Help: Algorithms in C (Sedgewick) "Graph.h"

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
 
M

Martijn

entropy123 said:
Judging by main I would call "Graph.h" but it looks like its been
sorta done already...

What do you mean by "call Graph.h"?
typdef struct Graph {
int E; /*Edges*/
int G; /*Verticies/
}

What does definition of the Graph structure have to do with anything?
Any help would be much appreciated...

What exactly is the problem?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top