#include<iostream>
using namespace std;
#define mvnum 100//最大顶点数
typedef int arctype;//假设边的权值类型为整型
typedef char vertextype;//设顶点的数据类型为字符型
typedef struct
{
vertextype vexs[mvnum];//顶点表
arctype arcs[mvnum][mvnum];//邻接矩阵
int vexnum, arcnum;
}amgraph;
int visited[mvnum] = { 0 };
void DFS(amgraph& G, int v)//第v个结点开始
{
cout <<v;
visited[v] = 1;
for (int w = 0;w < G.vexnum;w++)
{
if (G.arcs[v][w] != 0 && !visited[w])
DFS(G, w);
}
}
int main()
{
return 0;
}
深度优先搜索遍历算法的实现
最新推荐文章于 2024-09-16 12:36:03 发布