Skip to content

cytoscape.deserializeElements(input)

cytoscape.deserializeElements — Core > Export and snapshots > Graph data and wire format. Cytoscape.js signatures, parameters and return contract.

cytoscape.deserializeElements — Core › Export and snapshots › Graph data and wire format

Preview · Core › Export and snapshots › Graph data and wire format

Read in the complete API reference · All API members

// Deserialize a serializeElements buffer (or a view over one) back into the columnar elements form
cytoscape.deserializeElements(input: ArrayBuffer | ArrayBufferView): ColumnarElements

Deserialize a serializeElements buffer (or a view over one) back into the columnar elements form. Numeric columns are zero-copy views into the given buffer; a misaligned view is copied once to realign.

Parameters
NameDescription
input: ArrayBuffer | ArrayBufferView

a serializeElements buffer, or a view over one

Returns ColumnarElements

the columnar form, whose numeric columns are views into the input rather than copies — so the buffer must outlive the result, and writing into either is visible through the other. Graph-level data is the exception in two ways: it is decoded from JSON rather than viewed, and cy.add() deliberately ignores it (see ColumnarElements.data)

Example

const payload = cytoscape.deserializeElements(cy.serialize());
console.log(payload.nodes.count); // 3

Example graph and handle setup

Throws

if the platform is big-endian, or the buffer is too short, truncated or of an unsupported format version