summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/graph/Edge.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2017-02-09 11:50:31 -0500
committerbculkin2442 <bjculkin@mix.wvu.edu>2017-02-09 11:50:31 -0500
commitd2af58b0f68ebfbba2be7e7679efec6c8c0af12f (patch)
tree2b16fbf014db350126e8c1b5f081312276f85f62 /BJC-Utils2/src/main/java/bjc/utils/graph/Edge.java
parent187e1815488e3c1ed22e7592f304e632cffefb82 (diff)
Update
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/graph/Edge.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/graph/Edge.java32
1 files changed, 12 insertions, 20 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 fa34083..2ad4132 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/graph/Edge.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/graph/Edge.java
@@ -9,12 +9,12 @@ package bjc.utils.graph;
* The type of the nodes in the graph
*/
public class Edge<T> {
- /**
+ /*
* The distance from initial to terminal node
*/
private final int distance;
- /**
+ /*
* The initial and terminal nodes of this edge
*/
private final T source, target;
@@ -22,32 +22,27 @@ public class Edge<T> {
/**
* Create a new edge with set parameters
*
- * @param initialNode
+ * @param initial
* The initial node of the edge
- * @param terminalNode
+ * @param terminal
* The terminal node of the edge
* @param distance
* The distance between initial and terminal edge
*/
- public Edge(T initialNode, T terminalNode, int distance) {
- if (initialNode == null) {
+ public Edge(T initial, T terminal, int distance) {
+ if (initial == null) {
throw new NullPointerException(
"Initial node must not be null");
- } else if (terminalNode == null) {
+ } else if (terminal == null) {
throw new NullPointerException(
"Terminal node must not be null");
}
- this.source = initialNode;
- this.target = terminalNode;
+ this.source = initial;
+ this.target = terminal;
this.distance = distance;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -57,7 +52,6 @@ public class Edge<T> {
} else if (getClass() != obj.getClass()) {
return false;
} else {
-
Edge<?> other = (Edge<?>) obj;
if (distance != other.distance) {
@@ -108,20 +102,18 @@ public class Edge<T> {
return target;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {
final int prime = 31;
+
int result = 1;
+
result = prime * result + distance;
result = prime * result
+ ((source == null) ? 0 : source.hashCode());
result = prime * result
+ ((target == null) ? 0 : target.hashCode());
+
return result;
}