// Triangle counting: per-node triangle counts, local clustering coefficients, and the collection's transitivity, read over the simple undirected graph (direction ignored, parallel edges collapsed, loops excluded)
eles.triangleCount(options?: TriangleCountOptions): AlgoRun<TriangleCountResult>Triangle counting: per-node triangle counts, local clustering coefficients, and the collection's transitivity, read over the simple undirected graph (direction ignored, parallel edges collapsed, loops excluded). Async: returns a promise, and executor ('cpu' | 'gpu' | 'auto', default 'auto'; 'workers' runs the reference on one pool worker) picks where the counting runs — under 'auto' the GPU's A²∘A matmul is used only on graphs dense enough to beat the CPU's sparse walk (a mean degree of 64).
| Name | Description |
|---|---|
options: TriangleCountOptions? |
|
Fields of options
| Name | Description |
|---|---|
executor: AlgoExecutor? | where the run executes; see |
AlgoRun<TriangleCountResult>a promise of { triangles, clusteringCoefficient, totalTriangles, transitivity } — with cancel() on it: a pending run rejects with CancelledError, a 'cpu' run has already completed
Example
const run = eles.triangleCount({ executor: 'cpu' });const result = await run;console.log(result.totalTriangles); // 0if executor is invalid; rejects if executor: 'gpu' is unavailable in this environment