//图,用邻接表表示
//编译环境:Visual Studio 2008,win 32 console application
//ALGragh.c
#include <stdio.h>
#include <stdlib.h>
#define ERROR 0
#define OK 1
#define MAX_VERTEX_NUM 10
#define QM 10 //队列的最大元素个数
int visited[MAX_VERTEX_NUM];
typedef char VertexType;
typedef int InfoType;
//弧节点(边节点)结构
typedef struct _ArcNode
{
int adjvex;//该弧所指向的顶点的位置
struct _ArcNode *nextarc;//指向下一条弧的指针
InfoType info;//信息,本例中为弧的权重
}ArcNode;
//顶点表节点结构
typedef struct _VNode
{
int data;
ArcNode *firstarc;//边表的头指针
}VNode;
//图的结构
typedef struct
{
VNode vertex[MAX_VERTEX_NUM];//表头向量
int vexnum,arcnum;//当前的顶点数和弧数
}AdjList;
定义队列/
typedef struct
{
VertexType *base;
VertexType front,rear;
}SQueue;
函数声明/
int CreateGragh(AdjList *G);
int LocateVex(AdjList *G,VertexType v);
void DispGragh(AdjList *G);
void BFS(AdjList *G,int v0);//广度遍历
void DFS(AdjList *G,int v0);//深度遍历
///与队列有关的声明/
void InitQueue(SQueue *Q);
void EnQueue(SQueue *Q,int e);
int QueueEmpty(SQueue