Skip to content

eles.affinityPropagation(options?)

eles.affinityPropagation — Collection > Algorithms > Clustering. Cytoscape.js signatures, parameters and return contract.

eles.affinityPropagation — Collection › Algorithms › Clustering

Preview · Collection › Algorithms › Clustering

Read in the complete API reference · All API members

// Affinity propagation, which picks exemplars by message passing and so needs no target cluster count
eles.affinityPropagation(options?: AffinityPropagationOptions): AlgoRun<Collection<NodeData, EdgeData, NodeData>[]>

Affinity propagation, which picks exemplars by message passing and so needs no target cluster count.

Async: returns a promise, and executor ('cpu' | 'gpu' | 'auto', default 'auto'; 'workers' runs the reference on one pool worker) picks where the message passing runs; 'cpu' is the reproducible reference.

Parameters
NameDescription
options: AffinityPropagationOptions?

{ attributes, distance, preference, damping, minIterations, maxIterations, executor }

Fields of options
NameDescription
distance: DistanceMetric?
preference: AffinityPreference?
damping: number?
maxIterations: number?
minIterations: number?
attributes: AffinityAttributeFn[]?
executor: AlgoExecutor?

where the run executes; see AlgoExecutor (default 'auto')

Returns AlgoRun<Collection<NodeData, EdgeData, NodeData>[]>

a promise of one collection per cluster — with cancel() on it: a pending run rejects with CancelledError, a 'cpu' run has already completed

Example

const run = cy.nodes().affinityPropagation({ damping: 0.5, preference: 0, attributes: [node => node.data('score')], executor: 'cpu' });
const result = await run;
console.log(result.reduce((sum, cluster) => sum + cluster.length, 0)); // 3

Example graph and handle setup

Throws

if executor is invalid; rejects if executor: 'gpu' is unavailable, or if damping/preference are invalid

Also spelled eles.ap.