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

Method new

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

Source from the content-addressed store, hash-verified

27
28impl Bipartite {
29 pub fn new(g: &dyn IGraph) -> Self {
30 let mut tc = Self {
31 marked: vec![false; g.V()],
32 color: vec![false; g.V()],
33 edge_to: vec![0; g.V()],
34 cycle: None,
35 is_bipartite: true,
36 };
37
38 for s in 0..g.V() {
39 if !tc.marked[s] {
40 tc.dfs(g, s);
41 }
42 }
43
44 tc
45 }
46
47 pub fn is_bipartite(&self) -> bool {
48 self.is_bipartite

Callers

nothing calls this directly

Calls 2

VMethod · 0.45
dfsMethod · 0.45

Tested by

no test coverage detected