Skip to content

Instantly share code, notes, and snippets.

@rudiejd
Created July 20, 2020 02:38
Show Gist options
  • Save rudiejd/74ee4165378fff431058c6d3ed2d8313 to your computer and use it in GitHub Desktop.
Save rudiejd/74ee4165378fff431058c6d3ed2d8313 to your computer and use it in GitHub Desktop.
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