From 3d53287ff65a2eec40231fdeb41ef7fc7e6be7c4 Mon Sep 17 00:00:00 2001 From: Safi Date: Tue, 7 Apr 2026 22:36:45 +0100 Subject: [PATCH] Fix Louvain fallback hang on large sparse graphs (#48) --- CHANGELOG.md | 4 ++++ graphify/cluster.py | 4 +++- pyproject.toml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e7fb6b6..03d569da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ Full release notes with details on each version: [GitHub Releases](https://github.com/safishamsi/graphify/releases) +## 0.3.11 (2026-04-07) + +- Fix: Louvain fallback hangs indefinitely on large sparse graphs — added `max_level=10, threshold=1e-4` to prevent infinite loops while preserving community quality (#48) + ## 0.3.10 (2026-04-07) - Fix: Windows UnicodeEncodeError during `graphify install` — replaced arrow character with `->` in all print statements (#47) diff --git a/graphify/cluster.py b/graphify/cluster.py index 25b9db12..7019cdec 100644 --- a/graphify/cluster.py +++ b/graphify/cluster.py @@ -16,7 +16,9 @@ def _partition(G: nx.Graph) -> dict[str, int]: pass # Fallback: networkx louvain (available since networkx 2.7) - communities = nx.community.louvain_communities(G, seed=42) + # max_level=10 and threshold=1e-4 prevent indefinite hangs on large sparse graphs + # while producing equivalent community quality to the defaults on typical corpora + communities = nx.community.louvain_communities(G, seed=42, max_level=10, threshold=1e-4) return {node: cid for cid, nodes in enumerate(communities) for node in nodes} diff --git a/pyproject.toml b/pyproject.toml index ed818490..279f8716 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "graphifyy" -version = "0.3.10" +version = "0.3.11" description = "AI coding assistant skill (Claude Code, Codex, OpenCode, OpenClaw) - turn any folder of code, docs, papers, or images into a queryable knowledge graph" readme = "README.md" license = { file = "LICENSE" }