mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-10 21:43:15 +08:00
style: do not suppress serial
(#5168)
This commit is contained in:
1
pom.xml
1
pom.xml
@ -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>
|
||||
|
@ -73,13 +73,6 @@ public final class TopologicalSort {
|
||||
}
|
||||
}
|
||||
|
||||
static class BackEdgeException extends RuntimeException {
|
||||
|
||||
BackEdgeException(String backEdge) {
|
||||
super("This graph contains a cycle. No linear ordering is possible. " + backEdge);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Depth First Search
|
||||
*
|
||||
@ -131,7 +124,7 @@ public final class TopologicalSort {
|
||||
*
|
||||
* 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;
|
||||
|
@ -4,7 +4,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;
|
||||
@ -55,7 +54,7 @@ class TopologicalSortTest {
|
||||
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);
|
||||
|
Reference in New Issue
Block a user