public boolean removeVertex(ExecutableMethod v) { return graph.removeVertex(v); }
public boolean removeVertex(ExecutableMethod v) { return graph.removeVertex(v); }
/** * Removes vertices from graph * @param graph raph to mutate * @param vertices vertices to remove */ public static <V> void removeVertices(DirectedGraph<V, DefaultEdge> graph, Set<V> vertices) { for (V vertex : vertices) { if (graph.containsVertex(vertex)) { graph.removeVertex(vertex); } } } }
protected List<ATermAppl> computeDefinitionOrder() { List<ATermAppl> definitionOrder = CollectionUtils.makeList(); definitionOrder.add( TOP ); definitionOrder.addAll( getEquivalents( TOP ) ); graph.removeVertex( TOP ); destructiveTopologocialSort( definitionOrder ); definitionOrder.add( BOTTOM ); return definitionOrder; }
protected List<ATermAppl> computeDefinitionOrder() { List<ATermAppl> definitionOrder = CollectionUtils.makeList(); definitionOrder.add( TOP ); definitionOrder.addAll( getEquivalents( TOP ) ); graph.removeVertex( TOP ); destructiveTopologocialSort( definitionOrder ); definitionOrder.add( BOTTOM ); return definitionOrder; }
private void createGraphNodes() { // copy CFG nodes addVertices(cfg); for (BasicBlock b : vertexSet()) if (b.isExitBlock() && !graph.removeVertex(b)) // TODO refactor throw new IllegalStateException("internal error building up CDG"); }
private void replaceVertex(JavaClass newClass) { List<JavaClass> incomingEdges = getParents(newClass); graph.removeVertex(newClass); graph.addVertex(newClass); for (JavaClass each : incomingEdges) { graph.addEdge(each, newClass); } }
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 replaceVertex(JavaElement newClass) { List<Element> incomingEdges = getParents(newClass); graph.removeVertex(newClass); graph.addVertex(newClass); for (Element each : incomingEdges) { graph.addEdge(each, newClass); } }
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 ); } }
if (graph.containsVertex(alternateVertex)) { dependents = getIncomingVertices(graph, alternateVertex); graph.removeVertex(alternateVertex);
public void destructiveTopologocialSort(List<ATermAppl> nodesSorted) { Queue<ATermAppl> nodesPending = createQueue(); for( ATermAppl node : graph.vertexSet() ) { if( graph.outDegreeOf( node ) == 0 ) nodesPending.add( node ); } while( !nodesPending.isEmpty() ) { ATermAppl node = nodesPending.remove(); assert graph.outDegreeOf( node ) == 0; nodesSorted.addAll( getAllEquivalents( node ) ); for( DefaultEdge edge : graph.incomingEdgesOf( node ) ) { ATermAppl source = graph.getEdgeSource( edge ); if( graph.outDegreeOf( source ) == 1 ) nodesPending.add( source ); } graph.removeVertex( node ); } assert graph.vertexSet().isEmpty() : "Failed to sort elements: " + graph.vertexSet(); } }
public void destructiveTopologocialSort(List<ATermAppl> nodesSorted) { Queue<ATermAppl> nodesPending = createQueue(); for( ATermAppl node : graph.vertexSet() ) { if( graph.outDegreeOf( node ) == 0 ) nodesPending.add( node ); } while( !nodesPending.isEmpty() ) { ATermAppl node = nodesPending.remove(); assert graph.outDegreeOf( node ) == 0; nodesSorted.addAll( getAllEquivalents( node ) ); for( DefaultEdge edge : graph.incomingEdgesOf( node ) ) { ATermAppl source = graph.getEdgeSource( edge ); if( graph.outDegreeOf( source ) == 1 ) nodesPending.add( source ); } graph.removeVertex( node ); } assert graph.vertexSet().isEmpty() : "Failed to sort elements: " + graph.vertexSet(); } }
/** * In some cases there can be isolated nodes within a CFG. For example in an * completely empty try-catch-finally. Since these nodes are not reachable * but cause trouble when determining the entry point of a CFG they get * removed. * * @return a int. */ public int removeIsolatedNodes() { Set<BytecodeInstruction> candidates = determineEntryPoints(); int removed = 0; if (candidates.size() > 1) { for (BytecodeInstruction instruction : candidates) { if (outDegreeOf(instruction) == 0) { if (graph.removeVertex(instruction)) { removed++; BytecodeInstructionPool.getInstance(classLoader).forgetInstruction(instruction); } } } } return removed; }
private void connectCFG( RawControlFlowGraph cfg, BytecodeInstruction call, Map<RawControlFlowGraph, Map<BytecodeInstruction, CCFGCodeNode>> tempMap) { // add MethodCallNode and MethodReturnNode CCFGMethodReturnNode returnNode = new CCFGMethodReturnNode(call); CCFGMethodCallNode callNode = new CCFGMethodCallNode(call, returnNode); addVertex(callNode); addVertex(returnNode); // connect with method entry and exit nodes of called method CCFGNode calleeEntry = methodEntries.get(call.getCalledMethod()); CCFGNode calleeExit = methodExits.get(call.getCalledMethod()); CCFGMethodCallEdge callEdge = new CCFGMethodCallEdge(call, true); CCFGMethodCallEdge returnEdge = new CCFGMethodCallEdge(call, false); addEdge(callNode, calleeEntry, callEdge); addEdge(calleeExit, returnNode, returnEdge); // redirect edges from the original CodeNode to the new nodes CCFGNode origCallNode = tempMap.get(cfg).get(call); if (!redirectEdges(origCallNode, callNode, returnNode) || !graph.removeVertex(origCallNode)) throw new IllegalStateException( "internal error while connecting cfgs during CCFG construction"); }