From c641a6290c787ab5e310266376d0580ee4de1114 Mon Sep 17 00:00:00 2001 From: yangdx Date: Tue, 18 Mar 2025 00:00:56 +0800 Subject: [PATCH] Ensure unique edge IDs for NetworkX --- lightrag/kg/networkx_impl.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lightrag/kg/networkx_impl.py b/lightrag/kg/networkx_impl.py index 004cfd4f..7026cf6d 100644 --- a/lightrag/kg/networkx_impl.py +++ b/lightrag/kg/networkx_impl.py @@ -373,6 +373,9 @@ class NetworkXStorage(BaseGraphStorage): # Add edges to result for edge in subgraph.edges(): source, target = edge + # Esure unique edge_id for undirect graph + if source > target: + source, target = target, source edge_id = f"{source}-{target}" if edge_id in seen_edges: continue