#define MAX_VERTICES 50
#define TRUE 1
#define FALSE 0
short intvidited[MAX_VERTICES];
typedef struct node* node_pointer;
typedef struct node{
int vertex;
struct node* link;
};
typedef struct queue* queue_pointer;
typedef struct queue{
int vertex;
queue_pointer link;
};
void addq(queue_pointer*, queue_pointer*,int);
int deleteq(queue_pointer*);
void bfs(int v){
node_pointer w;
queue_pointer front,rear;
front=rear=NULL;
printf("%5d",v);
visited[v]=TRUE;
addq(&front,&rear,v);
while(front){
v=deleteq(&front);
for(w=graph[v]; w; w=w->link)
if(visited[w->vertex]){
printf("%5d",w->vertex);
addq(&front,&rear,w->vertex);
visited[w->vertex]=TRUE;
}
}
}