Browse Source

modified: be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java

Jdihadi Ahamdy 3 years ago
parent
commit
65d760558c

+ 6
- 0
be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java View File

@@ -5,5 +5,11 @@ public class AStarAlgorithm extends DijkstraAlgorithm {
5 5
     public AStarAlgorithm(ShortestPathData data) {
6 6
         super(data);
7 7
     }
8
+    /*Réécriture de la méthiode newLabel*/
9
+    /*Afin d'utiliser LabelSatr au lieu de Label dans l'algo*/
10
+    protected Label Label (Node node, ShortestpathData data) {
11
+    	return new LabelSatr(node,data);
12
+    }
13
+    
8 14
 
9 15
 }

+ 11
- 23
be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java View File

@@ -36,11 +36,12 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
36 36
         
37 37
         notifyOriginProcessed(data.getOrigin());
38 38
 
39
-        /////////////////////////////////////////////////////////////////////////////////////////////////
40
-        //////////////////////////////////////INITIALISATION/////////////////////////////////////////////
41
-        /////////////////////////////////////////////////////////////////////////////////////////////////
39
+// -----------------initialisation-------------------------------------------------
40
+
42 41
         BinaryHeap<Label> tas = new BinaryHeap<Label>();
42
+        
43 43
         ArrayList<Label> labels = new ArrayList<Label>();
44
+        
44 45
         //On initialise tous les labels à +infini, avec marque à false et pere à NULL
45 46
         for (int i = 0; i < nbNodes; i++) {
46 47
         	labels.add(new Label(nodes.get(i)));
@@ -49,13 +50,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
49 50
         labels.get(index_origine).setCost(0);
50 51
         //On insère le label actualisé dans le tas
51 52
         tas.insert(labels.get(index_origine));
52
-		/////////////////////////////////////////////////////////////////////////////////////////////////
53
-		//////////////////////////////////////INITIALISATION/////////////////////////////////////////////
54
-		/////////////////////////////////////////////////////////////////////////////////////////////////
55
-        
56
-		/////////////////////////////////////////////////////////////////////////////////////////////////
57
-		/////////////////////////////////////////ITERATIONS//////////////////////////////////////////////
58
-		/////////////////////////////////////////////////////////////////////////////////////////////////
53
+
54
+//--------------------Boucle d'iteration-------------------------------------------
59 55
         
60 56
         //Définition d'une variable pour compter le nombre d'itérations pour le debogage
61 57
         int nbIterations = 0;
@@ -71,7 +67,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
71 67
         	//Vérification de la taille du tas
72 68
         	System.out.println("Taille du tas : " + tas.size());
73 69
         	
74
-        	//Debogage
70
+        	//Sortie debogueur 
71
+        	
75 72
         	//Incrémentation du nombre d'itérations
76 73
         	nbIterations++;
77 74
         	//Verification du tas
@@ -82,11 +79,10 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
82 79
         		System.out.println("Tas non valide");
83 80
         	}
84 81
         	
85
-        	
86 82
         	//On récupère les arcs successeurs du label minimal
87 83
         	List<Arc> arcs = label_min.getNode().getSuccessors();
88 84
         	
89
-        	//Debogage
85
+        	//Sortie debogueur
90 86
         	System.out.println("Nb successeurs du label : " + arcs.size());
91 87
         	
92 88
         	for (int i = 0; i < arcs.size(); i++) {
@@ -118,13 +114,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
118 114
         		}
119 115
         	}
120 116
         }
121
-		/////////////////////////////////////////////////////////////////////////////////////////////////
122
-		/////////////////////////////////////////ITERATIONS//////////////////////////////////////////////
123
-		/////////////////////////////////////////////////////////////////////////////////////////////////
124 117
         
125
-        /////////////////////////////////////////////////////////////////////////////////////////////////
126
-        //////////////////////////////////CREATION DE LA SOLUTION////////////////////////////////////////
127
-        /////////////////////////////////////////////////////////////////////////////////////////////////
118
+//-------------------On crée notre solution -------------------------------------
128 119
         ShortestPathSolution solution = null;
129 120
         
130 121
         //La destination n'a pas de prédécesseur, le chemin est infaisable
@@ -169,11 +160,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
169 160
             }
170 161
             
171 162
         }
172
-		/////////////////////////////////////////////////////////////////////////////////////////////////
173
-		//////////////////////////////////CREATION DE LA SOLUTION////////////////////////////////////////
174
-		/////////////////////////////////////////////////////////////////////////////////////////////////
175
-
176 163
         return solution;
177 164
     }
165
+   
178 166
 
179 167
 }

Loading…
Cancel
Save