loadGraph()
loadGraph(
input):ExecutionGraph
Defined in: loader.ts:58
Deserialize a JSON object (or JSON string) into a valid ExecutionGraph.
Use this whenever you read a trace file from disk or receive one over the
network. It normalizes nodes into a proper Map regardless of the
serialization format.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | string | Record<string, unknown> | A parsed JSON object, or a JSON string to be parsed. |
Returns
A valid ExecutionGraph ready for use with query functions.
Throws
If the input cannot be parsed or is missing required fields.
Example
import { readFileSync } from 'fs';
import { loadGraph, getStats } from 'agentflow-core';
const graph = loadGraph(readFileSync('trace.json', 'utf8'));
console.log(getStats(graph));