@topolab/tda 0.0.0-stage → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +106 -0
- package/CITATION.cff +72 -0
- package/LICENSE +21 -0
- package/README.md +100 -2
- package/SECURITY.md +34 -0
- package/THIRD_PARTY_LICENSES.md +697 -0
- package/dist/arrangement.d.ts +50 -0
- package/dist/arrangement.d.ts.map +1 -0
- package/dist/arrangement.js +63 -0
- package/dist/arrangement.js.map +1 -0
- package/dist/build_info.json +12 -0
- package/dist/check.d.ts +118 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +298 -0
- package/dist/check.js.map +1 -0
- package/dist/complex.d.ts +543 -0
- package/dist/complex.d.ts.map +1 -0
- package/dist/complex.js +712 -0
- package/dist/complex.js.map +1 -0
- package/dist/diagram.d.ts +116 -0
- package/dist/diagram.d.ts.map +1 -0
- package/dist/diagram.js +238 -0
- package/dist/diagram.js.map +1 -0
- package/dist/diagram_of.d.ts +17 -0
- package/dist/diagram_of.d.ts.map +1 -0
- package/dist/diagram_of.js +40 -0
- package/dist/diagram_of.js.map +1 -0
- package/dist/experimental.d.ts +18 -0
- package/dist/experimental.d.ts.map +1 -0
- package/dist/experimental.js +16 -0
- package/dist/experimental.js.map +1 -0
- package/dist/flat.d.ts +64 -0
- package/dist/flat.d.ts.map +1 -0
- package/dist/flat.js +158 -0
- package/dist/flat.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/ladder/tda_ladder.d.ts +223 -0
- package/dist/ladder/tda_ladder.js +1360 -0
- package/dist/ladder/tda_ladder_bg.wasm +0 -0
- package/dist/ladder/tda_ladder_bg.wasm.d.ts +43 -0
- package/dist/ladder.d.ts +306 -0
- package/dist/ladder.d.ts.map +1 -0
- package/dist/ladder.js +607 -0
- package/dist/ladder.js.map +1 -0
- package/dist/load.d.ts +53 -0
- package/dist/load.d.ts.map +1 -0
- package/dist/load.js +173 -0
- package/dist/load.js.map +1 -0
- package/dist/memory.d.ts +58 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +2 -0
- package/dist/memory.js.map +1 -0
- package/dist/persistence.d.ts +349 -0
- package/dist/persistence.d.ts.map +1 -0
- package/dist/persistence.js +478 -0
- package/dist/persistence.js.map +1 -0
- package/dist/pkg/tda_wasm.d.ts +13 -0
- package/dist/pkg/tda_wasm.js +2528 -0
- package/dist/prepared.d.ts +62 -0
- package/dist/prepared.d.ts.map +1 -0
- package/dist/prepared.js +81 -0
- package/dist/prepared.js.map +1 -0
- package/dist/rivet_input.d.ts +93 -0
- package/dist/rivet_input.d.ts.map +1 -0
- package/dist/rivet_input.js +132 -0
- package/dist/rivet_input.js.map +1 -0
- package/dist/source.d.ts +43 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +99 -0
- package/dist/source.js.map +1 -0
- package/dist/tda.wasm +0 -0
- package/dist/two_parameter.d.ts +243 -0
- package/dist/two_parameter.d.ts.map +1 -0
- package/dist/two_parameter.js +275 -0
- package/dist/two_parameter.js.map +1 -0
- package/dist/types.d.ts +146 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/vineyard.d.ts +278 -0
- package/dist/vineyard.d.ts.map +1 -0
- package/dist/vineyard.js +236 -0
- package/dist/vineyard.js.map +1 -0
- package/package.json +77 -4
- package/src/arrangement.ts +96 -0
- package/src/check.ts +338 -0
- package/src/complex.ts +1179 -0
- package/src/diagram.ts +299 -0
- package/src/diagram_of.ts +40 -0
- package/src/experimental.ts +17 -0
- package/src/flat.ts +204 -0
- package/src/index.ts +181 -0
- package/src/ladder.ts +903 -0
- package/src/load.ts +201 -0
- package/src/memory.ts +58 -0
- package/src/persistence.ts +752 -0
- package/src/prepared.ts +111 -0
- package/src/rivet_input.ts +195 -0
- package/src/source.ts +132 -0
- package/src/two_parameter.ts +480 -0
- package/src/types.ts +163 -0
- package/src/vineyard.ts +463 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Every user-visible change to `@topolab/tda` is listed here. The format
|
|
4
|
+
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions
|
|
5
|
+
follow [Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [0.4.0]
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **Two-parameter persistence** (experimental, over Z/2).
|
|
12
|
+
`functionRipsPresentation`, `degreeRipsPresentation` and
|
|
13
|
+
`bifiltrationPresentation` compute a minimal presentation of the homology
|
|
14
|
+
of a function-Rips or degree-Rips bifiltration or of any bifiltered
|
|
15
|
+
complex, one grade a cell or several; `bigradedBetti` gives the bigraded Betti numbers and
|
|
16
|
+
the Hilbert function, and `fiberedBarcode` the barcode along one or
|
|
17
|
+
several lines. The live example of the Two-parameter persistence guide
|
|
18
|
+
shows them.
|
|
19
|
+
`coarsenPresentation` coarsens a presentation onto RIVET's grid of bins,
|
|
20
|
+
and `augmentedArrangement` (`@topolab/tda/experimental`, a handle that owns
|
|
21
|
+
native memory) builds RIVET's augmented arrangement, whose
|
|
22
|
+
`fiberedBarcode` answers from a stored barcode template per cell; its
|
|
23
|
+
barcodes agree with RIVET's in `benchmarks/two_parameter/rivet_fibered.py`.
|
|
24
|
+
`parseRivetInput` reads RIVET's input data files, `rivetPresentation`
|
|
25
|
+
computes the module such a file describes, and `firepPresentation` the
|
|
26
|
+
module of a chain complex of free bigraded modules (RIVET's FIRep).
|
|
27
|
+
`rivetPresentation` computes RIVET's built-in functions
|
|
28
|
+
(`--function balldensity[r]`, `gaussian[σ]`, `eccentricity[p]`, with
|
|
29
|
+
RIVET's defaults for empty brackets) from the points or the metric space.
|
|
30
|
+
`rivetPresentation(text, { degree })` takes the text of a file, not
|
|
31
|
+
`parseRivetInput`'s result, and its degree defaults to 0, as RIVET's
|
|
32
|
+
`--homology`; both functions call the Rust crate's reader and need the
|
|
33
|
+
module. The Rust crate `topolab-tda` offers the same module
|
|
34
|
+
(`two_parameter`), RIVET files included (`parse_rivet_input`,
|
|
35
|
+
`rivet_presentation`); a line given to `fiberedBarcode` by its angle or
|
|
36
|
+
its direction is built by the crate's `Line::from_angle` or `Line::new`,
|
|
37
|
+
so the npm package, the Python package and the crate return the same
|
|
38
|
+
bits.
|
|
39
|
+
|
|
40
|
+
## [0.3.1]
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
|
|
44
|
+
- The changelog. 0.3.0 shipped the vineyard additions (any prime field, representative
|
|
45
|
+
cycles at chosen times) under an `[Unreleased]` heading; they are listed under 0.3.0 below. The
|
|
46
|
+
code is the same as in 0.3.0.
|
|
47
|
+
|
|
48
|
+
## [0.3.0] — first public release
|
|
49
|
+
|
|
50
|
+
### Added
|
|
51
|
+
|
|
52
|
+
- **Entry points.** `@topolab/tda` (the root), `@topolab/tda/ladder`
|
|
53
|
+
(commutative ladders, a WebAssembly module of its own, experimental as a
|
|
54
|
+
whole) and `@topolab/tda/experimental` (`prepareComplex`), plus the
|
|
55
|
+
binaries `@topolab/tda/tda.wasm` and `@topolab/tda/ladder.wasm`
|
|
56
|
+
for `load(source)`, and `@topolab/tda/package.json`.
|
|
57
|
+
- **Loading.** `load`, `unload`, `isLoaded` and `version` on the root and on
|
|
58
|
+
`./ladder`; the functions that need the module throw until `load()` resolves.
|
|
59
|
+
- **Complexes.** Rips, Čech, Delaunay–Čech, alpha (weighted or unweighted),
|
|
60
|
+
coupled alpha (2D), weak witness, k-fold cover, ellipsoid (Rips-type and
|
|
61
|
+
Čech), wing, box and cubical complexes. `cechPersistence`,
|
|
62
|
+
`alphaPersistence`, `kFoldCoverPersistence`, `ellipsoidRipsPersistence`,
|
|
63
|
+
`ellipsoidCechPersistence`, `wingPersistence` and
|
|
64
|
+
`boxFiltrationPersistence` build the complex and reduce it in one call.
|
|
65
|
+
- **Persistence.** `persistence` of any explicit complex, `ripsPersistence`
|
|
66
|
+
(with cycle or cocycle representatives), `cubicalPersistence`,
|
|
67
|
+
`zigzagPersistence` with `insertOp` and `removeOp`, and
|
|
68
|
+
`volumeOptimalCycles`. The `coeff` option takes any prime `p` up to
|
|
69
|
+
2^31 − 1 (`Z/p`); zigzag persistence is over Z/2.
|
|
70
|
+
- **Vineyards.** `vineyard(complex, frames)` follows persistence classes
|
|
71
|
+
through a straight-line homotopy of values on a single complex, using the
|
|
72
|
+
transposition update of Cohen-Steiner, Edelsbrunner, and Morozov
|
|
73
|
+
(SoCG 2006), and returns vines as typed arrays of knots. `cubicalVineyard`
|
|
74
|
+
follows the cubical diagrams of a sequence of images or volumes of the
|
|
75
|
+
same shape, and `ripsVineyard` follows the Rips diagrams of a moving point
|
|
76
|
+
cloud, each building one shared complex and assigning its values at every
|
|
77
|
+
frame. All three take `coeff` (any prime `p` from 2 to 2^31 − 1, default
|
|
78
|
+
2, reported in the result's `coeff`) and `representatives: { times, dims? }`,
|
|
79
|
+
which returns one representative cycle over `Z/coeff` per persisting vine
|
|
80
|
+
at each requested time in `[0, frames − 1]` (`VineyardRepresentatives`,
|
|
81
|
+
`VineyardRepresentativesOptions`). Stable: checked against GUDHI 3.12
|
|
82
|
+
(`SimplexTree`, `CubicalComplex` and `RipsComplex`) on 30 seeded inputs
|
|
83
|
+
over `Z/2` and `Z/3` at every frame and at interpolated times between
|
|
84
|
+
frames.
|
|
85
|
+
- **Diagrams.** `bettiNumbers`, `bettiCurve`, `persistenceLandscape`,
|
|
86
|
+
`persistenceImage`, and the exact `diagramBottleneck` and
|
|
87
|
+
`diagramWasserstein`.
|
|
88
|
+
- **Data.** Point clouds `{ coords, d }` (`pointCloud` converts nested
|
|
89
|
+
arrays), images `{ values, shape }` in NumPy's axis order, complexes as
|
|
90
|
+
typed arrays (`flatten`, `materialize`). Every result is plain data with no
|
|
91
|
+
memory inside WebAssembly, except the handle of the experimental
|
|
92
|
+
`prepareComplex`.
|
|
93
|
+
- **Errors.** `TypeError` or `RangeError` naming the parameter for a bad
|
|
94
|
+
argument, and a `TypeError` naming the function and the key for an option
|
|
95
|
+
the function does not take; `RangeError` with the engine's message for an
|
|
96
|
+
input an engine refuses, and with a message that starts with
|
|
97
|
+
`input too large:` for an input over a fixed size limit; `Error` for a
|
|
98
|
+
failure inside an engine or a call before `load()`. Every entry of an array
|
|
99
|
+
of numbers must be a number; typed arrays made in another realm are
|
|
100
|
+
accepted. An input too large for the module's memory is a `RangeError` with
|
|
101
|
+
`code: 'TOO_LARGE'` and a `details` object (types `CapacityError`,
|
|
102
|
+
`CapacityDetails`); the instance is replaced before the error is thrown, so
|
|
103
|
+
the next call needs no `load()`.
|
|
104
|
+
- **Runtimes.** ES modules only, no runtime dependencies. Node.js 22 or later,
|
|
105
|
+
or a browser with WebAssembly SIMD, bulk memory and reference types.
|
|
106
|
+
- **Licence.** MIT (LICENSE); third-party notices in THIRD_PARTY_LICENSES.md.
|
package/CITATION.cff
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use this software, please cite it as below. For the algorithms it implements and the software it vendors, see https://topolab.ai/tda/docs/references/."
|
|
3
|
+
type: software
|
|
4
|
+
title: "topolab TDA"
|
|
5
|
+
abstract: "Topological data analysis for the browser and Node.js, in Rust compiled to WebAssembly, as the package @topolab/tda."
|
|
6
|
+
version: "0.4.0"
|
|
7
|
+
license: MIT
|
|
8
|
+
url: "https://topolab.ai/tda/docs/"
|
|
9
|
+
authors:
|
|
10
|
+
- name: "topolab"
|
|
11
|
+
email: "dev@topolab.ai"
|
|
12
|
+
website: "https://topolab.ai"
|
|
13
|
+
references:
|
|
14
|
+
- type: article
|
|
15
|
+
title: "Ripser: efficient computation of Vietoris–Rips persistence barcodes"
|
|
16
|
+
authors:
|
|
17
|
+
- family-names: "Bauer"
|
|
18
|
+
given-names: "Ulrich"
|
|
19
|
+
journal: "Journal of Applied and Computational Topology"
|
|
20
|
+
volume: 5
|
|
21
|
+
start: "391"
|
|
22
|
+
end: "423"
|
|
23
|
+
year: 2021
|
|
24
|
+
url: "https://github.com/Ripser/ripser"
|
|
25
|
+
notes: "The Rust core's Rips persistence is written from this paper."
|
|
26
|
+
- type: article
|
|
27
|
+
title: "Geometry Helps to Compare Persistence Diagrams"
|
|
28
|
+
authors:
|
|
29
|
+
- family-names: "Kerber"
|
|
30
|
+
given-names: "Michael"
|
|
31
|
+
- family-names: "Morozov"
|
|
32
|
+
given-names: "Dmitriy"
|
|
33
|
+
- family-names: "Nigmetov"
|
|
34
|
+
given-names: "Arnur"
|
|
35
|
+
journal: "ACM Journal of Experimental Algorithmics"
|
|
36
|
+
volume: 22
|
|
37
|
+
year: 2017
|
|
38
|
+
url: "https://github.com/anigmetov/hera"
|
|
39
|
+
notes: "The bottleneck distance follows this paper."
|
|
40
|
+
- type: software
|
|
41
|
+
title: "LEMON"
|
|
42
|
+
authors:
|
|
43
|
+
- name: "Egerváry Research Group on Combinatorial Optimization (EGRES)"
|
|
44
|
+
license: "BSL-1.0"
|
|
45
|
+
version: "1.3.1"
|
|
46
|
+
url: "https://lemon.cs.elte.hu/"
|
|
47
|
+
notes: "The network simplex pivot of the exact Wasserstein distance is a Rust translation of parts of lemon/network_simplex.h (class NetworkSimplex), Copyright (C) 2003-2013 EGRES; the notice and licence text are in THIRD_PARTY_LICENSES.md."
|
|
48
|
+
- type: software
|
|
49
|
+
title: "Geogram (Delaunay PSM)"
|
|
50
|
+
authors:
|
|
51
|
+
- family-names: "Lévy"
|
|
52
|
+
given-names: "Bruno"
|
|
53
|
+
license: "BSD-3-Clause"
|
|
54
|
+
url: "https://github.com/BrunoLevy/geogram.psm.Delaunay"
|
|
55
|
+
notes: "The Rust triangulations behind the weighted alpha, Delaunay–Čech and k-fold cover builders follow its conventions (insertion semantics and the 3D symbolic perturbation). The PSM sources carry Copyright (c) 2000-2022 Inria; the repository's LICENSE reads Copyright (c) 2022, Bruno Levy."
|
|
56
|
+
- type: conference-paper
|
|
57
|
+
title: "The Gudhi Library: Simplicial Complexes and Persistent Homology"
|
|
58
|
+
authors:
|
|
59
|
+
- family-names: "Maria"
|
|
60
|
+
given-names: "Clément"
|
|
61
|
+
- family-names: "Boissonnat"
|
|
62
|
+
given-names: "Jean-Daniel"
|
|
63
|
+
- family-names: "Glisse"
|
|
64
|
+
given-names: "Marc"
|
|
65
|
+
- family-names: "Yvinec"
|
|
66
|
+
given-names: "Mariette"
|
|
67
|
+
collection-title: "Mathematical Software – ICMS 2014"
|
|
68
|
+
publisher:
|
|
69
|
+
name: "Springer"
|
|
70
|
+
year: 2014
|
|
71
|
+
url: "https://gudhi.inria.fr/"
|
|
72
|
+
notes: "MIT. The farthest-point subsampling of the witness complex is an edited port of GUDHI 3.11.0's choose_n_farthest_points (Copyright (C) 2016 Inria; notice in THIRD_PARTY_LICENSES.md), and the enclosing-ball value rule of the Čech builders is the rule of its MEB_filtration.h."
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 topolab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,101 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @topolab/tda
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
topolab TDA is topological data analysis for the browser and Node.js, in Rust compiled to WebAssembly. It builds a filtered complex from points or from an image, computes its persistent homology, and compares or summarises the diagrams. Everything runs on the caller's machine, with no runtime dependency and nothing native to install.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @topolab/tda
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The package is ES-module only and has no runtime dependencies. It needs Node.js 22 or later, or a browser with WebAssembly SIMD, bulk memory and reference types. The WebAssembly module, `tda.wasm`, about 2.2 MB (about 0.8 MB gzipped), is part of the package.
|
|
12
|
+
|
|
13
|
+
| | Needs | Tested |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| Node.js | 22 or later | 22 and 24 |
|
|
16
|
+
| Browsers | WebAssembly SIMD, bulk memory and reference types: Chrome 96, Firefox 89, Safari 16.4 or later by the feature list | current Chrome, Edge, Firefox and WebKit (Playwright), macOS Safari and Safari in the iOS 27.1 Simulator, direct and bundled by Vite, esbuild and webpack |
|
|
17
|
+
| Operating systems | none beyond the above | macOS (arm64) and a Linux container; **not** Windows, native Linux x86-64, Android or a physical iPhone or iPad |
|
|
18
|
+
|
|
19
|
+
The minimum browser versions come from the WebAssembly features the module uses, not from running those versions. Compiling WebAssembly needs `wasm-unsafe-eval` in `script-src`.
|
|
20
|
+
|
|
21
|
+
### Loading the WebAssembly module
|
|
22
|
+
|
|
23
|
+
Call `await load()` once per thread before the functions that need the module; until it resolves they throw `Error('@topolab/tda is not loaded: await load() first')`. `unload()` drops the module so that its memory can be reclaimed, `isLoaded()` says whether it is loaded, and `version()` gives the version it was built as. `load()` without an argument reads the binary next to the package's code, `new URL('./tda.wasm', import.meta.url)`:
|
|
24
|
+
|
|
25
|
+
- **Node** reads the file with `fs`.
|
|
26
|
+
- **A bundler** that understands `new URL(…, import.meta.url)` emits `tda.wasm` as an asset and rewrites the URL; the browser then fetches it. Vite 8 and webpack 5 do. esbuild does not: it leaves the expression as it is, and `import.meta.url` is then the bundle's own URL, so copy the package's `dist/tda.wasm` next to the bundle (and, if you use `./ladder`, its `dist/ladder/tda_ladder_bg.wasm` into a `ladder` folder there), or pass `load` a URL.
|
|
27
|
+
- **Otherwise** serve `@topolab/tda/tda.wasm` yourself and pass its URL, or pass the bytes, a `Response` (or a promise of one) or a compiled `WebAssembly.Module`: `await load('/assets/tda.wasm')`, `await load(fetch(url))`, `await load(bytes)`.
|
|
28
|
+
|
|
29
|
+
Every call is synchronous and the module is single-threaded, so a long computation on the main thread freezes the page. In a Web Worker, await `load()` in the worker inside the `try` of its message handler, so that a failed load is posted back too, and post results back: they are plain data. See [Threads and workers](https://topolab.ai/tda/docs/concepts/threads-and-workers/).
|
|
30
|
+
|
|
31
|
+
## First computation
|
|
32
|
+
|
|
33
|
+
Save as `quickstart.mjs` in a project that has the package installed and run `node quickstart.mjs`.
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
import { load, pointCloud, ripsPersistence } from '@topolab/tda';
|
|
37
|
+
|
|
38
|
+
await load(); // once, before the first call
|
|
39
|
+
|
|
40
|
+
// The corners of a unit square. The four components merge as the edges
|
|
41
|
+
// appear at distance 1; the loop they close is created then and is filled at
|
|
42
|
+
// the diagonal, 2^(1/2).
|
|
43
|
+
const points = pointCloud([[0, 0], [1, 0], [1, 1], [0, 1]]);
|
|
44
|
+
const diagram = ripsPersistence(points, { maxDim: 1 });
|
|
45
|
+
|
|
46
|
+
console.log(diagram.scale); // 'edgeLength'
|
|
47
|
+
console.log(Array.from(diagram.pairs[0])); // [0, 1, 0, 1, 0, 1, 0, Infinity]
|
|
48
|
+
console.log(Array.from(diagram.pairs[1])); // [1, 1.4142135623730951]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`pairs[k]` is a flat array `[birth, death, birth, death, …]` for the homology of dimension `k`. A death of `Infinity` means the class still persists at the end of the computed filtration; with a finite cutoff, it may be destroyed at a larger scale. The comment after each `console.log` is the value it prints, written as JavaScript. Rips values are edge lengths, twice the radius of the balls (see [Filtrations and scales](https://topolab.ai/tda/docs/concepts/filtrations-and-scales/)).
|
|
52
|
+
|
|
53
|
+
## What it computes
|
|
54
|
+
|
|
55
|
+
| Feature | Functions | Status |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| Alpha complex, unweighted or weighted (points in 3D) | `alphaComplex`, `alphaPersistence` | Stable |
|
|
58
|
+
| Rips complex, persistence and representatives | `ripsComplex`, `ripsPersistence` | Experimental |
|
|
59
|
+
| Čech and Delaunay–Čech complexes | `cechComplex`, `cechPersistence`, `delaunayCechComplex` | Stable |
|
|
60
|
+
| Euclidean (weak) witness complex | `witnessComplex` | Experimental |
|
|
61
|
+
| Cubical complexes of images and volumes, T- and V-constructions | `cubicalComplex`, `cubicalPersistence` | Stable (V-construction experimental) |
|
|
62
|
+
| Ellipsoid complex (Rips-type, a flag complex) | `ellipsoids`, `ellipsoidRipsComplex`, `ellipsoidRipsPersistence` | Experimental |
|
|
63
|
+
| Ellipsoidal Čech complex (a nerve) | `ellipsoidCechComplex`, `ellipsoidCechPersistence` | Experimental |
|
|
64
|
+
| Wing complex (2D, a flag complex) | `wings`, `wingComplex`, `wingPersistence` | Experimental |
|
|
65
|
+
| Box filtration (2D and 3D) | `boxFiltration`, `boxFiltrationPersistence` | Experimental |
|
|
66
|
+
| k-fold cover complex (multicover, fixed k) | `kFoldCoverComplex`, `kFoldCoverPersistence` | Stable |
|
|
67
|
+
| Coupled alpha complex (2D) | `coupledAlphaComplex` | Experimental |
|
|
68
|
+
| Persistent homology of any explicit complex | `persistence` | Stable |
|
|
69
|
+
| Zigzag persistence | `zigzagPersistence`, `insertOp`, `removeOp` | Stable |
|
|
70
|
+
| Vineyards: the classes of a diagram followed through a homotopy of the values, of images and of moving point clouds | `vineyard`, `cubicalVineyard`, `ripsVineyard` | Stable |
|
|
71
|
+
| Commutative ladders CL(n): decomposition for n ≤ 4, interval approximation for any n | `@topolab/tda/ladder` | Experimental |
|
|
72
|
+
| Bottleneck and Wasserstein distances, exact, with the matching | `diagramBottleneck`, `diagramWasserstein` | Stable |
|
|
73
|
+
| Betti numbers and curves, persistence landscapes, persistence images | `bettiNumbers`, `bettiCurve`, `persistenceLandscape`, `persistenceImage` | Experimental |
|
|
74
|
+
| Volume-optimal cycles ((n−1)-homology in Rⁿ) | `volumeOptimalCycles` | Experimental |
|
|
75
|
+
| Prepared complexes | `prepareComplex` (`@topolab/tda/experimental`) | Experimental |
|
|
76
|
+
|
|
77
|
+
Persistence takes coefficients in Z/p for every prime p up to 2^31 − 1 (default 2); zigzag persistence is over Z/2.
|
|
78
|
+
|
|
79
|
+
Each feature carries one of two labels, shown in the table above.
|
|
80
|
+
|
|
81
|
+
- **Stable**: the function is documented in the [API reference](https://topolab.ai/tda/docs/api/js/), tested against the independent references named in [Numerical contracts](https://topolab.ai/tda/docs/concepts/numerical-contracts/) (which says what each comparison covers and what it does not), and kept. Where a change alters the output of a stable function, the changelog says so.
|
|
82
|
+
- **Experimental**: the function works and is tested, but it promises less. Its options, defaults or result shape can change in any release, it can be removed, and its numerical contract says how far its values are checked (several are not claimed to match a reference bit for bit).
|
|
83
|
+
|
|
84
|
+
A 0.x version promises no compatibility under semantic versioning; every change that affects a caller is listed in the changelog.
|
|
85
|
+
|
|
86
|
+
## Documentation
|
|
87
|
+
|
|
88
|
+
- [Documentation](https://topolab.ai/tda/docs/)
|
|
89
|
+
- [Getting started](https://topolab.ai/tda/docs/getting-started/)
|
|
90
|
+
- [API reference](https://topolab.ai/tda/docs/api/js/)
|
|
91
|
+
- [Benchmarks](https://topolab.ai/tda/docs/benchmarks/)
|
|
92
|
+
- [Playground](https://topolab.ai/tda/play)
|
|
93
|
+
- [Licences](https://topolab.ai/licenses/)
|
|
94
|
+
|
|
95
|
+
## Security
|
|
96
|
+
|
|
97
|
+
Please report security issues privately, not in a public issue, by email to security@topolab.ai.
|
|
98
|
+
|
|
99
|
+
## Licence
|
|
100
|
+
|
|
101
|
+
MIT, "Copyright (c) 2026 topolab". The full text is the `LICENSE` file in the package. Third-party notices are on [Licences](https://topolab.ai/tda/docs/licences/); the papers each method follows are on [References](https://topolab.ai/tda/docs/references/). The full notices and licence texts are in `THIRD_PARTY_LICENSES.md` in the package and at [topolab.ai/licenses/](https://topolab.ai/licenses/).
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
## Reporting a vulnerability
|
|
4
|
+
|
|
5
|
+
Please report security issues privately, not in a public issue, by email to
|
|
6
|
+
security@topolab.ai.
|
|
7
|
+
|
|
8
|
+
Include what you ran (the input, or a script that builds it), what happened,
|
|
9
|
+
and the version of `@topolab/tda`. We will acknowledge the report and keep you
|
|
10
|
+
informed while we work on it.
|
|
11
|
+
|
|
12
|
+
## Supported versions
|
|
13
|
+
|
|
14
|
+
The latest published version of `@topolab/tda`.
|
|
15
|
+
|
|
16
|
+
## What counts
|
|
17
|
+
|
|
18
|
+
The package runs on the caller's machine, in the browser, a worker or Node.
|
|
19
|
+
Reports we treat as security issues include memory-safety faults in the
|
|
20
|
+
WebAssembly modules (the main module and the ladder engine, both Rust)
|
|
21
|
+
reachable from the public API, input that makes the wrapper or module read or write outside the data it was given, and
|
|
22
|
+
anything in the build that could put code into `dist/` that is not built
|
|
23
|
+
from the package's sources.
|
|
24
|
+
|
|
25
|
+
Inputs above the documented limits are refused with a `RangeError` (for
|
|
26
|
+
example a Rips complex above 2^25 simplices, refused as `input too large: …`;
|
|
27
|
+
see [Fixed limits](https://topolab.ai/tda/docs/concepts/limits-errors-memory/#fixed-limits));
|
|
28
|
+
an input that exhausts memory or time below those limits is
|
|
29
|
+
a bug, and a public issue is fine for it. The exact Wasserstein distance
|
|
30
|
+
(`diagramWasserstein`) builds a dense (n + 1) × (m + 1) transport problem of
|
|
31
|
+
n and m finite points; above 16,777,216 entries it is refused with a
|
|
32
|
+
`RangeError`, and below that it can still exhaust the memory of a small
|
|
33
|
+
device, which is reported as `TOO_LARGE` (see
|
|
34
|
+
[Errors](https://topolab.ai/tda/docs/concepts/limits-errors-memory/#errors)).
|