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

Method has_parallel_edges

src/graph/undirected/cycle.rs:73–94  ·  view source on GitHub ↗

does this graph have two parallel edges?

(&mut self, graph: &dyn IGraph)

Source from the content-addressed store, hash-verified

71
72 // does this graph have two parallel edges?
73 fn has_parallel_edges(&mut self, graph: &dyn IGraph) -> bool {
74 self.marked.fill(false);
75
76 for v in 0..graph.V() {
77 for &w in graph.adj(v) {
78 if self.marked[w] {
79 let mut cycle = Stack::default();
80 cycle.push(v);
81 cycle.push(w);
82 cycle.push(v);
83 self.cycle = Some(cycle);
84 return true;
85 }
86 self.marked[w] = true;
87 }
88
89 // reset so marked[v] = false for all v
90 self.marked.fill(false);
91 }
92
93 false
94 }
95}

Callers 1

newMethod · 0.80

Calls 3

pushMethod · 0.80
VMethod · 0.45
adjMethod · 0.45

Tested by

no test coverage detected