export interface LayoutNode { id: string; width: number; height: number; /** * Optional cluster id. When set, the node is placed inside a dagre compound * subgraph keyed by this value, so same-cluster nodes lay out as a cohesive * block (swim-lane grouping). Omitting it on all nodes yields the flat layout. */ cluster?: string; } export interface LayoutEdge { from: string; to: string; } /** * Bounding box of a cluster (compound subgraph) after layout, in the same * top-left coordinate space as LayoutResult. Returned via `clusters` so callers * can draw a labeled band/container behind each group. */ export interface ClusterResult { x: number; y: number; width: number; height: number; } /** * Compute dynamic width for a node based on its edge degree (connection count). * Nodes with many connections get wider to accommodate distributed connection points. * * @param nodeId - The node identifier * @param edges - All edges in the graph * @param baseWidth - Minimum width for nodes with few connections (default 300) * @param growthPerEdge - Additional width per connection above threshold (default 80) * @param threshold - Number of connections before growth kicks in (default 3) */ export declare function computeDynamicWidth(nodeId: string, edges: LayoutEdge[], baseWidth?: number, growthPerEdge?: number, threshold?: number): number; /** Connection count (in + out) for a node across all edges. */ export declare function nodeDegree(nodeId: string, edges: LayoutEdge[]): number; export interface LayoutOptions { rankdir?: 'TB' | 'LR' | 'BT' | 'RL'; nodesep?: number; ranksep?: number; marginx?: number; marginy?: number; align?: 'UL' | 'UR' | 'DL' | 'DR'; /** * dagre rank-assignment algorithm. `network-simplex` (dagre default) minimises * total edge length and is best for dense graphs; `tight-tree` and * `longest-path` are cheaper alternatives. */ ranker?: 'network-simplex' | 'tight-tree' | 'longest-path'; } export interface LayoutResult { x: number; y: number; width: number; height: number; } export interface LayoutWithClusters { nodes: Map; clusters: Map; } export declare function computeGraphLayout(nodes: LayoutNode[], edges: LayoutEdge[], options?: LayoutOptions): Promise>; /** * Same layout as {@link computeGraphLayout} but also returns the bounding box of * each compound cluster (derived from `node.cluster`). Use this for grouped ERDs * that draw a labeled swim-lane band behind each group; the flat path that does * not need bands keeps using {@link computeGraphLayout}. */ export declare function computeGraphLayoutWithClusters(nodes: LayoutNode[], edges: LayoutEdge[], options?: LayoutOptions): Promise;