Verif fastest
This commit is contained in:
commit
728f069973
4 changed files with 16 additions and 9 deletions
|
@ -17,7 +17,7 @@ public class AStarAlgorithm extends DijkstraAlgorithm {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void shortestVerif(ShortestPathSolution solution,ArrayList<Node> solutionNodes , ShortestPathData data)
|
||||
public void ShortestVerif(ShortestPathSolution solution,ArrayList<Node> solutionNodes , ShortestPathData data)
|
||||
{
|
||||
Path p = Path.createShortestPathFromNodes(data.getGraph(), solutionNodes);
|
||||
System.out.println("shortest path : " + p.getLength());
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.insa.graphs.algorithm.utils.BinaryHeap;
|
|||
import org.insa.graphs.model.Arc;
|
||||
import org.insa.graphs.model.Node;
|
||||
import org.insa.graphs.model.Path;
|
||||
import org.insa.graphs.model.Point;
|
||||
|
||||
public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||
|
||||
|
@ -82,10 +83,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Label dest =List_Label.get(data.getDestination().getId());
|
||||
|
||||
Label dest =List_Label.get(data.getDestination().getId());
|
||||
while (dest.getParent() != null){
|
||||
Arcs.add(dest.getParent());
|
||||
dest = List_Label.get(dest.getParent().getOrigin().getId());
|
||||
|
@ -97,15 +96,14 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
|||
solutionNodes.add(a.getOrigin());
|
||||
}
|
||||
solutionNodes.add(data.getDestination());
|
||||
shortestVerif(solution, solutionNodes, data);
|
||||
ShortestVerif(solution, solutionNodes, data);
|
||||
fastestVerif(solution, solutionNodes, data);
|
||||
|
||||
volDoiseauVerif(data, solution);
|
||||
return solution;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void shortestVerif(ShortestPathSolution solution,ArrayList<Node> solutionNodes , ShortestPathData data)
|
||||
//Permet de vérifier si le chemin obtenu par la solution est bien le plus court
|
||||
public void ShortestVerif(ShortestPathSolution solution,ArrayList<Node> solutionNodes , ShortestPathData data)
|
||||
{
|
||||
Path p = Path.createShortestPathFromNodes(data.getGraph(), solutionNodes);
|
||||
System.out.println("shortest path : " + p.getLength());
|
||||
|
@ -124,4 +122,13 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
|||
}
|
||||
|
||||
}
|
||||
// Permet de vérifier si la distance de la solution est plus long que la distance à vol d'oiseau
|
||||
public void volDoiseauVerif(ShortestPathData data, ShortestPathSolution solution){
|
||||
double distanceV = Point.distance(data.getGraph().get(data.getOrigin().getId()).getPoint(), data.getDestination().getPoint());
|
||||
if (distanceV > solution.getPath().getLength()){
|
||||
System.out.println("La solution n'est pas réalisable");
|
||||
} else {
|
||||
System.out.println("La solution est réalisable");
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue