//图的广度优先遍历算法、
#include "stdafx.h"
#include<iostream>
using namespace std;
#define OK 1
#define ERROR -1
#define MAXNUM 100
#define MAXINT 32767
typedef int Status;
typedef char VerTexType;
typedef int ArcType;
typedef int QElemType;
typedef struct {
QElemType * base; // dynamic Initialization
int front, rear;
}sqQueue;
typedef struct {
VerTexType vexs[MAXNUM];
ArcType arcs[MAXNUM][MAXNUM];
int vexnum, arcnum;
}AMGraph;
Status InitiQueue(sqQueue &q) {
q.base = new QElemType[MAXNUM];
if (!q.base)exit(ERROR);
q.front = q.rear = 0;
return OK;
}
Status EnQueue(sqQueue &q, QElemType e) {
// 队满不能进队
if ((q.rear + 1) % MAXNUM == q.front) {
#include "stdafx.h"
#include<iostream>
using namespace std;
#define OK 1
#define ERROR -1
#define MAXNUM 100
#define MAXINT 32767
typedef int Status;
typedef char VerTexType;
typedef int ArcType;
typedef int QElemType;
typedef struct {
QElemType * base; // dynamic Initialization
int front, rear;
}sqQueue;
typedef struct {
VerTexType vexs[MAXNUM];
ArcType arcs[MAXNUM][MAXNUM];
int vexnum, arcnum;
}AMGraph;
Status InitiQueue(sqQueue &q) {
q.base = new QElemType[MAXNUM];
if (!q.base)exit(ERROR);
q.front = q.rear = 0;
return OK;
}
Status EnQueue(sqQueue &q, QElemType e) {
// 队满不能进队
if ((q.rear + 1) % MAXNUM == q.front) {