shortest_distance_matrix
ShortestDistanceMatrix
Bases: NKAlgorithm
An algorithm to compute a matrix of the shortest distance between all nodes (if a path exists between the nodes). The algorithm uses networkit's APSP algorithm.
run()
Build distance matrix for all nodes in the graph.
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray[N, N]: Shortest distance matrix between all [N] nodes in the graph. |
Note
APSP returns np max float64 value if there is no path to the node.
This value is replaced by np.inf.
This method uses OpenMP and parallelizes the computation.
You can restrict the number of threads by calling set_number_of_threads method.