图的邻接矩阵存储,以及在此基础上实现的广度优先遍历(BFS)。
如有错误,请帮忙指出啦!!!
喜欢的话点个赞呗!!!
/*图的邻接矩阵+广度优先遍历*/
#include<stdio.h>
#include<stdlib.h>
#define INFINITE 65535
#define MaxSize 100
typedef char VertexType;
typedef int EdgeType;
typedef int ElemType;
typedef struct{
ElemType data[MaxSize];
int front, rear;
}SqQueue;
typedef struct Graph{
VertexType vexs[MaxSize]; //顶点表
EdgeType arc[MaxSize][MaxSize]; //邻接矩阵
int vexNum, arcNum;
}Graph;
void InitQueue(SqQueue *Q); //初始化循环队列
int IsEmpty(SqQueue Q); //判队空
int EnQueue(SqQueue *Q, ElemType e); //入队
int DeQueue(SqQueue *Q, ElemType *e); //出队
/*-----------------------------------------------------------------------------*/
int visited[MaxSize];
SqQueue Q;
void CreateGraph(Graph *G); //创建图
void OutputGraph(Graph G); //输出图中所有顶点
int GetVexIndex(Graph G,VertexType vex); //根据顶点信息得出其对应的顶点序号
int FirstNeighbor(Graph G,