dijkstra_path_digraph

Function dijkstra_path_digraph 

Source
pub fn dijkstra_path_digraph<N, E, Ix>(
    graph: &DiGraph<N, E, Ix>,
    source: &N,
    target: &N,
) -> Result<Option<Path<N, E>>>
where N: Node + Debug, E: EdgeWeight + Zero + One + Add<Output = E> + PartialOrd + Copy + Debug + Default, Ix: IndexType,
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 in
  • source - The source node
  • target - The target node

§Returns

  • Ok(Some(Path)) - If a path exists
  • Ok(None) - If no path exists
  • Err(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.