MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / DFS

Method DFS

Java/DFSTraversal.java:22–33  ·  view source on GitHub ↗
(int vertex)

Source from the content-addressed store, hash-verified

20 }
21
22 void DFS(int vertex) {
23 visited[vertex] = true; /* Mark the current node as visited */
24 System.out.print(vertex + " ");
25
26 // Iterator<Integer> it = adj[vertex].listIterator();
27 ListIterator<Integer> ti = adj[vertex].listIterator();
28 while (ti.hasNext()) {
29 int n = ti.next();
30 if (!visited[n])
31 DFS(n);
32 }
33 }
34
35 public static void main(String args[]) {
36 Scanner sc = new Scanner(System.in);

Callers 1

mainMethod · 0.95

Calls 3

hasNextMethod · 0.80
nextMethod · 0.80
printMethod · 0.45

Tested by

no test coverage detected