Last active
August 29, 2015 14:23
-
-
Save akellehe/8197d6e27983acd4649c to your computer and use it in GitHub Desktop.
The recursive version
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_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