icentral_graph/
read_graph.rs1crate::ix!();
2
3impl<GH> ReadGraph for Graph<GH>
4where GH: BccGraphHashInterface
5{
6 type Error = BetweennessCentralityError;
7
8 fn read_graph(&mut self, path: &str)
16 -> Result<(),Self::Error>
17 {
18 debug!("reading graph from filename: {}", path);
19
20 let fin = File::open(path)?;
21
22 let mut bytes = fin.bytes().map(|ch| ch.unwrap());
23
24 let n: usize = read!("{} ",bytes);
25 let m: usize = read!("{}",bytes);
26
27 self.init_size(n);
28
29 for i in 0..m {
30
31 let src: usize = read!("{} ",bytes);
32 let dst: usize = read!("{}",bytes);
33
34 self.insert_edge(&Edge::new_with_ids(src,dst))?;
35 }
36
37 self.init_internals()?;
38
39 debug!("finished reading graph from file:\n{:#?}", self);
40
41 Ok(())
42 }
43}