-
[输入]
图的顶点个数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
-
C#五子棋源代码
C#五子棋源代码,人与电脑对战的五子棋游戏,为了更好的实现游戏逻辑,在界面上没有过多考虑,因此图省事使用了IrisSkin2.dll控件,想自己做界面的可去掉此控件。
- 2022-07-26 20:06:52下载
- 积分:1
-
一些编写jsp程序的资料,适于初学者,希望对初学者有用。
一些编写jsp程序的资料,适于初学者,希望对初学者有用。-Jsp some preparation procedure, suitable for beginners, and they hope to be useful for beginners.
- 2022-02-06 14:38:03下载
- 积分:1
-
rescue elf, leisure games, a girlfriend of attention, particularly for girls to...
拯救小精灵,休闲游戏,有女朋友的注意了,特别适合女孩子玩,全屏游戏,下载后直接把后缀改为jar即可-rescue elf, leisure games, a girlfriend of attention, particularly for girls to play, full-screen games, After downloading directly to the suffix can jar
- 2023-06-12 05:40:03下载
- 积分:1
-
温度传感器ds18b20
温度传感器ds18b20-Temperature sensor DS18B20
- 2022-08-25 06:10:15下载
- 积分:1
-
VB拼图游戏-甲虫2源码
2004年重写的甲虫2拼图游戏,仍然使用VB编写。甲虫2的定位仍然是MiniGame,以第一版为蓝本重新编写了代码,用时一天,不包含测试。操作除保留上一代的键盘方向键(←↑↓→)外,更加入鼠标支持。游戏规则仍旧是将玩家自选的凌乱图片复原到原貌。可作为VB编写拼图游戏的一个范本来参考。
- 2022-03-02 23:30:04下载
- 积分:1
-
易语言内存读写例子
易语言内存读写例子-easy language to read and write memory examples!
- 2022-06-02 23:57:12下载
- 积分:1
-
分水岭算法的演示程序
分水岭算法的演示程序
分水岭算法的演示程序
分水岭算法的演示程序
-watershed algorithm Demonstration Program watershed algorithm Demonstration Program
- 2022-03-09 15:16:05下载
- 积分:1
-
ep1c20 LEON3 for改变FPGA的补丁。
leon3 patch for altera ep1c20 FPGA.
- 2022-01-30 10:09:41下载
- 积分:1
-
Swing浏览器插件实例,这个简单的例子可以用在双屏推送上的测试例子...
Swing浏览器插件实例,这个简单的例子可以用在双屏推送上的测试例子-swing
- 2022-02-11 16:18:01下载
- 积分:1