spacenet.global_metrics.mean_detour_index#
- spacenet.global_metrics.mean_detour_index(spatial_network, edge_weight_name='Distance', max_distance=inf, low_memory=False)#
Computes the mean detour index of a spatial network, which is defined as the average ratio of the shortest path distance between pairs of nodes to the direct distance between those nodes in space, for all pairs of nodes that are within a specified maximum distance of each other. The euclidean distance between nodes is used as a direct distance metric, and the shortest path distance is computed using Dijkstra’s algorithm with edge weights specified by edge_weight_name.
- Parameters:
- spatial_networknetworkx.Graph
The spatial network for which to compute the detour index. The graph should have edge weights corresponding to the distance between nodes, and node attributes corresponding to the position of each node in space.
- edge_weight_namestr, optional
The name of the edge attribute in the graph that corresponds to the distance between nodes. Default is ‘Distance’.
- max_distancefloat, optional
The maximum distance to consider when computing the detour index. Only pairs of nodes that are within this distance of each other will be included in the computation. Default is np.inf (no limit).
- low_memorybool, optional
Whether to use a low-memory implementation of Dijkstra’s algorithm that computes distances in batches. This can be useful for large networks that do not fit in memory. Default is False.
- Returns:
- mean_detour_indexfloat
The detour index of the spatial network, which is defined as the average ratio of the shortest path distance between pairs of nodes to the direct distance between those nodes in space, for all pairs of nodes that are within the specified maximum distance of each other.