MHCXGraph.core.subgraphs.extract_k_hop_subgraph¶
- MHCXGraph.core.subgraphs.extract_k_hop_subgraph(g: Graph, central_node: str, k: int, k_only: bool = False, filter_dataframe: bool = True, update_coords: bool = True, recompute_distmat: bool = False, inverse: bool = False, return_node_list: bool = False) Graph | list[str] | None[source]¶
Select nodes by k-hop neighborhood.
- Parameters:
g (nx.Graph) – Input graph.
central_node (str) – Center node ID.
k (int) – Number of hops.
k_only (bool, default=False) – If True, include exactly k-hop nodes; otherwise include all <= k.
filter_dataframe – See
extract_subgraph_from_node_list().update_coords – See
extract_subgraph_from_node_list().recompute_distmat – See
extract_subgraph_from_node_list().inverse – See
extract_subgraph_from_node_list().return_node_list – See
extract_subgraph_from_node_list().
- Returns:
Subgraph or node list.
- Return type: