graphclust.graphs.knn_graph#

graphclust.graphs.knn_graph(X, k=5, metric='euclidean')[source]#

Symmetric \(k\)-nearest-neighbor graph.

Samples \(\mathbf{x}_i\) and \(\mathbf{x}_j\) are linked when one of them is among the \(k\) nearest neighbors of the other (union rule).

Examples

>>> import numpy as np
>>> A = knn_graph(np.arange(10.0).reshape(-1, 1), k=1)
>>> int(A.nnz // 2)
9

Examples using graphclust.graphs.knn_graph#

Proximity graphs and their nesting

Proximity graphs and their nesting

Geodesic distances on a neighborhood graph

Geodesic distances on a neighborhood graph

Combining quantization, distance and mapping

Combining quantization, distance and mapping