Interface GraphIndex<T>

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
CachingGraphIndex, OnDiskGraphIndex, OnHeapGraphIndex

public interface GraphIndex<T> extends AutoCloseable
Represents a graph-based vector index. Nodes are represented as ints, and edges are represented as adjacency lists.

Mostly this applies to any graph index, but a few methods (e.g. getVector()) are specifically included to support the DiskANN-based design of OnDiskGraphIndex.

All methods are threadsafe. Operations that require persistent state are wrapped in a View that should be created per accessing thread.

  • Method Details

    • size

      int size()
      Returns the number of nodes in the graph
    • getNodes

      NodesIterator getNodes()
      Get all node ordinals included in the graph. The nodes are NOT guaranteed to be presented in any particular order.
      Returns:
      an iterator over nodes where nextInt returns the next node.
    • getView

      GraphIndex.View<T> getView()
      Return a View with which to navigate the graph. Views are not threadsafe.
    • maxDegree

      int maxDegree()
      Returns:
      the maximum number of edges per node
    • getIdUpperBound

      default int getIdUpperBound()
      Returns:
      the maximum node id in the graph. May be different from size() if nodes are being added concurrently, or if nodes have been deleted (and cleaned up).
    • containsNode

      default boolean containsNode(int nodeId)
      Returns:
      true iff the graph contains the node with the given ordinal id
    • close

      void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException
    • prettyPrint

      static <T> String prettyPrint(GraphIndex<T> graph)