while
This commit is contained in:
parent
f2c643c952
commit
c91585c90d
2 changed files with 7 additions and 1 deletions
|
@ -24,17 +24,21 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
ArrayList<Label> List = new ArrayList<Label>(); //List de labels
|
ArrayList<Label> List = new ArrayList<Label>(); //List de labels
|
||||||
BinaryHeap<Label> Tas = new BinaryHeap<Label>();
|
BinaryHeap<Label> Tas = new BinaryHeap<Label>();
|
||||||
ArrayList<Arc> arcs = new ArrayList<Arc>();
|
ArrayList<Arc> arcs = new ArrayList<Arc>();
|
||||||
|
Label dest = null;
|
||||||
|
|
||||||
for (Node x: data.getGraph().getNodes())
|
for (Node x: data.getGraph().getNodes())
|
||||||
{
|
{
|
||||||
Label a= new Label(x,Double.MAX_VALUE,null);
|
Label a= new Label(x,Double.MAX_VALUE,null);
|
||||||
|
if (a.getSommet() == data.getDestination()){
|
||||||
|
dest = a;
|
||||||
|
}
|
||||||
List.add(a);
|
List.add(a);
|
||||||
}
|
}
|
||||||
List.get(data.getOrigin().getId()).setCost(0);
|
List.get(data.getOrigin().getId()).setCost(0);
|
||||||
Tas.insert(List.get(data.getOrigin().getId()));
|
Tas.insert(List.get(data.getOrigin().getId()));
|
||||||
int i = 1;
|
int i = 1;
|
||||||
Label x;
|
Label x;
|
||||||
while (MarqueExiste(List)){
|
while (MarqueExiste(List) && dest.isMarque() == false){
|
||||||
x = Tas.findMin();
|
x = Tas.findMin();
|
||||||
x.setMarque(true);
|
x.setMarque(true);
|
||||||
Tas.deleteMin();
|
Tas.deleteMin();
|
||||||
|
@ -45,6 +49,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
if(!l.isMarque()){
|
if(!l.isMarque()){
|
||||||
double cout = l.getCost();
|
double cout = l.getCost();
|
||||||
System.out.println("c = " + cout);
|
System.out.println("c = " + cout);
|
||||||
|
Boolean changé = false;
|
||||||
l.setCost(Math.min(l.getCost(), x.getCost()+suivant.getLength()));
|
l.setCost(Math.min(l.getCost(), x.getCost()+suivant.getLength()));
|
||||||
System.out.println("l = " + l.getCost());
|
System.out.println("l = " + l.getCost());
|
||||||
System.out.println("x = " + x.getCost());
|
System.out.println("x = " + x.getCost());
|
||||||
|
@ -59,6 +64,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
arcs.add(suivant);
|
arcs.add(suivant);
|
||||||
l.setMarque(true);
|
l.setMarque(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue