Skip to content

eles.randomWalkWithRestartProximity(options?)

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

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

Preview · Collection › Algorithms › Similarity, diffusion and resistance

Read in the complete API reference · All API members

// All-pairs random-walk-with-restart proximity — the full matrix S = c·(I − (1−c)·W)⁻¹, whose column s is the walk restarting at s
eles.randomWalkWithRestartProximity(options?: RandomWalkWithRestartOptions): AlgoRun<RandomWalkWithRestartProximityResult>

All-pairs random-walk-with-restart proximity — the full matrix S = c·(I − (1−c)·W)⁻¹, whose column s is the walk restarting at s. Async: executor ('cpu' | 'gpu' | 'workers' | 'auto', default 'auto') picks between one sparse solve per column on the CPU, the same solves spread over the worker pool (matching 'cpu') and the dense Neumann iteration on the GPU — under 'auto' the GPU from 256 nodes at any density, else the pool from 128. All-pairs (O(n²) memory). dangling is the seed form's: dead ends restart at the column's node by default, or absorb.

Parameters
NameDescription
options: RandomWalkWithRestartOptions?

{ restartProbability, maxIterations, tolerance, directed, weight, dangling, executor }

Fields of options
NameDescription
seeds: Collection | null?

the nodes the walk restarts at (required for the seed form)

restartProbability: number?

the restart probability c (default 0.15); must sit in (0, 1)

maxIterations: number?

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

tolerance: number?

stop once the L1 step drops under tolerance (default 1e-6) — per column, for the proximity form

directed: boolean?

walk out-edges only

weight: WeightFn?
dangling: 'restart' | 'absorb'?

where a walker at a node with no out-edges goes: 'restart' (default) back to the seeds, as NetworkX's personalised PageRank does, so scores sum to 1; 'absorb' nowhere — the walk ends there and its mass is lost

executor: AlgoExecutor?

where the run executes; see AlgoExecutor (default 'auto'). The seed form has no GPU path; the proximity form takes the GPU from GPU_MIN_N nodes at any density (72.6).

Returns AlgoRun<RandomWalkWithRestartProximityResult>

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

Example

const run = eles.randomWalkWithRestartProximity({ seeds: cy.getElementById('a'), executor: 'cpu' });
const result = await run;
console.log(result.proximity(cy.getElementById('a'), cy.getElementById('a')) > 0); // true

Example graph and handle setup

Throws

if executor, restartProbability or dangling is invalid; rejects if executor: 'gpu' is unavailable in this environment