Skip to content

eles.heatDiffusion(options?)

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

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

Preview · Collection › Algorithms › Similarity, diffusion and resistance

Read in the complete API reference · All API members

// Heat diffusion from a seeds collection: unit heat spread over the seeds flows along edges for time, through the kernel exp(−t·L) of the weighted Laplacian
eles.heatDiffusion(options?: HeatDiffusionOptions): AlgoRun<HeatDiffusionResult>

Heat diffusion from a seeds collection: unit heat spread over the seeds flows along edges for time, through the kernel exp(−t·L) of the weighted Laplacian. Total heat is conserved under the default laplacian: 'combinatorial'; 'normalized' diffuses over I − D^{-½}AD^{-½} instead, whose spectrum is bounded whatever the degrees — hubs neither hoard nor flood — at the price of conservation. Async; the vector form is O(E) per series term on the CPU, so there is no GPU path — an explicit executor: 'gpu' rejects and points at heatKernel. Edges are read undirected with positive weights.

Parameters
NameDescription
options: HeatDiffusionOptions?

{ seeds, time, weight, laplacian, executor }

Fields of options
NameDescription
seeds: Collection | null?

the nodes the heat starts on (required for the seed form)

time: number?

how long the heat flows (default 0.1); must be positive

weight: WeightFn?
laplacian: HeatLaplacian?

which Laplacian drives the diffusion (default 'combinatorial', L = D − A, heat-conserving); 'normalized' is I − D^{-½}AD^{-½}, whose spectrum is bounded by 2 so the scaling exponent depends on time alone — heat is then not conserved

executor: AlgoExecutor?

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

Returns AlgoRun<HeatDiffusionResult>

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.heatDiffusion({ 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, time or laplacian is invalid, if seeds holds no node of the collection, or if an edge weight is not positive