nocad.distances.geodesic_distances#

nocad.distances.geodesic_distances(adj, weighted=False)[source]#

Matrix of shortest-path lengths \(\ell_{ij}\) from \(x_i\) to \(x_j\).

Parameters:
adjarray_like or sparse, shape (N, N)
weightedbool, default=False

Use edge weights as lengths (Dijkstra); otherwise every edge has length one.

Returns:
distndarray of shape (N, N), inf where no path exists, zero diagonal.

Examples

>>> geodesic_distances([[0, 1, 0], [0, 0, 1], [0, 0, 0]])
array([[ 0.,  1.,  2.],
       [inf,  0.,  1.],
       [inf, inf,  0.]])