forked from jainaman224/Algo_Ds_Notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Arista.java
49 lines (40 loc) · 1.03 KB
/
Arista.java
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package kruskal;
public class Arista implements Comparable<Arista> {
private final Integer u;
private final Integer v;
public int getU() {
return u;
}
public int getV() {
return v;
}
private final int weight;
public Arista(int a, int b, int peso) {
this.u = a;
this.v = b;
this.weight = peso;
}
public int getPeso() {
return this.weight;
}
@Override
public int compareTo(Arista o) {
if (this.weight == o.weight) {
return 0;
}
return this.weight - o.weight;
}
@Override
public boolean equals(Object arista) {
if (!(arista instanceof Arista)) {
return false;
}
Arista o = (Arista) arista;
if (this.getU() == o.getU() && this.getV() == o.getV()) {
return true;
} else if (this.getU() == o.getV() && this.getV() == o.getU()) {
return true;
}
return false;
}
}