-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStructure4.java
More file actions
48 lines (36 loc) · 871 Bytes
/
Copy pathStructure4.java
File metadata and controls
48 lines (36 loc) · 871 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
36
37
38
39
40
41
42
43
44
45
46
47
48
public class Structure4 extends Structure3_4 {
private int C; // coût max d'une arête
public void initialiser(int n, int C) {
paquets = new Liste[C+1];
sommets = new ElementListe[n];
this.C = C;
for (int i = 0 ; i<C+1 ; i++) {
paquets[i] = new Liste();
}
for (int i = 0 ; i<n ; i++) {
sommets[i] = null;
}
}
public boolean estVide() {
if (paquets.length < sommets.length) {
for (int i = 0 ; i<paquets.length ; i++) {
if (!paquets[i].estVide()) {
return false;
}
}
return true;
} else {
for (int i = 0 ; i<sommets.length ; i++) {
if (sommets[i] != null) {
return false;
}
}
return true;
}
}
public void ajouter(Sommet s) {
ElementListe elem = new ElementListe(s, s.distance);
paquets[(s.distance)%(C+1)].inserer(elem);
sommets[s.num] = elem;
}
}