MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / add_node

Method add_node

graphlite/src/storage/graph_cache.rs:54–76  ·  view source on GitHub ↗

Add a node to the graph

(&mut self, node: Node)

Source from the content-addressed store, hash-verified

52
53 /// Add a node to the graph
54 pub fn add_node(&mut self, node: Node) -> Result<(), GraphError> {
55 // Check if node already exists
56 if self.nodes.contains_key(&node.id) {
57 return Err(GraphError::NodeAlreadyExists(node.id));
58 }
59
60 // Update label indices
61 for label in &node.labels {
62 self.node_labels
63 .entry(label.clone())
64 .or_default()
65 .push(node.id.clone());
66 }
67
68 // Initialize adjacency lists for this node
69 self.adjacency_out.insert(node.id.clone(), Vec::new());
70 self.adjacency_in.insert(node.id.clone(), Vec::new());
71
72 // Store the node
73 self.nodes.insert(node.id.clone(), node);
74
75 Ok(())
76 }
77
78 /// Add an edge to the graph
79 pub fn add_edge(&mut self, edge: Edge) -> Result<(), GraphError> {

Callers 9

load_graph_by_pathMethod · 0.80
union_graphsMethod · 0.80
to_undirected_graphMethod · 0.80
apply_undo_to_graphMethod · 0.80
execute_modificationMethod · 0.80
execute_modificationMethod · 0.80
execute_modificationMethod · 0.80
apply_undo_operationMethod · 0.80

Calls 3

cloneMethod · 0.80
contains_keyMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected