Skip to content

eles.floydWarshall(options?)

eles.floydWarshall — Collection > Algorithms > Search and shortest paths. Cytoscape.js signatures, parameters and return contract.

eles.floydWarshall — Collection › Algorithms › Search and shortest paths

Preview · Collection › Algorithms › Search and shortest paths

Read in the complete API reference · All API members

// Floyd–Warshall all-pairs shortest paths
eles.floydWarshall(options?: FloydWarshallOptions): AlgoRun<FloydWarshallResult>

Floyd–Warshall all-pairs shortest paths. O(n³) — for a single source prefer dijkstra/bellmanFord. Async: the expensive whole-graph tier returns promises, and executor ('cpu' | 'gpu' | 'auto', default 'auto'; 'workers' runs the reference on one pool worker) picks where the maths runs; 'cpu' is the reproducible reference.

Parameters
NameDescription
options: FloydWarshallOptions?

{ weight, directed, executor }

Fields of options
NameDescription
weight: WeightFn?
directed: boolean?
executor: AlgoExecutor?

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

Returns AlgoRun<FloydWarshallResult>

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

Example

const run = eles.floydWarshall({ executor: 'cpu' });
const result = await run;
console.log(result.distance(cy.getElementById('a'), cy.getElementById('c'))); // 2

Example graph and handle setup

Throws

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