-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEdge.java
More file actions
35 lines (30 loc) · 762 Bytes
/
Edge.java
File metadata and controls
35 lines (30 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
public class Edge {
public double distance;
public Vertex source;
public Vertex target;
public Edge(Vertex vertex1, Vertex vertex2, double weight) {
source = vertex1;
target = vertex2;
this.distance = weight;
}
public String toString() {
return source + " - " + target;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null) {
return false;
}
if (!(o instanceof Edge)) {
return false;
}
Edge oEdge = (Edge) o;
return (source.equals(oEdge.source) && target.equals(oEdge.target)
&& distance == oEdge.distance)
|| (source.equals(oEdge.target) && target.equals(oEdge.source)
&& distance == oEdge.distance);
}
}