图的遍历
的有关信息介绍如下:#include"stdio.h"#include"string.h"#include"stdlib.h"#include"math.h"#define MAX_INT 1000#define MAX_VERTEX_NUM 20#define MAX_QUEUE_NUMBER 20typedef struct ArcNode{ int adjvex; double adj; struct ArcNode *nextarc;}ArcNode;typedef struct VexNode{ char szName[40]; ArcNode *firstarc;}VexNode,AdjList[MAX_VERTEX_NUM];typedef struct { AdjList vexs; int vexnum,arcnum;}Net;//定义队列typedef struct{ int *elem; int front, rear;}Queue;void InitQueue(Queue &Q){ Q.elem = new int[MAX_QUEUE_NUMBER]; Q.front = Q.rear = 0;}int EmptyQueue(Queue Q){ if(Q.front==Q.rear) return 0; else return 1;}void DestroyQueue(Queue &Q){ delete []Q.elem; Q.front = Q.rear = 0;}void EnterQueue(Queue &Q, int e){ if((Q.rear + 1)%MAX_QUEUE_NUMBER != Q.front) Q.elem[Q.rear ] = e; else printf("队列满!\n"); Q.rear = (Q.rear + 1)%MAX_QUEUE_NUMBER;}void LeaveQueue(Queue &Q, int &e){ if(Q.rear != Q.front) e = Q.elem[Q.front]; else printf("队列空!\n"); Q.front = (Q.front+1)%MAX_QUEUE_NUMBER;}int LocateVex(Net ga,char *name){ int i; for(i=0;i