Package search; import static Java. lang. system. out; public class deepfirstsearch {public static void main (string ARGs []) {// graph initialization int G [] [] = new int [9] [9]; // G [0] [1] = 1; G [1] [2] = 1; G [2] [3] = 1; G [1] [4] = 1; G [0] [5] = 1; G [5] [6] = 1; G [5] [7] = 1; int visited [] = new int [G. length]; for (INT I = 0; I <G. length; I ++) for (Int J = 0; j <G. length; j ++) if (G [I] [J] = 1) g [J] [I] = 1; go (G, visited );} /** this method is the execution of the depth-first search, which only searches for the current K-point All connected nodes **/public static void DFS (INT [] [] A, int visited [], int K) // start from start to find {visited [k] = 1; // access K node out. println (k); // access all nodes connected to K below for (INT I = 0; I <. length; I ++) {// if this node is connected to K and has not been accessed, then access this node if (a [k] [I] = 1 & visited [I]! = 1) DFS (A, visited, I) ;}/ ** this is an in-depth Priority Search for the entire image, this ensures that all nodes are searched again **/public static void go (INT [] [] A, int visited []) {// locate the point connected to K and find an access request to access a for (INT I = 0; I <. length; I ++) if (visited [I]! = 1) DFS (A, visited, I );}}