pub trait ShortestPath<R, T> {
    // Required method
    fn find_shortest_path(
        &self,
        from: NodeId,
        to: NodeId
    ) -> Option<Vec<NodeId>>;
}
Expand description

ShortestPath trait provides functionality to compute shortest path in a network.

It is generic over two types R and T. R represents some properties of the network (like weights or capacities), and T represents the numerical type for calculations (like distances or costs).

Implementations of ShortestPath provide a method find_shortest_path() that takes the starting and destination nodes, and returns the shortest path from the start to the destination node as a vector of node IDs.

Required Methods§

source

fn find_shortest_path(&self, from: NodeId, to: NodeId) -> Option<Vec<NodeId>>

Finds the shortest path from the start node to the destination node.

Arguments
  • from - The ID of the starting node.
  • to - The ID of the destination node.
Returns
  • Option<Vec<NodeId>> - If a path exists, returns the path as a vector of Node IDs, where the first element is the start node and the last is the destination node. If no path exists, returns None.

Implementors§

source§

impl<R: Copy, T: CoordNum> ShortestPath<R, T> for TransitNetwork<R, T>