import { type GraphInstance } from './graphology-compat.js'; import type { Community } from '../types.js'; /** * Shape of a community-member node for summary generation — a `title` plus the * `tags` frontmatter list. Decoupled from the graphology graph so callers * without a live graph (e.g. the write-path prune in `store/communities.ts`) * can regenerate summaries from a SQLite lookup. */ export interface SummaryMember { title: string; tags: string[]; } /** * Render a human-readable community summary from its live members. * * Shape: `"Key members: T1, T2, .... Tags: a, b, c. N nodes total."` — the * tag clause is omitted when no tags exist. Expects `members` to already be * sorted in display order (typically by PageRank descending). * * `totalCount` defaults to `members.length` but can be overridden when the * caller has some ids that aren't resolvable to a `SummaryMember` (e.g. a * half-stale cache row where an id no longer exists in the node store) and * wants the trailing `N nodes total` to reflect the authoritative count * rather than just the nodes that had title/tag data. * * Extracted so both the Louvain first-pass (`detectCommunities` below) and * the write-path cache prune (`pruneNodeFromCommunities` in the store) * produce identical strings. Without this, the `summary` field drifts out of * sync with `nodeIds` on every delete. */ export declare function buildSummary(members: SummaryMember[], totalCount?: number): string; /** * Louvain community detection with a heuristic summary per community. * * For each detected community we: * - Sort members by PageRank and take the top member as the community label. * - List the titles of the top 5 members. * - Tally `frontmatter.tags` across members for a short tag summary. * * Accepts any graphology graph; callers typically pass an undirected * projection (Louvain requires undirected / can mutate weights otherwise). */ export declare function detectCommunities(graph: GraphInstance, resolution?: number): Community[]; /** * Score modularity of a community partition on an undirected graph. * * Louvain maximizes modularity — values close to 1 indicate strongly * separable communities; values near 0 (or negative) mean the partition * barely improves on random assignment. `detect_themes` warns callers * when this score drops below 0.3, which is the conventional "clusters * are meaningful" threshold in the network-science literature. * * Wraps graphology-communities-louvain's `.modularity` helper so callers * don't import louvain directly just for scoring. */ export declare function computeModularity(graph: GraphInstance, assignments: Record): number;