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

Method remove_edge

graphlite/src/storage/graph_cache.rs:319–342  ·  view source on GitHub ↗

Remove an edge

(&mut self, edge_id: &str)

Source from the content-addressed store, hash-verified

317
318 /// Remove an edge
319 pub fn remove_edge(&mut self, edge_id: &str) -> Result<Edge, GraphError> {
320 let edge = self
321 .edges
322 .remove(edge_id)
323 .ok_or_else(|| GraphError::EdgeNotFound(edge_id.to_string()))?;
324
325 // Remove from label index
326 if let Some(edges) = self.edge_labels.get_mut(&edge.label) {
327 edges.retain(|id| id != edge_id);
328 if edges.is_empty() {
329 self.edge_labels.remove(&edge.label);
330 }
331 }
332
333 // Remove from adjacency lists
334 if let Some(outgoing) = self.adjacency_out.get_mut(&edge.from_node) {
335 outgoing.retain(|id| id != edge_id);
336 }
337 if let Some(incoming) = self.adjacency_in.get_mut(&edge.to_node) {
338 incoming.retain(|id| id != edge_id);
339 }
340
341 Ok(edge)
342 }
343
344 /// Get graph statistics
345 pub fn stats(&self) -> GraphStats {

Callers 5

remove_nodeMethod · 0.80
apply_undo_to_graphMethod · 0.80
execute_modificationMethod · 0.80
execute_modificationMethod · 0.80
apply_undo_operationMethod · 0.80

Calls 3

get_mutMethod · 0.80
removeMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected