build_centroid_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_centroid_distance_graph(nodes: Sequence[HabitatGraphNode], 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 nodes whose centroid distance is within threshold.

Parameters:
  • nodes – Nodes to include in the graph. For pairwise graphs this must contain nodes from both habitat labels.

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

  • graph_kind – "single" or "pairwise".

  • distance_threshold – Maximum Euclidean centroid distance in pixel units.

  • edge_weight – Optional distance-derived edge weighting mode.

  • include_intra_edges – For pairwise graphs, also add same-label proximity edges within each habitat. PathPrism source (multi_graph_process.py) adds those intra edges even though the STAR Methods text said inter-only. Whole-graph metrics (modularity, assortativity, betweenness) use the full graph; interface metrics (isolated ratio, avg_h*_per_h*, pair degree family) count inter-class neighbors only.

Returns:

Lightweight graph with all input nodes and inferred edges.

Return type:

HabitatGraph