Interface GraphTraversalStrategy<V>
- All Known Implementing Classes:
BFSTraversal, DFSTraversal
public interface GraphTraversalStrategy<V>
Strategy interface for graph traversal algorithms.
Implementations provide different traversal strategies (DFS, BFS, etc.) and can optionally leverage compute backends for acceleration.
Usage:
GraphTraversalStrategy<String> dfs = new DFSTraversal<>();
graph.traverse(startVertex, dfs, (vertex, depth) -> {
System.out.println(" ".repeat(depth) + vertex);
});
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Method Summary
Modifier and TypeMethodDescriptionvoidTraverses the graph starting from the given vertex.default voidtraverse(Graph<V> graph, V start, VertexVisitor<V> visitor, ComputeBackend backend) Traverses the graph using a specific backend.
-
Method Details
-
traverse
Traverses the graph starting from the given vertex.The implementation chooses the appropriate backend automatically (CPU or GPU) based on graph size and backend availability.
- Parameters:
graph- the graph to traversestart- the starting vertexvisitor- the visitor to call for each vertex
-
traverse
Traverses the graph using a specific backend.This allows advanced users to override automatic backend selection.
- Parameters:
graph- the graph to traversestart- the starting vertexvisitor- the visitor to call for each vertexbackend- the backend to use
-