pub trait PathFinding {
    // Required methods
    fn shortest_path_distance(
        &self,
        source: NodeId,
        target: NodeId
    ) -> Option<f64>;
    fn shortest_path_nodes(
        &self,
        start: NodeId,
        end: NodeId
    ) -> Option<Vec<NodeId>>;
    fn shortest_path_edges(
        &self,
        start: NodeId,
        end: NodeId
    ) -> Option<Vec<EdgeId>>;
}
Expand description

PathFinding trait provides pathfinding algorithms for railway networks.

Required Methods§

source

fn shortest_path_distance(&self, source: NodeId, target: NodeId) -> Option<f64>

Calculate the shortest path distance between two nodes.

Arguments
  • source - The ID of the source node.
  • target - The ID of the target node.
Returns

Returns the distance of the shortest path between the source and target nodes if it exists.

source

fn shortest_path_nodes(&self, start: NodeId, end: NodeId) -> Option<Vec<NodeId>>

Calculate the shortest path between two nodes as a list of node IDs.

Arguments
  • start - The ID of the start node.
  • end - The ID of the end node.
Returns

Returns a Vec<i64> containing the IDs of the nodes in the shortest path if it exists. The returned vector includes the start and end node IDs.

source

fn shortest_path_edges(&self, start: NodeId, end: NodeId) -> Option<Vec<EdgeId>>

Calculate the shortest path between two nodes as a list of edge IDs.

Arguments
  • start - The ID of the start node.
  • end - The ID of the end node.
Returns

Returns a Vec<i64> containing the IDs of the edges in the shortest path if it exists.

Implementors§