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 Type
    Method
    Description
    void
    traverse(Graph<V> graph, V start, VertexVisitor<V> visitor)
    Traverses the graph starting from the given vertex.
    default void
    traverse(Graph<V> graph, V start, VertexVisitor<V> visitor, ComputeBackend backend)
    Traverses the graph using a specific backend.
  • Method Details

    • traverse

      void traverse(Graph<V> graph, V start, VertexVisitor<V> visitor)
      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 traverse
      start - the starting vertex
      visitor - the visitor to call for each vertex
    • traverse

      default void traverse(Graph<V> graph, V start, VertexVisitor<V> visitor, ComputeBackend backend)
      Traverses the graph using a specific backend.

      This allows advanced users to override automatic backend selection.

      Parameters:
      graph - the graph to traverse
      start - the starting vertex
      visitor - the visitor to call for each vertex
      backend - the backend to use