pub struct KnowledgeGraph {
pub nodes: HashMap<String, GraphNode>,
pub edges: HashMap<String, GraphEdge>,
pub adjacency_list: HashMap<String, HashSet<String>>,
pub reverse_adjacency_list: HashMap<String, HashSet<String>>,
pub metadata: HashMap<String, Value>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}Expand description
Core knowledge graph structure
Fields§
§nodes: HashMap<String, GraphNode>Graph nodes indexed by ID
edges: HashMap<String, GraphEdge>Graph edges indexed by ID
adjacency_list: HashMap<String, HashSet<String>>Node adjacency list for efficient traversal
reverse_adjacency_list: HashMap<String, HashSet<String>>Reverse adjacency list for incoming edges
metadata: HashMap<String, Value>Graph metadata
created_at: DateTime<Utc>Graph creation timestamp
updated_at: DateTime<Utc>Last update timestamp
Implementations§
Source§impl KnowledgeGraph
impl KnowledgeGraph
Sourcepub fn add_node(&mut self, node: GraphNode) -> RragResult<()>
pub fn add_node(&mut self, node: GraphNode) -> RragResult<()>
Add a node to the graph
Sourcepub fn add_edge(&mut self, edge: GraphEdge) -> RragResult<()>
pub fn add_edge(&mut self, edge: GraphEdge) -> RragResult<()>
Add an edge to the graph
Sourcepub fn get_neighbors(&self, node_id: &str) -> Vec<&GraphNode>
pub fn get_neighbors(&self, node_id: &str) -> Vec<&GraphNode>
Get neighbors of a node
Sourcepub fn get_incoming_neighbors(&self, node_id: &str) -> Vec<&GraphNode>
pub fn get_incoming_neighbors(&self, node_id: &str) -> Vec<&GraphNode>
Get incoming neighbors of a node
Sourcepub fn get_node_edges(&self, node_id: &str) -> Vec<&GraphEdge>
pub fn get_node_edges(&self, node_id: &str) -> Vec<&GraphEdge>
Get edges connected to a node
Sourcepub fn remove_node(&mut self, node_id: &str) -> RragResult<()>
pub fn remove_node(&mut self, node_id: &str) -> RragResult<()>
Remove a node and its connected edges
Sourcepub fn find_nodes_by_type(&self, node_type: &NodeType) -> Vec<&GraphNode>
pub fn find_nodes_by_type(&self, node_type: &NodeType) -> Vec<&GraphNode>
Find nodes by type
Sourcepub fn find_edges_by_type(&self, edge_type: &EdgeType) -> Vec<&GraphEdge>
pub fn find_edges_by_type(&self, edge_type: &EdgeType) -> Vec<&GraphEdge>
Find edges by type
Sourcepub fn calculate_metrics(&self) -> GraphMetrics
pub fn calculate_metrics(&self) -> GraphMetrics
Calculate graph metrics
Sourcepub fn merge(&mut self, other: &KnowledgeGraph) -> RragResult<()>
pub fn merge(&mut self, other: &KnowledgeGraph) -> RragResult<()>
Merge another graph into this one
Trait Implementations§
Source§impl Clone for KnowledgeGraph
impl Clone for KnowledgeGraph
Source§fn clone(&self) -> KnowledgeGraph
fn clone(&self) -> KnowledgeGraph
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for KnowledgeGraph
impl Debug for KnowledgeGraph
Source§impl Default for KnowledgeGraph
impl Default for KnowledgeGraph
Source§impl<'de> Deserialize<'de> for KnowledgeGraph
impl<'de> Deserialize<'de> for KnowledgeGraph
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for KnowledgeGraph
impl RefUnwindSafe for KnowledgeGraph
impl Send for KnowledgeGraph
impl Sync for KnowledgeGraph
impl Unpin for KnowledgeGraph
impl UnwindSafe for KnowledgeGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more