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

Finding the nodes between two nodes #204

Closed
eyildiz-ugoe opened this issue Sep 22, 2022 · 1 comment
Closed

Finding the nodes between two nodes #204

eyildiz-ugoe opened this issue Sep 22, 2022 · 1 comment

Comments

@eyildiz-ugoe
Copy link

I have a tree over which I'd like to print the path between two nodes. I could not find a function that does the magic, but I believe the closest is expand_tree(). However, upon calling it and trying to print the nodes, I get an error:

path = tree.expand_tree(tree.get_node(4), filter=tree.get_node(83), sorting=False)
for node in path:
    print(node)
Traceback (most recent call last):
  File "E:\question.py", line 55, in <module>
    for node in path:
  File "E:\Anaconda3\envs\3dreconst\lib\site-packages\treelib\tree.py", line 427, in expand_tree
    raise NodeIDAbsentError("Node '%s' is not in the tree" % nid)
treelib.exceptions.NodeIDAbsentError: Node 'Node(tag=4, identifier=4, data=None)' is not in the tree

What am I doing wrong?

@eyildiz-ugoe
Copy link
Author

eyildiz-ugoe commented Sep 22, 2022

Found it.

path_to_node = tree.expand_tree(4, filter=lambda x: x.tag != 83)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant