Run ❯
×
Change Orientation
Change Theme, Dark/Light
import numpy as np from scipy.sparse.csgraph import bellman_ford from scipy.sparse import csr_matrix arr = np.array([ [0, -1, 2], [1, 0, 0], [2, 0, 0] ]) newarr = csr_matrix(arr) print(bellman_ford(newarr, return_predecessors=True, indices=0))
(array([ 0., -1., 2.]), array([-9999, 0, 0], dtype=int32))