/* Search for the image's breadth first */
# Include <stdlib. h>
# Define MAXQUEUE 10/* Maximum queue capacity */
Struct node/* Graphic Vertex Structure Announcement */
{
Int vertex;/* vertex data */
Struct node * nextnode;/* indicates the indicator of the next vertex */
};
Typedef struct node * graph;/* New graph structure State */
Struct node head [9];/* array of graph vertex structures */
Int visited [9];/* traverse record array */
Int queue [MAXQUEUE];/* queue array declaration */
Int front =-1;/* front-end of the queue */
Int rear =-1;/* backend of the queue */
/*----------------------------------------*/
/* Create a graph */
/*----------------------------------------*/
Void creategraph (int * node, int num)
{
Graph newnode;/* New vertex indicator */
Graph ptr;
Int from;/* the starting point of the Edge */
Int to;/* edge end */
Int I;
For (I = 0; I <num; I ++)/* read the Circuit of The Edge */
{
From = node [I * 2];/* edge start point */
To = node [I * 2 + 1];/* edge end */
/* Create a new vertex memory */
Newnode = (graph) malloc (sizeof (struct node ));
Newnode-> vertex = to;/* create vertex content */
Newnode-> nextnode = NULL;/* set the initial value of the indicator */
Ptr = & (head [from]);/* vertex position */
While (ptr-> nextnode! = NULL)/* traverse to the end of the linked list */
Ptr = ptr-> nextnode;/* next vertex */
Ptr-> nextnode = newnode;/* insert end */
}
}
</