MCPcopy
hub / github.com/google/guava / getReachableNodes

Method getReachableNodes

guava/src/com/google/common/graph/Graphs.java:224–235  ·  view source on GitHub ↗

Returns the nodes reachable from {@code node} in {@code graph}, according to the given {@code strategy}.

(
      Graph<N> graph, N node, TransitiveClosureSelfLoopStrategy strategy)

Source from the content-addressed store, hash-verified

222 * strategy}.
223 */
224 private static <N> Iterable<N> getReachableNodes(
225 Graph<N> graph, N node, TransitiveClosureSelfLoopStrategy strategy) {
226 Traverser<N> traverser = Traverser.forGraph(graph);
227 switch (strategy) {
228 case ADD_SELF_LOOPS_ALWAYS: // always include 'node'
229 return traverser.breadthFirst(node);
230 case ADD_SELF_LOOPS_FOR_CYCLES: // include 'node' iff there's an incident cycle
231 // note that if 'node' has a self-loop, it will appear in its successors
232 return traverser.breadthFirst(graph.successors(node));
233 }
234 throw new IllegalArgumentException("Unrecognized strategy: " + strategy);
235 }
236
237 /**
238 * A strategy for adding self-loops to {@linkplain #transitiveClosure(Graph,

Callers 1

transitiveClosureMethod · 0.95

Calls 3

forGraphMethod · 0.95
successorsMethod · 0.65
breadthFirstMethod · 0.45

Tested by

no test coverage detected