数据结构实验七图的创建与遍历.doc
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《数据结构实验七图的创建与遍历.doc》由会员分享,可在线阅读,更多相关《数据结构实验七图的创建与遍历.doc(5页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Four short words sum up what has lifted most successful individuals above the crowd: a little bit more.-author-date数据结构实验七图的创建与遍历实验要求与规范实验七 图的创建与遍历实验目的: 通过上机实验进一步掌握图的存储结构及基本操作的实现。实验内容与要求: 要求: 能根据输入的顶点、边/弧的信息建立图; 实现图中顶点、边/弧的插入、删除; 实现对该图的深度优先遍历;实现对该图的广度优先遍历。备注:单号基于邻接矩阵,双号基于邻接表存储结构实现上述操作。算法设计:-#include
2、 #include #define INFINITY 32767 #define MAX_VEX 20 /最大顶点个数 #define QUEUE_SIZE (MAX_VEX+1) /队列长度 using namespace std; bool *visited; /访问标志数组/图的邻接矩阵存储结构 typedef structchar *vexs; /顶点向量 int arcsMAX_VEXMAX_VEX; /邻接矩阵 int vexnum,arcnum; /图的当前顶点数和弧数 Graph; /队列类 class Queuepublic:void InitQueue() base=(in
3、t *)malloc(QUEUE_SIZE*sizeof(int); front=rear=0; void EnQueue(int e) baserear=e; rear=(rear+1)%QUEUE_SIZE; void DeQueue(int &e) e=basefront; front=(front+1)%QUEUE_SIZE; public: int *base; int front; int rear; ; /图G中查找元素c的位置 int Locate(Graph G,char c)for(int i=0;iG.vexnum;i+)if(G.vexsi=c) return i; r
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据结构 实验 创建 遍历
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内