-
[输入]
图的顶点个数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程序源代码,编译命令cc
C程序源代码,编译命令cc-ofgetfget.c-lcurses 此程序适用于SCOUNIX主机系-C source code, compile command cc-ofgetfget.c- lcurses this procedure applies to SCO UNIX mainframe line
- 2023-08-01 17:15:02下载
- 积分:1
-
VHDL SPI interface, the application of Altera EMP off
VHDL 实现的SPI接口,在Altera EMP7128 上应用过-VHDL SPI interface, the application of Altera EMP off
- 2022-08-07 13:24:30下载
- 积分:1
-
这是一个较好的关于主从报表的源代码,希望大家共同学习!...
这是一个较好的关于主从报表的源代码,希望大家共同学习!-This is a good statement from the owner of the source code, we hope to learn together!
- 2022-03-21 00:50:33下载
- 积分:1
-
一个时钟的源程序的程序,实现了功能的控制等…
针对一款时钟的源代码程序,实现时钟控制等功能,led display c-A clock for the source code of procedure, to achieve control of features such as clock, led display c
- 2022-07-25 13:34:31下载
- 积分:1
-
CUDA计算架构的GPU的互信息
cuda compute device architecture mutual information on the gpu
- 2022-03-01 20:24:10下载
- 积分:1
-
改文档为PHP文档,可供大家参考使用
改文档为PHP文档,可供大家参考使用 -reform document for PHP files, which can be used as reference documents for the reform PHP documentation for reference use
- 2022-05-14 10:20:08下载
- 积分:1
-
VC++ Common GIS function development solution (1.1) source code, C++ Of GIS to d...
VC++通用GIS功能开发解决方案(1.1)源代码,C++的GIS开发小型SDK组件的代码示例,有助于学习掌握基本的C++/GIS开发技术。源自网上收集,可供学习和参考使用。-VC++ Common GIS function development solution (1.1) source code, C++ Of GIS to develop small SDK sample code components, contribute to learning and mastering the basic C++/GIS technology. Derived from the online collection, available for study and reference.
- 2023-06-26 04:10:04下载
- 积分:1
-
Communication software communication software communication software
通讯软件 通讯软件-Communication software communication software communication software
- 2022-01-26 00:34:52下载
- 积分:1
-
Pontoon, English
浮舟英汉词典,袖珍型词典,喜欢就拿去吧。-Pontoon, English-Chinese dictionary, pocket dictionary, like to take it.
- 2022-04-21 15:28:37下载
- 积分:1