Esse commit está contido em:
Bensouda Idriss 2023-04-19 13:55:45 +02:00
commit c91585c90d
2 arquivos alterados com 7 adições e 1 exclusões

Ver arquivo

@ -24,17 +24,21 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
ArrayList<Label> List = new ArrayList<Label>(); //List de labels
BinaryHeap<Label> Tas = new BinaryHeap<Label>();
ArrayList<Arc> arcs = new ArrayList<Arc>();
Label dest = null;
for (Node x: data.getGraph().getNodes())
{
Label a= new Label(x,Double.MAX_VALUE,null);
if (a.getSommet() == data.getDestination()){
dest = a;
}
List.add(a);
}
List.get(data.getOrigin().getId()).setCost(0);
Tas.insert(List.get(data.getOrigin().getId()));
int i = 1;
Label x;
while (MarqueExiste(List)){
while (MarqueExiste(List) && dest.isMarque() == false){
x = Tas.findMin();
x.setMarque(true);
Tas.deleteMin();
@ -45,6 +49,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
if(!l.isMarque()){
double cout = l.getCost();
System.out.println("c = " + cout);
Boolean changé = false;
l.setCost(Math.min(l.getCost(), x.getCost()+suivant.getLength()));
System.out.println("l = " + l.getCost());
System.out.println("x = " + x.getCost());
@ -59,6 +64,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
arcs.add(suivant);
l.setMarque(true);
}
}
}
}