c0dbaf7b577faceac53b68e8bf778a57c370b325
[Mitarbeiter/Tim-Zeitz/stud-rust-base.git] / src / bin / example.rs
1 extern crate stud_rust_base;
2
3 use stud_rust_base::{
4     types::*,
5     io::*,
6     time::report_time,
7 };
8
9 use std::{env, path::Path};
10
11 fn main() {
12     let mut args = env::args();
13     args.next();
14
15     let arg = &args.next().expect("No directory arg given");
16     let path = Path::new(arg);
17
18     let first_out = Vec::<EdgeId>::load_from(path.join("first_out").to_str().unwrap()).expect("could not read first_out");
19     let head = Vec::<NodeId>::load_from(path.join("head").to_str().unwrap()).expect("could not read head");
20     let travel_time = Vec::<Weight>::load_from(path.join("travel_time").to_str().unwrap()).expect("could not read travel_time");
21
22     report_time("iterating over arcs of some node", || {
23         let node_id = 42;
24         for edge_id in first_out[node_id] .. first_out[node_id + 1] {
25             println!("There is an arc from {} to {} with weight {}", node_id, head[edge_id as usize], travel_time[edge_id as usize]);
26         }
27     });
28
29     vec![42; 42].write_to(path.join("distances").to_str().unwrap()).expect("could not write distances");
30 }