Browse Source

Dernieres modifications

Auriane Lartigue 3 years ago
parent
commit
03d1d8f729

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

@@ -43,6 +43,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
43 43
         double old_cost = 0 ; // on utilisera cette variable pour vérifier si le coût est croissant
44 44
         
45 45
         int nbMarque = 0; // correspond au nombre de sommet marqué
46
+        int explorer = 0 ; // correspond au nombre de sommet exploré
47
+        
46 48
         while(!TabLabel[data.getDestination().getId()].isMarque() ) { // tant que la destination est non marqués 
47 49
         	Node X ;
48 50
         	try {
@@ -73,6 +75,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
73 75
 		        				Tas.insert(TabLabel[Y.getId()]);
74 76
 		        				TabLabel[Y.getId()].setFather(a);
75 77
 		        				this.notifyNodeReached(Y);
78
+		        				explorer ++ ;
76 79
 		        			}
77 80
 		        			else if(TabLabel[Y.getId()].getCost() > TabLabel[X.getId()].getCost()+ data.getCost(a)) {
78 81
 		        				TabLabel[Y.getId()].setCost( TabLabel[X.getId()].getCost()+ data.getCost(a) );
@@ -85,7 +88,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
85 88
 	        	}
86 89
         	}
87 90
         }
88
-
91
+        long fin  = System.nanoTime(); // pour le temps d'execution
92
+        
89 93
         // Create the path from the array of predecessors...
90 94
         ArrayList<Arc> arcs = new ArrayList<>();
91 95
         
@@ -134,6 +138,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
134 138
         
135 139
         
136 140
         System.out.println("Nb iterations: " + nbMarque  + ", Nb arcs du PCC: " + arcs.size());
141
+        System.out.println("Nb de sommets explorés : " + explorer);
142
+        
137 143
         return solution;
138 144
 
139 145
 }

+ 2
- 2
be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/ComparerAlgoTest.java View File

@@ -96,7 +96,7 @@ public class ComparerAlgoTest {
96 96
 			Assume.assumeTrue(parameters.getOrigin() == parameters.getDestination() && parameters.getGraph().getMapName() != graph2.getMapName());
97 97
 			ShortestPathAlgorithm DA = new DijkstraAlgorithm(parameters);
98 98
 			ShortestPathAlgorithm BF = new BellmanFordAlgorithm(parameters);
99
-			assertEquals( DA.run().getPath() ,  BF.run().getPath());	
99
+			assertEquals( DA.run().getStatus() ,  BF.run().getStatus());	
100 100
 	 }
101 101
 	
102 102
 	// -----------------------------DijkstraNormalPathSP-------------------------------------
@@ -117,7 +117,7 @@ public class ComparerAlgoTest {
117 117
 			Assume.assumeTrue(parameters.getOrigin() == parameters.getDestination() && parameters.getGraph().getMapName() != graph2.getMapName());
118 118
 		 	AStarAlgorithm AS = new AStarAlgorithm(parameters);
119 119
 			ShortestPathAlgorithm BF = new BellmanFordAlgorithm(parameters);
120
-			assertEquals( AS.run().getPath() ,  BF.run().getPath());	
120
+			assertEquals( AS.run().getStatus() ,  BF.run().getStatus());
121 121
 	 }
122 122
 	
123 123
 	// ----------------------------------AStarNormalPathSP-------------------------------------

Loading…
Cancel
Save