grid_distance_graph#
- tangles.util.graph.similarity.grid_distance_graph(grid_shape: tuple[int, int], max_dist: float = 3.0, normalize: bool = False, dist: str = 'euklid') csr_array #
A function to create a grid-like graph where every vertex is connected to all neighbors that are close (in grid coordinates).
Returns a 2-dimensional matrix, where the index of each axis represents the index of a square. The value is the distance between the squares in the grid.
Parameters#
- grid_shapeshape
A shape. Given as a tuple containing exactly two integers.
- max_distfloat
Maximal distance of two connected vertices.
- normalizebool
If True, distances are normalized.
- dist{‘euklid’, ‘manhattan’}
The metric that will be used to calculate the distances.
Returns#
- sparse.csr_array
A similarity graph between the pixels.