Skip to content

Conversation

orxfun
Copy link
Owner

@orxfun orxfun commented Jun 6, 2025

  • parallelized walks: The main contribution of this PR is enabling parallel iterators over various tree iterators and walks with any of the traversals. Parallelization is obtained simply by adding _par suffix to name of the sequential counterpart. These methods return a orx_parallel::ParIter which allows for significant improvements in computation time. The following is the list of new methods returning parallel iterators:
    • children_par
    • ancestors_par
    • custom_walk_par
    • walk_par
    • walk_with_par
    • paths_par
    • paths_with_par
    • leaves_par
    • leaves_with_par
  • custom walks: custom_walk(next_node) method is implemented. This method returns an iterator over the nodes with custom traversal strategy. Traversal strategy is determined by the argument next_node. next_node is a function with the signature Fn(Node) -> Option<Node>. Iteration starts with the self and terminates when next_node returns None. This provides a convenient and flexible way to create custom walks. Notice that iteration in all directions can be defined and infinite iterations can be created. Mutable version custom_walk_mut(next_node) is also implemented for NodeMut.
  • avoiding allocation in paths iterator: paths was returning impl Iterator<Item = impl Iterator<&V::Item>>. Now it returns impl Iterator<Item = impl Iterator<&V::Item> + Clone>. In other words, each path element is a cheaply cloneable iterator. This allows for converting the path into_iterable which can be iterated over multiple times, and hence, provides the means to avoid allocation and collecting the paths into collections.
  • Examples for different iterators, walks are added and linked from the documentation.

@orxfun orxfun merged commit ddb2d0b into main Jun 7, 2025
2 checks passed
@orxfun orxfun deleted the parallel-walks branch June 7, 2025 19:02
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

Successfully merging this pull request may close these issues.

1 participant