NNSOM.utils.distances

NNSOM.utils.distances(pos)[source]

Compute shortest-path distances between all pairs of SOM neurons.

Builds an adjacency graph where two neurons are connected if their Euclidean distance is at most 1 (i.e., immediate hex neighbours), then uses Floyd-Warshall to compute all-pairs shortest paths.

Parameters:

pos (np.ndarray, shape (2, N)) – Neuron positions as returned by calculate_positions().

Returns:

dist – Matrix of topological (graph-hop) distances between neurons.

Return type:

np.ndarray, shape (N, N)