icentral_graph/
connected_component_size.rs

1crate::ix!();
2
3impl<GH> ConnectedComponentSize for Graph<GH> {
4
5    /// do a dfs from this guy to figure out the
6    /// size of the connected component connected
7    /// to the bcc through v and this edge
8    ///
9    fn connected_component_size_through_v_and_this_edge(
10        &self, 
11        visit_markers: &mut VisitMarkers, 
12        u:             NodeId) -> usize 
13    {
14        let mut cnt: usize = 0;
15
16        let mut stack: Stack<NodeId> = default!();
17
18        stack.push(u);
19
20        visit_markers.visit(u);
21
22        while let Some(vv) = stack.pop() {
23
24            cnt += 1;
25
26            let nbr_vec = self.neighbors(vv);
27
28            for &nbr in nbr_vec.iter() {
29
30                if visit_markers.unvisited(nbr) {
31
32                    visit_markers.visit(nbr);
33
34                    stack.push(nbr);
35                }
36            }
37        }
38
39        cnt
40    }
41}