/** * Return a Collection of successor nodes of a certain vertex. * * @param vertex the step or node its successors nodes will be returned. * @return collection of successor DAGNodes for each node. */ protected Collection<DAGNode<? extends Job>> getNodeSuccessors(Object vertex) { Collection<DAGNode<? extends Job>> nodeSuccessors = Sets.newHashSet(); List successorNodes = Graphs.successorListOf(jobsGraph, vertex); for (Object node : successorNodes) { BaseFlowStep step = (BaseFlowStep) node; String name = step.getName(); nodeSuccessors.add(dagNamesMap.get(name)); } return nodeSuccessors; } }
/** * Return a Collection of successor nodes of a certain vertex. * * @param vertex the step or node its successors nodes will be returned. * @return collection of successor DAGNodes for each node. */ protected Collection<DAGNode<? extends Job>> getNodeSuccessors(Object vertex) { Collection<DAGNode<? extends Job>> nodeSuccessors = Sets.newHashSet(); List successorNodes = Graphs.successorListOf(jobsGraph, vertex); for (Object node : successorNodes) { BaseFlowStep step = (BaseFlowStep) node; String name = step.getName(); nodeSuccessors.add(dagNamesMap.get(name)); } return nodeSuccessors; } }
@Override public List<FlowElement> successorListOf( FlowElement flowElement ) { return Graphs.successorListOf( graph, flowElement ); }
@Override public Collection<Flow> getSuccessorFlows( Flow flow ) { return Graphs.successorListOf( flowGraph, flow ); }
public List<V> getChildrenOf(V node) { return Graphs.successorListOf(tree, node); }
@SuppressWarnings("unchecked") private List<Integer>[] buildAdjacencyList() { @SuppressWarnings("rawtypes") List[] Ak = new ArrayList[nVertices]; for (int j = 0; j < nVertices; j++) { V v = iToV[j]; List<V> s = Graphs.successorListOf(graph, v); Ak[j] = new ArrayList<Integer>(s.size()); for (V value : s) { Ak[j].add(vToI.get(value)); } } return Ak; }
public List<? extends ElementGraph> getChildren( ElementGraph parent ) { List<Delegate> delegates = Graphs.successorListOf( graph, new Delegate( parent ) ); List<ElementGraph> results = new ArrayList<>(); for( Delegate delegate : delegates ) results.add( delegate.graph ); return results; }
public Collection<Duct> getHeads() { return Graphs.successorListOf( ductGraph, getHEAD() ); }
private List<V> createOrderedVertexList(DirectedGraph<V, ?> graph, V start) { Queue<V> todo = new LinkedList<V>(); List<V> visited = new LinkedList<V>(); todo.add(start); while (!todo.isEmpty()) { V current = todo.poll(); visited.add(current); for (V suc : Graphs.successorListOf(graph, current)) { if (!todo.contains(suc) && !visited.contains(suc)) { todo.add(suc); } } } return visited; }
private static <A, B> Set<A> reachableFromSource(DirectedGraph<A, B> graph, A source) { Set<A> res = new HashSet<A>(); Queue<A> todo = new LinkedList<A>(); todo.add(source); while (!todo.isEmpty()) { A current = todo.poll(); res.add(current); for (A succ : Graphs.successorListOf(graph, current)) { if (!todo.contains(succ) && !res.contains(succ)) { todo.add(succ); } } } return res; }
/** * Returns the successor list of a node for directed graphs or the neighbor * list of a node for undirected graphs. Used in BFS, DFS, Strahler. * * @param node The node. * @return The outgoing edges of the node. */ public List<V> successorListOf(V node) { if (graph instanceof DirectedGraph) { return Graphs.successorListOf((DirectedGraph) graph, node); } else { return Graphs.neighborListOf(graph, node); } }
/** * Return a Collection of successor nodes of a certain vertex. * * @param vertex the step or node its successors nodes will be returned. * @return collection of successor DAGNodes for each node. */ protected Collection<DAGNode<? extends Job>> getNodeSuccessors(Object vertex) { Collection<DAGNode<? extends Job>> nodeSuccessors = Sets.newHashSet(); List successorNodes = Graphs.successorListOf(jobsGraph, vertex); for (Object node : successorNodes) { BaseFlowStep step = (BaseFlowStep) node; String name = step.getName(); nodeSuccessors.add(dagNamesMap.get(name)); } return nodeSuccessors; } }
/** * Return a Collection of successor nodes of a certain vertex. * * @param vertex the step or node its successors nodes will be returned. * @return collection of successor DAGNodes for each node. */ protected Collection<DAGNode<? extends Job>> getNodeSuccessors(Object vertex) { Collection<DAGNode<? extends Job>> nodeSuccessors = Sets.newHashSet(); List successorNodes = Graphs.successorListOf(jobsGraph, vertex); for (Object node : successorNodes) { BaseFlowStep step = (BaseFlowStep) node; String name = step.getName(); nodeSuccessors.add(dagNamesMap.get(name)); } return nodeSuccessors; } }
/** * Graph filtering helper recursive method. * @param excluded Already excluded connectors ids. * @param cnn Connector to exclude. */ private void exclude(final Set<UUID> excluded, final ConnectorObject cnn) { if (excluded.add(cnn.getId())) { for (final ConnectorObject target : Graphs.successorListOf(graph, cnn)) { exclude(excluded, target); } } }
protected Decision[] createSuccessors( String[] categories, Fields expectedFields, Tree tree, Node node ) { List<Node> successorNodes = Graphs.successorListOf( tree.getGraph(), node ); if( successorNodes.size() == 0 ) return new Decision[]{new FinalDecision( categories, tree, node )}; Decision[] successors = new Decision[ successorNodes.size() ]; for( int i = 0; i < successorNodes.size(); i++ ) { Node successorNode = successorNodes.get( i ); successors[ i ] = new PredicatedDecision( categories, expectedFields, tree, successorNode ); } return successors; }
/** * Returns the unique successors of the given vertex if it exists in the cache, otherwise it is * initialized. * * @param v the given vertex * @return the unique successors of the given vertex */ public Set<V> successorsOf(V v) { return fetch(v, successors, k -> new Neighbors<>(Graphs.successorListOf(graph, v))); }
/** * Merge the indexes of the current connected component * @param d is the root node * */ private void mergeRangeNode(T d) { for (T ch : Graphs.successorListOf(namedDAG, d)) { if (!ch.equals(d)) { mergeRangeNode(ch); //merge the index of the node with the index of his child ranges.get(d).addRange(ranges.get(ch).getIntervals()); } } } }
/** * Computes the transitive closure of a directed acyclic graph in $O(nm)$ * * @param graph - Graph to compute transitive closure for. * @param <V> the graph vertex type * @param <E> the graph edge type */ public <V, E> void closeDirectedAcyclicGraph(DirectedAcyclicGraph<V, E> graph) { Deque<V> orderedVertices = new ArrayDeque<>(graph.vertexSet().size()); new TopologicalOrderIterator<>(graph).forEachRemaining(orderedVertices::addFirst); for (V vertex : orderedVertices) { for (V successor : Graphs.successorListOf(graph, vertex)) { for (V closureVertex : Graphs.successorListOf(graph, successor)) { graph.addEdge(vertex, closureVertex); } } } }
private void dfs(V vertex) { visited.add(vertex); for (V suc : Graphs.successorListOf(graph, vertex)) { if (!visited.contains(suc)) { traversalTree.addEdge(vertex, suc); dfs(suc); } else { if (traversalTree.isAncestor(vertex, suc)) { backwardEdges.add(graph.getEdge(vertex, suc)); } else if (traversalTree.isDescendant(vertex, suc)) { forwardEdges.add(graph.getEdge(vertex, suc)); } else { crossEdges.add(graph.getEdge(vertex, suc)); } } } }
public void setChildren( ElementGraph parent, List<? extends ElementGraph> children ) { Delegate parentDelegate = new Delegate( parent ); if( !graph.addVertex( parentDelegate ) ) graph.removeAllVertices( Graphs.successorListOf( graph, parentDelegate ) ); for( ElementGraph child : children ) { Delegate childDelegate = new Delegate( child ); graph.addVertex( childDelegate ); graph.addEdge( parentDelegate, childDelegate ); } }