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.
Calculate the shortest path distance between two nodes.
source
- The ID of the source node.
target
- The ID of the target node.
Returns the distance of the shortest path between the source and target nodes if it exists.
Calculate the shortest path between two nodes as a list of node IDs.
start
- The ID of the start node.
end
- The ID of the end node.
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.
Calculate the shortest path between two nodes as a list of edge IDs.
start
- The ID of the start node.
end
- The ID of the end node.
Returns a Vec<i64>
containing the IDs of the edges in the shortest path if it exists.