Skip to content

topologicalH0

function topologicalH0(
hdIn,
ldIn,
opts?): MetricResult & {
hdDiagram: PersistenceH0;
ldDiagram: PersistenceH0;
};

Defined in: metrics/topology.ts:248

Do the data and the projection merge into connected pieces at the same scales?

Sweeps a distance threshold from 0 upwards and compares when clusters join in each space. Unlike measures fixed at one k or one clustering, this covers every scale at once — it catches a projection that fuses two branches of a manifold too early, or keeps them apart too long.

  • Needs: high-dimensional data and projection. No labels.
  • Range: [0, ∞), lower is better; 0 means identical merge structure. With the default scale: "diameter" a uniform rescaling scores 0, and values are in [0, 1].
  • Cost: O(N²·D).

Sees merging, not holes — for those use topologicalH1. Per-point values give each point’s share of the discrepancy.

ParameterType
hdInPointsInput
ldInPointsInput
optsTopologyOptions

MetricResult & { hdDiagram: PersistenceH0; ldDiagram: PersistenceH0; }

Rieck & Leitte, Computer Graphics Forum 34 (2015) https://doi.org/10.1111/cgf.12655

import { topologicalH0 } from "@saehrimnir/sickle";
const t = topologicalH0(data, projection);
t.value; // 0.0528 — bottleneck distance, normalised by diameter
t.localKind; // "share" — each rank gap split across the MST edge endpoints
t.local[0]; // 0.0025
// Raw units instead of diameter-normalised, and Wasserstein instead:
topologicalH0(data, projection, { scale: "none" }).value; // 1.5859
topologicalH0(data, projection, { distance: "wasserstein", p: 1 });