bundles / skimage latest / skimage / graph / spath / shortest_path
function
skimage.graph.spath:shortest_path
source: /dev/scikit-image/src/skimage/graph/spath.py:5
Signature
def shortest_path(arr, reach = 1, axis = -1, output_indexlist = False)Summary
Find the shortest path through an n-d array from one side to another.
Parameters
arr: ndarray of float64reach: int, optionalBy default (
reach = 1), the shortest path can only move one row up or down for every step it moves forward (i.e., the path gradient is limited to 1).reachdefines the number of elements that can be skipped along each non-axis dimension at each step.axis: int, optionalThe axis along which the path must always move forward (default -1)
output_indexlist: bool, optionalSee return value p for explanation.
Returns
p: iterable of intFor each step along
axis, the coordinate of the shortest path. Ifoutput_indexlistis True, then the path is returned as a list of n-d tuples that index intoarr. If False, then the path is returned as an array listing the coordinates of the path along the non-axis dimensions for each step along the axis dimension. That is,p.shape == (arr.shape[axis], arr.ndim-1)except that p is squeezed before returning so ifarr.ndim == 2, thenp.shape == (arr.shape[axis],)cost: floatCost of path. This is the absolute sum of all the differences along the path.
Aliases
skimage.graph.shortest_path