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;
|
Node currentNode;
|
||||||
double currentCost;
|
double currentCost;
|
||||||
double newCost;
|
double newCost;
|
||||||
|
Label newLabel;
|
||||||
|
|
||||||
|
|
||||||
while (nbMarques != tailleGraphe)
|
while (nbMarques != tailleGraphe)
|
||||||
|
|
@ -55,14 +56,14 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
|
|
||||||
for(Arc arc : currentNode.getSuccessors())
|
for(Arc arc : currentNode.getSuccessors())
|
||||||
{
|
{
|
||||||
currentLabel = labelSommets.get(arc.getDestination().getId());
|
newLabel = labelSommets.get(arc.getDestination().getId());
|
||||||
if(!currentLabel.getMarque())
|
if(!newLabel.getMarque())
|
||||||
{
|
{
|
||||||
currentCost = currentLabel.getCost();
|
currentCost = newLabel.getCost() + currentLabel.getCost();
|
||||||
newCost = arc.getLength();
|
newCost = arc.getLength();
|
||||||
if(newCost < currentCost || currentCost == -1.0)
|
if(newCost < currentCost || currentCost == -1.0)
|
||||||
{
|
{
|
||||||
currentLabel.setNouveauChemin(arc, newCost);
|
newLabel.setNouveauChemin(arc, newCost);
|
||||||
leTas.insert(arc.getDestination());
|
leTas.insert(arc.getDestination());
|
||||||
labelSommets.set(arc.getDestination().getId(), currentLabel);
|
labelSommets.set(arc.getDestination().getId(), currentLabel);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue