aryagraph.algorithms.paths.shortest_path_length#

aryagraph.algorithms.paths.shortest_path_length(g: Graph, source: Hashable, target: Hashable | None = None, weight: str | Callable[[Hashable, Hashable, dict], float] | None = None, method: str = 'auto') → Any[source]#

Length of a shortest path (hops, or total weight); same arguments as shortest_path().

With target=None returns a NodeMap {node: distance} over every node reachable from source (in order of discovery).