Skip to main content

GraphStore

Trait GraphStore 

Source
pub trait GraphStore {
    type Node;
    type Edge;
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn add_node(&mut self, node: Self::Node) -> Result<String>;
    fn add_edge(
        &mut self,
        from_id: &str,
        to_id: &str,
        edge: Self::Edge,
    ) -> Result<String>;
    fn find_nodes(&self, criteria: &str) -> Result<Vec<Self::Node>>;
    fn get_neighbors(&self, node_id: &str) -> Result<Vec<Self::Node>>;
    fn traverse(
        &self,
        start_id: &str,
        max_depth: usize,
    ) -> Result<Vec<Self::Node>>;
    fn stats(&self) -> GraphStats;
}
Expand description

Graph operations abstraction for knowledge graph management

§Synchronous Version

This trait provides synchronous operations for graph management.

Required Associated Types§

Source

type Node

The node type this graph store handles

Source

type Edge

The edge type this graph store handles

Source

type Error: Error + Send + Sync + 'static

The error type returned by graph operations

Required Methods§

Source

fn add_node(&mut self, node: Self::Node) -> Result<String>

Add a node to the graph

Source

fn add_edge( &mut self, from_id: &str, to_id: &str, edge: Self::Edge, ) -> Result<String>

Add an edge between two nodes

Source

fn find_nodes(&self, criteria: &str) -> Result<Vec<Self::Node>>

Find nodes by criteria

Source

fn get_neighbors(&self, node_id: &str) -> Result<Vec<Self::Node>>

Get neighbors of a node

Source

fn traverse(&self, start_id: &str, max_depth: usize) -> Result<Vec<Self::Node>>

Perform graph traversal

Source

fn stats(&self) -> GraphStats

Get graph statistics

Implementors§