/** * Graph Algorithms for Policy Graph Traversal * * Provides BFS/DFS traversal with hop limiting for fold radius computation. * Used by Atlas Frame generation to extract module neighborhoods. */ import type { Policy } from "../../types/policy.js"; export interface GraphEdge { from: string; to: string; type: "allowed" | "forbidden"; } export interface NeighborhoodResult { modules: Set; edges: GraphEdge[]; } /** * Build adjacency lists from policy graph * * Creates both allowed and forbidden edge lists from the policy. * This enables traversal along allowed paths while tracking forbidden * edges for context. * * @param policy - The policy object containing module definitions * @returns Object with allowed and forbidden adjacency lists */ export declare function buildAdjacencyLists(policy: Policy): { allowedEdges: Map>; forbiddenEdges: Map>; }; /** * Extract N-hop neighborhood from seed modules using BFS * * Traverses the policy graph starting from seed modules, expanding * up to N hops away. Includes both allowed and forbidden edges for context. * * Algorithm: * 1. Start with seed modules at distance 0 * 2. For each module at distance d < foldRadius: * - Find all neighbors via allowed edges (both inbound and outbound) * - Find all neighbors via forbidden edges (both inbound and outbound) * - Mark neighbors at distance d+1 * 3. Collect all edges (allowed + forbidden) between discovered modules * * @param policy - The policy object containing module definitions * @param seedModules - Starting module IDs * @param foldRadius - Maximum number of hops to expand (default: 1) * @returns Set of module IDs and edges in the neighborhood */ export declare function extractNeighborhood(policy: Policy, seedModules: string[], foldRadius?: number): NeighborhoodResult; /** * Generate 2D coordinates for modules using a simple force-directed layout * * Uses a basic spring-embedding algorithm: * - Modules repel each other (avoid overlap) * - Connected modules attract each other (edges pull them together) * - Iteratively adjust positions until stable or max iterations reached * * @param modules - Module IDs to position * @param edges - Edges between modules * @param width - Canvas width (default: 1000) * @param height - Canvas height (default: 1000) * @param iterations - Number of layout iterations (default: 50) * @returns Map of module ID to [x, y] coordinates */ export declare function generateCoordinates(modules: Set, edges: GraphEdge[], width?: number, height?: number, iterations?: number): Map; /** * Adapter function for backward compatibility with fold-radius.ts * Builds a simple graph representation for BFS traversal */ export interface Graph { modules: Set; adjacency: Map>; } export declare function buildPolicyGraph(policy: Policy): Graph; export declare function getNeighbors(moduleId: string, graph: Graph): string[];