Skip to content

Commit 88f2467

Browse files
Adding build failed fixes.
1 parent 58e322b commit 88f2467

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,8 @@ public static List<Integer> sort(Graph g) {
108108
Stack<Integer> stack = new Stack<>();
109109

110110
for (int i = 0; i < n; i++) {
111-
if (!visited[i]) {
112-
if (dfs(i, visited, recStack, adj, stack)) {
113-
throw new IllegalArgumentException("cycle detected in graph");
114-
}
111+
if (!visited[i] && dfs(i, visited, recStack, adj, stack)) {
112+
throw new IllegalArgumentException("cycle detected in graph");
115113
}
116114
}
117115

0 commit comments

Comments
 (0)