icentral_graph/
create_and_push_new_muc.rs

1crate::ix!();
2
3impl<GH> CreateAndPushNewMuc for Graph<GH> 
4
5where GH
6: ExtendWith<GH,Error=BetweennessCentralityError> 
7+ GetConnectedComponentSizes 
8+ GetEdges
9+ GetNeighborsForNode
10+ GetNodeIdRange
11+ HasMapForNode
12+ InsertEdge
13+ InsertNode
14+ MappedNodes
15+ NumEdges
16+ NumNodes
17{
18    type Error = BetweennessCentralityError;
19
20    fn create_and_push_new_muc(
21        &mut self, 
22        shortest_path: &Vec<NodeId>,
23        edge:          &Edge, 
24        src_muc_id:    MinimumUnionCycleId,
25        dst_muc_id:    MinimumUnionCycleId)
26    -> Result<MinimumUnionCycleId,Self::Error>
27    {
28        debug!("we will create and push a new MUC");
29
30        let mut new_muc: MinimumUnionCycle<GH> = default!();
31
32        new_muc.set_id(self.mucs.len());
33
34        merge_mucs(
35            &mut self.nodes_to_mucs,
36            &mut new_muc, 
37            &mut self.mucs[dst_muc_id.val()]
38        );
39
40        merge_mucs(
41            &mut self.nodes_to_mucs,
42            &mut new_muc, 
43            &mut self.mucs[src_muc_id.val()]
44        );
45
46        for &node in shortest_path.iter() {
47
48            let node_muc_id: MinimumUnionCycleId = self.nodes_to_mucs.mucid_for_node(node);
49
50            if node_muc_id != new_muc.id() {
51
52                merge_mucs(
53                    &mut self.nodes_to_mucs,
54                    &mut new_muc, 
55                    &mut self.mucs[node_muc_id.val()]
56                );
57            }
58        }
59
60        new_muc.insert_edge(&edge);
61
62        let id = new_muc.id();
63
64        // cout << endl << endl;
65        // new_muc.muc_subgraph.print_graph();
66        //
67        self.mucs.push(new_muc);
68
69        Ok(id)
70    }
71}