Skip to main content

Link

Struct Link 

Source
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: String

Source node of the link

§to_node: String

Target node of the link

§route_id: String

Corresponding route

§travel_cost: f64

Travel time along the link (in minutes or any consistent unit)

§headway: f64

Service headway. Boarding links have headway > 0 (frequency = 1/headway). On-board (riding) links have headway = 0 (no waiting).

Implementations§

Source

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>> =
24        HashMap::from([("A".to_string(), HashMap::from([("B".to_string(), 1.0)]))]);
25    let res = compute_sf(&all_links, &all_nodes, destination_node, &od_matrix);
26    println!("Optimal strategy:");
27    println!("\tNode labels:");
28    for (node_id, node_label) in &res.strategy.labels {
29        println!("\t\tu_{{i}} = {}: {:.6}", node_id, node_label);
30    }
31    println!("\tNodes probablities:");
32    for (node_id, freq) in &res.strategy.freqs {
33        println!("\t\tf_{{i}} = {}: {:.6}", node_id, freq);
34    }
35    println!("\tAttractive links set:");
36    for link in &res.strategy.a_set {
37        println!("\t\t a = (i, j) = ({}, {})", link.from_node, link.to_node);
38    }
39    println!("Volumes:");
40    println!("\tLinks volumes:");
41    for (from_node, to_map) in &res.volumes.links {
42        for (to_node, volume) in to_map {
43            println!(
44                "\t\tv_{{i, j}} = ({}, {}): {:.6}",
45                from_node, to_node, volume
46            );
47        }
48    }
49    println!("\tNodes volumes:");
50    for (node_id, volume) in &res.volumes.nodes {
51        println!("\t\tv_{{i}} = {}: {:.6}", node_id, volume);
52    }
53}

Trait Implementations§

Source§

fn clone(&self) -> Link

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

fn eq(&self, other: &Link) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.