# Coverage details for edu.uci.ics.jung.algorithms.connectivity.KNeighborhoodExtractor

Line | Hits | Source
--- | --- | ---
1 |  | `/*`
2 |  | `* Copyright (c) 2003, the JUNG Project and the Regents of the University`
3 |  | `* of California`
4 |  | `* All rights reserved.`
5 |  | `*`
6 |  | `* This software is open-source under the BSD license; see either`
7 |  | `* "license.txt" or`
8 |  | `* http://jung.sourceforge.net/license.txt for a description.`
9 |  | `*/`
10 |  | `package edu.uci.ics.jung.algorithms.connectivity;`
11 |  | ``
12 |  | `import java.util.Set;`
13 |  | ``
14 |  | `import edu.uci.ics.jung.graph.DirectedGraph;`
15 |  | `import edu.uci.ics.jung.graph.Graph;`
16 |  | `import edu.uci.ics.jung.graph.filters.Filter;`
17 |  | `import edu.uci.ics.jung.graph.filters.impl.KNeighborhoodFilter;`
18 |  | ``
19 |  | `/**`
20 |  | `* Extracts the subgraph (neighborhood) from a graph whose nodes are no more than distance k away from at`
21 |  | `* least one of the root nodes (starting vertices).`
22 |  | `* @author Scott White and Danyel Fisher`
23 |  | `*/`
24 | 0 | `public class KNeighborhoodExtractor {`
25 |  | ``
26 |  | `/**`
27 |  | `* Extracts the subgraph comprised of all vertices within distance K (undirected) from any`
28 |  | `* node in rootNodes.`
29 |  | `* @param graph the graph whose subgraph is to be extracted`
30 |  | `* @param rootNodes the set of root nodes (starting vertices) in the graph`
31 |  | `* @param radiusK the radius of the subgraph to be extracted`
32 |  | `*/`
33 |  | `static public Graph extractNeighborhood(`
34 |  | `Graph graph,`
35 |  | `Set rootNodes,`
36 |  | `int radiusK) {`
37 | 1 | `return extract(graph, rootNodes, radiusK, KNeighborhoodFilter.IN_OUT);`
38 |  | `}`
39 |  | ``
40 |  | `/**`
41 |  | `* Extracts the subgraph comprised of all vertices within distance K (out-directed) from any`
42 |  | `* node in rootNodes.`
43 |  | `*@param graph the graph whose subgraph is to be extracted`
44 |  | `* @param rootNodes the set of root nodes (starting vertices) in the graph`
45 |  | `* @param radiusK the radius of the subgraph to be extracted`
46 |  | `*/`
47 |  | `static public Graph extractOutDirectedNeighborhood(`
48 |  | `DirectedGraph graph,`
49 |  | `Set rootNodes,`
50 |  | `int radiusK) {`
51 | 0 | `return extract(graph, rootNodes, radiusK, KNeighborhoodFilter.OUT);`
52 |  | `}`
53 |  | ``
54 |  | `/**`
55 |  | `* Extracts the subgraph comprised of all vertices within distance K (in-directed) from any`
56 |  | `* node in rootNodes.`
57 |  | `* @param graph the graph whose subgraph is to be extracted`
58 |  | `* @param rootNodes the set of root nodes (starting vertices) in the graph`
59 |  | `* @param radiusK the radius of the subgraph to be extracted`
60 |  | `*/`
61 |  | `static public Graph extractInDirectedNeighborhood(`
62 |  | `DirectedGraph graph,`
63 |  | `Set rootNodes,`
64 |  | `int radiusK) {`
65 | 0 | `return extract(graph, rootNodes, radiusK, KNeighborhoodFilter.IN);`
66 |  | `}`
67 |  | ``
68 |  | `static private Graph extract(`
69 |  | `Graph graph,`
70 |  | `Set rootNodes,`
71 |  | `int radiusK,`
72 |  | `int edgeType) {`
73 | 1 | `Filter nf = new KNeighborhoodFilter(rootNodes, radiusK, edgeType);`
74 | 1 | `return nf.filter(graph).assemble();`
75 |  | `}`
76 |  | ``
77 |  | `}`

this report was generated by version 1.0.5 of jcoverage. visit www.jcoverage.com for updates. | copyright © 2003, jcoverage ltd. all rights reserved. Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.