Skip to content

eles.simRank(options?)

eles.simRank — Collection > Algorithms > Similarity, diffusion and resistance. Cytoscape.js signatures, parameters and return contract.

eles.simRank — Collection › Algorithms › Similarity, diffusion and resistance

Preview · Collection › Algorithms › Similarity, diffusion and resistance

Read in the complete API reference · All API members

// SimRank — "two nodes are similar when their neighbors are similar", the Jeh–Widom recursive fixed point, iterated as dense products S′ = C·Q·S·Qᵀ
eles.simRank(options?: SimRankOptions): AlgoRun<SimRankResult>

SimRank — "two nodes are similar when their neighbors are similar", the Jeh–Widom recursive fixed point, iterated as dense products S′ = C·Q·S·Qᵀ. Async: returns a promise, and executor ('cpu' | 'gpu' | 'auto', default 'auto'; 'workers' runs the reference on one pool worker) picks where the iteration runs — under 'auto' the GPU from 256 nodes at any density. The undirected default compares all neighbors; directed: true compares the classic in-neighborhoods. All-pairs (O(n²) memory).

Parameters
NameDescription
options: SimRankOptions?

{ dampingFactor, maxIterations, tolerance, directed, executor }

Fields of options
NameDescription
dampingFactor: number?

the decay per neighborhood step (default 0.8); must sit in (0, 1)

maxIterations: number?

iteration cap when the tolerance is never met (default 50)

tolerance: number?

stop once max |Δs| ≤ tolerance (default 1e-4)

directed: boolean?

compare in-neighborhoods (the classic form) instead of undirected ones

executor: AlgoExecutor?

where the run executes; see AlgoExecutor (default 'auto'). 'auto' takes the GPU from GPU_MIN_N nodes at any density (72.6: the products beat the per-pair CPU iteration everywhere).

Returns AlgoRun<SimRankResult>

a promise of the { similarity } accessor — with cancel() on it: a pending run rejects with CancelledError, a 'cpu' run has already completed

Example

const run = eles.simRank({ executor: 'cpu' });
const result = await run;
console.log(result.similarity(cy.getElementById('a'), cy.getElementById('a'))); // 1

Example graph and handle setup

Throws

if executor or dampingFactor is invalid; rejects if executor: 'gpu' is unavailable in this environment