https://www.bilibili.com/video/av25761720
https://www.bilibili.com/video/av25763384
(BFS与DFS介绍视频,十分感谢“正月点灯笼”这位up主,我是看了该up主的视频然后自己编写java版程序)
这个是路线图,下面代码所写的二位数组是基于这个图编写的
至于图中右上角的文字和路线之间的数字请忽略
DFS
import java.util.Stack;
public class DFS {
public static void main(String[] args) {
int[][] graph = new int[6][6];
graph[0][1] = 1;
graph[0][3] = 1;
graph[1][2] = 1;
graph[1][4] = 1;
graph[2][5] = 1;
graph[3][4] = 1;
graph[4][0] =