Skip to content

ctx.degreeOf(slot)

ctx.degreeOf — Extensions > Layout context > Columnar reads. Cytoscape.js signatures, parameters and return contract.

ctx.degreeOf — Extensions › Layout context › Columnar reads

Preview · Extensions › Layout context › Columnar reads

Read in the complete API reference · All API members

// O(1) degree off the CSR adjacency
ctx.degreeOf(slot: number): number

O(1) degree off the CSR adjacency.

Parameters
NameDescription
slot: number

a node slot, as handed out by nodeSlots()

Returns number

its whole-graph degree, loops counted twice

Example

// Inside a custom layout, ctx is supplied by the library.
cy.layout({ impl: { run(ctx) {
const slots = ctx.nodeSlots();
console.log(ctx.degreeOf(slots[0])); // 1
} } }).run();

Example graph and handle setup