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

Method new

src/graph/undirected/cycle.rs:17–33  ·  view source on GitHub ↗
(g: &dyn IGraph)

Source from the content-addressed store, hash-verified

15
16impl Cycle {
17 pub fn new(g: &dyn IGraph) -> Self {
18 let mut cycle = Self {
19 marked: vec![false; g.V()],
20 cycle: None,
21 edge_to: vec![0; g.V()],
22 };
23
24 if !cycle.has_parallel_edges(g) {
25 for s in 0..g.V() {
26 if !cycle.marked[s] {
27 cycle.dfs(g, s, s);
28 }
29 }
30 }
31
32 cycle
33 }
34
35 /// Returns true if the graph G has a cycle.
36 pub fn has_cycle(&self) -> bool {

Callers

nothing calls this directly

Calls 3

has_parallel_edgesMethod · 0.80
VMethod · 0.45
dfsMethod · 0.45

Tested by

no test coverage detected