spacenet.helpers.shortest_path_length_node_a_to_node_b#

spacenet.helpers.shortest_path_length_node_a_to_node_b(spatial_network, node_a, node_b, edge_weight_name='Distance')#

Computes the shortest path distance from node_a to node_b in a spatial network using Dijkstra’s algorithm, with the specified edge weight. The function first checks if the distance from node_a to node_b is already cached in the spatial network’s distance cache for the given edge weight. If it is cached, it returns the cached distance. If not, it computes the shortest path distance using Dijkstra’s algorithm and returns the result.

Parameters:
spatial_networkNetworkX graph

The spatial network for which to compute the shortest path distance.

node_aint or other

The index of the source node. This can be an integer or any other hashable type that represents a node in the spatial network.

node_bint or other

The index of the target node. This can be an integer or any other hashable type that represents a node in the spatial network.

edge_weight_namestr, optional

The name of the edge attribute to use as the weight for computing the shortest path distance. Default is ‘Distance’.

Returns:
shortest_path_distancefloat

The shortest path distance from node_a to node_b in the spatial network, computed using Dijkstra’s algorithm with the specified edge weight.