forked from jainaman224/Algo_Ds_Notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vertice.java
42 lines (33 loc) · 885 Bytes
/
Vertice.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
package kruskal;
import java.util.HashMap;
import java.util.Objects;
public class Vertice {
private final Integer id;
private final HashMap<Integer, Vertice> ways;
public Vertice(Integer id) {
this.id = id;
ways = new HashMap<>();
}
public Integer getId() {
return id;
}
public void link(Vertice v) {
if (!ways.containsKey(v.getId())) {
ways.put(v.getId(), v);
}
}
public HashMap<Integer, Vertice> getDifferentWays() {
return ways;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Vertice other = (Vertice) obj;
return Objects.equals(this.id, other.id);
}
}