Skip to content

eles.randomWalkWithRestart(options?)

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

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

Preview · Collection › Algorithms › Similarity, diffusion and resistance

Read in the complete API reference · All API members

// Random walk with restart — network propagation from a seeds collection: a walker follows edges with probability 1−c and restarts at the seeds with probability c, and the stationary distribution scores every node by proximity to the seeds
eles.randomWalkWithRestart(options?: RandomWalkWithRestartOptions): AlgoRun<RandomWalkWithRestartResult>

Random walk with restart — network propagation from a seeds collection: a walker follows edges with probability 1−c and restarts at the seeds with probability c, and the stationary distribution scores every node by proximity to the seeds. Async; the vector iteration is O(E) per step on the CPU, so there is no GPU path — an explicit executor: 'gpu' rejects and points at randomWalkWithRestartProximity. A node with no out-edges sends the walker back to the seeds (dangling: 'restart', default — NetworkX's personalised PageRank), so scores sum to 1; dangling: 'absorb' ends the walk there instead, and scores can sum below 1.

Parameters
NameDescription
options: RandomWalkWithRestartOptions?

{ seeds, 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<RandomWalkWithRestartResult>

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

Example

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

Example graph and handle setup

Throws

if executor, restartProbability or dangling is invalid, or if seeds holds no node of the collection