import { Graph } from '../../../algorithms/graph/graph.js'; import { Edge, Node } from '../../../algorithms/types/graph.js'; /** * Configuration for salience coverage computation. */ export interface SalienceCoverageConfig { /** * Number of top paths to consider from each seed pair. * @default 10 */ topK: number; /** * Length penalty parameter for path ranking. * - λ = 0: Pure MI quality (default) * - λ > 0: Penalise longer paths * @default 0 */ lambda?: number; /** * Traversal mode for path ranking. * @default "undirected" */ traversalMode?: "directed" | "undirected"; } /** * Result of salience coverage computation. */ export interface SalienceCoverageResult { /** * Primary metric: fraction of top-K salient paths found. * Values in [0, 1] where 1 = all top-K paths discovered. */ "salience-coverage": number; /** * Same as salience-coverage (recall of top-K paths). */ "salience-recall": number; /** * Precision: of discovered paths, what fraction are in top-K? * Values in [0, 1]. Lower values indicate discovering irrelevant paths. */ "salience-precision": number; /** * Absolute count of top-K salient paths found. */ "top-k-found": number; /** * Total number of top-K salient paths (ground truth size). */ "top-k-total": number; } /** * Convert a path to a canonical signature for comparison. * * Uses node IDs joined by "->" to create direction-independent signatures. * For undirected graphs, the path is normalized to start from the * lexicographically smaller endpoint, allowing "A->B->C" and "C->B->A" * to match as the same undirected path. * * @param path - Array of node IDs forming a path * @returns Canonical path signature string * * @example * ```typescript * pathSignature(["A", "B", "C"]); // "A->B->C" * pathSignature(["C", "B", "A"]); // "A->B->C" (normalized) * pathSignature(["1", "20", "34"]); // "1->20->34" * pathSignature(["34", "20", "1"]); // "1->20->34" (normalized) * ``` */ export declare const pathSignature: (path: string[]) => string; /** * Compute ground truth salience paths for a test case. * * For each seed pair, runs Path Salience ranking and extracts the top-K * highly-ranked paths. These form the ground truth for evaluation. * * **Preprocessing phase**: Run once per test case, reused across all SUTs. * * @template N - Node type * @template E - Edge type * @param graph - The graph to analyse * @param seeds - Array of seed node IDs * @param config - Configuration for ranking and K selection * @returns Set of path signatures representing top-K salient paths * * @example * ```typescript * const graph = new Graph(false); * // ... populate graph ... * * const groundTruth = computeSalienceGroundTruth( * graph, * ["seed1", "seed2", "seed3"], * { topK: 10, lambda: 0 } * ); * // groundTruth is Set of path signatures * ``` */ export declare const computeSalienceGroundTruth: (graph: Graph, seeds: string[], config: SalienceCoverageConfig) => Set; /** * Compute salience coverage for an expansion result. * * Measures what percentage of ground truth salient paths were discovered * by the expansion algorithm. * * @param discoveredPaths - Array of paths discovered by the SUT * @param groundTruthPaths - Set of top-K salient path signatures (ground truth) * @returns Salience coverage metrics * * @example * ```typescript * const discovered = [ * { nodes: ["A", "B", "C"] }, * { nodes: ["A", "X", "Y", "C"] } * ]; * * const groundTruth = new Set([ * "A->B->C", * "A->X->Y->C", * "A->D->E->C" * ]); * * const coverage = computeSalienceCoverage(discovered, groundTruth); * // { * // "salience-coverage": 0.667, // 2 of 3 top-K paths found * // "salience-recall": 0.667, * // "salience-precision": 1.0, // All discovered paths are in top-K * // "top-k-found": 2, * // "top-k-total": 3 * // } * ``` */ export declare const computeSalienceCoverage: (discoveredPaths: Array<{ nodes: string[]; }>, groundTruthPaths: Set) => SalienceCoverageResult; /** * Compute salience coverage for paths stored as string arrays. * * Convenience overload for when paths are already string arrays. * * @param discoveredPaths - Array of path string arrays * @param groundTruthPaths - Set of top-K salient path signatures * @returns Salience coverage metrics */ export declare const computeSalienceCoverageFromStringPaths: (discoveredPaths: string[][], groundTruthPaths: Set) => SalienceCoverageResult; //# sourceMappingURL=salience-coverage.d.ts.map