Class GraphRAGStrategy

java.lang.Object
com.tnsai.intelligence.rag.GraphRAGStrategy
All Implemented Interfaces:
RAGStrategy

public final class GraphRAGStrategy extends Object implements RAGStrategy
Deterministic, bounded graph traversal retrieval strategy.

The framework ranks seed nodes, traverses outgoing edges, prevents cycles within each path, and emits each node once through its highest-scoring path. Scores decay by edge weight and depth. A non-empty source fence prevents both retrieval and traversal through nodes outside the selected sources.

Since:
0.13.0
  • Field Details

    • DEFAULT_MAX_DEPTH

      public static final int DEFAULT_MAX_DEPTH
      Default maximum traversal depth.
      See Also:
    • DEFAULT_DEPTH_DECAY

      public static final double DEFAULT_DEPTH_DECAY
      Default relevance decay applied for every traversed edge.
      See Also:
    • DEFAULT_MAX_VISITED_NODES

      public static final int DEFAULT_MAX_VISITED_NODES
      Default hard bound on expanded graph nodes per retrieval.
      See Also:
  • Constructor Details

    • GraphRAGStrategy

      public GraphRAGStrategy(String providerName, GraphStore store, Set<String> allowedSources, int maxDepth, double depthDecay, int maxVisitedNodes)
      Creates a graph strategy.
      Parameters:
      providerName - provenance name of the graph provider
      store - graph data access implementation
      allowedSources - exact source fence; empty allows every source
      maxDepth - maximum number of edges traversed from a seed
      depthDecay - relevance multiplier applied at each depth
      maxVisitedNodes - hard expansion bound
  • Method Details

    • name

      public String name()
      Description copied from interface: RAGStrategy
      Returns the unique name of this strategy (e.g., "vector", "keyword", "hybrid").

      Names are compared case-insensitively using Locale.ROOT.

      Specified by:
      name in interface RAGStrategy
      Returns:
      the strategy name, never null
    • retrieve

      public List<RetrievedDocument> retrieve(String query, RAGContext context)
      Description copied from interface: RAGStrategy
      Retrieves documents relevant to the given query.

      Every returned document must exactly match all metadata filters in the context. Implementations apply that constraint before limiting the result to RAGContext.maxResults().

      Specified by:
      retrieve in interface RAGStrategy
      Parameters:
      query - the search query (never null)
      context - retrieval parameters (max results, min score, exact metadata filters)
      Returns:
      an unmodifiable list of retrieved documents, sorted by descending relevance