// Effective resistance and commute time — the graph as a resistor network
eles.effectiveResistance(options?: EffectiveResistanceOptions): AlgoRun<EffectiveResistanceResult>Effective resistance and commute time — the graph as a resistor network. Weights are conductances by default, the convention of the papers that define the weighted measure; weightAs: 'resistance' reads them as resistances, NetworkX's default. resistance(a, b) comes from the Laplacian pseudo-inverse, commuteTime(a, b) the expected round-trip steps of the random walk (component volume × resistance). Pairs in different components answer Infinity. Async: executor ('cpu' | 'gpu' | 'auto', default 'auto') picks between dense f64 elimination on the CPU and Newton–Schulz matmul iteration on the GPU; both are O(n³), so 'auto' takes the GPU on size alone.
| Name | Description |
|---|---|
options: EffectiveResistanceOptions? |
|
Fields of options
| Name | Description |
|---|---|
weight: WeightFn? | |
weightAs: 'conductance' | 'resistance'? | what |
executor: AlgoExecutor? | where the run executes; see |
AlgoRun<EffectiveResistanceResult>a promise of the { resistance, commuteTime } accessors — with cancel() on it: a pending run rejects with CancelledError, a 'cpu' run has already completed
Example
const run = eles.effectiveResistance({ executor: 'cpu' });const result = await run;console.log(result.resistance(cy.getElementById('a'), cy.getElementById('c')) > 0); // trueif executor or weightAs is invalid; rejects if an edge weight is not positive or executor: 'gpu' is unavailable