MCP(costs, offsets=None, fully_connected=True, sampling=None)
Equivalent to the :None:None:`offsets`
provided to the constructor, or if none were so provided, the offsets created for the requested n-d neighborhood. These are useful for interpreting the traceback
array returned by the find_costs() method.
Given an n-d costs array, this class can be used to find the minimum-cost path through that array from any set of points to any other set of points. Basic usage is to initialize the class and call find_costs() with a one or more starting indices (and an optional list of end indices). After that, call traceback() one or more times to find the path from any given end-position to the closest starting index. New paths through the same costs array can be found by calling find_costs() repeatedly.
The cost of a path is calculated simply as the sum of the values of the :None:None:`costs`
array at each point on the path. The class MCP_Geometric, on the other hand, accounts for the fact that diagonal vs. axial moves are of different lengths, and weights the path cost accordingly.
Array elements with infinite or negative costs will simply be ignored, as will paths whose cumulative cost overflows to infinite.
A list of offset tuples: each offset specifies a valid move from a given n-d position. If not provided, offsets corresponding to a singly- or fully-connected n-d neighborhood will be constructed with make_offsets(), using the :None:None:`fully_connected`
parameter value.
If no :None:None:`offsets`
are provided, this determines the connectivity of the generated neighborhood. If true, the path may go along diagonals between elements of the :None:None:`costs`
array; otherwise only axial moves are permitted.
For each dimension, specifies the distance between two cells/voxels. If not given or None, the distance is assumed unit.
A class for finding the minimum cost path through a given n-d costs array.
The following pages refer to to this document either explicitly or contain code examples using this.
skimage.graph.mcp.route_through_array
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