// Neighborhood similarity — pairwise Jaccard, cosine or overlap coefficients over neighbor sets (deduped; loops excluded; directed: true compares out-neighborhoods)
eles.neighborhoodSimilarity(options?: NeighborhoodSimilarityOptions): AlgoRun<NeighborhoodSimilarityResult>Neighborhood similarity — pairwise Jaccard, cosine or overlap coefficients over neighbor sets (deduped; loops excluded; directed: true compares out-neighborhoods). The result is all-pairs, so it holds O(n²) counts like floydWarshall. Async: returns a promise, and executor ('cpu' | 'gpu' | 'auto', default 'auto') picks where the shared-neighbor counts are computed — under 'auto' the GPU's A·Aᵀ matmul is used only on graphs dense enough to beat the CPU's wedge walk (a mean degree of 64).
| Name | Description |
|---|---|
options: NeighborhoodSimilarityOptions? |
|
Fields of options
| Name | Description |
|---|---|
metric: SimilarityMetric? | the normalization (default 'jaccard') |
directed: boolean? | compare out-neighborhoods instead of undirected ones |
executor: AlgoExecutor? | where the run executes; see |
AlgoRun<NeighborhoodSimilarityResult>a promise of the { similarity } accessor — with cancel() on it: a pending run rejects with CancelledError, a 'cpu' run has already completed
Example
const run = eles.neighborhoodSimilarity({ executor: 'cpu' });const result = await run;console.log(result.similarity(cy.getElementById('a'), cy.getElementById('a'))); // 1if executor or metric is invalid; rejects if executor: 'gpu' is unavailable in this environment