icentral_graph/
approx_brandes_iteration_runtime_on_bcc_subgraph.rs

1crate::ix!();
2
3impl<GH> ApproxBrandesIterationRuntimeOnBccSubgraph for Graph<GH> 
4
5where GH
6: CreateNamedEmpty
7+ DebugIterationStep 
8+ FindPruningCounts 
9+ GetEdges 
10+ GetNeighborsForNode 
11+ GetNodeIdRange
12+ GetSigmaValueForNode
13+ HasEdge
14+ InitDebugIteration
15+ InsertEdge
16+ MappedNodes
17+ NumEdges
18+ NumNodes
19+ PairDependencyForNode
20+ ParentsForNode
21+ RemoveEdge
22+ BccGraphHashInterface
23{
24
25    /**
26      | approximates the runtime of Brandes
27      | iteration on a bcc subgraph by doing
28      | @num_iter iteration and taking the average
29      | if @num_iter is -1 the number of iteration
30      | is just going to be the number of nodes in
31      | the graph
32      |
33      */
34    fn approx_bcc_iter_tm(&mut self, 
35        src:           NodeId,
36        dst:           NodeId,
37        avg_iter_time: &mut Duration,
38        num_iter:      Option<usize>) 
39    -> Result<(),BetweennessCentralityError> 
40    {
41        let mut tm: Timer = Timer::default();
42
43        let bcc_name = name![self.name(), "approx_bcc_iter_tm::bcc"];
44
45        let mut bcc = BiconnectedComponentsScratch::empty(bcc_name);
46
47        let num_iter = num_iter.unwrap_or(bcc.bcc_subgraph_num_nodes());
48
49        self.find_edge_bcc_with_scratch(&mut bcc, &Edge::new(src,dst));
50
51        let scores_name = name![self.name(), "approx_bcc_iter_tm::scores"];
52
53        let mut scores = BetweennessScores::new_from_nodeids(
54            bcc.bcc_subgraph_mapped_nodes(),
55            scores_name
56        );
57
58        tm.start();
59
60        bcc.compute_bc(&mut scores, Some(num_iter));
61
62        tm.stop();
63
64        *avg_iter_time = tm.interval() / num_iter as u32;
65
66        Ok(())
67    }
68}