算法代码
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 100
typedef int VerTexType;
typedef int EdgeType;
typedef struct{
VerTexType verxs[MAXSIZE];
EdgeType arcs[MAXSIZE][MAXSIZE];
int vexnum,arcnum;
}AMGraph;
int visited[MAXSIZE];
void Create_AMGraph(AMGraph * G);
void DFSTraverse(AMGraph G);
void BFSTraverse(AMGraph G);
int main(){
AMGraph G;
printf("\n---采用邻接矩阵表示图的遍历---\n\n");
Create_AMGraph(&G);
printf("\n-----------邻接矩阵深度优先搜索遍历序列---------------\n\n");
DFSTraverse(G);
printf("\n-----------邻接矩阵广度优先搜索遍历序列---------------\n\n");
BFSTraverse(G);
printf("\n\n");
system("pause");
return 0;
}
void Create_AMGraph(AMGraph * G){
int i,j,k;
printf("请输入要创建的顶点数和边数:(空格间隔)\n"