-
[输入]
图的顶点个数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
-
Jbuilder开发的多人聊天系统!客户端跟服务器端源代码都有!
Jbuilder开发的多人聊天系统!客户端跟服务器端源代码都有!-Jbuilder development of the people chatting system. Client server with source code!
- 2022-05-29 19:28:09下载
- 积分:1
-
冒泡法,快速排序等排序的实现
冒泡法,快速排序等排序的实现-Bubble, rapid sequencing order as the realization
- 2022-01-30 19:30:24下载
- 积分:1
-
Socket建立服务器,比较简单,一看就清楚的程序代码
Socket建立服务器,比较简单,一看就清楚的程序代码
- 2023-08-03 13:55:03下载
- 积分:1
-
wince小游戏24点
流行的小游戏,对于wince新手来说,是一个很好的跳板,能更快的进步!
- 2022-05-09 04:15:32下载
- 积分:1
-
该程序是演示ARM的5个ADC转换功能,在AD采样时轮流切换...
该程序是演示ARM的5个ADC转换功能,在AD采样时轮流切换-The ARM program is to demonstrate the 5 ADC conversion functions in AD, when the sampling switch rotation
- 2022-02-01 21:34:17下载
- 积分:1
-
无刷直流电动机需要多种电压电平来控制转速:0V 使电动机停转,5V 使电动机以最大转速运转,而在0V和5V之间的电压则使电动机以较低的转速运转...
无刷直流电动机需要多种电压电平来控制转速:0V 使电动机停转,5V 使电动机以最大转速运转,而在0V和5V之间的电压则使电动机以较低的转速运转-The needs of a wide range of brushless DC motor voltage level to control the rotational speed: 0V stop the motor switch, 5V maximum speed of the motor running, and in between 0V and 5V voltage while the motor running at low speed
- 2022-07-14 10:04:40下载
- 积分:1
-
Section map we can look at the fortran program
切面图的fortran程序 大家随意-Section map we can look at the fortran program
- 2022-03-26 12:40:29下载
- 积分:1
-
用于批量删除某类文件的一个小程序
用于批量删除某类文件的一个小程序-volume for the deletion of certain documents a small program
- 2023-02-25 17:00:03下载
- 积分:1
-
可以对操作系统的注册表进行读、写、删除操作
可以对操作系统的注册表进行读、写、删除操作-The registry of the operating system can read, write, delete
- 2022-01-28 21:55:46下载
- 积分:1