T - the type of node in the graphpublic class AcyclicDepthFirstPostOrderTraversalWithDependencyStack<T> extends Object
This version of algorithm tracks traversal path in DependencyStack structure and
provides it to user in GraphTraversableWithDependencyStack callback.
If a cycle is encountered, a CycleException is thrown by traverse(Iterable).
| Constructor and Description |
|---|
AcyclicDepthFirstPostOrderTraversalWithDependencyStack(GraphTraversableWithDependencyStack<T> traversable,
java.util.function.BiFunction<DependencyStack,T,DependencyStack> dependencyStackChild) |
| Modifier and Type | Method and Description |
|---|---|
Iterable<T> |
traverse(Iterable<? extends T> initialNodes) |
Iterable<T> |
traverse(Iterable<? extends T> initialNodes,
java.util.function.Predicate<T> shouldExploreChildren)
Performs a depth-first, post-order traversal over a DAG.
|
public AcyclicDepthFirstPostOrderTraversalWithDependencyStack(GraphTraversableWithDependencyStack<T> traversable, java.util.function.BiFunction<DependencyStack,T,DependencyStack> dependencyStackChild)
dependencyStackChild - a function to construct a child stack from a stack and a new graph
node. In the most cases it is just an invocation of DependencyStack.child(DependencyStack.Element).public Iterable<T> traverse(Iterable<? extends T> initialNodes) throws CycleException
CycleExceptionpublic Iterable<T> traverse(Iterable<? extends T> initialNodes, java.util.function.Predicate<T> shouldExploreChildren) throws CycleException
initialNodes - The nodes from which to perform the traversal. Not allowed to contain
null.shouldExploreChildren - Whether or not to explore a particular node's children. Used to
support short circuiting in the traversal.CycleException - if a cycle is found while performing the traversal.