/** * 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 String writeServiceGraph(final ServiceTree serviceTree) { final StringBuilder textGraph = new StringBuilder().append(String.format("%n")); final DepthFirstIterator<IServiceTreeVertex<?>, DefaultEdge> dfs = new DepthFirstIterator<>(serviceTree, serviceTree.getRoot()); // Walk the graph depth-first and use the service tree listener // to create a text representation of the service tree final TextServiceTreeListener listener = new TextServiceTreeListener(serviceTree, textGraph); dfs.addTraversalListener(listener); while (dfs.hasNext()) { dfs.next(); } return textGraph.toString(); }
subset1.add(v); return v; }).map((v) -> new DepthFirstIterator<>(dg, v)).forEachOrdered((it) -> { while (it.hasNext()) { subset1.add(it.next()); subset2.add(v); return v; }).map((v) -> new DepthFirstIterator<>(gd, v)).forEachOrdered((it) -> { while (it.hasNext()) { subset2.add(it.next());
private void addTrapsToGraph() { DepthFirstIterator<FlowElement, Scope> iterator = getDepthFirstIterator(); while( iterator.hasNext() ) { FlowElement element = iterator.next(); if( !( element instanceof Pipe ) ) continue; Pipe pipe = (Pipe) element; Tap trap = traps.get( pipe.getName() ); if( trap == null ) continue; addVertex( trap ); if( LOG.isDebugEnabled() ) LOG.debug( "adding trap edge: " + pipe + " -> " + trap ); if( getEdge( pipe, trap ) != null ) continue; addEdge( pipe, trap ).setName( pipe.getName() ); // name scope after previous pipe } }
List<V> tour = new ArrayList<>(n + 1); V start = graph.vertexSet().iterator().next(); DepthFirstIterator<V, DefaultEdge> dfsIt = new DepthFirstIterator<>(mst, start); while (dfsIt.hasNext()) { V v = dfsIt.next(); if (found.add(v)) { tour.add(v);
/** * Graph edges may not be named "." or ".." and any non-root node has exactly * one incoming edge. */ private static void checkEdgeInvariants( final CatalogDirectoryNode root, final UnmodifiableGraph<CatalogNodeType, CatalogDirectoryEntry> g) { final DepthFirstIterator<CatalogNodeType, CatalogDirectoryEntry> di = new DepthFirstIterator<>(g); while (di.hasNext()) { final CatalogNodeType k = di.next(); final Set<CatalogDirectoryEntry> ie = g.incomingEdgesOf(k); if (k.equals(root)) { Assert.assertEquals(0L, (long) ie.size()); } else { Assert.assertEquals(1L, (long) ie.size()); final CatalogDirectoryEntry ee = ie.iterator().next(); Assert.assertNotEquals(".", ee.getName()); Assert.assertNotEquals("..", ee.getName()); } } }
/** * Get the descendants of a vertex. * * @param vertex the vertex to get the descendants of * @return {@link Set} of descendants of a vertex */ public Set<V> getDescendants(V vertex) { Iterator<V> iterator = new DepthFirstIterator<>(this, vertex); Set<V> descendants = new HashSet<>(); // Do not add start vertex to result. if (iterator.hasNext()) { iterator.next(); } iterator.forEachRemaining(descendants::add); return descendants; }
final DepthFirstIterator< List< Spot >, DefaultEdge > depthFirstIterator = new DepthFirstIterator< >( branchGraph ); while ( depthFirstIterator.hasNext() ) final List< Spot > branch = depthFirstIterator.next();
public static List<String> calculateParents(Graph<String, DefaultEdge> graph, String currentNode) { List<String> result = new ArrayList<>(); GraphIterator<String, DefaultEdge> it = new DepthFirstIterator<>(graph, currentNode); while (it.hasNext()) { result.add(it.next()); } Collections.reverse(result); return result.subList(0, result.size() - 1); }
final DepthFirstIterator< List< Spot >, DefaultEdge > depthFirstIterator = new DepthFirstIterator< >( branchGraph ); while ( depthFirstIterator.hasNext() ) final List< Spot > branch = depthFirstIterator.next();
public static List<String> calculateParents(Graph<String, DefaultEdge> graph, String currentNode) { List<String> result = new ArrayList<>(); GraphIterator<String, DefaultEdge> it = new DepthFirstIterator<>(graph, currentNode); while (it.hasNext()) { result.add(it.next()); } Collections.reverse(result); return result.subList(0, result.size() - 1); }
DepthFirstIterator<Action, DefaultEdge> iterator = new DepthFirstIterator<>(workflowGraph, start); while (iterator.hasNext()) { Action a = iterator.next(); Action transition = getTransition(workflowGraph, a); switch (a.getType()) {
/** * Get the ancestors of a vertex. * * @param vertex the vertex to get the ancestors of * @return {@link Set} of ancestors of a vertex */ public Set<V> getAncestors(V vertex) { EdgeReversedGraph<V, E> reversedGraph = new EdgeReversedGraph<>(this); Iterator<V> iterator = new DepthFirstIterator<>(reversedGraph, vertex); Set<V> ancestors = new HashSet<>(); // Do not add start vertex to result. if (iterator.hasNext()) { iterator.next(); } iterator.forEachRemaining(ancestors::add); return ancestors; }
/** * Returns a new depth first iterator over the spots connected by links in * this model. A boolean flag allow to set whether the returned iterator * does take into account the edge direction. If true, the iterator will not * be able to iterate backward in time. * * @param start * the spot to start iteration with. Can be <code>null</code>, * then the start will be taken randomly and will traverse all * the links. * @param directed * if true returns a directed iterator, undirected if false. * @return a new depth-first iterator. */ public GraphIterator< Spot, DefaultWeightedEdge > getDepthFirstIterator( final Spot start, final boolean directed ) { if ( directed ) return new TimeDirectedDepthFirstIterator( graph, start ); return new DepthFirstIterator< >( graph, start ); }
/** * Returns a new depth first iterator over the spots connected by links in * this model. A boolean flag allow to set whether the returned iterator * does take into account the edge direction. If true, the iterator will not * be able to iterate backward in time. * * @param start * the spot to start iteration with. Can be <code>null</code>, * then the start will be taken randomly and will traverse all * the links. * @param directed * if true returns a directed iterator, undirected if false. * @return a new depth-first iterator. */ public GraphIterator< Spot, DefaultWeightedEdge > getDepthFirstIterator( final Spot start, final boolean directed ) { if ( directed ) return new TimeDirectedDepthFirstIterator( graph, start ); return new DepthFirstIterator< >( graph, start ); }
public String completePlanTemplate() { LOGGER.debug("Completing BPEL process template..."); /* Traverse the management flow and add the nodes in the order of their execution to a list */ List<Node> managementTaskSeq = new ArrayList<Node>(); GraphIterator<Node, Link> iterator = new DepthFirstIterator<Node, Link>(mangagementFlow); while (iterator.hasNext()) { Node node = iterator.next(); /* In this version the templates do only support management tasks and exclusive gateway */ if (node instanceof ManagementTask) { /* Wrapper adds convenience functions that can be accessed from the Velocity template */ ManagementTaskTemplateWrapper taskWrapper = new ManagementTaskTemplateWrapper((ManagementTask) node); //TODO move to factory and remove setters from constructor managementTaskSeq.add(taskWrapper); } else if (node instanceof Gateway) { managementTaskSeq.add(node); } } VelocityContext context = new VelocityContext(); /* In the Velocity template for each management task an own scope is created containing the variables and * activities required to perform the management task based on the properties of the respective task */ Template planTemplate = Velocity.getTemplate(TEMPLATE_PATH + "bpel_management_plan_template.xml"); context.put("mngmtTaskList", managementTaskSeq); StringWriter planWriter = new StringWriter(); planTemplate.merge(context, planWriter); String bpelProcessContent = planWriter.toString(); LOGGER.debug("Completed BPEL process template" + bpelProcessContent); return bpelProcessContent; }
return new DepthFirstIterator<HepRelVertex, DefaultEdge>( graph, start);
new DepthFirstIterator<HepRelVertex, DefaultEdge>( graph, root);
new DepthFirstIterator<Object, DefaultEdge>(completeGraph); Object vertex; while (iter.hasNext()) {
Iterator<Object> i = new DepthFirstIterator<Object, DefaultEdge>(g); i.hasNext();)