{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / graph / _mcp / MCP

class

skimage.graph._mcp:MCP

source: /dev/scikit-image/build/cp314/src/skimage/graph/_mcp.cpython-314-darwin.so

Signature

class   MCP ( costs offsets = None fully_connected = True sampling = None )

Members

Summary

A class for finding the minimum cost path through a given n-d costs array.

Extended Summary

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 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.

Parameters

costs : ndarray
offsets : iterable, optional

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 fully_connected parameter value.

fully_connected : bool, optional

If no offsets are provided, this determines the connectivity of the generated neighborhood. If true, the path may go along diagonals between elements of the costs array; otherwise only axial moves are permitted.

sampling : tuple, optional

For each dimension, specifies the distance between two cells/voxels. If not given or None, the distance is assumed unit.

Attributes

offsets : ndarray

Equivalent to the 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.

Aliases

  • skimage.graph.MCP