From f99c4a3738e51132b3b407c9da22ecd02e44574f Mon Sep 17 00:00:00 2001 From: yangdx Date: Wed, 24 Sep 2025 18:03:11 +0800 Subject: [PATCH] Fix graph truncation logic for depth-limited traversals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Only set truncated flag for node limit • Keep depth limit info logging • Improve log message clarity • Fix false truncation detection --- lightrag/kg/networkx_impl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lightrag/kg/networkx_impl.py b/lightrag/kg/networkx_impl.py index 1f716ba0..91e238d1 100644 --- a/lightrag/kg/networkx_impl.py +++ b/lightrag/kg/networkx_impl.py @@ -402,14 +402,14 @@ class NetworkXStorage(BaseGraphStorage): # Check if graph is truncated - either due to max_nodes limit or depth limit if (queue and len(bfs_nodes) >= max_nodes) or has_unexplored_neighbors: - result.is_truncated = True if len(bfs_nodes) >= max_nodes: + result.is_truncated = True logger.info( f"[{self.workspace}] Graph truncated: max_nodes limit {max_nodes} reached" ) else: logger.info( - f"[{self.workspace}] Graph truncated: only {len(bfs_nodes)} nodes found within max_depth {max_depth}" + f"[{self.workspace}] Graph truncated: found {len(bfs_nodes)} nodes within max_depth {max_depth}" ) # Create subgraph with BFS discovered nodes