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

AbstractTrees interface #18

Open
asinghvi17 opened this issue Oct 25, 2024 · 0 comments
Open

AbstractTrees interface #18

asinghvi17 opened this issue Oct 25, 2024 · 0 comments

Comments

@asinghvi17
Copy link

I coded up a brief implementation of the AbstractTrees.jl interface here:

using AbstractTrees
import SpatialIndexing as SI

AbstractTrees.children(node::SI.Branch) = SI.children(node)
AbstractTrees.nodevalue(node::SI.Branch) = SI.mbr(node)

AbstractTrees.children(node::T) where {T <: SI.Leaf} = T[]
AbstractTrees.nodevalue(node::SI.Leaf) = leaf.children

AbstractTrees.ParentLinks(::Type{<: SI.Node}) = AbstractTrees.ImplicitParents()
AbstractTrees.SiblingLinks(::Type{<: SI.Node}) = AbstractTrees.ImplicitSiblings()
AbstractTrees.ChildIndexing(::Type{<: SI.Node}) = AbstractTrees.IndexedChildren()

AbstractTrees.NodeType(::Type{<:SI.Node{T,N,V}}) where {T,N,V} = SI.Node{T, N, V}

This provides iterators like DFS (post and pre ordered), BFS, and leaf iterators.

Would there be interest in a PR adding this + tests to the package? I am currently working on a problem that requires me to depth-first search down R-trees that partition geometries.

Let me know what you think @alyst!

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