Version Dijkstra corrigée (pas testée)
This commit is contained in:
parent
a0bcb97341
commit
aff74a7bad
1 changed files with 5 additions and 4 deletions
|
@ -40,6 +40,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
|||
Node currentNode;
|
||||
double currentCost;
|
||||
double newCost;
|
||||
Label newLabel;
|
||||
|
||||
|
||||
while (nbMarques != tailleGraphe)
|
||||
|
@ -55,14 +56,14 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
|||
|
||||
for(Arc arc : currentNode.getSuccessors())
|
||||
{
|
||||
currentLabel = labelSommets.get(arc.getDestination().getId());
|
||||
if(!currentLabel.getMarque())
|
||||
newLabel = labelSommets.get(arc.getDestination().getId());
|
||||
if(!newLabel.getMarque())
|
||||
{
|
||||
currentCost = currentLabel.getCost();
|
||||
currentCost = newLabel.getCost() + currentLabel.getCost();
|
||||
newCost = arc.getLength();
|
||||
if(newCost < currentCost || currentCost == -1.0)
|
||||
{
|
||||
currentLabel.setNouveauChemin(arc, newCost);
|
||||
newLabel.setNouveauChemin(arc, newCost);
|
||||
leTas.insert(arc.getDestination());
|
||||
labelSommets.set(arc.getDestination().getId(), currentLabel);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue