TraversalRepeatExt
Attributes
- Graph
- Supertypes
- class AnyValtrait Matchableclass Any
Members list
Type members
Types
Value members
Concrete methods
Repeat the given traversal
Repeat the given traversal
By default it will continue repeating until there's no more results, not emit anything along the way, and use depth first search.
The @param behaviourBuilder allows you to configure end conditions (until|whilst|maxDepth), whether it should emit elements it passes by, and which search algorithm to use (depth-first or breadth-first).
Search algorithm: Depth First Search (DFS) vs Breadth First Search (BFS): DFS means the repeat step will go deep before wide. BFS does the opposite: wide before deep. For example, given the graph
L3 <- L2 <- L1 <- Center -> R1 -> R2 -> R3 -> R4
DFS will iterate the nodes in the order:
Center, L1, L2, L3, R1, R2, R3, R4
BFS will iterate the nodes in the order:
Center, L1, R1, R1, R2, L3, R3, R4
Attributes
- See also:
RepeatTraversalTests for more detail and examples for all of the above.
- Note:
this works for domain-specific steps as well as generic graph steps - for details please take a look at the examples in RepeatTraversalTests: both '''.followedBy''' and '''.out''' work.
- Example:
.repeat(_.out) // repeat until there's no more elements, emit nothing, use DFS .repeat(_.out)(_.maxDepth(3)) // perform exactly three repeat iterations .repeat(_.out)(_.until(_.property(Name).endsWith("2"))) // repeat until the 'Name' property ends with '2' .repeat(_.out)(_.emit) // emit everything along the way .repeat(_.out)(_.emit.breadthFirstSearch) // emit everything, use BFS .repeat(_.out)(_.emit(_.property(Name).startsWith("L"))) // emit if the 'Name' property starts with 'L'