Created
July 20, 2020 02:38
-
-
Save rudiejd/74ee4165378fff431058c6d3ed2d8313 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 make_graph(query, depth, children): | |
return _make_graph(query, depth, children, dict()) | |
def _make_graph(query, depth, children, d): | |
for i in range(children): | |
rand_artist = get_random_rec(query) | |
if rand_artist == None: | |
break | |
if depth == 0: | |
d[query] = {rand_artist}; | |
return d; | |
if query in d.keys(): | |
d[query].add(rand_artist) | |
else: | |
d[query] = {rand_artist} | |
d = _make_graph(rand_artist, depth-1, d) | |
return d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment