实验环境:win10, DEV C++5.11 实验要求: 实现图的深度优先遍历 实验代码: #include <iostream> #define maxSize 255 #include "stdlib.h" /* run this program using the console pauser or add your own getch, system("pause") or input loop */ /*the definition of s…
图的深度优先遍历c++实现 深度优先搜索 邻接矩阵的创建 int i, j, m, a, b; cin >> n >> m; //初始化二维矩阵 for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) if (i == j)e[i][j] = 0; else e[i][j] = 0x3f; //读入顶点之间的边 for (i = 1; i <= m; i++) { cin >> a >> b; e…