In JUNG 2.0, this is edu.uci.ics.jung.algorithms.filters.KNeighborhoodFilter :
A filter used to extract a k-neighborhood around one or more roots of node (s). A K-neighborhood is defined as a subgraph, an induced set of vertices that are k or less hops (unweighted shortest distance path) from the root node.
(, /):
Graph<V, E> graph =
int k = 3;
V startVertex =
Filter<V, E> filter = new KNeighborhoodFilter<V, E>(
startVertex, k, EdgeType.IN_OUT);
Graph<V, E> neighborhood = filter.transform(graph);
neighborhood , . node.