Skip to content

cy.collection()

cy.collection — Core > Accessing elements. Cytoscape.js signatures, parameters and return contract.

cy.collection — Core › Accessing elements

Preview · Core › Accessing elements

Read in the complete API reference · All API members

// Create an empty collection bound to this core
cy.collection(): Collection<NodeData, EdgeData>

Create an empty collection bound to this core. Use it as an accumulator, for example cy.collection().union(cy.nodes({ selected: true })).

This method takes no arguments. Query with cy.elements(query) or build a collection with union() to include existing elements.

Returns Collection<NodeData, EdgeData>

a collection of zero elements

Example

console.log(cy.collection().map(ele => ele.id())); // []

Example graph and handle setup

Throws

if called with any argument — use cy.add() to insert definitions or set operations to build collections