diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2017-10-08 22:39:59 -0300 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2017-10-08 22:39:59 -0300 |
| commit | c82e3b3b2de0633317ec8fc85925e91422820597 (patch) | |
| tree | 96567416ce23c5ce85601f9cedc3a94bb1c55cba /BJC-Utils2/src/main/java/bjc/utils/graph/Edge.java | |
| parent | b3ac1c8690c3e14c879913e5dcc03a5f5e14876e (diff) | |
Start splitting into maven modules
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.java | 112 |
1 files changed, 0 insertions, 112 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 deleted file mode 100644 index 0152e3d..0000000 --- a/BJC-Utils2/src/main/java/bjc/utils/graph/Edge.java +++ /dev/null @@ -1,112 +0,0 @@ -package bjc.utils.graph; - -/** - * An edge in a weighted graph - * - * @author ben - * - * @param <T> - * 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; - - /** - * Create a new edge with set parameters - * - * @param initial - * The initial node of the edge - * @param terminal - * The terminal node of the edge - * @param distance - * The distance between initial and terminal edge - */ - public Edge(final T initial, final T terminal, final int distance) { - if (initial == null) - throw new NullPointerException("Initial node must not be null"); - else if (terminal == null) throw new NullPointerException("Terminal node must not be null"); - - this.source = initial; - this.target = terminal; - this.distance = distance; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - else if (obj == null) - return false; - else if (getClass() != obj.getClass()) - return false; - else { - final 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 - * - * @return The distance between the initial and terminal nodes of this - * edge - */ - public int getDistance() { - return distance; - } - - /** - * Get the initial node of an edge - * - * @return The initial node of this edge - */ - public T getSource() { - return source; - } - - /** - * Get the target node of an edge - * - * @return The target node of this edge - */ - public T getTarget() { - return target; - } - - @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; - } - - @Override - public String toString() { - return " first vertex " + source + " to vertex " + target + " with distance: " + distance; - } -} |
