flow-knn
Algorithm-agnostic k-nearest-neighbour graphs for large-n flow cytometry (and other embedding pipelines).
Overview
Build a KnnGraph once (compute_knn) and reuse it across various algorithms (PaCMAP, UMAP, or other embedders) — or persist it with write_knn_graph / read_knn_graph.
How it Works
recommend_method picks a backend from ((n, d)). Backends share one KnnGraph shape (indices + distances). Exact Rayon brute-force is always available; optional HNSW (usearch), ann-search-rs, kiddo, and GPU paths are feature-gated.
Related crates
Use a sibling instead when you need:
- PaCMAP embedding →
flow-pacmap— primary consumer; staged KNN beforefit_transform - FCS I/O →
flow-fcs
Installation
Or add it directly to your Cargo.toml:
[]
= { = "0.1.1", = ["hnsw"] }
| Feature | Backend | Notes |
|---|---|---|
hnsw (default) |
usearch | C++ FFI + simsimd |
ann-search |
ann-search-rs | Pure-Rust HNSW |
gpu |
ann-search-rs + cubeCL | GpuExact / GpuIvf / GpuNnDescent via wgpu |
| (always) | Exact | Rayon brute-force baseline |
kdtree |
kiddo | Currently falls back to exact |
API Usage
use ;
use Path;
Performance
See docs/PERF_MATRIX.md. Extend timings with:
FLOW_KNN_BENCH_PRESSURE=1
License
MIT