/** * Actually compute the traversal if it is not in the cache. */ private LinkedList<T> computeRecursiveTraversal(T node, NodePath<T> nodePath) { try { LinkedList<T> imports = new LinkedList<>(); Set<T> alreadyIncludedImports = new HashSet<>(); for (T neighbor : this.traversalFunction.apply(node)) { nodePath.appendNode(neighbor); addSubtraversal(neighbor, imports, alreadyIncludedImports, nodePath); nodePath.popTail(); } return imports; } catch (ExecutionException ee) { throw new RuntimeException(ee); } }
public void appendNode(T node) { if (this.nodesSet.contains(node)) { throw new CircularDependencyException("Found cycle in traversal: " + computePath(node)); } this.nodesSet.add(node); this.nodesList.add(node); }
/** * Actually compute the traversal if it is not in the cache. */ private LinkedList<T> computeRecursiveTraversal(T node, NodePath<T> nodePath) { try { LinkedList<T> imports = new LinkedList<>(); Set<T> alreadyIncludedImports = new HashSet<>(); for (T neighbor : this.traversalFunction.apply(node)) { nodePath.appendNode(neighbor); addSubtraversal(neighbor, imports, alreadyIncludedImports, nodePath); nodePath.popTail(); } return imports; } catch (ExecutionException ee) { throw new RuntimeException(ee); } }
public void appendNode(T node) { if (this.nodesSet.contains(node)) { throw new CircularDependencyException("Found cycle in traversal: " + computePath(node)); } this.nodesSet.add(node); this.nodesList.add(node); }
/** * Traverse the graph starting at the provided node. * @param startingNode starting node. * @return a List containing the DFS traversal starting at the node. * @throws CircularDependencyException if there is a circular dependency in the loaded traversal. */ List<T> traverseGraphRecursively(T startingNode) { return doTraverseGraphRecursively(startingNode, new NodePath<>(startingNode)); }
/** * Traverse the graph starting at the provided node. * @param startingNode starting node. * @return a List containing the DFS traversal starting at the node. * @throws CircularDependencyException if there is a circular dependency in the loaded traversal. */ List<T> traverseGraphRecursively(T startingNode) { return doTraverseGraphRecursively(startingNode, new NodePath<>(startingNode)); }