From 42f7d379a430aaf2fad169f0170de04072b08b10 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Fri, 22 Apr 2016 14:48:04 -0400 Subject: Formatting changes --- BJC-Utils2/src/main/java/bjc/utils/graph/Edge.java | 80 +++++++++++----------- .../src/main/java/bjc/utils/graph/Graph.java | 42 ++++++------ 2 files changed, 61 insertions(+), 61 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/graph') diff --git a/BJC-Utils2/src/main/java/bjc/utils/graph/Edge.java b/BJC-Utils2/src/main/java/bjc/utils/graph/Edge.java index 58a233a..fa34083 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/graph/Edge.java +++ b/BJC-Utils2/src/main/java/bjc/utils/graph/Edge.java @@ -43,6 +43,43 @@ public class Edge { this.distance = distance; } + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } else if (obj == null) { + return false; + } else if (getClass() != obj.getClass()) { + return false; + } else { + + Edge other = (Edge) obj; + + if (distance != other.distance) { + return false; + } else if (source == null) { + if (other.source != null) { + return false; + } + } else if (!source.equals(other.source)) { + return false; + } else if (target == null) { + if (other.target != null) { + return false; + } + } else if (!target.equals(other.target)) { + return false; + } + + return true; + } + } + /** * Get the distance in this edge * @@ -71,12 +108,6 @@ public class Edge { return target; } - @Override - public String toString() { - return " first vertex " + source + " to vertex " + target - + " with distance: " + distance; - } - /* * (non-Javadoc) * @@ -94,40 +125,9 @@ public class Edge { return result; } - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else if (obj == null) { - return false; - } else if (getClass() != obj.getClass()) { - return false; - } else { - - Edge other = (Edge) obj; - - if (distance != other.distance) { - return false; - } else if (source == null) { - if (other.source != null) { - return false; - } - } else if (!source.equals(other.source)) { - return false; - } else if (target == null) { - if (other.target != null) { - return false; - } - } else if (!target.equals(other.target)) { - return false; - } - - return true; - } + public String toString() { + return " first vertex " + source + " to vertex " + target + + " with distance: " + distance; } } diff --git a/BJC-Utils2/src/main/java/bjc/utils/graph/Graph.java b/BJC-Utils2/src/main/java/bjc/utils/graph/Graph.java index fbaf3f6..0574325 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/graph/Graph.java +++ b/BJC-Utils2/src/main/java/bjc/utils/graph/Graph.java @@ -25,6 +25,27 @@ import bjc.utils.funcdata.IFunctionalMap; * The label for vertices */ public class Graph { + /** + * Create a graph from a list of edges + * + * @param + * The type of data stored in the edges + * + * @param edges + * The list of edges to build from + * @return A graph built from the provided edge-list + */ + public static Graph fromEdgeList(List> edges) { + Graph g = new Graph<>(); + + edges.forEach(edge -> { + g.addEdge(edge.getSource(), edge.getTarget(), + edge.getDistance(), true); + }); + + return g; + } + /** * The backing representation of the graph */ @@ -265,25 +286,4 @@ public class Graph { return adjacencyMap; } - - /** - * Create a graph from a list of edges - * - * @param - * The type of data stored in the edges - * - * @param edges - * The list of edges to build from - * @return A graph built from the provided edge-list - */ - public static Graph fromEdgeList(List> edges) { - Graph g = new Graph<>(); - - edges.forEach(edge -> { - g.addEdge(edge.getSource(), edge.getTarget(), - edge.getDistance(), true); - }); - - return g; - } } -- cgit v1.2.3