迷宫问题,求最短路径长度、最短路径条数、所有最短路径,DFS+BFS+栈+队列

这篇博客介绍了如何解决迷宫问题,通过深度优先搜索(DFS)和广度优先搜索(BFS)算法找到了96条不同的最短路径,并给出了每条路径的详细步骤。路径长度均为11步,展示了从起点到终点的多种最优解。
摘要由CSDN通过智能技术生成

一组测试数据得到的结果

8 8 3
3 3
4 5
6 6
2 1
7 7

最短路径   1 :
(2, 1) (3, 1) (4, 1) (5, 1) (6, 1) (7, 1) (7, 2) (7, 3) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径   2 :
(2, 1) (3, 1) (4, 1) (5, 1) (6, 1) (6, 2) (7, 2) (7, 3) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径   3 :
(2, 1) (3, 1) (4, 1) (5, 1) (6, 1) (6, 2) (6, 3) (7, 3) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径   4 :
(2, 1) (3, 1) (4, 1) (5, 1) (6, 1) (6, 2) (6, 3) (6, 4) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径   5 :
(2, 1) (3, 1) (4, 1) (5, 1) (6, 1) (6, 2) (6, 3) (6, 4) (6, 5) (7, 5) (7, 6) (7, 7)

最短路径   6 :
(2, 1) (3, 1) (4, 1) (5, 1) (5, 2) (6, 2) (7, 2) (7, 3) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径   7 :
(2, 1) (3, 1) (4, 1) (5, 1) (5, 2) (6, 2) (6, 3) (7, 3) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径   8 :
(2, 1) (3, 1) (4, 1) (5, 1) (5, 2) (6, 2) (6, 3) (6, 4) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径   9 :
(2, 1) (3, 1) (4, 1) (5, 1) (5, 2) (6, 2) (6, 3) (6, 4) (6, 5) (7, 5) (7, 6) (7, 7)

最短路径  10 :
(2, 1) (3, 1) (4, 1) (5, 1) (5, 2) (5, 3) (6, 3) (7, 3) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径  11 :
(2, 1) (3, 1) (4, 1) (5, 1) (5, 2) (5, 3) (6, 3) (6, 4) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径  12 :
(2, 1) (3, 1) (4, 1) (5, 1) (5, 2) (5, 3) (6, 3) (6, 4) (6, 5) (7, 5) (7, 6) (7, 7)

最短路径  13 :
(2, 1) (3, 1) (4, 1) (5, 1) (5, 2) (5, 3) (5, 4) (6, 4) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径  14 :
(2, 1) (3, 1) (4, 1) (5, 1) (5, 2) (5, 3) (5, 4) (6, 4) (6, 5) (7, 5) (7, 6) (7, 7)

最短路径  15 :
(2, 1) (3, 1) (4, 1) (5, 1) (5, 2) (5, 3) (5, 4) (5, 5) (6, 5) (7, 5) (7, 6) (7, 7)

最短路径  16 :
(2, 1) (3, 1) (4, 1) (5, 1) (5, 2) (5, 3) (5, 4) (5, 5) (5, 6) (5, 7) (6, 7) (7, 7)

最短路径  17 :
(2, 1) (3, 1) (4, 1) (4, 2) (5, 2) (6, 2) (7, 2) (7, 3) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径  18 :
(2, 1) (3, 1) (4, 1) (4, 2) (5, 2) (6, 2) (6, 3) (7, 3) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径  19 :
(2, 1) (3, 1) (4, 1) (4, 2) (5, 2) (6, 2) (6, 3) (6, 4) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径  20 :
(2, 1) (3, 1) (4, 1) (4, 2) (5, 2) (6, 2) (6, 3) (6, 4) (6, 5) (7, 5) (7, 6) (7, 7)

最短路径  21 :
(2, 1) (3, 1) (4, 1) (4, 2) (5, 2) (5, 3) (6, 3) (7, 3) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径  22 :
(2, 1) (3, 1) (4, 1) (4, 2) (5, 2) (5, 3) (6, 3) (6, 4) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径  23 :
(2, 1) (3, 1) (4, 1) (4, 2) (5, 2) (5, 3) (6, 3) (6, 4) (6, 5) (7, 5) (7, 6) (7, 7)

最短路径  24 :
(2, 1) (3, 1) (4, 1) (4, 2) (5, 2) (5, 3) (5, 4) (6, 4) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径  25 :
(2, 1) (3, 1) (4, 1) (4, 2) (5, 2) (5, 3) (5, 4) (6, 4) (6, 5) (7, 5) (7, 6) (7, 7)

最短路径  26 :
(2, 1) (3, 1) (4, 1) (4, 2) (5, 2) (5, 3) (5, 4) (5, 5) (6, 5) (7, 5) (7, 6) (7, 7)

最短路径  27 :
(2, 1) (3, 1) (4, 1) (4, 2) (5, 2) (5, 3) (5, 4) (5, 5) (5, 6) (5, 7) (6, 7) (7, 7)

最短路径  28 :
(2, 1) (3, 1) (4, 1) (4, 2) (4, 3) (5, 3) (6, 3) (7, 3) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径  29 :
(2, 1) (3, 1) (4, 1) (4, 2) (4, 3) (5, 3) (6, 3) (6, 4) (7, 4) (7, 5) (7, 6) (7, 7)

最短路径  30 :
(2, 1) (3, 1) (4, 1) (4, 2) (4, 3) (5, 3) (6, 3) (6, 4) (6, 5) (7, 5) (7, 6) (7, 7)

最短路径  31 :

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值