Function: getDrawOps()
ts
function getDrawOps(g: Graph, opts?: DrawOpsOptions): XdotOp[];Defined in: render/xdot-public.ts:161
Lay out g, render to xdot, parse every draw-attribute stream, and return all ops as a flat XdotOp[] in paint order (graph → node → edge).
Consumers discriminate on the kind field of the XdotOp union — no string parsing required.
Parameters
g
A Graph from parse() or the builder API.
opts?
Optional: { engine } overrides the default 'dot'.
Returns
XdotOp[]
Flat typed draw-op array covering the full graph.
Throws
ParseError if the xdot DOT output cannot be re-parsed.
Throws
RenderError if layout or rendering fails.
Example
ts
import { parse } from '@knowvah/dot-engine';
import { getDrawOps } from '@knowvah/dot-engine/render';
const g = parse('digraph { a -> b; }');
for (const op of getDrawOps(g)) {
switch (op.kind) {
case 'filled_ellipse':
case 'unfilled_ellipse':
drawEllipse(op.ellipse);
break;
case 'text':
drawText(op.text);
break;
// ...handle the remaining XdotOp kinds
}
}See
- lib/xdot/xdot.h
- lib/gvc/gvc.h:gvRender