Commit 9c3f8871 authored by Ranadeep Biswas's avatar Ranadeep Biswas
Browse files

fixed cycle detection

parent 64820825
......@@ -52,7 +52,7 @@ where
fn dfs_util_reach(&self, s: &T, u: &T, reachable: &mut HashSet<T>) -> bool {
if let Some(vs) = self.adj_map.get(u) {
for &v in vs.iter() {
if reachable.insert(v) && self.dfs_util_reach(s, &v, reachable) {
if &v == s || (reachable.insert(v) && self.dfs_util_reach(s, &v, reachable)) {
return true;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment