Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tree.siblings(u) method #2616

Closed
jeromekelleher opened this issue Oct 29, 2022 · 0 comments · Fixed by #2618
Closed

Add Tree.siblings(u) method #2616

jeromekelleher opened this issue Oct 29, 2022 · 0 comments · Fixed by #2618
Labels
enhancement New feature or request good first issue Good for newcomers Python API Issue is about the Python API

Comments

@jeromekelleher
Copy link
Member

It is sometimes useful to have the list of siblings of a given node, and it would be handy to have the method to do it directly:

def siblings(self, u):
    sibs = []
    parent = self.parent(u)
    if parent != -1:
        sibs =  [v for v in self.children(parent) if u != v]
    return sibs

This should do the trick I think?

@jeromekelleher jeromekelleher added enhancement New feature or request good first issue Good for newcomers Python API Issue is about the Python API labels Oct 29, 2022
@szhan szhan mentioned this issue Oct 30, 2022
3 tasks
@mergify mergify bot closed this as completed in #2618 Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers Python API Issue is about the Python API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant