Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #731
Problem
On large wikis the Sparse cluster knowledge-gap warning fires on nearly every community. The reporter's math is correct and confirmed against the code:
cohesionis the classic density2E / (n(n-1)), which decays as O(1/n). With the fixed thresholdcohesion < 0.15, no community larger than ~55 pages (at the reporter's mean degree of 8.1) can ever pass, so real, well-linked topic clusters are permanently flagged — and the suggested remedy ("add links") pushes users toward filler wikilinks.Fix (reporter's option 1 — scale-invariant)
CommunityInfogainsmeanIntraDegree = 2 * intraEdges / nodeCount(average links per page into the same community), computed alongside the existingcohesionindetectCommunities(cohesionitself is kept — it is asserted in existing tests and remains meaningful).SPARSE_CLUSTER_MIN_MEAN_INTRA_DEGREE = 2inwiki-graph.ts, consumed by both flag sites so they cannot drift apart:detectKnowledgeGaps(graph-insights.ts): condition becomesmeanIntraDegree < 2 && nodeCount >= 3, and the description now states something actionable: "N pages average X.X links to other pages in this cluster".graph-view.tsx, which had a second, independent hard-coded0.15.The reporter's own numbers validate the boundary: at mean degree 8.1, a 55-page community scores cohesion exactly 0.15 (n=56 drops below) — precisely the "~55 pages max" they measured.
Testing
wiki-graph-analysis.test.ts: two 4-cliques + a bridge → each communitymeanIntraDegree === 3, plus a nodeCount-weighted conservation assertion (Σ n·meanIntraDegree === 2 × intra-community edges) that holds for any Louvain partition.graph-insights.test.ts(new): a 500-node community with mean intra-degree 8 (cohesion 0.016) is not flagged (previously always flagged); a 10-node community at 0.8 is flagged with the new description; boundary at exactly 2.0 not flagged; <3 nodes not flagged; isolated/bridge paths unregressed.npm run test:mocks: 133 files / 1883 tests passed ·npm run typecheck: clean