Browse Source

ajout de tas.isValid et vérifications (sans junit)

Favary Pierre 2 years ago
parent
commit
ce16e03284

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

44
         		
44
         		
45
 	        	tablabel[x].marque=true;
45
 	        	tablabel[x].marque=true;
46
 	        	this.notifyNodeMarked(tablabel[x].sommet_courant);
46
 	        	this.notifyNodeMarked(tablabel[x].sommet_courant);
47
+	        	//System.out.printf("%f\n",tablabel[x].cout);
48
+	        	//System.out.printf("%d\n",tablabel[x].sommet_courant.getNumberOfSuccessors());
47
 	        	nomark--;
49
 	        	nomark--;
48
 	        	int y;
50
 	        	int y;
49
 	        	
51
 	        	
50
 	        	for (Arc arcy: tablabel[x].sommet_courant.getSuccessors()) {
52
 	        	for (Arc arcy: tablabel[x].sommet_courant.getSuccessors()) {
51
 	        		
53
 	        		
52
 	        		y=arcy.getDestination().getId();
54
 	        		y=arcy.getDestination().getId();
55
+	        		//System.out.println(tas.isValid());
53
 	        		
56
 	        		
54
 	        		if (!tablabel[y].marque && data.isAllowed(arcy)) {//ligne 108 de l'excel d'avancement
57
 	        		if (!tablabel[y].marque && data.isAllowed(arcy)) {//ligne 108 de l'excel d'avancement
55
 	        			
58
 	        			

+ 16
- 1
be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinaryHeap.java View File

208
     public String toString() {
208
     public String toString() {
209
         return BinaryHeapFormatter.toStringTree(this, 8);
209
         return BinaryHeapFormatter.toStringTree(this, 8);
210
     }
210
     }
211
-
211
+    
212
+    public boolean isValid()    {//utilisé pour la vérification du Dijkstra
213
+    	boolean reponse=true;
214
+    	if (this.isEmpty()) {
215
+    		BinaryHeap<E> copie=new BinaryHeap<E>(this);
216
+    		E prec=null;
217
+    		E nouv=null;
218
+    		while (!copie.isEmpty() && reponse) {
219
+    			nouv=this.deleteMin();
220
+    			if (prec.compareTo(nouv)>0)
221
+    				reponse=false;
222
+    			prec=nouv;
223
+    		}
224
+    	}
225
+    	return reponse;
226
+    }
212
 }
227
 }

Loading…
Cancel
Save