-
[输入]
图的顶点个数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
-
rtc
rtc-rtc
- 2022-07-27 06:29:12下载
- 积分:1
-
30天改变你的人生,30天改变你的人生30天改变你的人生,30天改变你的人生...
30天改变你的人生,30天改变你的人生30天改变你的人生,30天改变你的人生-30 days to change your life, 30 days to change your life 30 days to change your life, 30 days to change your life
- 2022-02-05 03:10:05下载
- 积分:1
-
泰利特容易Python脚本文件
Telit easy python scripting document
- 2022-10-11 19:25:03下载
- 积分:1
-
一个简单的点
简单的点阵程序,在一个16*16的点阵上显示一个汉字-A simple dot-matrix procedure, a 16* 16 dot matrix display a Chinese character
- 2022-08-07 19:11:21下载
- 积分:1
-
贪吃蛇源码 vc6.0编译无错,代码可用,可以完成平常见到的贪吃蛇的功能...
贪吃蛇源码 vc6.0编译无错,代码可用,可以完成平常见到的贪吃蛇的功能-classical game, snake eating food and then became long
- 2023-04-09 21:15:04下载
- 积分:1
-
with the ringing language games, very suitable for the preparation of the game h...
一款用c语言编写的猜数字游戏,非常适合刚刚开始编写游戏的新手-with the ringing language games, very suitable for the preparation of the game has just begun newbie
- 2022-01-25 16:18:52下载
- 积分:1
-
System Dynamics Simulation Software vesim the Chinese user manual is described i...
详细介绍了系统动力学仿真软件vesim的中文用户手册。
- 2022-03-20 17:28:24下载
- 积分:1
-
《Dreamweaver MX 2004中文版精彩设计百例》源代码,WinRAR自解压包...
《Dreamweaver MX 2004中文版精彩设计百例》源代码,WinRAR自解压包-"Dreamweaver MX 2004 Chinese version brilliant design hundred cases" source code, WinRAR self-extract package
- 2022-04-10 19:22:27下载
- 积分:1
-
方佳时fahirjgjkdfjkl阿拉伯distribution of the
fahirjgjkdfjkl 丰卡时间阿科技安分 发 啊啊啊啊啊 -fahirjgjkdfjkl Fonka time distribution of the Arab-Israeli Science and Technology Security ah ah ah ah ah
- 2022-01-25 14:25:06下载
- 积分:1