Skip to content

Commit

Permalink
style: do not suppress serial
Browse files Browse the repository at this point in the history
  • Loading branch information
vil02 committed May 19, 2024
1 parent 5ee98ee commit 7247fbd
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
<arg>-Xlint:all</arg>
<arg>-Xlint:-auxiliaryclass</arg>
<arg>-Xlint:-rawtypes</arg>
<arg>-Xlint:-serial</arg>
<arg>-Xlint:-try</arg>
<arg>-Xlint:-unchecked</arg>
<arg>-Xlint:-lossy-conversions</arg>
Expand Down
9 changes: 1 addition & 8 deletions src/main/java/com/thealgorithms/sorts/TopologicalSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ public void addEdge(String label, String... next) {
}
}

static class BackEdgeException extends RuntimeException {

BackEdgeException(String backEdge) {
super("This graph contains a cycle. No linear ordering is possible. " + backEdge);
}
}

/*
* Depth First Search
*
Expand Down Expand Up @@ -131,7 +124,7 @@ private static String sort(Graph graph, Vertex u, LinkedList<String> list) {
*
* In many cases, we will not know u.f, but v.color denotes the type of edge
* */
throw new BackEdgeException("Back edge: " + u.label + " -> " + label);
throw new RuntimeException("This graph contains a cycle. No linear ordering is possible. Back edge: " + u.label + " -> " + label);
}
});
u.color = Color.BLACK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertIterableEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import com.thealgorithms.sorts.TopologicalSort.BackEdgeException;
import com.thealgorithms.sorts.TopologicalSort.Graph;
import java.util.LinkedList;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -55,7 +53,7 @@ public void failureTest() {
graph.addEdge("6", "2");
graph.addEdge("7", "");
graph.addEdge("8", "");
Exception exception = assertThrows(BackEdgeException.class, () -> TopologicalSort.sort(graph));
Exception exception = assertThrows(RuntimeException.class, () -> TopologicalSort.sort(graph));
String expected = "This graph contains a cycle. No linear ordering is possible. "
+ "Back edge: 6 -> 2";
assertEquals(exception.getMessage(), expected);
Expand Down

0 comments on commit 7247fbd

Please sign in to comment.