Main Page   Data Structures   File List   Data Fields   Globals  

bfs.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "full_bfs.h"
#include "memory_man.h"

Include dependency graph for bfs.c:

Include dependency graph

Functions

int main (int argc, char *argv[])
void exit_error (char *err_msg)
 Clears the resources and exists with an error code. More...

int get_line (FILE *stream, char *line, int size)
 Reads a line from the input stream. More...

void print_help (char *prog_name)
 Prints a concise message describing the command line. More...

void print_children (Node *node)
void tree_print (Node *root)
 Prints a tree from root. More...

void graph_init (Graph *graph, const char *file_name)
 Initializes a graph. More...

void graph_clear (Graph *graph)
 Clears a graph. More...

Nodeget_node_by_id (Graph *graph, unsigned int id)
 Obtains a graph node by its id. More...

void BFS (Graph *graph, Node *root)

Function Documentation

void BFS Graph   graph,
Node   root
 

void exit_error char *    err_msg
 

Clears the resources and exists with an error code.

int get_line FILE *    stream,
char *    line,
int    size
 

Reads a line from the input stream.

Node* get_node_by_id Graph   graph,
unsigned int    id
 

Obtains a graph node by its id.

Obtains a graph node by its id. If the id is invalid, generates an error

void graph_clear Graph   graph
 

Clears a graph.

Clears a graph Deallocates all data structures used by a graph

Parameters:
graph  the graph to be cleared

void graph_init Graph   graph,
const char *    file_name
 

Initializes a graph.

Reads a description of a graph from an input file and creates it. Allocates an array if nodes, and adds arcs as necessary.

Parameters:
graph  the output graph
file_name  the name of the input file that contains the graph description.
The file format follows. The number of nodes in the graph (must be greater than 0) followed by bi-directional arcs. An id of a node is a number from 0 to n-1. Each arc is described by a pair of nodes embeded within parenthesis and separated with a comma, for example (1, 2)

Returns:
0 upon success, and a negative number upon failure.
Possible errors: 1. The input file does not exist or it is not readable 2. The number of nodes is 0 3. An attempt to insert an arc that already exists. For example (a,b), (b,a) 4. An attempt to insert a self loops (a, a)

int main int    argc,
char *    argv[]
 

void print_children Node   node
 

void print_help char *    prog_name
 

Prints a concise message describing the command line.

void tree_print Node   root
 

Prints a tree from root.


Generated on Mon May 10 18:07:26 2004 for BFS by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002