Skip to content

ctx.components()

ctx.components — Extensions > Layout context > Writing positions and finishing. Cytoscape.js signatures, parameters and return contract.

ctx.components — Extensions › Layout context › Writing positions and finishing

Preview · Extensions › Layout context › Writing positions and finishing

Read in the complete API reference · All API members

// The scope's connected components over nodeSlots() ( factored out of packComponents for layouts that pack their own arrays): union-find over the scope's own edges — an edge with an endpoint outside the scope connects nothing here — indexed by position in nodeSlots()
ctx.components(): Components

The scope's connected components over nodeSlots() (* factored out of packComponents for layouts that pack their own arrays): union-find over the scope's own edges — an edge with an endpoint outside the scope connects nothing here — indexed by position in nodeSlots().

Returns Components

the component assignment, ids in first-seen node order

Example

cy.layout({ impl: { run(ctx) {
console.log(ctx.components().count); // 1
} } }).run();

Example graph and handle setup