pub struct Link {
pub from_node: String,
pub to_node: String,
pub route_id: String,
pub travel_cost: f64,
pub headway: f64,
}Expand description
Link is an edge in the transit network graph.
Fields§
§from_node: StringSource node of the link
to_node: StringTarget node of the link
route_id: StringCorresponding route
travel_cost: f64Travel time along the link (in minutes or any consistent unit)
headway: f64Service headway. Boarding links have headway > 0 (frequency = 1/headway). On-board (riding) links have headway = 0 (no waiting).
Implementations§
Source§impl Link
impl Link
Sourcepub fn new(
from_node: &str,
to_node: &str,
route_id: &str,
travel_cost: f64,
headway: f64,
) -> Self
pub fn new( from_node: &str, to_node: &str, route_id: &str, travel_cost: f64, headway: f64, ) -> Self
Convenience constructor
Examples found in repository?
examples/paper/main.rs (line 11)
5fn main() {
6 let all_nodes: HashSet<String> = ["A", "X", "X2", "Y", "Y3", "B"]
7 .iter()
8 .map(|s| s.to_string())
9 .collect();
10 let all_links = vec![
11 Link::new("A", "B", "Line 1", 25.0, 6.0),
12 Link::new("A", "X2", "Line 2", 7.0, 6.0),
13 Link::new("X2", "X", "Line 2", 0.0, 0.0),
14 Link::new("X", "X2", "Line 2", 0.0, 6.0),
15 Link::new("X2", "Y", "Line 2", 6.0, 0.0),
16 Link::new("Y3", "Y", "Line 3", 0.0, 15.0),
17 Link::new("Y", "B", "Line 4", 10.0, 3.0),
18 Link::new("X", "Y3", "Line 3", 4.0, 15.0),
19 Link::new("Y", "Y3", "Line 3", 0.0, 15.0),
20 Link::new("Y3", "B", "Line 3", 4.0, 0.0),
21 ];
22 let destination_node = "B";
23 let od_matrix: HashMap<String, HashMap<String, f64>> = HashMap::from([(
24 "A".to_string(),
25 HashMap::from([("B".to_string(), 1.0)]),
26 )]);
27 let res = compute_sf(&all_links, &all_nodes, destination_node, &od_matrix);
28 println!("Optimal strategy:");
29 println!("\tNode labels:");
30 for (node_id, node_label) in &res.strategy.labels {
31 println!("\t\tu_{{i}} = {}: {:.6}", node_id, node_label);
32 }
33 println!("\tNodes probablities:");
34 for (node_id, freq) in &res.strategy.freqs {
35 println!("\t\tf_{{i}} = {}: {:.6}", node_id, freq);
36 }
37 println!("\tAttractive links set:");
38 for link in &res.strategy.a_set {
39 println!("\t\t a = (i, j) = ({}, {})", link.from_node, link.to_node);
40 }
41 println!("Volumes:");
42 println!("\tLinks volumes:");
43 for (from_node, to_map) in &res.volumes.links {
44 for (to_node, volume) in to_map {
45 println!("\t\tv_{{i, j}} = ({}, {}): {:.6}", from_node, to_node, volume);
46 }
47 }
48 println!("\tNodes volumes:");
49 for (node_id, volume) in &res.volumes.nodes {
50 println!("\t\tv_{{i}} = {}: {:.6}", node_id, volume);
51 }
52}Trait Implementations§
impl StructuralPartialEq for Link
Auto Trait Implementations§
impl Freeze for Link
impl RefUnwindSafe for Link
impl Send for Link
impl Sync for Link
impl Unpin for Link
impl UnsafeUnpin for Link
impl UnwindSafe for Link
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more