You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
find_import_cycles: nx.simple_cycles() called without length_bound hangs on large import graphs #1196
find_import_cycles() in graphify/analyze.py enumerates cycles with an unboundednx.simple_cycles(file_graph) and only afterwards filters to len(cycle) <= max_cycle_length, breaking once top_n * 10 short cycles are collected:
On a real-world repo whose file-level import graph contains many long elementary cycles, the generator yields an astronomically large number of long cycles that all fail the <= max_cycle_length filter, so cycles never reaches top_n * 10 and the early-break never fires. nx.simple_cycles is an unbounded elementary-cycle enumerator (worst case exponential), so report generation hangs at 100% CPU and never returns.
length_bound is supported on networkx.simple_cycles since NetworkX 3.1. With it, report generation dropped from "never returns" to ~0.1s on a 32k-node graph in our testing. The subsequent len(cycle) <= max_cycle_length check then becomes redundant but harmless.
Separately (DX note, not the bug)
On graphs of this size, clustering also falls back to pure-Python networkx.community.louvain_communities when graspologic isn't installed, which took >15 min and pegged a core. Installing graspologic (native Leiden) brought it to <1s. Might be worth documenting graspologic as a recommended extra for large graphs, or surfacing a warning when falling back.
Happy to send a PR for the length_bound one-liner if useful.
Fixed in e477825. Passed length_bound=max_cycle_length to nx.simple_cycles() in analyze.py:690. NetworkX now prunes cycles during enumeration instead of post-filtering, dropping report generation from never-returns to ~0.1s on dense graphs.
Activity
fix: three correctness bugs — cycle hang, label token budget, fuzzy d…
safishamsi commentedon Jun 8, 2026
Fixed in e477825. Passed
length_bound=max_cycle_lengthtonx.simple_cycles()inanalyze.py:690. NetworkX now prunes cycles during enumeration instead of post-filtering, dropping report generation from never-returns to ~0.1s on dense graphs.Merge origin/v8 into falkordb-backend
fix: three correctness bugs — cycle hang, label token budget, fuzzy d…
fix(analyze): list two-file import cycles before the enumeration cap …
fix(analyze): list two-file import cycles before the enumeration cap …