Skip to content

eles.degreeCentrality(options?)

eles.degreeCentrality — Collection > Algorithms > Centrality. Cytoscape.js signatures, parameters and return contract.

eles.degreeCentrality — Collection › Algorithms › Centrality

Preview · Collection › Algorithms › Centrality

Read in the complete API reference · All API members

// Compute Opsahl's generalized degree for one node in this collection
eles.degreeCentrality(options?: DegreeCentralityOptions): DegreeCentralityResult

Compute Opsahl's generalized degree for one node in this collection. alpha interpolates between counting edges (0) and summing their weights (1); intermediate values combine both. Directed results separate incoming and outgoing degree.

Parameters
NameDescription
options: DegreeCentralityOptions?

{ root, weight, alpha, directed }; root is required, weight(edge) defaults to 1, alpha defaults to 0, and directed defaults to false

Fields of options
NameDescription
root: Collection | null?
weight: WeightFn?
directed: boolean?
alpha: number?

0 = count degree, 1 = weight sum (Opsahl's generalized degree)

normalization: 'max' | 'size'?

read by degreeCentralityNormalized only: 'max' (default) divides by the largest degree, 'size' by n − 1 — NetworkX's degree_centrality and igraph's normalized = TRUE

Returns DegreeCentralityResult

{ degree }, or { indegree, outdegree } when directed

Example

const result = eles.degreeCentrality({ root: cy.getElementById('b') });
console.log(result.degree); // 2

Example graph and handle setup

Throws

if root is missing or does not contain a node

Also spelled eles.dc.