VerifVD
This commit is contained in:
parent
7624518c7e
commit
0b0d107956
2 changed files with 13 additions and 5 deletions
|
@ -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());
|
||||
|
||||
while (dest.getParent() != null){
|
||||
Arcs.add(dest.getParent());
|
||||
dest = List_Label.get(dest.getParent().getOrigin().getId());
|
||||
|
@ -98,11 +97,11 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
|||
}
|
||||
solutionNodes.add(data.getDestination());
|
||||
ShortestVerif(solution, solutionNodes, data);
|
||||
|
||||
volDoiseauVerif(data, solution);
|
||||
return solution;
|
||||
|
||||
}
|
||||
|
||||
//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);
|
||||
|
@ -112,4 +111,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.
Loading…
Reference in a new issue