Skip to content

eles.pageRank(options?)

eles.pageRank — Collection > Algorithms > Centrality. Cytoscape.js signatures, parameters and return contract.

eles.pageRank — Collection › Algorithms › Centrality

Preview · Collection › Algorithms › Centrality

Read in the complete API reference · All API members

// PageRank over the subgraph
eles.pageRank(options?: PageRankOptions): AlgoRun<PageRankResult>

PageRank over the subgraph. Undirected by default — each edge is walked both ways, as NetworkX and igraph do — and directed: true follows source → target only. Async: returns a promise, and executor ('cpu' | 'gpu' | 'auto', default 'auto'; 'workers' runs the reference on one pool worker) picks where the power method runs; 'cpu' is the reproducible reference.

Parameters
NameDescription
options: PageRankOptions?

{ dampingFactor, precision, iterations, weight, directed, executor }; dampingFactor is the textbook α in (0, 1], default 0.85

Fields of options
NameDescription
dampingFactor: number?

the probability of following an out-edge rather than teleporting — the textbook α, in (0, 1] (default 0.85)

precision: number?
iterations: number?
weight: WeightFn?
directed: boolean?

walk edges source → target only (default false: an undirected run walks each edge both ways, as NetworkX and igraph do)

executor: AlgoExecutor?

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

Returns AlgoRun<PageRankResult>

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

Example

const run = eles.pageRank({ executor: 'cpu' });
const result = await run;
console.log(result.rank(cy.getElementById('c')) > 0); // true

Example graph and handle setup

Throws

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