hyperpaths_rs/transit_network.rs
1/// Link is an edge in the transit network graph.
2#[derive(Debug, Clone, PartialEq)]
3pub struct Link {
4 /// Source node of the link
5 pub from_node: String,
6 /// Target node of the link
7 pub to_node: String,
8 /// Corresponding route
9 pub route_id: String,
10 /// Travel time along the link (in minutes or any consistent unit)
11 pub travel_cost: f64,
12 /// Service headway. Boarding links have headway > 0 (frequency = 1/headway).
13 /// On-board (riding) links have headway = 0 (no waiting).
14 pub headway: f64,
15}
16
17impl Link {
18 /// Convenience constructor
19 pub fn new(
20 from_node: &str,
21 to_node: &str,
22 route_id: &str,
23 travel_cost: f64,
24 headway: f64,
25 ) -> Self {
26 Link {
27 from_node: from_node.to_string(),
28 to_node: to_node.to_string(),
29 route_id: route_id.to_string(),
30 travel_cost,
31 headway,
32 }
33 }
34}