Skip to content

Instantly share code, notes, and snippets.

@ziyoshams
Last active July 30, 2018 15:20
Show Gist options
  • Save ziyoshams/44d7153aaf8855f60f079e87826efdfb to your computer and use it in GitHub Desktop.
Save ziyoshams/44d7153aaf8855f60f079e87826efdfb to your computer and use it in GitHub Desktop.
dfs(startingNode){
let visited = this.createVisitedObject();
this.dfsHelper(startingNode, visited);
}
dfsHelper(startingNode, visited){
visited[startingNode] = true;
console.log(startingNode);
let arr = this.AdjList.get(startingNode);
for(let elem of arr){
if(!visited[elem]){
this.dfsHelper(elem, visited);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment