#ifndef _GRAPH_H #define _GRAPH_H /* * We can use this header for both * directed graph or undirected graph * by toggle boolean flag 'directed' * in graph structure. */ #include #include #include #include "queue/queue.h" #define MAXV 5 /* maximum number of vertices */ typedef struct edgenode { int y; /* adjacency info */ int weight; /* edge weight if any */ struct edgenode * next; /* next edge in list */ } edgeNode; /* graph nodes start by 1 */ typedef struct { edgeNode * edges[MAXV + 1]; /* adjacency info */ int degree[MAXV + 1]; /* outdegree of each vertex */ int nvertices; /* number of vertices in graph */ int nedges; /* number of edges in graph */ bool directed; /* is the graph directed? */ bool discovered[MAXV + 1]; bool processed[MAXV + 1]; int parent[MAXV + 1]; } graph; void retreat (char * str); void initializeGraph(graph * g, bool directed); void readGraph (graph * g, bool directed); void insertEdge (graph * g, int x, int y, bool directed); void printGraph (graph * g); void purgeGraph (graph * g); void initializeSearch(graph * g); void bfs(graph * g, int start); #endif