-
[输入]
图的顶点个数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
-
气温不起额武器恶趣味气 味人屋企 人我确认
气温不起额武器恶趣味气 味人屋企 人我确认-qweqwe
- 2022-03-03 20:47:42下载
- 积分:1
-
一个C#开发的类似PHOTOSHOP的软件,用到了很多图形算法.
一个C#开发的类似PHOTOSHOP的软件,用到了很多图形算法.-A C# Developed similar PHOTOSHOP software, used a lot of graphics algorithms.
- 2023-02-19 08:45:03下载
- 积分:1
-
球队队员的管理,包括球员年龄,身高,体重的统计,工资派发...
球队队员的管理,包括球员年龄,身高,体重的统计,工资派发-The management of players, including players age, height, weight statistics, the distribution of wages
- 2023-02-28 17:00:04下载
- 积分:1
-
Tetris vc6 prepare concise interface window scaling freedom
俄罗斯方块 vc6编写 界面简洁 窗口自由缩放 -Tetris vc6 prepare concise interface window scaling freedom
- 2023-06-28 06:10:04下载
- 积分:1
-
自己写的一个文字游戏源码!vs2005上写的
自己写的一个文字游戏源码!vs2005上写的-Write their own source of a word game! written in VS2005
- 2022-08-05 22:59:30下载
- 积分:1
-
在MATLAB环境中的WCDMA Design using Simulink,和功能演示.对做第三代移动通信仿真非常有用...
在MATLAB环境中的WCDMA Design using Simulink,和功能演示.对做第三代移动通信仿真非常有用-in MATLAB environment WCDMA Design using Simulink. and functional demo. right to do the 3rd Generation Mobile Communication Simulation very useful
- 2022-05-22 07:11:06下载
- 积分:1
-
ao的一些代码集合,初学者通过这些代码,可以初步了解arcobject。...
ao的一些代码集合,初学者通过这些代码,可以初步了解arcobject。-ao some code set, beginners through these codes can be a preliminary understanding arcobject.
- 2022-05-16 10:08:01下载
- 积分:1
-
某物
没有什么功能,真的没有,你要不信就打开看看。。。说你不听,说了也白说-something
- 2023-01-06 09:55:04下载
- 积分:1
-
刷新bios,最新版本. 刷新bios,最新版本.
刷新bios,最新版本. 刷新bios,最新版本.-Refresh the bios, the latest version. Refresh the bios, the latest version. Refresh the bios, the latest version.
- 2023-08-13 15:35:04下载
- 积分:1