// Export graph elements and graph-level data as a binary buffer
cy.serialize(): ArrayBufferExport graph elements and graph-level data as a binary buffer. Load it into a new instance with cytoscape({ elements: buffer }), or add its elements to an existing instance with cy.add(buffer).
The buffer carries element identity, positions, topology, selection and data. It excludes stylesheet, viewport and scratch. Constructor loading applies its graph-level data; add() leaves the destination's graph data unchanged.
ArrayBuffera fresh little-endian buffer, self-contained (every edge endpoint indexes a node in the same payload) and directly loadable — derived geometry is flushed first, so parent boxes are the current ones rather than whatever was last materialized
Example
const buffer = cy.serialize();const restored = cytoscape({ headless: true, elements: buffer });console.log(restored.nodes().length); // 3restored.destroy();