-
[输入]
图的顶点个数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
-
国防工业部VB高级编程源码
国防工业部VB高级编程源码-defense ministry source VB Advanced Programming
- 2022-03-17 19:51:40下载
- 积分:1
-
procedures with Java JiuGongTu series of the game program, which is applet, comp...
用JAVA程序编的九宫棋程序,该程序是applet,请编译后执行-procedures with Java JiuGongTu series of the game program, which is applet, compiled implementation
- 2023-08-20 02:35:03下载
- 积分:1
-
稀疏矩阵
此代码是关于稀疏矩阵。我表示稀疏矩阵为结构。它还可以做稀疏矩阵加法。如果你读了这段代码然后你可以了解有关内存分配、 指针和结构中的应用。稀疏 matrix 元素几乎为 0,所以如果你将它定义为 2 的三维数组,然后它会浪费内存。解我的想法是,使用结构.通知: 我是韩国的所以所有的文件和在 c 文件上的评论由朝鲜语写的。
- 2022-10-02 11:45:05下载
- 积分:1
-
This is a Gaussian elimination of the solution equation c language. For multiple...
这是一个高斯消元发解方程的c语言实现。对于接多元方程非常的方便-This is a Gaussian elimination of the solution equation c language. For multiple access very convenient equation
- 2022-02-02 13:19:39下载
- 积分:1
-
timing charateristics of netlist in verilog
timing charateristics of netlist in verilog
- 2022-08-15 18:53:32下载
- 积分:1
-
土木工程中无应力时长度计算程序,可按内容适当作修改再应用于不同的地方...
土木工程中无应力时长度计算程序,可按内容适当作修改再应用于不同的地方-civil engineering at length without stress calculation procedures can be revised as appropriate then applied to different places
- 2023-08-11 10:20:03下载
- 积分:1
-
非常之经典的停车场停车问题,解决停车问题的算法
非常之经典的停车场停车问题,解决停车问题的算法-very classic car parks and solving the parking problem Algorithm
- 2023-06-21 01:55:03下载
- 积分:1
-
埋藏史计算软件,用于石油系统;非原创,欢迎下载交流
埋藏史计算软件,用于石油系统;非原创,欢迎下载交流-Burial history calculation software for the oil system non-original, welcome to download the exchange of
- 2022-06-21 22:51:25下载
- 积分:1
-
一个复数运算的类
一个复数运算的类-a complex computing category
- 2022-03-24 00:24:23下载
- 积分:1