Skip to main content

shortest_path_distance

Function shortest_path_distance 

Source
pub fn shortest_path_distance(
    graph: &DiGraph<NetelementSide, f64>,
    node_map: &HashMap<NetelementSide, NodeIndex>,
    from: &NetelementSide,
    to: &NetelementSide,
) -> Option<f64>
Expand description

Compute the shortest-path distance between two netelement sides.

Uses a direction-aware Dijkstra that prevents consecutive external-edge (connection) traversals. At netelement connections, multiple netelement sides may connect at the same point via zero-weight external edges. Standard Dijkstra can “shortcut” through a connection (e.g. NE_B → connection → NE_C) without traversing the connecting netelement, which would represent a physically impossible direction reversal for a train.

Returns None if no path exists (disconnected components).