Package io.github.jbellis.jvector.graph
Interface GraphIndex<T>
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
CachingGraphIndex,OnDiskGraphIndex,OnHeapGraphIndex
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.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()default booleancontainsNode(int nodeId) default intgetNodes()Get all node ordinals included in the graph.getView()Return a View with which to navigate the graph.intstatic <T> StringprettyPrint(GraphIndex<T> graph) intsize()Returns the number of nodes in the graph
-
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
nextIntreturns 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
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-
prettyPrint
-