-
[输入]
图的顶点个数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
-
针对飞利浦公司LPC2104的模拟总线软件包,
针对飞利浦公司LPC2104的模拟总线软件包,-against Philips LPC2104 Bus simulation package,
- 2022-03-10 15:38:35下载
- 积分:1
-
51 CRC code
51的CRC代码-51 CRC code
- 2023-02-27 11:50:04下载
- 积分:1
-
dos learning process is essential to learn dos Oh, you want to be useful
dos学习程序
学习dos必备哦
希望对大家有用-dos learning process is essential to learn dos Oh, you want to be useful
- 2022-07-05 09:47:45下载
- 积分:1
-
可视为小到中等大小的公司基本的POS
A Visual basic POS for small to medium sized companies
- 2022-05-06 08:07:18下载
- 积分:1
-
一个小时钟程序,做得很漂亮
一个小时钟程序,做得很漂亮-A small clock procedures, do have a pretty
- 2022-10-19 07:45:03下载
- 积分:1
-
游戏运行时,你只需输入"押金"(任意整数),然后系统会提示你输入一个数,试试看,说不定你要猜中,还要动点脑子哟!^_^祝君好运...
游戏运行时,你只需输入"押金"(任意整数),然后系统会提示你输入一个数,试试看,说不定你要猜中,还要动点脑子哟!^_^祝君好运-running game, you only need to input the "deposits" (arbitrary integer), the system will then prompt you for a few, give it a try, perhaps you want to guess, but also fixed point brain yo! ^ _ ^ Best of luck
- 2022-02-26 22:24:35下载
- 积分:1
-
这是数据库的教程,非常专业的讲稿这是数据库的教程,是某重点大学的非常专业的讲稿,...
这是数据库的教程,非常专业的讲稿这是数据库的教程,是某重点大学的非常专业的讲稿,-This is the Guide database, a very professional script is a tutorial database is a key university in a very professional script,
- 2022-08-20 19:08:02下载
- 积分:1
-
奥林巴斯xD
奥林巴斯xD-picture读写电路设计-Olympus xD-picture literacy Circuit Design
- 2022-12-10 07:45:03下载
- 积分:1
-
基于NI的抽奖程序
别的论坛找来的抽奖程序,大家在办工会活动时可以使用。。很好用。去年,我们单位办了一个游园抽奖活动,我就带着它去,最后领导表扬,同事认可。其实,我觉得这个程序,只要对其进行小幅度的改动,就可以拿来作为恋人生日配对的程序,大家就可以去拿哄小女孩儿了。。
- 2023-05-20 05:30:03下载
- 积分:1