epsilon_neighborhood_graph#
- tangles.util.graph.similarity.epsilon_neighborhood_graph(X: ndarray, max_dist: float, dist2sim=None, metric: str = 'precomputed') csr_matrix #
Creates a neighborhood graph from precomputed distances.
Every node is connected to every other node that has distance at most max_dist.
Parameters#
- Xnp.ndarray
If metric is ‘precomputed’ X is a condensed distance matrix (see
scipy.spatial.distance.squareform()
). Otherwise X is the data andscipy.spatial.distance.pdist()
is called taking X as its argument.- max_distfloat
Maximal distance.
- dist2simCallable[[float], float], optional
Function that transforms a similarity to a distance. Defaults to the constant 1 function (i.e. unweighted).
- metricstr
Either ‘precomputed’ or a metric from
scipy.spatial.distance.pdist()
.
Returns#
- sparse.csr_matrix
Sparse adjacency matrix of the epsilon-neighborhood graph.