diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml index 8d8052869..0a5354382 100644 --- a/spotbugs-exclude.xml +++ b/spotbugs-exclude.xml @@ -222,9 +222,6 @@ - - - diff --git a/src/main/java/com/thealgorithms/datastructures/graphs/ConnectedComponent.java b/src/main/java/com/thealgorithms/datastructures/graphs/ConnectedComponent.java index d2b76e8e0..520a16817 100644 --- a/src/main/java/com/thealgorithms/datastructures/graphs/ConnectedComponent.java +++ b/src/main/java/com/thealgorithms/datastructures/graphs/ConnectedComponent.java @@ -81,8 +81,7 @@ class Graph> { Set markedNodes = new HashSet(); for (Node n : nodeList) { - if (!markedNodes.contains(n)) { - markedNodes.add(n); + if (markedNodes.add(n)) { markedNodes.addAll(depthFirstSearch(n, new ArrayList())); count++; }