for (DefaultEdge edge : graph.edgeSet()) { PlanFragmentId source = graph.getEdgeSource(edge); PlanFragmentId target = graph.getEdgeTarget(edge);
/** * @param clickable * the edge. * @return the target state of this edge. */ public StateVertex getTargetState(Eventable clickable) { return sfg.getEdgeTarget(clickable); }
@Override public T valueOf(DefaultEdge e) { return graph.getEdgeTarget(e); } });
@Override public T valueOf(DefaultEdge e) { return graph.getEdgeTarget(e); } });
public ExecutableMethod getEdgeTarget(DirectedEdge<ExecutableMethod> e) { return graph.getEdgeTarget(e); }
public ExecutableMethod getEdgeTarget(DirectedEdge<ExecutableMethod> e) { return graph.getEdgeTarget(e); }
/** * <p>getEdgeTarget</p> * * @param e a E object. * @return a V object. */ public V getEdgeTarget(E e) { if (!containsEdge(e)) throw new IllegalArgumentException("edge not in graph"); return graph.getEdgeTarget(e); }
/** * Fetch all of the dependencies of the given source vertex * @return mutable snapshot of the target vertices of all outgoing edges */ public static <V> Set<V> getOutgoingVertices(DirectedGraph<V, DefaultEdge> graph, V source) { Set<DefaultEdge> edges = graph.outgoingEdgesOf(source); Set<V> targets = new LinkedHashSet<V>(); for (DefaultEdge edge : edges) { targets.add(graph.getEdgeTarget(edge)); } return targets; }
/** * @param pageID The pageID of the category. * @return A set of child nodes of the given category. */ protected Set<Integer> __getChildren(int pageID) { Set<DefaultEdge> outgoingEdges = graph.outgoingEdgesOf(pageID); Set<Integer> outLinks = new HashSet<Integer>(); for (DefaultEdge edge : outgoingEdges) { outLinks.add(graph.getEdgeTarget(edge)); } return outLinks; }
/** * Returns the set of outgoing states. * * @param stateVertix * the state. * @return the set of outgoing states from the stateVertix. */ public Set<StateVertex> getOutgoingStates(StateVertex stateVertix) { final Set<StateVertex> result = new HashSet<StateVertex>(); for (Eventable c : getOutgoingClickables(stateVertix)) { result.add(sfg.getEdgeTarget(c)); } return result; }
/** {@inheritDoc} */ @Override public String toString() { StringBuffer sb = new StringBuffer(); for (ControlFlowEdge e : graph.edgeSet()) { sb.append(graph.getEdgeSource(e) + " -> " + graph.getEdgeTarget(e)); sb.append("\n"); } return sb.toString(); }
public static void renderDirected(DirectedGraph graph, String fileName) throws IOException { try (PrintStream out = new PrintStream(new FileOutputStream(fileName))) { out.println("digraph G {"); for (Object e : graph.edgeSet()) { out.println("\t" + graph.getEdgeSource(e) + " -> " + graph.getEdgeTarget(e)); } out.println("}"); } } }
public void removeChilds(String dynamicRoot, String dynKey) { Iterator<DefaultEdge> iterator = graph.outgoingEdgesOf(dynamicRoot).iterator(); List<DefaultEdge> list = new ArrayList<DefaultEdge>(); while(iterator.hasNext()) { DefaultEdge edge = iterator.next(); String target = graph.getEdgeTarget(edge); if(target.startsWith(dynKey)) { list.add(edge); } } graph.removeAllEdges(list); }
private void collapseCycle(Set<ATermAppl> scc) { Iterator<ATermAppl> i = scc.iterator(); ATermAppl rep = i.next(); while( i.hasNext() ) { ATermAppl node = i.next(); addEquivalent( rep, node ); for( DefaultEdge edge : graph.incomingEdgesOf( node ) ) { ATermAppl incoming = graph.getEdgeSource( edge ); if( !incoming.equals( rep ) ) graph.addEdge( incoming, rep ); } for( DefaultEdge edge : graph.outgoingEdgesOf( node ) ) { ATermAppl outgoing = graph.getEdgeTarget( edge ); if( !outgoing.equals( rep ) ) graph.addEdge( rep, outgoing ); } graph.removeVertex( node ); } }
private void collapseCycle(Set<ATermAppl> scc) { Iterator<ATermAppl> i = scc.iterator(); ATermAppl rep = i.next(); while( i.hasNext() ) { ATermAppl node = i.next(); addEquivalent( rep, node ); for( DefaultEdge edge : graph.incomingEdgesOf( node ) ) { ATermAppl incoming = graph.getEdgeSource( edge ); if( !incoming.equals( rep ) ) graph.addEdge( incoming, rep ); } for( DefaultEdge edge : graph.outgoingEdgesOf( node ) ) { ATermAppl outgoing = graph.getEdgeTarget( edge ); if( !outgoing.equals( rep ) ) graph.addEdge( rep, outgoing ); } graph.removeVertex( node ); } }
private DefaultEdge visit(int node) { colorMap.put(node, Color.grey); Set<DefaultEdge> outgoingEdges = categoryGraph.getGraph().outgoingEdgesOf(node); for (DefaultEdge edge : outgoingEdges) { int outNode = categoryGraph.getGraph().getEdgeTarget(edge); if (colorMap.get(outNode).equals(Color.grey)) { return edge; } else if (colorMap.get(outNode).equals(Color.white)) { DefaultEdge e = visit(outNode); if (e != null) { return e; } } } colorMap.put(node, Color.black); return null; } }
@Override public void edgeTraversed(final EdgeTraversalEvent<DefaultEdge> e) { final IServiceDAGVertex<?> dagSource = traversedGraph.getEdgeSource(e.getEdge()); final IServiceDAGVertex<?> dagTarget = traversedGraph.getEdgeTarget(e.getEdge()); final Collection<IServiceTreeVertex<?>> treeParents = findVisitedDAGVertices(dagSource); treeParents.forEach(treeParent -> addTreeVertex(treeParent, dagTarget)); }
public Method createMethodFromSubgraph(DirectedGraph<CfgBlock, CfgEdge> subgraph, String newMethodName) { Preconditions.checkArgument(vertexSet().containsAll(subgraph.vertexSet()), "Method does not contain all nodes from subgraph."); Method subgraphMethod = new Method(location, newMethodName, this.parameterList, this.returnTypes); for (CfgBlock v : subgraph.vertexSet()) { subgraphMethod.addVertex(v); } for (CfgEdge e : subgraph.edgeSet()) { subgraphMethod.addEdge(subgraph.getEdgeSource(e), subgraph.getEdgeTarget(e)); } subgraphMethod.initialize(thisVariable, returnVariables, locals, source, isProgramEntry); return subgraphMethod; }
/** * Copy the source graph into the target graph */ public static <V> void copyGraph(DirectedGraph<V, DefaultEdge> sourceGraph, DirectedGraph<V, DefaultEdge> targetGraph) { addAllVertices(targetGraph, sourceGraph.vertexSet()); for (DefaultEdge edge : sourceGraph.edgeSet()) { targetGraph.addEdge(sourceGraph.getEdgeSource(edge), sourceGraph.getEdgeTarget(edge)); } }
/** * Removes cycles from the graph that was used to construct the cycle handler. * @throws WikiApiException Thrown if errors occurred. */ public void removeCycles() throws WikiApiException { DefaultEdge edge = null; while ((edge = findCycle()) != null) { Category sourceCat = wiki.getCategory(categoryGraph.getGraph().getEdgeSource(edge)); Category targetCat = wiki.getCategory(categoryGraph.getGraph().getEdgeTarget(edge)); logger.info("Removing cycle: " + sourceCat.getTitle() + " - " + targetCat.getTitle()); categoryGraph.getGraph().removeEdge(edge); } }