/* 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 */
}
}