Java Code Examples for edu.uci.ics.jung.graph.Graph#getOutEdges()
The following examples show how to use
edu.uci.ics.jung.graph.Graph#getOutEdges() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DependencyGraph.java From baleen with Apache License 2.0 | 6 votes |
/** Find and remove simple loops (e.g. a → b → a) from a Jung graph */ public static <V, E> void removeLoops(Graph<V, E> graph) { for (V v : graph.getVertices()) { for (E e : graph.getOutEdges(v)) { V dest = graph.getDest(e); E returnEdge = graph.findEdge(dest, v); if (returnEdge != null) { LOGGER.warn( "Loop detected between {} and {}. Original order will be preserved.", getName(v), getName(dest)); graph.removeEdge(returnEdge); } } } }
Example 2
Source File: MergeVertexFunctionGraphJob.java From ghidra with Apache License 2.0 | 5 votes |
private Collection<FGEdge> getEdges(FGVertex vertex) { Graph<FGVertex, FGEdge> graph = graphLayout.getGraph(); List<FGEdge> edges = new LinkedList<>(); Collection<FGEdge> inEdges = graph.getInEdges(vertex); if (inEdges != null) { edges.addAll(inEdges); } Collection<FGEdge> outEdges = graph.getOutEdges(vertex); if (outEdges != null) { edges.addAll(outEdges); } return edges; }
Example 3
Source File: SplitVertexFunctionGraphJob.java From ghidra with Apache License 2.0 | 5 votes |
private Collection<FGEdge> getEdges(FGVertex vertex) { Graph<FGVertex, FGEdge> graph = graphLayout.getGraph(); List<FGEdge> edges = new LinkedList<>(); Collection<FGEdge> inEdges = graph.getInEdges(vertex); if (inEdges != null) { edges.addAll(inEdges); } Collection<FGEdge> outEdges = graph.getOutEdges(vertex); if (outEdges != null) { edges.addAll(outEdges); } return edges; }
Example 4
Source File: VertexInfo.java From ghidra with Apache License 2.0 | 5 votes |
Set<FGEdge> getOutEdges(FGController controller, FGVertex vertex) { Set<FGEdge> edges = new HashSet<>(); FGData functionGraphData = controller.getFunctionGraphData(); FunctionGraph functionGraph = functionGraphData.getFunctionGraph(); Graph<FGVertex, FGEdge> graph = functionGraph; Collection<FGEdge> outEdges = graph.getOutEdges(vertex); if (outEdges == null) { return null; } edges.addAll(outEdges); return edges; }
Example 5
Source File: FGProvider.java From ghidra with Apache License 2.0 | 4 votes |
private void handleReferenceRemoved(DomainObjectChangeRecord record) { // // Get the affected vertex (if any). Determine if we have to combine the vertex with // the vertex below it (adding a reference creates a new basic block, which creates a new // vertex--we may need to reverse that process) // FGData functionGraphData = controller.getFunctionGraphData(); FunctionGraph functionGraph = functionGraphData.getFunctionGraph(); Reference reference = (Reference) record.getOldValue(); Address toAddress = reference.getToAddress(); FGVertex destinationVertex = functionGraph.getVertexForAddress(toAddress); if (destinationVertex == null) { return; // this particular removal doesn't affect our graph } // // How do we know if we can combine this vertex with its parent? Well, we have some // tests that must hold true: // -There must be only a fallthrough edge to the affected vertex // -The parent vertex must have only one flow--FallThrough // -There must not be any other references to the entry of the vertex // -There must not be any non-dynamic labels on the vertex // Graph<FGVertex, FGEdge> graph = functionGraph; Collection<FGEdge> inEdgesForDestination = graph.getInEdges(destinationVertex); if (inEdgesForDestination.size() == 0) { // must be in a dirty state with vertices and edges that don't match reality return; } if (inEdgesForDestination.size() > 1) { return; } FGEdge incomingEdge = inEdgesForDestination.iterator().next(); FGVertex parentVertex = incomingEdge.getStart(); Collection<FGEdge> outEdges = graph.getOutEdges(parentVertex); if (outEdges.size() > 1) { return; } FlowType flowType = incomingEdge.getFlowType(); if (!flowType.isFallthrough()) { return; } SymbolTable symbolTable = currentProgram.getSymbolTable(); AddressSetView vertexAddresses = destinationVertex.getAddresses(); Address minAddress = vertexAddresses.getMinAddress(); Symbol[] symbols = symbolTable.getSymbols(minAddress); if (symbols.length > 1) { return; // real user symbols } else if (symbols.length == 1) { if (!symbols[0].isDynamic()) { return; // real user symbol } } ReferenceManager referenceManager = currentProgram.getReferenceManager(); ReferenceIterator references = referenceManager.getReferencesTo(minAddress); if (references.hasNext()) { return; // other references to this vertex entry point } controller.mergeVertexWithParent(destinationVertex); }
Example 6
Source File: FGProvider.java From ghidra with Apache License 2.0 | 4 votes |
private void handleSymbolRemoved(DomainObjectChangeRecord record) { // // Get the affected vertex (if any). Determine if we have to combine the vertex with // the vertex below it (adding a symbol creates a new basic block, which creates a new // vertex--we may need to reverse that process) // FGData functionGraphData = controller.getFunctionGraphData(); FunctionGraph functionGraph = functionGraphData.getFunctionGraph(); Address address = ((ProgramChangeRecord) record).getStart(); FGVertex destinationVertex = functionGraph.getVertexForAddress(address); if (destinationVertex == null) { return; // this particular removal doesn't affect our graph } // // How do we know if we can combine this vertex with its parent? Well, we have some // tests that must hold true: // -There must be only a fallthrough edge to the affected vertex // -The parent vertex must have only one flow--FallThrough // -There must not be any other references to the entry of the vertex // -There must not be any non-dynamic labels on the vertex // Graph<FGVertex, FGEdge> graph = functionGraph; Collection<FGEdge> inEdgesForDestination = graph.getInEdges(destinationVertex); if (inEdgesForDestination.size() == 0) { // must be in a dirty state with vertices and edges that don't match reality return; } if (inEdgesForDestination.size() > 1) { controller.refreshDisplayWithoutRebuilding(); return; } FGEdge incomingEdge = inEdgesForDestination.iterator().next(); FGVertex parentVertex = incomingEdge.getStart(); Collection<FGEdge> outEdges = graph.getOutEdges(parentVertex); if (outEdges.size() > 1) { return; } FlowType flowType = incomingEdge.getFlowType(); if (!flowType.isFallthrough()) { controller.refreshDisplayWithoutRebuilding(); return; } SymbolTable symbolTable = currentProgram.getSymbolTable(); AddressSetView vertexAddresses = destinationVertex.getAddresses(); Address minAddress = vertexAddresses.getMinAddress(); Symbol[] symbols = symbolTable.getSymbols(minAddress); if (symbols.length > 1) { controller.refreshDisplayWithoutRebuilding(); return; // real user symbols } else if (symbols.length == 1) { if (!symbols[0].isDynamic()) { controller.refreshDisplayWithoutRebuilding(); return; // real user symbol } } ReferenceManager referenceManager = currentProgram.getReferenceManager(); ReferenceIterator references = referenceManager.getReferencesTo(minAddress); if (references.hasNext()) { return; // other references to this vertex entry point } controller.mergeVertexWithParent(destinationVertex); }