select_shortest_path_subgraph()
Return the induced subgraph over all hop-shortest paths between two nodes.
Usage
select_shortest_path_subgraph(
graph, *, source_key, target_key, directed=True, max_path_length=None
)Edge direction on the returned graph follows DependencyGraph semantics: A -> B means A depends on B. directed affects search only.
Parameters
graph: DependencyGraph-
Dependency graph to search.
source_key: NodeKey-
Path start node.
target_key: NodeKey-
Path end node.
directed: bool = True-
If
True, walk outgoing dependency edges only. IfFalse, treat each edge as bidirectional for reachability. max_path_length: int | None = None-
Optional hop-count ceiling.
0allows only the trivial same-key path.
Returns
DependencyGraph-
Induced subgraph of every hop-shortest path. Endpoints are always
included. Returned edges keep original direction, guards, and
provenance.
included. Returned edges keep original direction, guards, and
provenance.
Raises
ValueError-
If a key is missing,
max_path_lengthis negative, no path exists under the requested directionality, or the shortest path is longer thanmax_path_length. A directed miss that still has an undirected path mentionsdirected=False.