diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-22 14:48:04 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-22 14:48:04 -0400 |
| commit | 42f7d379a430aaf2fad169f0170de04072b08b10 (patch) | |
| tree | 5d46b43b2d9272f4e593820ee147b3ae3f0d82b0 /BJC-Utils2/src/main/java/bjc/utils/graph | |
| parent | b65b705c391bb772bc41269bce5243c1cc88969d (diff) | |
Formatting changes
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/graph')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/graph/Edge.java | 80 | ||||
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/graph/Graph.java | 42 |
2 files changed, 61 insertions, 61 deletions
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<T> { 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<T> { 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<T> { 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 @@ -26,6 +26,27 @@ import bjc.utils.funcdata.IFunctionalMap; */ public class Graph<T> { /** + * Create a graph from a list of edges + * + * @param <E> + * 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 <E> Graph<E> fromEdgeList(List<Edge<E>> edges) { + Graph<E> g = new Graph<>(); + + edges.forEach(edge -> { + g.addEdge(edge.getSource(), edge.getTarget(), + edge.getDistance(), true); + }); + + return g; + } + + /** * The backing representation of the graph */ private final IFunctionalMap<T, IFunctionalMap<T, Integer>> backingGraph; @@ -265,25 +286,4 @@ public class Graph<T> { return adjacencyMap; } - - /** - * Create a graph from a list of edges - * - * @param <E> - * 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 <E> Graph<E> fromEdgeList(List<Edge<E>> edges) { - Graph<E> g = new Graph<>(); - - edges.forEach(edge -> { - g.addEdge(edge.getSource(), edge.getTarget(), - edge.getDistance(), true); - }); - - return g; - } } |
