DFS BFS

 

数据结构的网站

https://www.yiibai.com/data_structure/depth-first-search-algorithm.html

先看一下这道题目

https://leetcode-cn.com/problems/shortest-bridge/solution/dfszhao-di-yi-ge-dao-bfszhao-zui-duan-ju-9vz5/

根据图的结构的不同,算法不同。

图的结构有,

链表数组:std::vector<std::list<int>> graph;

二维数组。

 

算法由队列辅助法,递归法。


对于链表数组

 

C++ 实现图的 DFS 和 BFS

https://murphypei.github.io/blog/2019/04/cpp-bfs-dfs

 

 

对于二维数组

https://blog.youkuaiyun.com/weixin_45830777/article/details/108433601

https://blog.youkuaiyun.com/weixin_42189888/article/details/88603515

 

 

dfs 二维数组 

https://blog.youkuaiyun.com/weixin_43537190/article/details/84076790

 

 

bfs 二维数组

https://www.cnblogs.com/keep23456/p/12372905.html

https://www.cnblogs.com/sweetiemelody/p/4296827.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值