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

Method get_all_neighbors

graphlite/src/storage/graph_cache.rs:260–278  ·  view source on GitHub ↗

Get all neighbors (both incoming and outgoing connections)

(&self, node_id: &str)

Source from the content-addressed store, hash-verified

258
259 /// Get all neighbors (both incoming and outgoing connections)
260 pub fn get_all_neighbors(&self, node_id: &str) -> Vec<&Node> {
261 let mut neighbors = Vec::new();
262
263 // Add outgoing neighbors
264 for edge in self.get_outgoing_edges(node_id) {
265 if let Some(node) = self.nodes.get(&edge.to_node) {
266 neighbors.push(node);
267 }
268 }
269
270 // Add incoming neighbors
271 for edge in self.get_incoming_edges(node_id) {
272 if let Some(node) = self.nodes.get(&edge.from_node) {
273 neighbors.push(node);
274 }
275 }
276
277 neighbors
278 }
279
280 /// Remove a node and all its connected edges
281 pub fn remove_node(&mut self, node_id: &str) -> Result<Node, GraphError> {

Callers

nothing calls this directly

Calls 3

get_outgoing_edgesMethod · 0.80
get_incoming_edgesMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected