import type { GraphDescription } from '../types/graph.js'; /** A node placed on the diagram. */ export interface LaidOutNode { /** The node's id. */ id: string; /** Left edge, in diagram units. */ x: number; /** Top edge, in diagram units. */ y: number; /** Box width. */ width: number; /** Box height. */ height: number; /** `start` and `end` are the graph's entry and exit; everything else is a `node`. */ kind: 'start' | 'end' | 'node'; /** True when the node waits for every branch before it runs. */ defer?: boolean; /** True when the node reuses results through a cache. */ cache?: boolean; } /** An edge between two placed nodes. */ export interface LaidOutEdge { /** The node it leaves. */ from: string; /** The node it reaches. */ to: string; /** Chosen by a router rather than always taken. */ conditional?: boolean; /** The router's key for this branch. */ label?: string; /** True when it points back up the diagram, as a cycle does. */ back: boolean; } /** A graph laid out for drawing. */ export interface GraphLayout { /** Every node, placed. */ nodes: LaidOutNode[]; /** Every edge. */ edges: LaidOutEdge[]; /** Diagram width. */ width: number; /** Diagram height. */ height: number; } /** * Lays a graph out in layers: each node sits one layer below the nearest node that leads to it. * * Breadth-first distance rather than longest path, so a cycle cannot push a node down forever; an * edge that goes back up is marked, and the drawing curves it round the side. Done here rather than * in the browser so neither the studio nor `toSvg()` needs a diagram library, and so the layout can be * tested. */ export declare function layoutGraph(graph: GraphDescription | { describe(): GraphDescription; }): GraphLayout;