Created
November 3, 2019 09:58
-
-
Save prateekjoshi565/0746dd4b5dcfedfcf0df2105ee6b39ad 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
def get_randomwalk(node, path_length): | |
random_walk = [node] | |
for i in range(path_length-1): | |
temp = list(G.neighbors(node)) | |
temp = list(set(temp) - set(random_walk)) | |
if len(temp) == 0: | |
break | |
random_node = random.choice(temp) | |
random_walk.append(random_node) | |
node = random_node | |
return random_walk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment