-
[输入]
图的顶点个数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
-
yuan dai ma
yuan dai ma
- 2022-06-11 21:09:17下载
- 积分:1
-
用protel软件打开来看的,烧程序电路板的原理接线图
用protel软件打开来看的,烧程序电路板的原理接线图-Using protel software, open view, the burning process the principle of the circuit board wiring diagram
- 2022-07-18 09:43:18下载
- 积分:1
-
类numberlistener实现ActionListener {
class NumberListener implements ActionListener{
public void actionPerformed(ActionEvent e){
if (!append) {
tf.setText("")
append=true
}
String s=tf.getText()
s+=e.getActionCommand()
tf.setText(s)
if (!btn[10].isEnabled()){
for(int i=10 i
- 2022-02-28 23:01:36下载
- 积分:1
-
(TC2中包含的头文件集合),有很多经典的头文件,我测试了一下可在VC6中直接调用了。...
(TC2中包含的头文件集合),有很多经典的头文件,我测试了一下可在VC6中直接调用了。-(TC2 contains a collection of header files), there are many classic header files, I tested you can directly call the VC6.
- 2023-01-07 10:50:02下载
- 积分:1
-
一元稀疏多项式
一元稀疏多项式简单计算器代码 调试过 可行-Dollar sparse polynomial
- 2022-03-23 12:46:40下载
- 积分:1
-
to reterive information about the mobile
to reterive information about the mobile
- 2023-01-31 17:05:03下载
- 积分:1
-
LabWindows CVI方面的经典教材
经典LabWindows CVI方面的教材《LabWindows CVI开发入门和进阶》一书第9章中的例题源码,使用LabWindows CVI的人用得着。麻烦管理员帮我开通下载功能,我急需要本网站上的labwindows/CVI方面的数据库教程,谢谢!-LabWindows CVI aspects of the classic textbook
- 2022-12-03 03:40:03下载
- 积分:1
-
news1.0.rar an anti
news1.0.rar 一个JAVA的反便宜软件 图形界面 我就想下个插件 请管理员帮帮忙啊-news1.0.rar an anti-Java GUI software cheaper, I would like to request the next possession plugin Help staff in Manga
- 2023-05-05 08:25:04下载
- 积分:1
-
Doc++,可以根据你的C/C++和java的源码文件中的注释行自动生成Html说明文件的工具,要用Gun的编译...
Doc++,可以根据你的C/C++和java的源码文件中的注释行自动生成Html说明文件的工具,要用Gun的编译-Doc, can you C/C and java source of the Notes document OK automatic generation Html note tools, compilers with Gun
- 2022-04-23 12:35:46下载
- 积分:1