Returns the nodes reachable from {@code node} in {@code graph}, according to the given {@code strategy}.
(
Graph<N> graph, N node, TransitiveClosureSelfLoopStrategy strategy)
| 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, |
no test coverage detected