From 45c2308605c90579e050b41cd367a3aa57503a19 Mon Sep 17 00:00:00 2001 From: vil02 Date: Sat, 8 Jun 2024 20:48:19 +0200 Subject: [PATCH] style: include `SUI_CONTAINS_BEFORE_ADD` --- spotbugs-exclude.xml | 3 --- .../datastructures/graphs/ConnectedComponent.java | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml index 8d80528696c0..0a5354382a4f 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 d2b76e8e06b1..520a1681774a 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 @@ public int countGraphs() { 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++; }