Functions S–T
Import these from @grafloria/engine.
Functions
serializeGraph
Freeze a live graph into the wire format.
Emits nodes and links in CANONICAL (id-sorted) order — the same discipline
Established in fromAdapter. Determinism needs both halves: a seeded
PRNG and a stable input order.
tsfunction serializeGraph(nodes: NodeModel[], links: LinkModel[]): LayoutGraph
serveLayout
Serve layout requests on a port. This IS the worker's message loop — call it
inside the worker script with self, or in a test with a fake port, or (see
LayoutHost) on the inline side of a loopback pair.
tsfunction serveLayout(port: LayoutServePort, deps: ServeLayoutDeps = {}): void
toElkPortSide
tsfunction toElkPortSide(side: PortSide): ElkPortSide
translateOptions
One vocabulary in, each engine's dialect out.
The adapters disagree about names for the same concept — dagre says rankdir,
nodesep, ranksep; ELK says elk.direction with words instead of letters.
Reusing this is what stops the nested path from quietly forking the options schema.
tsfunction translateOptions(
engine: string,
options: UnifiedLayoutOptions
): Partial<LayoutOptions>
treeLayout
Tree layout over one connected component.
Component packing (see component-packing.ts) is what turns this into a FOREST layout: each tree is laid out here, alone, and the boxes are packed afterwards. That division is why a five-tree forest comes out as five tidy trees rather than the pile dagre produces.
tsfunction treeLayout(
nodes: NodeModel[],
links: LinkModel[],
options: TreeLayoutOptions = {}
): LayoutResult
Was this page helpful?