forked from jainaman224/Algo_Ds_Notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VerticesSet.java
42 lines (31 loc) · 911 Bytes
/
VerticesSet.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;
public class VerticesSet {
final private HashMap<Integer, Vertice> conjunto;
public VerticesSet() {
this.conjunto = new HashMap<>();
}
public void addVertice(Vertice v) {
if (v == null) {
return;
}
if (!conjunto.containsKey(v.getId())) {
conjunto.put(v.getId(), v);
}
}
public boolean esConexo() {
return new ConnectionStructure(conjunto).isCompletelyConnected();
}
public boolean contains(Vertice v) {
return conjunto.containsValue(v);
}
public void enlaza(Vertice a, Vertice aAñadir) {
conjunto.get(a.getId()).link(aAñadir);
}
public int size() {
return this.conjunto.size();
}
public Vertice getVertice(Integer id) {
return conjunto.get(id);
}
}