Skip to content

Function: getLayout()

ts
function getLayout(g: Graph, opts?: GeometryOptions): LayoutSnapshot;

Defined in: api/geometry.ts:284

Returns a plain, JSON-serializable snapshot of the computed geometry for all nodes and edges in graph g.

Must be called after ctx.layout(g, engine) (or render) has run. Before layout the geometry fields hold calloc-zero defaults (every node at the origin, an empty bounding box), so a not-yet-laid-out graph is rejected with a RenderError rather than returning that all-zero snapshot as if it were real geometry.

Parameters

g

Graph

Laid-out graph (internal model; not mutated by this function).

opts?

GeometryOptions

Coordinate options; defaults to { yAxis: 'down' }.

Returns

LayoutSnapshot

Throws

RenderError if g has not been laid out.

See

lib/common/types.h:GD_bb, ND_coord, ED_spl