Skip to content

Instantly share code, notes, and snippets.

@akellehe
Last active August 29, 2015 14:23
Show Gist options
  • Save akellehe/8197d6e27983acd4649c to your computer and use it in GitHub Desktop.
Save akellehe/8197d6e27983acd4649c to your computer and use it in GitHub Desktop.
The recursive version
def get_descendants(node, A, descendants=None):
if not descendants:
descendants = []
descendants.append(node)
children = A.getrow(node).indices
for child in children:
descendants += get_descendants(child, A)
return descendants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment