-
[输入]
图的顶点个数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
-
labview的授权VI
1、打开“授权许可文件生成”,并运行
2、打开许可验证,可查看剩余使用权限
3、发现错误运行“调试差错程序)...
labview的授权VI
1、打开“授权许可文件生成”,并运行
2、打开许可验证,可查看剩余使用权限
3、发现错误运行“调试差错程序)-LabVIEW authorization VI1, open the
- 2022-03-11 07:16:38下载
- 积分:1
-
"vos mini edition"是目前非常流行的模拟钢琴类游戏的mini版,用java实现,通过程序的学习和编写,java学习者可以对java的图形和多媒体...
"vos mini edition"是目前非常流行的模拟钢琴类游戏的mini版,用java实现,通过程序的学习和编写,java学习者可以对java的图形和多媒体应用有了更深入的了解.-"Vos Mini Edition" is a popular emu-piano game in its mini version. Written in Java, you can get more details about the Java MultiMedia and Graphics with the coding and learning the program.
- 2023-01-01 14:55:03下载
- 积分:1
-
matlab对aloha,s
matlab对aloha,s-aloha,csma的仿真-matlab pairs of aloha, s-aloha, csma Simulation
- 2022-01-25 16:56:47下载
- 积分:1
-
矩阵的奇异值分解,ap为是矩阵a,up返回左奇异值,vp返回右奇异值...
矩阵的奇异值分解,ap为是矩阵a,up返回左奇异值,vp返回右奇异值-Matrix singular value decomposition, ap is the matrix for a, up to return the left singular value, vp return the right singular value
- 2022-03-03 12:23:18下载
- 积分:1
-
自己看看,JSP写的简单的聊天程序
自己看看,JSP写的简单的聊天程序-Could see for himself, JSP write a simple chat program
- 2022-03-25 16:10:42下载
- 积分:1
-
flash game series and is a useful Dongdong, hope to be able to help everyone
flash编的游戏是一个和好用的东东,希望能够帮助大家-flash game series and is a useful Dongdong, hope to be able to help everyone
- 2022-05-27 10:41:29下载
- 积分:1
-
不错的c程序啊,下载看看,代码函数也不是很复杂,仔细看看能看明白,我的一点心血!
不错的c程序啊,下载看看,代码函数也不是很复杂,仔细看看能看明白,我的一点心血!-good procedures ah, download see, code function is not very complicated, and to look carefully Naikanmengbai, my point effort!
- 2022-07-19 19:25:00下载
- 积分:1
-
(本文是在论坛已有一篇文章《SIRP法相干相关K分布雷达杂波的建模与仿真》的基础上修改而来,在此首先感谢这篇文章的作者给予我的帮助。之所以完成这篇文章,有三个方...
(本文是在论坛已有一篇文章《SIRP法相干相关K分布雷达杂波的建模与仿真》的基础上修改而来,在此首先感谢这篇文章的作者给予我的帮助。之所以完成这篇文章,有三个方面的原因:一是对原文章和仿真程序代码明显存在一些不一致的地方,因此,我这里对每个公式进行检验(后来证明文章的公式正确无误,但所给的仿真代码存在问题),二是对自己近4天工作的一个总结,以便以后学习可以参考;三是可以放在网上给初学者一些参考,以便后来者不再走自己曾经走过的弯路。文章的一些文字是在匆忙间完成,只求能表达所述意思,没有详细斟酌,海涵:-(This article is an article in the forum have been "SIRP law related coherent K distributed clutter radar modeling and simulation" on modified from the foundation, in this first of all thank the authors of this article has given me help. The reason why the completion of this articles, there are three reasons: First, the original article and simulation program code, there are some obvious inconsistencies, so I here the formula for each test (later proven formula article is correct, but give the simulation code problem exist), near two of their four days of a summary of the job in order to study the future reference three on-line can give some reference for beginners in order to go was no longer the tortuous path they have traversed. arti
- 2022-06-17 14:10:51下载
- 积分:1
-
一个基于马尔可夫链算法的思想编写的自动写文章的程序,输入一篇文章后,可以自动的输出一篇文章。...
一个基于马尔可夫链算法的思想编写的自动写文章的程序,输入一篇文章后,可以自动的输出一篇文章。-An algorithm based on Markov chains prepared by the idea of automatic procedures for writing articles, enter an article, you can automatically output of an article.
- 2022-07-24 23:14:30下载
- 积分:1