// 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.
| Name | Description |
|---|---|
options: RandomWalkWithRestartOptions? |
|
Fields of options
| Name | Description |
|---|---|
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 |
directed: boolean? | walk out-edges only |
weight: WeightFn? | |
dangling: 'restart' | 'absorb'? | where a walker at a node with no out-edges goes:
|
executor: AlgoExecutor? | where the run executes; see |
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); // trueif executor, restartProbability or dangling is invalid, or if seeds holds no node of the collection