#eles.length
// How many elements this collection holds
eles.length: numberHow many elements this collection holds.
numberInspect identity and collection membership.
eles.length// How many elements this collection holds
eles.length: numberHow many elements this collection holds.
numbereles.cy()// The core this collection belongs to
eles.cy(): Core<NodeData, EdgeData>The core this collection belongs to.
Core<NodeData, EdgeData>the instance that owns these elements — a collection cannot span two cores, so this is also the identity a set operation against a foreign collection would violate
eles.collection()// Create an empty collection bound to the same core
eles.collection(): Collection<NodeData, EdgeData, Data>Create an empty collection bound to the same core. Takes no arguments. Use union() to build a set from existing elements, or filter() to select members of this collection.
Collection<NodeData, EdgeData, Data>a fresh empty collection bound to this core — the seed for building a set up by union
if called with any argument — use cy.add() to insert definitions or set operations to build collections
eles.hasElementWithId(id)// Whether this collection contains an element with the given id
eles.hasElementWithId(id: string): booleanWhether this collection contains an element with the given id.
| Name | Description |
|---|---|
id: string | the element id |
booleantrue when a member has that id
eles.indexOf(ele)// Index of an element within this collection
eles.indexOf(ele: Collection): numberIndex of an element within this collection.
| Name | Description |
|---|---|
ele: Collection | the element to find; only its first element is used |
numberthe index, or -1 when it is not in this collection
eles.indexOfId(id)// Position of the element with this id within the collection
eles.indexOfId(id: string): numberPosition of the element with this id within the collection.
| Name | Description |
|---|---|
id: string | the element id |
numberthe index, or -1 when absent
ele.id()// The first element's id
ele.id(): string | undefinedThe first element's id. Cached on the handle, so it stays readable after the element is removed.
string | undefinedthe id, or undefined when the collection is empty
ele.group()// The first element's group
ele.group(): GroupName | undefinedThe first element's group. Cached on the handle, so it stays readable after removal.
GroupName | undefined'nodes' or 'edges', or undefined when empty
ele.json()// Plain-object form of the first element (undefined when empty)
ele.json(): Record<string, unknown> | undefinedPlain-object form of the first element (undefined when empty).
eles.jsons()// Plain-object form of every element
eles.jsons(): (Record<string, unknown> | undefined)[]Plain-object form of every element.
(Record<string, unknown> | undefined)[]one object per element, in collection order — the plural of json(), not a graph-level export
Example
console.log(eles.jsons().map(def => def.data.id)); // ['a', 'b', 'c', 'ab', 'bc']ele.isNode()// Whether the first element is a node
ele.isNode(): booleanWhether the first element is a node.
booleantrue for a node
ele.isEdge()// Whether the first element is an edge
ele.isEdge(): booleanWhether the first element is an edge.
booleantrue for an edge
ele.isLoop()// Whether the first element is a self-loop — an edge whose source and target are the same node
ele.isLoop(): booleanWhether the first element is a self-loop — an edge whose source and target are the same node.
booleantrue for a loop edge; false for nodes and removed elements
ele.isSimple()// Whether the first element is a non-loop edge
ele.isSimple(): booleanWhether the first element is a non-loop edge.
booleantrue for an edge between two distinct nodes
ele.removed()// Whether the first element has been removed from the graph
ele.removed(): booleanWhether the first element has been removed from the graph. A removed element's handle stays usable — reads are no-ops or undefined, and the cached id()/group() remain readable.
booleantrue when the element is no longer in the graph
ele.inside()// Whether the first element is still in the graph — the complement of removed()
ele.inside(): booleanWhether the first element is still in the graph — the complement of removed().
booleantrue when the element is live