InMemoryGraphStore
In-memory implementation of GraphStore using atomic references for thread-safe updates.
Thread-safety: This implementation is thread-safe via CAS (Compare-And-Swap) atomic operations. All mutations use linearizable atomic updates to ensure consistency under concurrent access.
Performance: Optimal for testing and small to medium graphs (<100k nodes). Not suitable for graphs requiring persistence.
Value parameters
- initialGraph
-
Optional initial graph state (defaults to empty)
Attributes
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Deletes a specific edge.
Deletes a specific edge.
Value parameters
- relationship
-
The relationship type
- source
-
The source node ID
- target
-
The target node ID
Attributes
- Returns
-
Right(()) on success or if edge doesn't exist, Left(error) on failure
- Definition Classes
Deletes a node and all its connected edges.
Deletes a node and all its connected edges.
Value parameters
- id
-
The node ID to delete
Attributes
- Returns
-
Right(()) on success or if node doesn't exist, Left(error) on failure
- Definition Classes
Retrieves neighboring nodes and their connecting edges.
Retrieves neighboring nodes and their connecting edges.
Value parameters
- direction
-
The direction of traversal (Outgoing, Incoming, Both)
- nodeId
-
The ID of the node
Attributes
- Returns
-
Right(Seq of (edge, neighbor node)) on success, Left(error) on failure
- Definition Classes
Retrieves a node by ID.
Retrieves a node by ID.
Value parameters
- id
-
The node ID
Attributes
- Returns
-
Right(Some(node)) if found, Right(None) if not found, Left(error) on failure
- Definition Classes
Loads the entire graph.
Loads the entire graph.
For implementations backed by external databases, consider pagination or size limits to avoid memory issues with large graphs.
Attributes
- Returns
-
Right(graph) on success, Left(error) on failure
- Definition Classes
Queries the graph based on filter criteria. Returns a subgraph matching the filter conditions.
Queries the graph based on filter criteria. Returns a subgraph matching the filter conditions.
If propertyKey or propertyValue filters are specified but not supported, the implementation must either apply them or return a clear error.
Value parameters
- filter
-
The filter criteria
Attributes
- Returns
-
Right(subgraph) on success, Left(error) on failure
- Definition Classes
Returns current graph snapshot. Safe for concurrent reads due to immutability.
Returns current graph snapshot. Safe for concurrent reads due to immutability.
Attributes
Computes statistics about the graph.
Computes statistics about the graph.
Attributes
- Returns
-
Right(stats) on success, Left(error) on failure
- Definition Classes
Traverses the graph starting from a node using BFS. All implementations must use Breadth-First Search for consistent result ordering.
Traverses the graph starting from a node using BFS. All implementations must use Breadth-First Search for consistent result ordering.
Missing start node: should return Right(Seq.empty) not an error, since traversal of a non-existent node yields no nodes.
Value parameters
- config
-
Traversal configuration (depth, direction, visited set). The direction parameter controls whether traversal follows outgoing, incoming, or all edges from each node.
- startId
-
The ID of the starting node
Attributes
- Returns
-
Right(Seq of traversed nodes) on success, Left(error) on critical failure
- Definition Classes
Inserts or updates an edge in the graph. Both source and target nodes must exist. If an edge with the same source, target, and relationship already exists, it is replaced.
Inserts or updates an edge in the graph. Both source and target nodes must exist. If an edge with the same source, target, and relationship already exists, it is replaced.
Value parameters
- edge
-
The edge to upsert
Attributes
- Returns
-
Right(()) on success, Left(error) if source or target nodes don't exist
- Definition Classes
Inserts or updates a node in the graph. If the node ID already exists, the existing node is replaced.
Inserts or updates a node in the graph. If the node ID already exists, the existing node is replaced.
Value parameters
- node
-
The node to upsert
Attributes
- Returns
-
Right(()) on success, Left(error) on failure
- Definition Classes