List<Set<PlanFragmentId>> schedulePhases = ImmutableList.copyOf(new TopologicalOrderIterator<>(componentGraph)); return schedulePhases;
TopologicalOrderIterator it = new TopologicalOrderIterator<Node, Object>(subgraph); int stateIndex = 0; while (it.hasNext()) { Node n = (Node) it.next(); if (n instanceof ProcessorNode) { ProcessorNode pn = (ProcessorNode) n;
/** * Creates a new instance of the factory * * @param errorTypesEnum an {@link ErrorTypeDefinition} implementation indicating all the errors from an extension * @param extensionNamespace the namespace for the {@link ErrorModel} to be generated */ public ErrorsModelFactory(ErrorTypeDefinition<?>[] errorTypesEnum, String extensionNamespace) throws IllegalModelDefinitionException { this.extensionNamespace = extensionNamespace.toUpperCase(); final DirectedGraph<ErrorTypeDefinition, Pair<ErrorTypeDefinition, ErrorTypeDefinition>> graph = toGraph(errorTypesEnum); errorModelMap = new HashMap<>(); initErrorModelMap(errorModelMap); new TopologicalOrderIterator<>(graph).forEachRemaining(errorType -> { ErrorModel errorModel = toErrorModel(errorType, errorModelMap); errorModelMap.put(errorModel.toString(), errorModel); }); addConnectivityErrors(errorModelMap); }
GraphIterator<String, DefaultEdge> graphIterator = new TopologicalOrderIterator<>(namespaceDAG); while (graphIterator.hasNext()) { final String namespace = graphIterator.next(); if (allExtensionsByNamespace.containsKey(namespace)) { result.add(allExtensionsByNamespace.get(namespace));
/** * Method getDepthFirstIterator returns the depthFirstIterator of this ElementGraph object. * * @return the depthFirstIterator (type DepthFirstIterator) of this ElementGraph object. */ public DepthFirstIterator<FlowElement, Scope> getDepthFirstIterator() { return new DepthFirstIterator<>( this.graph, Extent.head ); }
@Override public void setCrossComponentTraversal(boolean crossComponentTraversal) { if (initialized) { checkRadiusTraversal(crossComponentTraversal); } super.setCrossComponentTraversal(crossComponentTraversal); }
/** * Called when a vertex has been finished (meaning is dependent on traversal represented by * subclass). * * @param vertex vertex which has been finished */ protected void finishVertex(V vertex) { if (nListeners != 0) { fireVertexFinished(createVertexTraversalEvent(vertex)); } }
/** * @see CrossComponentIterator#encounterVertex(Object, Object) */ @Override protected void encounterVertex(V vertex, E edge) { int depth = (edge == null ? 0 : getSeenData(Graphs.getOppositeVertex(graph, edge, vertex)).depth + 1); putSeenData(vertex, new SearchNodeData<>(edge, depth)); queue.add(vertex); }
/** * Retrieves vertex from the {@code bucketList} and returns it. * * @return the vertex retrieved from the {@code bucketList}. */ private V advance() { V vertex = bucketList.poll(); if (vertex != null) { bucketList.updateBuckets(getUnvisitedNeighbours(vertex)); } return vertex; }
@Override public boolean hasNext() { if (cur != null) { return true; } cur = advance(); if (cur != null && nListeners != 0) { fireVertexTraversed(createVertexTraversalEvent(cur)); } return cur != null; }
@Override public boolean hasNext() { if (cur != null) { return true; } cur = advance(); if (cur != null && nListeners != 0) { fireVertexTraversed(createVertexTraversalEvent(cur)); } return cur != null; }
private void encounterStartVertex() { encounterVertex(startVertex, null); startVertex = null; }
/** * Create a new iterator * * @param graph the graph */ public AbstractGraphIterator(Graph<V, E> graph) { this.graph = Objects.requireNonNull(graph, "graph must not be null"); this.reusableEdgeEvent = new FlyweightEdgeEvent<>(this, null); this.reusableVertexEvent = new FlyweightVertexEvent<>(this, null); this.crossComponentTraversal = true; this.reuseEvents = false; }
/** * Create an edge traversal event. * * @param edge the edge * @return the event */ protected EdgeTraversalEvent<E> createEdgeTraversalEvent(E edge) { if (isReuseEvents()) { reusableEdgeEvent.setEdge(edge); return reusableEdgeEvent; } else { return new EdgeTraversalEvent<>(this, edge); } }
/** * Returns the edge connecting vertex $v$ to its parent in the spanning tree formed by the BFS * search, or null if $v$ is a root node. This method can only be invoked on a vertex $v$ once * the iterator has visited vertex $v$! * * @param v vertex * @return edge connecting vertex $v$ in the BFS search tree to its parent, or null if $v$ is a * root node */ public E getSpanningTreeEdge(V v) { assert getSeenData(v) != null; return getSeenData(v).edge; }
@Override public boolean hasNext() { return currentVertex != null && !isExhausted() && !sinkReached; }
/** * Method getTopologicalIterator returns the topologicalIterator of this ElementGraph object. * * @return the topologicalIterator (type TopologicalOrderIterator) of this ElementGraph object. */ public TopologicalOrderIterator<FlowElement, Scope> getTopologicalIterator() { return new TopologicalOrderIterator<>( this.graph ); }
/** * Returns the depth of vertex $v$ in the search tree. The depth of a vertex $v$ is defined as * the number of edges traversed on the path from the root of the BFS tree to vertex $v$. The * root of the search tree has depth 0. This method can only be invoked on a vertex $v$ once the * iterator has visited vertex $v$! * * @param v vertex * @return depth of vertex $v$ in the search tree */ public int getDepth(V v) { assert getSeenData(v) != null; return getSeenData(v).depth; }
@Override public Iterator<Node> getTopologicalOrderIterator() { return new TopologicalOrderIterator<Node, DefaultEdge>(this.g); }