From 27bf571d6413c3cc6a5d664b5bddd38d21d7b1cd Mon Sep 17 00:00:00 2001 From: EVE Date: Mon, 13 Mar 2017 16:42:21 -0400 Subject: Formatting --- .../main/java/bjc/utils/graph/AdjacencyMap.java | 48 +++++++++------------- 1 file changed, 19 insertions(+), 29 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/graph/AdjacencyMap.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/graph/AdjacencyMap.java b/BJC-Utils2/src/main/java/bjc/utils/graph/AdjacencyMap.java index c04aa23..5640ab6 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/graph/AdjacencyMap.java +++ b/BJC-Utils2/src/main/java/bjc/utils/graph/AdjacencyMap.java @@ -20,20 +20,19 @@ import bjc.utils.funcutils.FuncUtils; * @author ben * * @param - * The type of the nodes in the graph + * The type of the nodes in the graph */ public class AdjacencyMap { /** * Create an adjacency map from a stream of text * * @param stream - * The stream of text to read in + * The stream of text to read in * @return An adjacency map defined by the text */ public static AdjacencyMap fromStream(InputStream stream) { if (stream == null) { - throw new NullPointerException( - "Input source must not be null"); + throw new NullPointerException("Input source must not be null"); } // Create the adjacency map @@ -51,8 +50,7 @@ public class AdjacencyMap { vertexCount = Integer.parseInt(possible); } catch (NumberFormatException nfex) { InputMismatchException imex = new InputMismatchException( - "The first line must contain the number of vertices. " - + possible + "The first line must contain the number of vertices. " + possible + " is not a valid number"); imex.initCause(nfex); @@ -61,8 +59,7 @@ public class AdjacencyMap { } if (vertexCount <= 0) { - throw new InputMismatchException( - "The number of vertices must be greater than 0"); + throw new InputMismatchException("The number of vertices must be greater than 0"); } IList vertices = new FunctionalList<>(); @@ -81,14 +78,12 @@ public class AdjacencyMap { return adjacency; } - private static void readRow(AdjacencyMap adjacency, - int vertexCount, IHolder row, String strang) { + private static void readRow(AdjacencyMap adjacency, int vertexCount, IHolder row, + String strang) { String[] parts = strang.split(" "); if (parts.length != vertexCount) { - throw new InputMismatchException( - "Must specify a weight for all " + vertexCount - + " vertices"); + throw new InputMismatchException("Must specify a weight for all " + vertexCount + " vertices"); } int column = 0; @@ -124,7 +119,7 @@ public class AdjacencyMap { * Create a new map from a set of vertices * * @param vertices - * The set of vertices to create a map from + * The set of vertices to create a map from */ public AdjacencyMap(IList vertices) { if (vertices == null) { @@ -167,27 +162,23 @@ public class AdjacencyMap { * Set the weight of an edge * * @param source - * The source node of the edge + * The source node of the edge * @param target - * The target node of the edge + * The target node of the edge * @param weight - * The weight of the edge + * The weight of the edge */ public void setWeight(T source, T target, int weight) { if (source == null) { - throw new NullPointerException( - "Source vertex must not be null"); - } else if (target== null) { - throw new NullPointerException( - "Target vertex must not be null"); + throw new NullPointerException("Source vertex must not be null"); + } else if (target == null) { + throw new NullPointerException("Target vertex must not be null"); } if (!adjacency.containsKey(source)) { - throw new IllegalArgumentException("Source vertex " - + source + " isn't present in map"); + throw new IllegalArgumentException("Source vertex " + source + " isn't present in map"); } else if (!adjacency.containsKey(target)) { - throw new IllegalArgumentException("Target vertex " - + target+ " isn't present in map"); + throw new IllegalArgumentException("Target vertex " + target + " isn't present in map"); } adjacency.get(source).put(target, weight); @@ -214,12 +205,11 @@ public class AdjacencyMap { * Convert an adjacency map back into a stream * * @param sink - * The stream to convert to + * The stream to convert to */ public void toStream(OutputStream sink) { if (sink == null) { - throw new NullPointerException( - "Output source must not be null"); + throw new NullPointerException("Output source must not be null"); } PrintStream outputPrinter = new PrintStream(sink); -- cgit v1.2.3