-
[输入]
图的顶点个数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
-
陨石撞飞机(加强版)特别添加了声音效果以及背景的图案
陨石撞飞机(加强版)特别添加了声音效果以及背景的图案-Meteorite hit aircraft (enhanced version)
- 2022-10-25 03:50:04下载
- 积分:1
-
Using VC++ 6.0 for the Tankedaizhan, very practical, may be interested to see if...
用VC++ 6.0 编的坦克大战,蛮实用的,有兴趣的可以看看,会对你有所帮助。-Using VC++ 6.0 for the Tankedaizhan, very practical, may be interested to see if it would be helpful to you.
- 2022-01-22 13:34:11下载
- 积分:1
-
vb编写的水文监测系统。主要通过pc机的串口通讯。
vb编写的水文监测系统。主要通过pc机的串口通讯。-vb prepared by the hydrological monitoring system. Pc machine, mainly through the serial port communications.
- 2023-07-31 21:35:03下载
- 积分:1
-
这个是朋友叫做的,可以让电脑变魔术读懂你的心,好玩吧?看看吧...
这个是朋友叫做的,可以让电脑变魔术读懂你的心,好玩吧?看看吧-This is a friend called, and can allow the computer to read your mind magic, fun, right? Let" s see it
- 2022-01-24 09:37:54下载
- 积分:1
-
2009年9月 《无线电》附资料 可以下载 有源代码
2009年9月 《无线电》附资料 可以下载 有源代码-In September 2009 " radio" attached to the information source code can be downloaded
- 2022-06-12 07:17:37下载
- 积分:1
-
一个用于服务器与各客户端进行时间同步的源码.
一个用于服务器与各客户端进行时间同步的源码.-one for servers and the client time synchronization of the source.
- 2022-03-20 08:22:51下载
- 积分:1
-
最小二乘法多次曲线拟合算法
最小二乘法多次曲线拟合算法-Multi-times Least squares algorithm curve fitting
- 2022-03-30 16:57:49下载
- 积分:1
-
delphi与图形学结合的一个小程虚
delphi与图形学结合的一个小程虚-graphics with a combination of small-empty
- 2023-06-15 20:00:03下载
- 积分:1
-
C#做的定时关机、重新启动、注销程序,保护你的健康!
C#做的定时关机、重新启动、注销程序,保护你的健康!
- 2022-10-24 02:20:03下载
- 积分:1