Function shortest_path

Source
pub fn shortest_path<N, E, Ix>(
    graph: &Graph<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 using Dijkstra’s algorithm

§Arguments

  • graph - The 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