文件名称:tu

  • 所属分类:
  • 其他小程序
  • 资源属性:
  • [WORD]
  • 上传时间:
  • 2012-11-26
  • 文件大小:
  • 10kb
  • 下载次数:
  • 0次
  • 提 供 者:
  • Dem****
  • 相关连接:
  • 下载说明:
  • 别用迅雷下载,失败请重下,重下不扣分!

介绍说明--下载内容均来自于网络,请自行研究使用

[输入]

图的顶点个数N,图中顶点之间的关系及起点A和终点B

[输出]

若A到B无路径,则输出“There is no path” 否则输出A到B路径上个顶点

[存储结构]

图采用邻接矩阵的方式存储。

[算法的基本思想]

采用广度优先搜索的方法,从顶点A开始,依次访问与A邻接的顶点VA1,VA2,...,VAK, 访问遍之后,若没有访问B,则继续访问与VA1邻接的顶点VA11,VA12,...,VA1M,再访问与VA2邻接顶点...,如此下去,直至找到B,最先到达B点的路径,一定是边数最少的路径。实现时采用队列记录被访问过的顶点。每次访问与队头顶点相邻接的顶点,然后将队头顶点从队列中删去。若队空,则说明到不存在通路。在访问顶点过程中,每次把当前顶点的序号作为与其邻接的未访问的顶点的前驱顶点记录下来,以便输出时回溯。

#include<stdio.h>

int number //队列类型

typedef struct{

int q[20]

-[imported] map of the number of vertices N, Vertex map of the relationship between the starting point and end point A and B [output] if A to B without path then exporting "There is no path" Otherwise output A to B on the path vertices [storage structure] plan adopted adjacency matrix of storage. [Algorithm for the basic idea] BFS way from the vertex A, A visit followed with adjacent vertices VA1, VA2 ,..., VAK, visiting times, if not visit B, continue to visit with the VA1 adjacent vertices VA11, VA12 ,..., VA1M. VA2 and then visit the adjacent vertices ... and so on until finding B, the first to reach point B path, must be at least a few side paths. Queue used to achieve record was visited by the vertex. Each visit with the team atop the points are adjacent to the vertex, then t
相关搜索: 广度优先
bfs
BFS
matrix

(系统自动生成,下载前可以参看下载内容)

下载文件列表

tu.doc

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度更多...
  • 请直接用浏览器下载本站内容,不要使用迅雷之类的下载软件,用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.

相关评论

暂无评论内容.

发表评论

*主  题:
*内  容:
*验 证 码:

源码中国 www.ymcn.org