Skip to content

Instantly share code, notes, and snippets.

@phc15
Last active February 14, 2021 22:51
Show Gist options
  • Save phc15/0d7eba7994e8186f6610a6f1d0c20511 to your computer and use it in GitHub Desktop.
Save phc15/0d7eba7994e8186f6610a6f1d0c20511 to your computer and use it in GitHub Desktop.
void DFSRecursive(Graph g, int s, boolean[] visited) {
System.out.println("Visited vertex: " + s);
visited[s] = true;
for (int n : g.adj.get(s)) {
if (visited[n] == false) {
// visited[n] = true;
DFSRecursive(g, n, visited);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment