#include<iostream>
using namespace std;
#define QSIZE 20
#define MAXVEX 30
typedef char VType;
typedef int EType;
typedef struct
{
VType Vex[MAXVEX];
EType Arc[MAXVEX][MAXVEX];
int Vnums;
int Enums;
}MGraph;
typedef struct Queue
{
VType *pBase;
int Front;
int Rear;
}Queue;
void InitQueue(Queue &Q)
{
Q.pBase = new VType[QSIZE];
Q.Front = 0;
Q.Rear = 0;
}
bool QueueFull(Queue Q)
{
if ((Q.Rear + 1) % QSIZE == Q.Front)
return true;
else
return false;
}
bool QueueEmpty(Queue Q)
{
if (Q.Front == Q.Rear)
return true;
else
return false;
}
bool EnQueue(Queue &Q, int i)
{
if (QueueFull(Q))
return false;
Q.pBase[Q.Rear] = i;
Q.Rear = (Q.Rear + 1) % QSIZE;
}
bool DeQueue(Queue &Q,int &i)
{
if (QueueEmpty(Q))
return false;
i = Q.pBase[Q.Front];
Q.Front = (Q.Front + 1) % QSIZE;
}
void CreateMGraph(MGraph &G)
{
int i, j, k;
cin >> G.Vnums &
数据结构之图的邻接矩阵BFS(参考C博客—研究毛)
最新推荐文章于 2022-09-07 09:25:00 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)