Java – extract subgraphs from drawings using Jun?

I have a big picture. I'm using Jung I wonder if Jung provides a way to extract the two hop neighborhood of a vertex (including all edges) into a separate graph?

Solution

In Jung 2.0, it is edu uci. ics. jung. algorithms. filters. KNeighborhoodFilter:

This is how you use it (assuming you already have shapes and vertex / edge types):

Graph<V,E> graph = // ...
int k = 3; // maximum hops
V startVertex = // ... (pick your starting node)
Filter<V,E> filter = new KNeighborhoodFilter<V,E>(
    startVertex,k,EdgeType.IN_OUT);
Graph<V,E> neighborhood = filter.transform(graph);

The neighborhood graph will belong to the same class as the original graph You must create a new filter for each different starting node

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>