Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void TasTableau(int s) {
- // Initialisation
- int i;
- boolean test;
- int pivot = s;
- boolean[] C = new boolean[nb_sommets];
- int[] pere = new int [nb_sommets];
- int[] d = new int [nb_sommets];
- new TasTableau(nb_sommets);
- for(i = 0; i < nb_sommets; i++) {
- C[i] = false;
- pere[i] = -1;
- }
- d[s] = 0;
- C[s] = true;
- for(i = 0; i < nb_sommets; i++) {
- if(C[i] == false) {
- if(matrice[pivot][i] != 0) {
- d[i] = matrice[pivot][i];
- pere[i] = pivot;
- TasTableau.add(i, d[i]);
- }
- else
- d[i] = Integer.MAX_VALUE;
- }
- }
- while(true) {
- test = true;
- for(i = 0; i < C.length; i++)
- if(C[i] == false)
- test = false;
- if(test)
- break;
- pivot = TasTableau.del();
- while(C[pivot] == true) {
- pivot = TasTableau.del();
- }
- C[pivot] = true;
- //Mise a jour des distances
- for(i = 0; i < nb_sommets; i++) {
- if(matrice[pivot][i] != 0) {
- if(d[pivot] + matrice[pivot][i] < d[i]) {
- d[i] = d[pivot] + matrice[pivot][i];
- pere[i] = pivot;
- C[i] = false;
- TasTableau.add(i, d[i]);
- }
- }
- }
- }
- AffichageResult(s, pere, d);
- System.out.println();
- }
Add Comment
Please, Sign In to add comment