Skip to content

ele.degree(includeLoops?)

eles.degree — Collection > Algorithms > Structural measures. Cytoscape.js signatures, parameters and return contract.

eles.degree — Collection › Algorithms › Structural measures

Preview · Collection › Algorithms › Structural measures

Read in the complete API reference · All API members

// The first element's total degree, in + out, answered in O(1) off the adjacency index
ele.degree(includeLoops?: boolean): number | undefined

The first element's total degree, in + out, answered in O(1) off the adjacency index.

This is a singular accessor — it reports one node's degree, not a collection-wide figure. For the sum over the whole collection use totalDegree().

Parameters
NameDescription
includeLoops: boolean?Default: true

whether self-loops count (each contributes 2)

Returns number | undefined

the degree, or undefined when the first element is not a live node

Example

console.log(eles.degree()); // 1

Example graph and handle setup