00001 #ifndef BFS_H 00002 #define BFS_H 00003 00005 typedef struct node { 00007 unsigned int id; 00008 00009 /* The nodes directly connected to this node */ 00010 Neighbors_list neighbors; 00011 00012 /* Data used by the BFS algorithm: */ 00013 enum {white, gray, black} color; 00014 00015 /* A neighbor declared as parent in the tree */ 00016 struct node *parent; 00017 00018 /* The Neighbors declared as children in the tree */ 00019 Children_list children; 00020 } Node; 00021 00023 typedef struct graph { 00024 /* The graph nodes */ 00025 Node *nodes; 00026 00027 /* The number of nodes in the graph */ 00028 unsigned int size; 00029 } Graph; 00030 00032 int graph_init(Graph * graph, const char *file_name); 00033 00035 void graph_clear(Graph * graph); 00036 00038 void BFS(Node * root); 00039 00041 Node *get_node_by_id(Graph * graph, unsigned int id); 00042 00044 void tree_print(Node *root); 00045 00047 void exit_error(char *err_msg); 00048 00050 void print_help(char * prog_name); 00051 00053 int get_line(FILE * stream, char * line, int size); 00054 00055 #endif