Skip to content

Instantly share code, notes, and snippets.

@sazid
Created September 12, 2019 21:44
Show Gist options
  • Save sazid/832a0d99f6122b596155cd3fc3a6e536 to your computer and use it in GitHub Desktop.
Save sazid/832a0d99f6122b596155cd3fc3a6e536 to your computer and use it in GitHub Desktop.
void dfs(char node) {
status[node] = VISITING;
for (char child : graph[node]) {
if (status[child] == UNVISITED)
dfs(child);
else if (status[child] == VISITING) {
hasCycles = true;
return;
}
}
status[node] = VISITED;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment