# serializeDisjointSet

## Call Signature

> **serializeDisjointSet**(`set`, `options?`): `Uint8Array`

Defined in: [packages/disjoint-set/src/serialization/binary.ts:92](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/disjoint-set/src/serialization/binary.ts#L92)

Serialize a partition into canonical binary bytes. Growable layouts require an injective codec; indexed layouts synthesize their dense elements.

### Parameters

#### set

[`IndexedDisjointSet`](/reference/knotkit/disjoint-set/interfaces/indexeddisjointset/)

#### options?

[`SerializeDisjointSetOptions`](/reference/knotkit/disjoint-set/wire/interfaces/serializedisjointsetoptions/)

### Returns

`Uint8Array`

### Throws

With `MISSING_ELEMENT_CODEC`, `INVALID_CODEC_RESULT`, `NON_INJECTIVE_CODEC`, or `SERIALIZATION_LIMIT_EXCEEDED` when the input cannot be represented safely.

## Call Signature

> **serializeDisjointSet**<`T`>(`set`, `codec`, `options?`): `Uint8Array`

Defined in: [packages/disjoint-set/src/serialization/binary.ts:93](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/disjoint-set/src/serialization/binary.ts#L93)

Serialize a partition into canonical binary bytes. Growable layouts require an injective codec; indexed layouts synthesize their dense elements.

### Type Parameters

#### T

`T`

### Parameters

#### set

[`GrowableDisjointSet`](/reference/knotkit/disjoint-set/interfaces/growabledisjointset/)<`T`>

#### codec

[`ElementCodec`](/reference/knotkit/wire/interfaces/elementcodec/)<`T`>

#### options?

[`SerializeDisjointSetOptions`](/reference/knotkit/disjoint-set/wire/interfaces/serializedisjointsetoptions/)

### Returns

`Uint8Array`

### Throws

With `MISSING_ELEMENT_CODEC`, `INVALID_CODEC_RESULT`, `NON_INJECTIVE_CODEC`, or `SERIALIZATION_LIMIT_EXCEEDED` when the input cannot be represented safely.
