Last active
July 20, 2020 11:27
-
-
Save GAierken/cf38cc5809353227e3dabd7a52e8e8e0 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
// visiting/updating/checking each vertex in a graph recursive | |
depthFirstRecursive(start){ | |
const result = [] | |
const visited = {} | |
const adjacencyList = this.adjacencyList | |
(function dfs(vertex){ | |
if(!vertex) return null | |
visited[vertex] = true | |
result.push(vertex) | |
adjacencyList[verte].forEach((neighbor) => { | |
if(!visited[neighbor]){ | |
return dfs(neighbor) | |
} | |
}) | |
})(start) | |
return result | |
} | |
dfsIterative(start){ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment