rustworkx.graph_distance_matrix#
- graph_distance_matrix(graph, /, parallel_threshold=300, null_value=0.0)#
Get the distance matrix for an undirected graph
This differs from functions like digraph_floyd_warshall_numpy in that the edge weight/data payload is not used and each edge is treated as a distance of 1.
This function is also multithreaded and will run in parallel if the number of nodes in the graph is above the value of
parallel_threshold
(it defaults to 300). If the function will be running in parallel the env varRAYON_NUM_THREADS
can be used to adjust how many threads will be used.- Parameters:
graph (PyGraph) – The graph to get the distance matrix for
parallel_threshold (int) – The number of nodes to calculate the the distance matrix in parallel at. It defaults to 300, but this can be tuned
null_value (float) – An optional float that will treated as a null value. This element will be the default in the matrix and represents the absense of a path in the graph. By default this is
0.0
.
- Returns:
The distance matrix
- Return type: