build_min_distance_graph

Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.

build_min_distance_graph(node_result: HabitatNodeExtractionResult, labels: Tuple[int, ...], graph_kind: str, distance_threshold: float, edge_weight: Literal['none', 'distance', 'inverse_distance', 'contact_voxels'] = 'none', include_intra_edges: bool = False) → HabitatGraph[source]

Build a graph by connecting regions whose closest voxels are within threshold.

Unlike build_centroid_distance_graph(), the distance is the minimum Euclidean distance between any voxel of region A and any voxel of region B (closest-voxel / set-separation distance), not the distance between centroids and not the Hausdorff distance. Units are voxel indices, matching centroid_distance. The same d_min is stored on the edge as distance and is what avg_edge_distance summarizes.

An undirected edge exists when min_{a in A, b in B} ||a-b|| <= threshold.

Parameters:
  • node_result – Output from connected-region node extraction. Voxel coordinates are read from the component maps.

  • labels – One label for a single-habitat graph or two labels for a pair.

  • graph_kind – "single" or "pairwise".

  • distance_threshold – Maximum closest-point Euclidean distance in voxel index units. Reuses the same field as centroid_distance.

  • edge_weight – Optional distance-derived edge weighting mode.

  • include_intra_edges – For pairwise graphs, also add same-label closest-point edges within each habitat.

Returns:

Graph with closest-point edges.

Return type:

HabitatGraph

Raises:

ValueError – If distance_threshold < 0 or labels is empty.