Last active
July 30, 2018 15:20
-
-
Save ziyoshams/44d7153aaf8855f60f079e87826efdfb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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