# deserializeGraph

> **deserializeGraph**(`bytes`): [`Graph`](/reference/knotkit/graph/type-aliases/graph/)

Defined in: [packages/graph/src/serialization.ts:204](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/graph/src/serialization.ts#L204)

Decode bytes written by [serializeGraph](/reference/knotkit/graph/wire/functions/serializegraph/), restoring the layout, the flags, the vertex count, and the edges the artifact was serialized from.

Every edge is checked before any graph is built: endpoints in range, rows in canonical order, and contents that agree with the declared flags. The checked columns then become the graph’s storage directly, without the copy a factory makes of caller input. Allocation is bounded by [GRAPH_MAX_DECODE_VERTICES](/reference/knotkit/graph/wire/variables/graph_max_decode_vertices/) and by the payload’s length.

## Parameters

### bytes

`Uint8Array`

## Returns

[`Graph`](/reference/knotkit/graph/type-aliases/graph/)

## Throws

With a code from `GRAPH_PARSE_ERROR_CODES` when the payload is malformed, truncated, unsupported, over budget, or internally inconsistent.

## Throws

With code `MAX_CAPACITY_EXCEEDED` when the runtime refuses the graph’s storage.
