From 3d8d4e08ee1dec804f9b785e645a7f9a60c570d3 Mon Sep 17 00:00:00 2001 From: ayushcodes10 Date: Mon, 14 Sep 2026 14:04:12 +0530 Subject: [PATCH] Count an all file node community as thin, not invisible Number 3148 fixed shown to be computed directly instead of total minus thin, since the old formula counted a community with zero real nodes as shown even though the render loop skips it. That fix left thin itself under a zero real guard from before it, so a zero real community was excluded from both figures at once and went uncounted anywhere the report prints about itself, and shown plus thin no longer summed to the total community count. Both counting sites drop that guard so a community the render loop skips for having too few real nodes, zero included, is now always reflected in the thin figure next to it. Fixes #3548. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh (cherry picked from commit d616c330e34199c179ad777094952684ac8d9cd6) --- graphify/report.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/graphify/report.py b/graphify/report.py index 0f1c5e709..ac854a2e6 100644 --- a/graphify/report.py +++ b/graphify/report.py @@ -161,13 +161,18 @@ def generate( non_empty = {cid: nodes for cid, nodes in communities.items() if any(not _ifn(G, n) for n in nodes)} # One predicate for every figure the report prints about itself (#3148): - # "thin" is 0 < real < min_community_size, and "shown" is what the render - # loop below actually renders (real >= min_community_size) - previously - # shown was total-thin, which also counted communities with ZERO real - # nodes that the loop skips, overstating the count (#2129's residual). + # "thin" is real < min_community_size (ZERO real nodes included), and + # "shown" is what the render loop below actually renders (real >= + # min_community_size) - previously shown was total-thin, which also + # counted communities with ZERO real nodes that the loop skips, + # overstating the count (#2129's residual). A subsequent `0 <` guard on + # "thin" fixed that overcount but introduced the opposite gap: an + # all-file-node community (real == 0) is skipped by the SAME render loop + # yet was excluded from "thin" too, so it went uncounted anywhere and + # `shown + thin` silently undercounted `len(communities)` (#3548). thin_count_summary = sum( 1 for nodes in communities.values() - if 0 < _real_count(nodes) < min_community_size + if _real_count(nodes) < min_community_size ) shown_count = sum( 1 for nodes in communities.values() @@ -314,10 +319,12 @@ def generate( # Same threshold the Summary and Communities headers used (#3148): this # was a hardcoded 3, so with --min-community-size anything else the count # here disagreed with the label text beside it, which already printed - # min_community_size. + # min_community_size. No `0 <` guard, matching thin_count_summary above + # (#3548): an all-file-node community is skipped by the same render loop + # as a genuinely thin one, so it belongs in this count too. thin_communities = { cid: nodes for cid, nodes in communities.items() - if 0 < sum(1 for n in nodes if not _is_file_node(G, n)) < min_community_size + if sum(1 for n in nodes if not _is_file_node(G, n)) < min_community_size } gap_count = len(isolated) + len(thin_communities)