Merge branch 'master' of https://git.etud.insa-toulouse.fr/brunetto/BEGraphes
This commit is contained in:
commit
734fa38388
1 changed files with 24 additions and 14 deletions
|
@ -1,7 +1,6 @@
|
|||
package org.insa.graphs.algorithm.shortestpath;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import org.insa.graphs.model.Node;
|
||||
import org.insa.graphs.model.Arc;
|
||||
|
@ -22,6 +21,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
|||
int tailleGraphe = data.getGraph().size();
|
||||
int index = 0;
|
||||
|
||||
|
||||
ArrayList<Label> labelSommets = new ArrayList<Label>();
|
||||
Label currentLabel;
|
||||
|
||||
|
@ -46,6 +46,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
|||
double currentCost;
|
||||
double newCost;
|
||||
Label newLabel;
|
||||
notifyOriginProcessed(currentNode);
|
||||
|
||||
//Boucle principale ----------------------------------------------------
|
||||
|
||||
|
@ -59,17 +60,23 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
|||
currentLabel.setMarqueTrue();
|
||||
|
||||
|
||||
notifyNodeMarked(currentNode);
|
||||
|
||||
|
||||
for(Arc arc : currentNode.getSuccessors())
|
||||
{
|
||||
if(data.isAllowed(arc))
|
||||
{
|
||||
newLabel = labelSommets.get(arc.getDestination().getId());
|
||||
if(!newLabel.getMarque())
|
||||
{
|
||||
currentCost = newLabel.getCost();
|
||||
newCost = arc.getLength() + currentLabel.getCost();
|
||||
newCost = data.getCost(arc) + currentLabel.getCost();
|
||||
if(currentCost == -1.0)
|
||||
{
|
||||
newLabel.setNouveauChemin(arc, newCost);
|
||||
leTas.insert(newLabel);
|
||||
notifyNodeReached(newLabel.getSommetCourant());
|
||||
}
|
||||
else if(newCost < currentCost)
|
||||
{
|
||||
|
@ -79,6 +86,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,6 +111,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
|||
if(index != tailleGraphe)
|
||||
{
|
||||
Collections.reverse(arcListe);
|
||||
notifyDestinationReached(data.getDestination());
|
||||
return new ShortestPathSolution(data, AbstractSolution.Status.FEASIBLE, new Path(data.getGraph(),arcListe ));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue