import { Graph } from '../graph/graph'; import { ClusterMetrics, Community } from '../types/clustering-types'; import { Edge, Node } from '../types/graph'; /** * Calculate density for a cluster/community. * * Density formula: * density = actual_edges / possible_edges * * For undirected graphs: * - possible_edges = n * (n - 1) / 2 * * For directed graphs: * - possible_edges = n * (n - 1) * * Where n is the number of nodes in the cluster. * * Range: [0.0, 1.0] * - 1.0 = complete graph (all possible edges present) * - 0.0 = no internal edges * - Higher density indicates tighter community structure * @template N - Node type * @template E - Edge type * @param graph - Input graph * @param clusterNodes - Set of nodes in the cluster * @returns Density score in range [0.0, 1.0] * @example * ```typescript * const graph = new Graph(false); * // ... build graph ... * const cluster = new Set(['A', 'B', 'C']); * const density = calculateDensity(graph, cluster); * console.log(`Density: ${density.toFixed(3)}`); // e.g., "Density: 0.667" * ``` */ export declare const calculateDensity: (graph: Graph, clusterNodes: Set) => number; /** * Calculate average density across multiple clusters. * @template N - Node type * @template E - Edge type * @param graph - Input graph * @param clusters - Array of node sets representing clusters * @returns Average density score * @example * ```typescript * const clusters = [ * new Set(['A', 'B', 'C']), * new Set(['D', 'E', 'F']) * ]; * const avgDensity = calculateAverageDensity(graph, clusters); * ``` */ export declare const calculateAverageDensity: (graph: Graph, clusters: Set[]) => number; /** * Calculate coverage ratio: fraction of edges within clusters vs. total edges. * * coverage = (edges within clusters) / (total edges in graph) * * Range: [0.0, 1.0] * - Higher coverage means most edges are within communities * - Lower coverage means many inter-community edges * @template N - Node type * @template E - Edge type * @param graph - Input graph * @param clusters - Array of node sets representing clusters * @returns Coverage ratio * @example * ```typescript * const coverage = calculateCoverageRatio(graph, clusters); * console.log(`${(coverage * 100).toFixed(1)}% of edges are within clusters`); * ``` */ export declare const calculateCoverageRatio: (graph: Graph, clusters: Set[]) => number; /** * Calculate aggregated quality metrics for a clustering result. * * Computes modularity, average conductance, average density, coverage ratio, * and cluster count for a complete clustering. * @template N - Node type * @template E - Edge type * @param graph - Input graph * @param communities - Array of communities * @returns Aggregated ClusterMetrics * @example * ```typescript * const graph = new Graph(false); * const communities: Community[] = [...]; * const metrics = calculateClusterMetrics(graph, communities); * * console.log(`Modularity: ${metrics.modularity.toFixed(3)}`); * console.log(`Avg Conductance: ${metrics.avgConductance.toFixed(3)}`); * console.log(`Avg Density: ${metrics.avgDensity.toFixed(3)}`); * console.log(`Coverage: ${(metrics.coverageRatio * 100).toFixed(1)}%`); * console.log(`Clusters: ${metrics.numClusters}`); * ``` */ export declare const calculateClusterMetrics: (graph: Graph, communities: Community[]) => ClusterMetrics; /** * Update ClusterMetrics with per-community density values. * * Modifies community objects to include their individual density scores. * @template N - Node type * @template E - Edge type * @param graph - Input graph * @param communities - Array of communities (modified in place) * @example * ```typescript * const communities: Community[] = [...]; * updateCommunityDensities(graph, communities); * // Now each community has updated 'density' field * ``` */ export declare const updateCommunityDensities: (graph: Graph, communities: Community[]) => void; //# sourceMappingURL=cluster-quality.d.ts.map