edu.uci.ics.jung.graph.Graph Java Examples

The following examples show how to use edu.uci.ics.jung.graph.Graph. 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: DependencyGraphTest.java    From baleen with Apache License 2.0 6 votes vote down vote up
@Test
public void testRemoveLoops() {
  Graph<String, String> graph = new SparseMultigraph<>();
  graph.addVertex("v1");
  graph.addVertex("v2");
  graph.addVertex("v3");

  graph.addEdge("e1", "v1", "v2", EdgeType.DIRECTED);
  graph.addEdge("e2", "v2", "v1", EdgeType.DIRECTED);
  graph.addEdge("e3", "v1", "v3", EdgeType.DIRECTED);

  DependencyGraph.removeLoops(graph);

  assertEquals(3, graph.getVertexCount());
  assertEquals(2, graph.getEdgeCount());

  assertTrue(graph.getEdges().contains("e1"));
  assertTrue(graph.getEdges().contains("e3"));
}
 
Example #2
Source File: GraphViewerUtils.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public static <V extends VisualVertex, E extends VisualEdge<V>> 
	Rectangle getTotalGraphSizeInLayoutSpace(VisualizationServer<V, E> viewer) {
//@formatter:on

	Layout<V, E> layout = viewer.getGraphLayout();
	Graph<V, E> theGraph = layout.getGraph();
	Collection<V> vertices = theGraph.getVertices();
	Collection<E> edges = theGraph.getEdges();

	Function<V, Rectangle> vertexToBounds = createVertexToBoundsTransformer(viewer);

	if (!layoutUsesEdgeArticulations(layout)) {
		Rectangle bounds = getBoundsForVerticesInLayoutSpace(vertices, vertexToBounds);
		return bounds;
	}

	Function<E, List<Point2D>> edgeToArticulations = e -> e.getArticulationPoints();
	return getTotalGraphSizeInLayoutSpace(vertices, edges, vertexToBounds, edgeToArticulations);
}
 
Example #3
Source File: FGViewUpdater.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public FGVertex updateEdgeVertexForUngrouping(FunctionGraph functionGraph,
		GroupedFunctionGraphVertex groupedVertex, FGVertex originalVertex) {

	Graph<FGVertex, FGEdge> graph = functionGraph;
	if (graph.containsVertex(originalVertex)) {
		return originalVertex;
	}

	//
	// Look through the vertices to find the vertex that contains the given address.  We may
	// have multiple vertices that contain the address, as is the case when we are
	// transitioning from a group vertex that contains a group vertex that contains the
	// given address.
	//
	Address address = originalVertex.getVertexAddress();
	Collection<FGVertex> vertices = graph.getVertices();
	for (FGVertex vertex : vertices) {
		if (vertex.containsAddress(address) && !vertex.equals(groupedVertex)) {
			return vertex;
		}
	}

	// should never happen
	throw new AssertException("Cannot find any vertex for address: " + address);
}
 
Example #4
Source File: PageRankTest.java    From AGDISTIS with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void soEqualByRandomWalker() throws IOException {

	Graph g = new DirectedSparseMultigraph<Node, String>();

	Node n1 = new Node("N1", 0, 0,"pagerank");
	Node n2 = new Node("N2", 0, 0,"pagerank");
	Node n3 = new Node("N3", 0, 0,"pagerank");
	Node n4 = new Node("N4", 0, 0,"pagerank");

	g.addVertex(n1);
	g.addVertex(n2);
	g.addVertex(n3);
	g.addVertex(n4);

	PageRank pr = new PageRank();
	pr.runPr(g, 100, 0.001);

	assertTrue(n1.getPageRank() == 0.25);
	assertTrue(n2.getPageRank() == n3.getPageRank());
	assertTrue(n3.getPageRank() == n4.getPageRank());
	assertTrue(n4.getPageRank() == n1.getPageRank());

	// System.out.println("EQUAL2: " + n1);
}
 
Example #5
Source File: PageRankTest.java    From AGDISTIS with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void soEqual() throws IOException {

	Graph g = new DirectedSparseMultigraph<Node, String>();

	Node n1 = new Node("N1", 0, 0,"pagerank");
	Node n2 = new Node("N2", 0, 0,"pagerank");
	Node n3 = new Node("N3", 0, 0,"pagerank");
	Node n4 = new Node("N4", 0, 0,"pagerank");

	g.addEdge("e1", n1, n2);
	g.addEdge("e2", n2, n3);
	g.addEdge("e3", n3, n4);
	g.addEdge("e4", n4, n1);

	PageRank pr = new PageRank();
	pr.runPr(g, 100, 0.001);

	assertTrue(n1.getPageRank() == 0.25);
	assertTrue(n2.getPageRank() == n3.getPageRank());
	assertTrue(n3.getPageRank() == n4.getPageRank());
	assertTrue(n4.getPageRank() == n1.getPageRank());
	// System.out.println("EQUAL1: " + n1);

}
 
Example #6
Source File: ClusterModelGraphCreator.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Graph<String, String> createGraph() {
	Tree<String, String> graph = new DelegateTree<String, String>();
	if (clusterModel.getRootNode() == null) {
		return graph;
	}

	HierarchicalClusterNode root = clusterModel.getRootNode();
	graph.addVertex("Root");
	vertexMap.put("Root", root);

	for (HierarchicalClusterNode subNode : clusterModel.getRootNode().getSubNodes()) {
		createGraph(graph, "Root", subNode);
	}
	return graph;
}
 
Example #7
Source File: BasicEdgeRouter.java    From ghidra with Apache License 2.0 6 votes vote down vote up
protected boolean isOccluded(E edge, Shape graphSpaceShape) {

		Layout<V, E> layout = viewer.getGraphLayout();
		Graph<V, E> graph = layout.getGraph();
		Collection<V> vertices = graph.getVertices();

		for (V vertex : vertices) {
			Rectangle vertexBounds = getVertexBoundsInGraphSpace(viewer, vertex);

			Pair<V> endpoints = graph.getEndpoints(edge);
			if (vertex == endpoints.getFirst() || vertex == endpoints.getSecond()) {
				// do we ever care if an edge is occluded by its own vertices?
				continue;
			}

			if (graphSpaceShape.intersects(vertexBounds)) {
				return true;
			}
		}

		return false;
	}
 
Example #8
Source File: FileLinkGraphPanel.java    From netbeans-mmd-plugin with Apache License 2.0 6 votes vote down vote up
@Nonnull
private Graph<FileVertex, Number> makeGraph(@Nullable final File projectFolder, @Nullable final File startMindMap) {
  final DirectedSparseGraph<FileVertex, Number> result = new DirectedSparseGraph<>();

  final AtomicInteger edgeCounter = new AtomicInteger();

  final Set<File> mapFilesInProcessing = new HashSet<>();

  if (startMindMap != null) {
    addMindMapAndFillByItsLinks(null, result, projectFolder, startMindMap, edgeCounter, mapFilesInProcessing);
  } else if (projectFolder != null) {
    final Iterator<File> iterator = FileUtils.iterateFiles(projectFolder, new String[]{"mmd"}, true); //NOI18N
    while (iterator.hasNext()) {
      final File mmdFile = iterator.next();
      if (mmdFile.isFile()) {
        addMindMapAndFillByItsLinks(null, result, projectFolder, mmdFile, edgeCounter, mapFilesInProcessing);
      }
    }
  }

  return result;
}
 
Example #9
Source File: DependencyGraph.java    From baleen with Apache License 2.0 6 votes vote down vote up
/** Find and remove simple loops (e.g. a &rarr; b &rarr; 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 #10
Source File: DependencyGraph.java    From baleen with Apache License 2.0 6 votes vote down vote up
private Graph<AnalysisEngine, Integer> createDependencyGraph(
    List<AnalysisEngine> analysisEngines) {
  Graph<AnalysisEngine, Integer> graph = new SparseMultigraph<>();

  // First, add all annotators onto the graph
  for (AnalysisEngine ae : analysisEngines) graph.addVertex(ae);

  // Now add dependencies between annotators
  for (AnalysisEngine ae1 : analysisEngines) {
    for (AnalysisEngine ae2 : analysisEngines) {
      if (ae1 == ae2) continue;

      addAnnotatorDependencies(graph, ae1, ae2);
    }
  }

  return graph;
}
 
Example #11
Source File: FunctionGraphVertexAttributes.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private Map<FGVertex, Point> getVertexLocationsFromPropertyMaps(FunctionGraph functionGraph,
		ObjectPropertyMap vertexLocationPropertyMap,
		ObjectPropertyMap groupVertexLocationPropertyMap) {

	Map<FGVertex, Point> map = new HashMap<>();
	Graph<FGVertex, FGEdge> graph = functionGraph;
	Collection<FGVertex> vertices = graph.getVertices();
	for (FGVertex vertex : vertices) {
		SaveablePoint saveablePoint = getPointFromPropertyMap(vertex, vertexLocationPropertyMap,
			groupVertexLocationPropertyMap);
		if (saveablePoint != null) {
			Point point = saveablePoint.getPoint();
			map.put(vertex, point);
		}
	}
	return map;
}
 
Example #12
Source File: FGProvider.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private Pair<String, String> getTitleFromGraphData(String title) {

		FGData graphData = controller.getFunctionGraphData();
		Pair<String, String> result = new Pair<>(title, "");
		if (graphData == null) {
			return result;
		}

		Function function = graphData.getFunction();
		if (function == null) {
			return result;
		}

		FunctionGraph functionGraph = graphData.getFunctionGraph();
		Graph<FGVertex, FGEdge> graph = functionGraph;
		String first = "Function Graph";

		String programName =
			(currentProgram != null) ? currentProgram.getDomainFile().getName() : "";
		String second = function.getName() + " - " + graph.getVertexCount() + " vertices  (" +
			programName + ")";

		return new Pair<>(first, second);
	}
 
Example #13
Source File: JungToGDirectedGraphAdapter.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public GDirectedGraph<V, E> emptyCopy() {

	if (delegate instanceof GDirectedGraph) {
		return ((GDirectedGraph) delegate).emptyCopy();
	}

	Class<? extends Graph> clazz = delegate.getClass();

	try {
		Constructor<? extends Graph> constructor = clazz.getConstructor((Class<?>[]) null);
		Graph newGraph = constructor.newInstance((Object[]) null);
		return new JungToGDirectedGraphAdapter(newGraph);
	}
	catch (Exception e) {
		// shouldn't happen
		Msg.showError(this, null, "Error Creating Graph",
			"Unable to create a new instance of graph: " + clazz, e);
		return null;
	}
}
 
Example #14
Source File: LWPCommunityDetector.java    From topic-detection with Apache License 2.0 6 votes vote down vote up
public LocalModularity getIncrementalLWPModularity(Community<V,E> community, V candMember, LocalModularity mod) {
	int indS0 = mod.getInDegree();
	int outdS0 = mod.getOutDegree();
	
	Graph<V, E> graph = community.getReferenceGraph();
	List<V> communityMembers = community.getMembers();
	int M = community.getNumberOfMembers();
	
	int currentMemberInDegree = 0;
	for (int i = 0; i < M; i++){
		if (graph.findEdge(candMember, communityMembers.get(i))!= null){
			currentMemberInDegree++;
		} 
	}
	/* update out- and in-degree counts of community */
	outdS0 += graph.degree(candMember) - currentMemberInDegree;
	/* in-edges were counted twice so divide by 2 */
	//indS0 += (int)Math.round(currentMemberInDegree/2.0); // this is probably wrong!
	indS0 += currentMemberInDegree;
	
	return new LocalModularity(indS0, outdS0);

}
 
Example #15
Source File: AbstractFunctionGraphTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/** 
 * Finds an edge that represents the given edge, which may no longer exist with 
 * the same (==) edge instances.
 */
private FGEdge getCurrentEdge(FunctionGraph functionGraph, FGEdge edge) {
	FGVertex start = edge.getStart();
	FGVertex end = edge.getEnd();
	Address startAddress = start.getVertexAddress();
	Address endAddress = end.getVertexAddress();
	FGVertex v1 = functionGraph.getVertexForAddress(startAddress);
	FGVertex v2 = functionGraph.getVertexForAddress(endAddress);
	Graph<FGVertex, FGEdge> graph = functionGraph;
	return graph.findEdge(v1, v2);
}
 
Example #16
Source File: PageRankTest.java    From AGDISTIS with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void oneGetsMost() throws IOException {

	Graph g = new DirectedSparseMultigraph<Node, String>();

	Node m = new Node("Master", 0, 0,"pagerank");
	Node s1 = new Node("Slave1", 0, 0,"pagerank");
	Node s2 = new Node("Slave2", 0, 0,"pagerank");
	Node s3 = new Node("Slave3", 0, 0,"pagerank");
	Node s4 = new Node("Slave4", 0, 0,"pagerank");

	g.addEdge("e1", s1, m);
	g.addEdge("e2", s2, m);
	g.addEdge("e3", s3, m);
	g.addEdge("e4", s4, m);
	g.addEdge("self", m, m); // node to self: this edge prevents
								// randomWalker

	PageRank pr = new PageRank();
	pr.runPr(g, 100, 0.001);

	// System.out.println(m + " ( = 1/5 * 0.15 + 0.85)");
	// System.out.println(s1 + " ( = 1/5 * 0.15)");
	// System.out.println(s2 + " (usw.)");
	// System.out.println(s3);
	// System.out.println(s4);
}
 
Example #17
Source File: AbstractFunctionGraphTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
protected void doTestGroupAndUngroupVertices() {
	FGData graphData = graphFunction("01002cf5");
	FunctionGraph functionGraph = graphData.getFunctionGraph();
	Graph<FGVertex, FGEdge> graph = functionGraph;

	Set<FGVertex> ungroupedVertices = selectVertices( functionGraph, 
																"01002d2b" /* Another Local*/, 
																"01002d1f" /* MyLocal */);
	Set<FGEdge> ungroupedEdges = getEdges(graph, ungroupedVertices);
	assertEquals("Did not grab all known edges for vertices", 4, ungroupedEdges.size());

	group(ungroupedVertices);

	assertVerticesRemoved(graph, ungroupedVertices);
	assertEdgesRemoved(graph, ungroupedEdges);
	
	// -1 because one one of the edges was between two of the vertices being grouped
	int expectedGroupedEdgeCount = ungroupedEdges.size() - 1;
	GroupedFunctionGraphVertex groupedVertex =
		validateNewGroupedVertexFromVertices(functionGraph, ungroupedVertices, 
			expectedGroupedEdgeCount);

	ungroup(groupedVertex);

	assertVertexRemoved(graph, groupedVertex);
	assertVerticesAdded(graph, ungroupedVertices);
	assertEdgesAdded(functionGraph, ungroupedEdges);
	assertSelected(ungroupedVertices);
	
}
 
Example #18
Source File: AbstractFunctionGraphTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
protected void verifyEdgeCount(int expectedCount) {
	FGData data = getFunctionGraphData();
	FunctionGraph functionGraph = data.getFunctionGraph();
	Graph<FGVertex, FGEdge> graph = functionGraph;
	int actualCount = graph.getEdgeCount();
	assertEquals("Graph has a different number of edges than expected.", expectedCount,
		actualCount);
}
 
Example #19
Source File: LWPCommunityDetector.java    From topic-detection with Apache License 2.0 5 votes vote down vote up
/**
 * Compute the LPW modularity measure introduced by Luo, Wang and Promislow. This method
 * has been made public so that other algorithms can use the same measure (but a different
 * search strategy).
 * 
 * @param community Input community.
 * @return
 */
public LocalModularity getLWPModularity(Community<V,E> community){
	/* check community validity*/
	if (!community.isValid()) throw new IllegalArgumentException(
			"You should provide a valid community as argument to the algorithm!");

	Graph<V, E> graph = community.getReferenceGraph();
	
	List<V> communityMembers = community.getMembers();
	int M = community.getNumberOfMembers();
	int indS = 0;
	int outdS = 0;
	for (int i = 0; i < M; i++){
		V currentMember = communityMembers.get(i);
		int currentMemberInDegree = 0;
		for (int j = 0; j < M; j++){
			if (i==j) continue;
			if (graph.findEdge(currentMember, communityMembers.get(j))!= null){
				currentMemberInDegree++;
			}
		}
		/* update out- and in-degree counts of community */
		outdS += graph.degree(currentMember) - currentMemberInDegree;
		/* in-edges were counted twice so divide by 2 */
		indS += (int)Math.round(currentMemberInDegree/2.0); 
	}
	return new LocalModularity(indS, outdS);
}
 
Example #20
Source File: AbstractFunctionGraphTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
protected void assertVerticesRemoved(FGVertex... ungroupedVertices) {

		FunctionGraph functionGraph = getFunctionGraph();
		Graph<FGVertex, FGEdge> graph = functionGraph;
		for (FGVertex vertex : ungroupedVertices) {
			assertTrue("Graph still contains grouped vertex: " + vertex,
				!graph.containsVertex(vertex));
		}
	}
 
Example #21
Source File: AbstractFunctionGraphTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
protected void assertVerticesAdded(Graph<FGVertex, FGEdge> graph,
		Collection<FGVertex> ungroupedVertices) {

	for (FGVertex vertex : ungroupedVertices) {
		assertTrue("Graph does not contain the ungrouped vertex: " + vertex,
			graph.containsVertex(vertex));
	}
}
 
Example #22
Source File: GraphUtils.java    From roboconf-platform with Apache License 2.0 5 votes vote down vote up
/**
 * Writes a graph as a PNG image.
 * @param outputFile the output file
 * @param selectedComponent the component to highlight
 * @param layout the layout
 * @param graph the graph
 * @param edgeShapeTransformer the transformer for edge shapes (straight line, curved line, etc)
 * @throws IOException if something went wrong
 */
public static void writeGraph(
		File outputFile,
		Component selectedComponent,
		Layout<AbstractType,String> layout,
		Graph<AbstractType,String> graph ,
		AbstractEdgeShapeTransformer<AbstractType,String> edgeShapeTransformer,
		Map<String,String> options )
throws IOException {

	VisualizationImageServer<AbstractType,String> vis =
			new VisualizationImageServer<AbstractType,String>( layout, layout.getSize());

	vis.setBackground( Color.WHITE );
	vis.getRenderContext().setEdgeLabelTransformer( new NoStringLabeller ());
	vis.getRenderContext().setEdgeShapeTransformer( edgeShapeTransformer );

	vis.getRenderContext().setVertexLabelTransformer( new ToStringLabeller<AbstractType> ());
	vis.getRenderContext().setVertexShapeTransformer( new VertexShape());
	vis.getRenderContext().setVertexFontTransformer( new VertexFont());

	Color defaultBgColor = decode( options.get( DocConstants.OPTION_IMG_BACKGROUND_COLOR ), DocConstants.DEFAULT_BACKGROUND_COLOR );
	Color highlightBgcolor = decode( options.get( DocConstants.OPTION_IMG_HIGHLIGHT_BG_COLOR ), DocConstants.DEFAULT_HIGHLIGHT_BG_COLOR );
	vis.getRenderContext().setVertexFillPaintTransformer( new VertexColor( selectedComponent, defaultBgColor, highlightBgcolor ));

	Color defaultFgColor = decode( options.get( DocConstants.OPTION_IMG_FOREGROUND_COLOR ), DocConstants.DEFAULT_FOREGROUND_COLOR );
	vis.getRenderContext().setVertexLabelRenderer( new MyVertexLabelRenderer( selectedComponent, defaultFgColor ));
	vis.getRenderer().getVertexLabelRenderer().setPosition( Position.CNTR );

	BufferedImage image = (BufferedImage) vis.getImage(
			new Point2D.Double(
					layout.getSize().getWidth() / 2,
					layout.getSize().getHeight() / 2),
			new Dimension( layout.getSize()));

	ImageIO.write( image, "png", outputFile );
}
 
Example #23
Source File: VertexInfo.java    From ghidra with Apache License 2.0 5 votes vote down vote up
Set<FGEdge> getInEdges(FGController controller, FGVertex vertex) {

		Set<FGEdge> edges = new HashSet<>();
		FGData functionGraphData = controller.getFunctionGraphData();
		FunctionGraph functionGraph = functionGraphData.getFunctionGraph();
		Graph<FGVertex, FGEdge> graph = functionGraph;
		Collection<FGEdge> inEdges = graph.getInEdges(vertex);
		if (inEdges == null) {
			return null;
		}

		edges.addAll(inEdges);
		return edges;
	}
 
Example #24
Source File: MergeVertexFunctionGraphJob.java    From ghidra with Apache License 2.0 5 votes vote down vote up
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 #25
Source File: AbstractFunctionGraphTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void removeVertex(FunctionGraph functionGraph, Address vertexAddress) {
	Graph<FGVertex, FGEdge> graph = functionGraph;
	FGVertex vertex = functionGraph.getVertexForAddress(vertexAddress);
	runSwing(() -> graph.removeVertex(vertex));
	FGController controller = getFunctionGraphController();
	controller.repaint();
}
 
Example #26
Source File: GroupVertexSerializer.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public static Element getXMLForGroupedVertices(FunctionGraph functionGraph) {
	Element element = new Element(GROUP_VERTICES_ELEMENT_NAME);
	Graph<FGVertex, FGEdge> graph = functionGraph;
	Collection<FGVertex> vertices = graph.getVertices();
	for (FGVertex vertex : vertices) {
		if (vertex instanceof GroupedFunctionGraphVertex) {
			GroupedVertexInfo info =
				new GroupedVertexInfo((GroupedFunctionGraphVertex) vertex, functionGraph);
			element.addContent(info.toXML());
		}
	}
	return element;
}
 
Example #27
Source File: AbstractFunctionGraphTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
protected void verifyEdge(FGVertex start, FGVertex destination) {
	FGData data = getFunctionGraphData();
	FunctionGraph functionGraph = data.getFunctionGraph();
	Graph<FGVertex, FGEdge> graph = functionGraph;

	FGEdge edge = graph.findEdge(start, destination);
	assertNotNull("No edge exists for vertices: " + start + "   and   " + destination, edge);
}
 
Example #28
Source File: FGProvider.java    From ghidra with Apache License 2.0 5 votes vote down vote up
AddressSet getAddressesFromHoveredVertices() {
	AddressSet addresses = new AddressSet();
	FGData functionGraphData = controller.getFunctionGraphData();
	if (!functionGraphData.hasResults()) {
		return addresses;
	}

	FunctionGraph functionGraph = functionGraphData.getFunctionGraph();
	Graph<FGVertex, FGEdge> graph = functionGraph;
	Collection<FGVertex> hoveredVertices = GraphViewerUtils.getVerticesOfHoveredEdges(graph);
	for (FGVertex vertex : hoveredVertices) {
		addresses.add(vertex.getAddresses());
	}
	return addresses;
}
 
Example #29
Source File: GroupHistoryInfo.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private static Map<AddressHasher, FGVertex> hashVerticesByStartAndEndAddress(
		FunctionGraph functionGraph) {
	Map<AddressHasher, FGVertex> map = new HashMap<>();
	Graph<FGVertex, FGEdge> graph = functionGraph;
	Collection<FGVertex> vertices = graph.getVertices();

	for (FGVertex vertex : vertices) {
		AddressSetView addresses = vertex.getAddresses();
		Address minAddress = addresses.getMinAddress();
		Address maxAddress = addresses.getMaxAddress();
		map.put(new AddressHasher(minAddress, maxAddress), vertex);
	}
	return map;
}
 
Example #30
Source File: ShapeBasedTreeLayout.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void setGraph(Graph<V, E> graph) {
	if (graph instanceof Forest) {
		this.graph = (Forest<V, E>) graph;
		calculateLocations();
	} else {
		throw new IllegalArgumentException("graph must be a forest");
	}
}