Dernieres modifications
This commit is contained in:
parent
0484234692
commit
03d1d8f729
2 changed files with 9 additions and 3 deletions
|
@ -43,6 +43,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
double old_cost = 0 ; // on utilisera cette variable pour vérifier si le coût est croissant
|
double old_cost = 0 ; // on utilisera cette variable pour vérifier si le coût est croissant
|
||||||
|
|
||||||
int nbMarque = 0; // correspond au nombre de sommet marqué
|
int nbMarque = 0; // correspond au nombre de sommet marqué
|
||||||
|
int explorer = 0 ; // correspond au nombre de sommet exploré
|
||||||
|
|
||||||
while(!TabLabel[data.getDestination().getId()].isMarque() ) { // tant que la destination est non marqués
|
while(!TabLabel[data.getDestination().getId()].isMarque() ) { // tant que la destination est non marqués
|
||||||
Node X ;
|
Node X ;
|
||||||
try {
|
try {
|
||||||
|
@ -73,6 +75,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
Tas.insert(TabLabel[Y.getId()]);
|
Tas.insert(TabLabel[Y.getId()]);
|
||||||
TabLabel[Y.getId()].setFather(a);
|
TabLabel[Y.getId()].setFather(a);
|
||||||
this.notifyNodeReached(Y);
|
this.notifyNodeReached(Y);
|
||||||
|
explorer ++ ;
|
||||||
}
|
}
|
||||||
else if(TabLabel[Y.getId()].getCost() > TabLabel[X.getId()].getCost()+ data.getCost(a)) {
|
else if(TabLabel[Y.getId()].getCost() > TabLabel[X.getId()].getCost()+ data.getCost(a)) {
|
||||||
TabLabel[Y.getId()].setCost( TabLabel[X.getId()].getCost()+ data.getCost(a) );
|
TabLabel[Y.getId()].setCost( TabLabel[X.getId()].getCost()+ data.getCost(a) );
|
||||||
|
@ -85,7 +88,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
long fin = System.nanoTime(); // pour le temps d'execution
|
||||||
|
|
||||||
// Create the path from the array of predecessors...
|
// Create the path from the array of predecessors...
|
||||||
ArrayList<Arc> arcs = new ArrayList<>();
|
ArrayList<Arc> arcs = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -134,6 +138,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
|
|
||||||
|
|
||||||
System.out.println("Nb iterations: " + nbMarque + ", Nb arcs du PCC: " + arcs.size());
|
System.out.println("Nb iterations: " + nbMarque + ", Nb arcs du PCC: " + arcs.size());
|
||||||
|
System.out.println("Nb de sommets explorés : " + explorer);
|
||||||
|
|
||||||
return solution;
|
return solution;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class ComparerAlgoTest {
|
||||||
Assume.assumeTrue(parameters.getOrigin() == parameters.getDestination() && parameters.getGraph().getMapName() != graph2.getMapName());
|
Assume.assumeTrue(parameters.getOrigin() == parameters.getDestination() && parameters.getGraph().getMapName() != graph2.getMapName());
|
||||||
ShortestPathAlgorithm DA = new DijkstraAlgorithm(parameters);
|
ShortestPathAlgorithm DA = new DijkstraAlgorithm(parameters);
|
||||||
ShortestPathAlgorithm BF = new BellmanFordAlgorithm(parameters);
|
ShortestPathAlgorithm BF = new BellmanFordAlgorithm(parameters);
|
||||||
assertEquals( DA.run().getPath() , BF.run().getPath());
|
assertEquals( DA.run().getStatus() , BF.run().getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------DijkstraNormalPathSP-------------------------------------
|
// -----------------------------DijkstraNormalPathSP-------------------------------------
|
||||||
|
@ -117,7 +117,7 @@ public class ComparerAlgoTest {
|
||||||
Assume.assumeTrue(parameters.getOrigin() == parameters.getDestination() && parameters.getGraph().getMapName() != graph2.getMapName());
|
Assume.assumeTrue(parameters.getOrigin() == parameters.getDestination() && parameters.getGraph().getMapName() != graph2.getMapName());
|
||||||
AStarAlgorithm AS = new AStarAlgorithm(parameters);
|
AStarAlgorithm AS = new AStarAlgorithm(parameters);
|
||||||
ShortestPathAlgorithm BF = new BellmanFordAlgorithm(parameters);
|
ShortestPathAlgorithm BF = new BellmanFordAlgorithm(parameters);
|
||||||
assertEquals( AS.run().getPath() , BF.run().getPath());
|
assertEquals( AS.run().getStatus() , BF.run().getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------AStarNormalPathSP-------------------------------------
|
// ----------------------------------AStarNormalPathSP-------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue