aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2025-05-01 12:13:03 +0200
committerJonas Smedegaard <dr@jones.dk>2025-05-01 12:13:03 +0200
commit55f662bc7e9f7773ff5e7626d2642c61981f5c1c (patch)
treedd0e370a28281784bbf3539178a9444d013f9cb3
parent4aae69d885e99867af822a22202435954b5cba93 (diff)
internalize utility function assertConnected(), i.e. make it a method
-rw-r--r--src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java
index 5131b83..a7689f8 100644
--- a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java
+++ b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java
@@ -88,7 +88,7 @@ public final class Graph extends Storage {
GraphAlgorithms.readGraph(g, path);
}
- /// utility function to check that a graph is connected
+ /// check that a graph is connected
///
/// If check fails, throw an unchecked exception,
/// since it occurs at runtime and is unrecoverable.
@@ -97,10 +97,9 @@ public final class Graph extends Storage {
/// where n is the amount of vertices,
/// since visitDepthFirst() recurses out-edges of all vertices.
///
- /// @param g Graph to inspect
/// @throws IllegalArgumentException
/// https://docs.oracle.com/javase/tutorial/essential/exceptions/runtime.html
- public static void assertConnected(final AbstractGraph g) {
+ public void assertConnected() {
// collect all vertices in the graph
Collection<Vertex> c = g.vertices();
@@ -294,7 +293,7 @@ public final class Graph extends Storage {
GraphAlgorithms.printGraph(g);
// ensure the graph is connected
- assertConnected(g);
+ assertConnected();
System.out.println(
"\n\nGraph is connected"
+ " (otherwise an exception was thrown)");