shortest_path(arr, reach=1, axis=-1, output_indexlist=False)
By 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). :None:None:`reach`
defines the number of elements that can be skipped along each non-axis dimension at each step.
The axis along which the path must always move forward (default -1)
See return value p
for explanation.
For each step along :None:None:`axis`
, the coordinate of the shortest path. If :None:None:`output_indexlist`
is True, then the path is returned as a list of n-d tuples that index into :None:None:`arr`
. 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, :None:None:`p.shape == (arr.shape[axis], arr.ndim-1)`
except that p is squeezed before returning so if :None:None:`arr.ndim == 2`
, then :None:None:`p.shape == (arr.shape[axis],)`
Cost of path. This is the absolute sum of all the differences along the path.
Find the shortest path through an n-d array from one side to another.
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them