#ifndef GRAPH_H #define GRAPH_H /* adjacency list implementation */ struct edge; struct vertex { struct edge *adj; /* edges linked list */ }; struct edge /* probably not a good name for this */ { struct vertex *to; /* other vertex in edge */ struct edge *next; }; struct graph { struct vertex *v; /* array of vertices */ unsigned int nv; /* number of vertices */ }; struct graph *new_graph (unsigned int nv); void free_graph (struct graph *g); int add_arc (struct graph *g, unsigned int vi, unsigned int vj); void del_arc (struct graph *g, unsigned int vi, unsigned int vj); int add_edge (struct graph *g, unsigned int vi, unsigned int vj); void del_edge (struct graph *g, unsigned int vi, unsigned int vj); static __inline__ unsigned int vertex_id (struct graph *g, struct vertex *v) { return (unsigned int)(v - g->v); } #endif /* GRAPH_H */