Skip to content

Commit 87052f1

Browse files
committed
style: do not suppress serial
1 parent 5ee98ee commit 87052f1

File tree

3 files changed

+2
-11
lines changed

3 files changed

+2
-11
lines changed

pom.xml

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
<arg>-Xlint:all</arg>
8080
<arg>-Xlint:-auxiliaryclass</arg>
8181
<arg>-Xlint:-rawtypes</arg>
82-
<arg>-Xlint:-serial</arg>
8382
<arg>-Xlint:-try</arg>
8483
<arg>-Xlint:-unchecked</arg>
8584
<arg>-Xlint:-lossy-conversions</arg>

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

+1-8
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@ public void addEdge(String label, String... next) {
7373
}
7474
}
7575

76-
static class BackEdgeException extends RuntimeException {
77-
78-
BackEdgeException(String backEdge) {
79-
super("This graph contains a cycle. No linear ordering is possible. " + backEdge);
80-
}
81-
}
82-
8376
/*
8477
* Depth First Search
8578
*
@@ -131,7 +124,7 @@ private static String sort(Graph graph, Vertex u, LinkedList<String> list) {
131124
*
132125
* In many cases, we will not know u.f, but v.color denotes the type of edge
133126
* */
134-
throw new BackEdgeException("Back edge: " + u.label + " -> " + label);
127+
throw new RuntimeException("This graph contains a cycle. No linear ordering is possible. Back edge: " + u.label + " -> " + label);
135128
}
136129
});
137130
u.color = Color.BLACK;

src/test/java/com/thealgorithms/sorts/TopologicalSortTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import static org.junit.jupiter.api.Assertions.assertIterableEquals;
55
import static org.junit.jupiter.api.Assertions.assertThrows;
66

7-
import com.thealgorithms.sorts.TopologicalSort.BackEdgeException;
87
import com.thealgorithms.sorts.TopologicalSort.Graph;
98
import java.util.LinkedList;
109
import org.junit.jupiter.api.Test;
@@ -55,7 +54,7 @@ public void failureTest() {
5554
graph.addEdge("6", "2");
5655
graph.addEdge("7", "");
5756
graph.addEdge("8", "");
58-
Exception exception = assertThrows(BackEdgeException.class, () -> TopologicalSort.sort(graph));
57+
Exception exception = assertThrows(RuntimeException.class, () -> TopologicalSort.sort(graph));
5958
String expected = "This graph contains a cycle. No linear ordering is possible. "
6059
+ "Back edge: 6 -> 2";
6160
assertEquals(exception.getMessage(), expected);

0 commit comments

Comments
 (0)