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