knn_graph — 3D geodesic op

• Data kinds: points → graph

• Call: import fullseye as fs; fs.ledger.knn_graph(points: numpy.ndarray, k: int = 8) -> Tuple[numpy.ndarray, numpy.ndarray] (to call the implementation directly, import geodesic3d; geodesic3d.knn_graph(points: numpy.ndarray, k: int = 8) -> Tuple[numpy.ndarray, numpy.ndarray]; from the registry, ops3d.get("knn_graph"))

Usage

Each point's k nearest-neighbour indices and Euclidean distances (excluding itself). → (idx (N,k) int, dist (N,k) float).

Looks up the k+1 nearest neighbours of each point with scipy.spatial.cKDTree and returns the k of them excluding the point itself (distance 0). idx[i, j] is the index of the j-th nearest point to point i, dist[i, j] its Euclidean distance (in coordinate units), and each row is in ascending order of distance.

• points: coordinates of any dimension such as (N,3) (converted to float64). The shape is not validated.

• k: number of neighbours (default 8). Values above N-1 are silently truncated to N-1.

• When N < 2, no exception is raised; returns 2 empty arrays of shape (N,0).

Pitfall: with duplicate coordinates the KD-tree may not return the point itself in column 0. In that case the position of the point itself is searched per row and removed, and if the point itself is not among the k+1, the farthest 1 is dropped (the result is still k). geodesic_distances / farthest_point_sampling turn this result into an adjacency matrix (directed CSR, made undirected on the Dijkstra side) and use it to approximate geodesic distance.

References (sample data, literature)

• Sample-data catalog (download URLs / licences) — 2-D uses skimage.data (BSD/public domain) plus synthetic images; 3-D lists download URLs for real data sources (Stanford, PDS, …).

• Operator provenance and references — the sources of the research/methods this op family came from.

Runnable examples (verified samples that actually call this op)

• pcl_geodesic — py -3.11 examples_3d/pcl_geodesic.py

Ops the type connects to (they accept graph as input)

fuse_to_voxel

Same category (geodesic)

geodesic_distances · geodesic_mesh · farthest_point_sampling


*Provenance: geodesic3d.py — 3D operator registry. This per-op note is generated by tools/opdocs.py md (do not hand-edit).*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.