Created
June 6, 2020 01:56
-
-
Save wilderfield/fc1755449da2241ba41ed5ad7f485313 to your computer and use it in GitHub Desktop.
Adjacency List
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
graph = [[1,3,5], # node 0 connects out to node 1,3,5 | |
[2,4], # node 1 connects out to node 2,4 | |
[4], # node 2 connects out to node 4 | |
[1], # node 3 connects out to node 1 | |
[5], # node 4 connects out to node 5 | |
[]] # node 5 connects out to nothing | |
# This function returns the neighbors of a given node in a list | |
def getNeighbors(node): | |
return graph[node] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment