V - the vertex of the graphW - the weight of the graphpublic class BFS<V,W extends java.lang.Number> extends java.lang.Object implements VisitStrategy<V,W>
| Constructor and Description |
|---|
BFS() |
| Modifier and Type | Method and Description |
|---|---|
VisitInfo<V> |
visit(Graph<V,W> graph,
V source,
java.util.function.Consumer<V> visit)
With this the graph will be visited accordingly to the strategy of the visit.
Some strategy can accept a source vertex null, because they visit all the graph anyway. If you want to stop the visit of the graph, you just have to throw any exception in the visit function, but be sure to catch it |
public VisitInfo<V> visit(Graph<V,W> graph, V source, java.util.function.Consumer<V> visit) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
VisitStrategyvisit in interface VisitStrategy<V,W extends java.lang.Number>graph - the graph to visitsource - the source of the visitvisit - the function to apply at each vertex when they are visitedjava.lang.NullPointerException - if one of the arguments is null (only the consumers can be null)java.lang.IllegalArgumentException - if the source vertex is not in the graph