Skip to content

Commit 6298350

Browse files
committed
fix: resolve SpotBugs in Yens algorithm
1 parent 434848f commit 6298350

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/main/java/com/thealgorithms/graph/YensKShortestPaths.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ public static List<List<Integer>> kShortestPaths(int[][] weights, int src, int d
8787
long totalCost = rootCost + spurPath.cost; // spurPath.cost covers from spurNode to dst
8888
Path candidate = new Path(totalNodes, totalCost);
8989
String key = candidate.key();
90-
if (!seen.contains(key)) {
90+
if (seen.add(key)) {
9191
b.add(candidate);
92-
seen.add(key);
9392
}
9493
}
9594
}

0 commit comments

Comments
 (0)