-
[输入]
图的顶点个数N,图中顶点之间的关系及起点A和终点B
[输出]
若A到B无路径,则输出“There is no path” 否则输出A到B路...
[输入]
图的顶点个数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
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
- 2022-01-25 22:50:29下载
- 积分:1
-
幼儿学习识字和算数的小软件源码,适合3
幼儿学习识字和算数的小软件源码,适合3-6岁小孩子用.编的比较简单,如有问题请与我联系.-Children learning to read and write and count small software source code, suitable for 3-6 year-old child with. Made of relatively simple, if there are questions please contact me.
- 2023-05-21 10:55:04下载
- 积分:1
-
vod点歌系统,VB开发,操作…
vod 点歌系统,VB开发,操作相对比较简单.-UNESCO Intergovernmental following address system, VB development, operation is relatively simple.
- 2022-08-23 08:19:39下载
- 积分:1
-
地质内存 5509
测试 CPU SDRAM tms320c5509a
测试 ROM 处理器 tms320c5509a
- 2022-04-27 15:00:21下载
- 积分:1
-
服装销售管理系统
服装销售管理系统-clothing sales management system
- 2022-08-19 11:54:02下载
- 积分:1
-
用于水文领域,在调洪演算方面有很多用途,如皮尔逊三型曲线...
用于水文领域,在调洪演算方面有很多用途,如皮尔逊三型曲线-hydrology in the areas of flood calculus has many uses, such as Pearson three-curve
- 2022-01-22 07:43:20下载
- 积分:1
-
这是一个用abel语言编写的三角波发生器
这是一个用abel语言编写的三角波发生器-This is a language used abel triangular wave generator
- 2022-03-16 00:06:31下载
- 积分:1
-
该系统采用B/S架构设计的一个小型的通讯录系统,功能完善,非常实用...
该系统采用B/S架构设计的一个小型的通讯录系统,功能完善,非常实用-The system uses B/S architecture design of a small address book system, fully functional, very practical
- 2022-03-30 00:52:32下载
- 积分:1
-
双边带电路
双边带电路-Bilateral band circuit
- 2023-03-18 11:30:03下载
- 积分:1
-
主要用于考试报名时,区位码转换。
主要用于考试报名时,区位码转换。 -The main application for the examination, the area code-switching.
- 2022-03-16 14:15:59下载
- 积分:1