MCPcopy Create free account
hub / github.com/douchuan/algorithm / new

Method new

src/graph/undirected/cc.rs:29–45  ·  view source on GitHub ↗
(g: &dyn IGraph)

Source from the content-addressed store, hash-verified

27
28impl CC {
29 pub fn new(g: &dyn IGraph) -> Self {
30 let mut cc = Self {
31 count: 0,
32 marked: vec![false; g.V()],
33 id: vec![0; g.V()],
34 size: vec![0; g.V()],
35 };
36
37 for v in 0..g.V() {
38 if !cc.marked[v] {
39 cc.dfs(g, v);
40 cc.count += 1;
41 }
42 }
43
44 cc
45 }
46
47 /// are v and w connected?
48 pub fn connected(&self, v: usize, w: usize) -> bool {

Callers

nothing calls this directly

Calls 2

VMethod · 0.45
dfsMethod · 0.45

Tested by

no test coverage detected