icentral_graph/
insert_edge_and_update_bc.rs

1crate::ix!();
2
3impl<GH> InsertEdgeUpdateBc for Graph<GH>
4where GH
5: GraphHashMucInterface
6+ ResetWith<GH>
7+ RemoveEdge
8+ CreateNamedEmpty
9+ FindSingleSourceShortestPaths
10+ GetNodeIdRange
11+ GetNeighborsForNode
12+ ParentsForNode
13+ InitDebugIteration
14+ DebugIterationStep
15+ FindPruningCounts
16+ HasEdge
17+ PathCountForNode
18+ PairDependencyForNode
19+ SetPairDependencyForNode
20+ SetSigmaValueForNode
21+ GetSigmaValueForNode
22+ BccGraphHashInterface
23
24{
25    // incremental bc with bcc stuff
26    //
27    fn insert_edge_update_bc_experimental(&mut self, 
28        edge:        &Edge,
29        bcc_stat:    &mut BiconnectedComponentsStat,
30        max_iter_d1: Option<usize>,
31        max_iter_d2: Option<usize>) 
32    -> Result<(),BetweennessCentralityError>  
33    {
34        /*
35         | 1. edge must be in the graph so that bcc
36         | extraction works properly
37         |
38         | 2. the subgraph in the bcc must not have
39         | the edge (done inside
40         | bcc_delta_t::compute_bc)
41         |
42         */
43        let mut tm: Timer = Timer::default();
44
45        self.insert_edge(&edge);
46
47        let bcc_name = name![self.name(), "insert_edge_update_bc_experimental::bcc"];
48
49        let mut bcc = BiconnectedComponentsDelta::empty(bcc_name);
50
51        tm.start();
52
53        self.find_edge_bcc_with_delta(&mut bcc,&edge);
54
55        tm.stop();
56
57        bcc_stat.bcc_num_nodes = bcc.bcc_subgraph_num_nodes();
58        bcc_stat.bcc_num_edges = bcc.bcc_subgraph_num_edges();
59
60        bcc_stat.bcc_find_time = tm.interval();
61
62        tm.start();
63
64        if max_iter_d1.is_some() || max_iter_d2.is_some() {
65
66            bcc.compute_bc_maxiter_exp(
67                &mut self.scores, 
68                edge.src, 
69                edge.dst, 
70                bcc_stat, 
71                max_iter_d1, 
72                max_iter_d2
73            );
74
75        } else {
76
77            bcc.compute_bc_exp(
78                &mut self.scores, 
79                edge.src, 
80                edge.dst, 
81                bcc_stat, 
82                max_iter_d1, 
83                max_iter_d2
84            );
85        }
86
87        tm.stop();
88
89        bcc_stat.bc_update_time = tm.interval();
90
91        bcc.bcc_subgraph_remove_edge(&edge);
92
93        let (d0,d1,d2) = bcc.bcc_subgraph_find_pruning_counts_exp(
94            edge.src, 
95            edge.dst, 
96        )?;
97
98        bcc_stat.tot_d0_iter = d0; 
99        bcc_stat.tot_d1_iter = d1; 
100        bcc_stat.tot_d2_iter = d2;
101
102        bcc.bcc_subgraph_insert_edge(&edge);
103
104        Ok(())
105    }
106}