scalax.collection.GraphTraversal
Determines which connected nodes the traversal has to follow.
The default value is Successors
.
Predicate to filter the nodes to be visited during traversal.
The default value is anyNode
, that is no filtering.
A return of true
signals that the traversal is to be canceled.
Predicate to filter the edges to be visited during traversal.
The default value is anyEdge
meaning that no filtering takes place.
Function to be called on visiting a node for the first time
during a traversal. It can mutate the node or carry out any other side effect.
The default value is the empty function noNodeAction
. Alternatively, an instance of ExtendedNodeVisitor
may be passed to obtain additional state information such as the current
depth. The concrete type of the last argument, the informer
depends on the underlying implementation so you need to match against it. Concerning this method please match against
scalax.collection.GraphTraversalImpl.DfsInformer or
scalax.collection.GraphTraversalImpl.BfsInformer depending on the
breadthFirst
argument.
Function to be called on visiting an edge.
It can mutate the node or carry out any other side effect.
The default value is the empty function noEdgeAction
.
If a NodeOrdering
or EdgeOrdering
different from noOrdering
is supplied
neighbor nodes will be sorted during the traversal. Thus it is guaranteed that
the smaller an element's ranking the sooner it will be processed. In case of
EdgeOrdering
it is guaranteed that the smaller an edge's ranking the sooner
its relevant end(s) will be processed.
Traverses this graph from root
for side-effects allowing
Traverses this graph from root
for side-effects allowing
a) to filter nodes and/or edges, b) to carry out any side effect at visited nodes and/or edges and c) to cancel the traversal at any node.
The node where subsequent graph traversals start.
The traversal stops at the first node except for root
for which
this predicate holds true and returns it.
The default value noNode
leads to a full traversal.
If true
the traversal is based on a breath first
(BFS, layer-for-layer) search, otherwise on a depth first search (DFS).
The default value is BFS.
A positive value limiting the number of layers for Bfs respectively
the number of consecutive child visits before siblings are visited for Dfs.
0
, the default value, indicates that the traversal should have
an unlimited depth meaning that it will be continued until either
it's canceled or all nodes have been visited.
the node found if any.
Starting at root
, functionally traverses this graph up to maxDepth
layers
using the breadth first search algorithm and all filters, visitors etc.
Starting at root
, functionally traverses this graph up to maxDepth
layers
using the breadth first search algorithm and all filters, visitors etc.
passed to the encapsulating Traversal
instance.
The node where subsequent graph traversals start.
The traversal stops at the first node except for root
for which
this predicate holds true and returns it.
The default value noNode
leads to a full traversal.
A positive value limiting the number of layers for Bfs respectively
the number of consecutive child visits before siblings are visited for Dfs.
0
, the default value, indicates that the traversal should have
an unlimited depth meaning that it will be continued until either
it's canceled or all nodes have been visited.
the node found if any.
Starting at root
, functionally traverses this graph up to maxDepth
layers
using the depth first search algorithm and all filters, visitors etc.
Starting at root
, functionally traverses this graph up to maxDepth
layers
using the depth first search algorithm and all filters, visitors etc.
passed to the encapsulating Traversal
instance.
The node where subsequent graph traversals start.
The traversal stops at the first node except for root
for which
this predicate holds true and returns it.
The default value noNode
leads to a full traversal.
A positive value limiting the number of layers for Bfs respectively
the number of consecutive child visits before siblings are visited for Dfs.
0
, the default value, indicates that the traversal should have
an unlimited depth meaning that it will be continued until either
it's canceled or all nodes have been visited.
Function to be called on reaching an already visited node
when moving up in the imaginary tree of a depth first search. Paired with
nodeVisitor
(the 'down-visitor'), this 'up-visitor' enables a stack-wise view of
the traversed nodes. The default value is the empty function noNodeUpAction
.
Alternatively, an instance of ExtendedNodeVisitor
may be passed to obtain additional state information such as the current
depth. The concrete type of the last argument, the informer
depends on the underlying implementation so you need to match against it. Concerning this method please match against
scalax.collection.GraphTraversalImpl.DfsInformer.
the node found if any.
Computes the filtered direct predecessors of node
.
Computes the filtered direct predecessors of node
.
It also calls edgeVisitor
but does not call nodeVisitor
.
the node the direct predecessors are to be calculated of.
function returning whether a specific node has already been visited during the current traversal.
whether to sort in reverse order. Only applicable when ordering
is
different from noOrdering
.
Computes the filtered direct successors of node
.
Computes the filtered direct successors of node
.
It also calls edgeVisitor
but does not call nodeVisitor
.
the node the direct successors are to be calculated of.
function returning whether a specific node has already been visited during the current traversal.
whether to sort in reverse order. Only applicable when ordering
is
different from noOrdering
.
Computes the filtered neighbors of node
.
Computes the filtered neighbors of node
.
It also calls edgeVisitor
but does not call nodeVisitor
.
the node the adjacent are to be calculated of.
function returning whether a specific node has already been visited during the current traversal.
whether to sort in reverse order. Only applicable when ordering
is
different from noOrdering
.
Synonym for breadthFirstSearch
Synonym for breadthFirstSearch
Synonym for depthFirstSearch
Synonym for depthFirstSearch
(traversal: OuterNode[Traversal]).toString()
Abstract class for functional traversals.
In addition to the
traverse
methods defined for nodes, this concept supports repeated traversals with constant direction, filters and visitors. CallnewTraversal
to create an instance and call any subsequent traversals on that instance.(Since version 1.8.0) use one of Traverser factory methods instead.