图
数据结构 图
吹灭读书灯 一身都是月
你还有好多未完成的梦
你有什么理由停下脚步
展开
-
C++使用邻接表储存图与DFS、BFS遍历(使用类模板)详细注释
用邻接表实现图:(先放上总代码吧,仔细看也不多的????)#include <iostream>#include <queue>using namespace std;const int MaxSize = 10; //图的最大顶点数bool visited[10] = {0,0,0,0,0,0,0,0,0,0};struct ArcNode //边表{ int adjvex; //邻接点域,存储该顶点对应的下标 struct ArcNo原创 2020-05-11 15:49:36 · 956 阅读 · 2 评论 -
C++使用邻接矩阵储存图与DFS、BFS遍历(使用类模板)
使用邻接矩阵储存图/* 使用邻接矩阵储存图 */#include <iostream>#include <queue>using namespace std;bool visited[10] = {0,0,0,0,0,0,0,0,0,0};const int MaxSize=10; //最大顶点数template <class DataType>class Mgraph{ public: Mgraph(DataType a[],原创 2020-05-11 15:26:26 · 603 阅读 · 0 评论