-
[输入]
图的顶点个数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
-
altera cycloneII fpga 的pcb封装图,protel格式的,下载后加载,省得自己画了。...
altera cycloneII fpga 的pcb封装图,protel格式的,下载后加载,省得自己画了。-altera cycloneII fpga the pcb package plans, protel format, download load clinics to save their own a painting.
- 2023-02-23 23:30:03下载
- 积分:1
-
a very common procedure, the database application, prepared by PB
很普通的一个程序,数据库的应用,PB编写的-a very common procedure, the database application, prepared by PB
- 2022-06-18 01:06:57下载
- 积分:1
-
数据结构。表用于创建线性和线性规模的圣..
数据结构第一次实验。用来创建线性表和求取线性表的第i个元素。-data structure first experiment. Table used to create linear and linear scale struck the first i elements.
- 2022-07-27 21:37:37下载
- 积分:1
-
This is a language used to write c produced color box.
这是一个采用c语言来编写制作彩色框。-This is a language used to write c produced color box.
- 2022-07-19 18:59:09下载
- 积分:1
-
主要用于排队仿真,用的是MATLAB语言,希望能和大家分享。
主要用于排队仿真,用的是MATLAB语言,希望能和大家分享。-Mainly used in queuing simulation, using the MATLAB language, want to share with you all.
- 2022-01-26 00:56:02下载
- 积分:1
-
贪吃蛇游戏代码.不是我写的,有兴趣的可以看一下.
贪吃蛇游戏代码.不是我写的,有兴趣的可以看一下.-Snake game code. I did not write and are interested can look at.
- 2023-03-09 00:50:03下载
- 积分:1
-
prolog program, it seems quite good, we may as well look at the question I do no...
prolog程序,好像挺不错的,大家不妨看看,那里不懂问我哈-prolog program, it seems quite good, we may as well look at the question I do not know where Kazakhstan
- 2023-06-09 01:25:03下载
- 积分:1
-
peeping, including client and server. no source function. the computer can send...
偷窥者 ,包括客户端和服务端,无源程序功能.可以给对方电脑发送.可以偷窥到对方的桌面内容,按设置的时间进行刷新.为了速度,可以设定获取桌面图像的位数.-peeping, including client and server. no source function. the computer can send to each other. can peeping into the opponent"s desktop, set up by the time set. To speed access can set the desktop image median.
- 2022-01-25 19:09:49下载
- 积分:1
-
AH简单下载系统
AH简单下载系统-AH simple Download System Proposed
- 2023-03-05 16:20:04下载
- 积分:1