pub fn dijkstra_path_digraph<N, E, Ix>(
graph: &DiGraph<N, E, Ix>,
source: &N,
target: &N,
) -> Result<Option<Path<N, E>>>Expand description
Finds the shortest path between source and target nodes in a directed graph using Dijkstra’s algorithm
This is the modern API that provides a clearer name for directed graph path finding. This is the recommended function to use for directed graphs.
§Arguments
graph- The directed graph to search insource- The source nodetarget- The target node
§Returns
Ok(Some(Path))- If a path existsOk(None)- If no path existsErr(GraphError)- If the source or target node is not in the graph
§Time Complexity
O((V + E) log V) where V is the number of vertices and E is the number of edges.
§Space Complexity
O(V) for the distance array and predecessor tracking.