By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,133 Members | 1,113 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,133 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
entropy123 wrote:
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?

--
Martijn Haak
http://www.serenceconcepts.nl
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.