Skip to content

eles.remove()

eles.remove — Collection > Graph manipulation. Cytoscape.js signatures, parameters and return contract.

eles.remove — Collection › Graph manipulation

Preview · Collection › Graph manipulation

Read in the complete API reference · All API members

// Remove these elements from the graph; incident edges of removed nodes cascade
eles.remove(): Collection<NodeData, EdgeData, Data>

Remove these elements from the graph; incident edges of removed nodes cascade. Already-removed elements are skipped (no second remove event).

Returns Collection<NodeData, EdgeData, Data>

the elements actually removed — the closure, so it can be larger than the receiver: removing a parent brings its descendants, and removing a node brings its incident edges. The returned refs are dead by construction (removals are terminal), so only their cached id()/group() still read

Example

const removed = cy.getElementById('c').remove();
console.log(removed.removed()); // true
console.log(cy.hasElementWithId('c')); // false

Example graph and handle setup