import { GraphExpander } from '../../interfaces/graph-expander'; /** * Result from random-priority expansion - matches DegreePrioritisedExpansionResult. */ export interface RandomPriorityResult { /** Discovered paths (only populated when N >= 2 seeds) */ paths: Array<{ fromSeed: number; toSeed: number; nodes: string[]; }>; /** Union of all nodes visited by all frontiers */ sampledNodes: Set; /** Set of edges visited during expansion */ sampledEdges: Set; /** Per-frontier visited sets (for diagnostics) */ visitedPerFrontier: Array>; /** Statistics about the expansion */ stats: RandomPriorityStats; /** Maps each node to the iteration when it was first discovered */ nodeDiscoveryIteration: Map; } /** * Statistics collected during random-priority expansion. */ export interface RandomPriorityStats { /** Total nodes expanded (popped from frontiers) */ nodesExpanded: number; /** Total edges traversed */ edgesTraversed: number; /** Iterations (single node expansions) performed */ iterations: number; /** Breakdown of nodes by degree ranges */ degreeDistribution: Map; } /** * Random Priority Bidirectional Expansion * * Baseline algorithm that selects nodes randomly from the frontier. * This serves as a null hypothesis baseline - if degree-prioritised expansion * doesn't outperform random selection, the degree heuristic provides no value. * * **Key Properties**: * - Random node selection from frontier (no priority) * - Seeded RNG for reproducibility * - No systematic hub avoidance OR hub seeking * - Terminates when all frontiers exhausted * * **Use in Experiments**: * - If MI ranking correlation is higher with degree-prioritised than random, * the degree heuristic is effective * - If path diversity is higher with degree-prioritised than random, * hub avoidance contributes to diversity * * @template T - Type of node data returned by expander */ export declare class RandomPriorityExpansion { private readonly expander; private readonly seeds; private readonly frontiers; private readonly paths; private readonly sampledEdges; private readonly rng; private stats; private readonly nodeDiscoveryIteration; /** * Create a new random-priority expansion. * * @param expander - Graph expander providing neighbour access * @param seeds - Array of seed node IDs (N >= 1) * @param seed - Random seed for reproducibility (default: 42) * @throws Error if no seeds provided */ constructor(expander: GraphExpander, seeds: readonly string[], seed?: number); /** * Run the expansion to completion. * * Terminates when all frontiers are exhausted (no unexpanded nodes remain). * * @returns Expansion results including paths and sampled subgraph */ run(): Promise; /** * Check if any frontier has unexpanded nodes. * @internal */ private hasNonEmptyFrontier; /** * Randomly select a non-empty frontier. * Returns -1 if all frontiers are empty. * @internal */ private selectRandomFrontier; /** * Reconstruct path from meeting point between two frontiers. * @param stateA * @param stateB * @param meetingNode * @internal */ private reconstructPath; /** * Check if an equivalent path already exists. * @param fromSeed * @param toSeed * @param nodes * @internal */ private pathExists; /** * Record degree in distribution histogram. * @param degree * @internal */ private recordDegree; /** * Get histogram bucket for a degree value. * @param degree * @internal */ private getDegreeBucket; } //# sourceMappingURL=random-priority.d.ts.map