Dijkstra V1
This commit is contained in:
parent
fc999621f7
commit
36249318ce
3 changed files with 50 additions and 5 deletions
|
@ -1,5 +1,11 @@
|
|||
package org.insa.graphs.algorithm.shortestpath;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.insa.graphs.algorithm.utils.BinaryHeap;
|
||||
import org.insa.graphs.model.Node;
|
||||
|
||||
public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||
|
||||
public DijkstraAlgorithm(ShortestPathData data) {
|
||||
|
@ -11,6 +17,19 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
|||
final ShortestPathData data = getInputData();
|
||||
ShortestPathSolution solution = null;
|
||||
// TODO:
|
||||
|
||||
ArrayList<Label> List = new ArrayList<Label>(); //List de labels
|
||||
BinaryHeap<Label> Tas = new BinaryHeap<Label>();
|
||||
|
||||
for (Node x: data.getGraph().getNodes())
|
||||
{
|
||||
Label a= new Label(x,false,0,null);
|
||||
List.add(a);
|
||||
|
||||
}
|
||||
List.get(0).setCost(0);
|
||||
Tas.insert(List.get(0));
|
||||
|
||||
return solution;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@ import java.util.ArrayList;
|
|||
import org.insa.graphs.model.Arc;
|
||||
import org.insa.graphs.model.Node;
|
||||
|
||||
public class Label {
|
||||
public class Label implements Comparable<Label> {
|
||||
private Node sommet;
|
||||
private boolean marque;
|
||||
private double cost;
|
||||
private Arc parent;
|
||||
private final ArrayList<Node> listLabels;
|
||||
|
||||
|
||||
|
||||
public Label(Node sommet, boolean marque, double cost, Arc parent) {
|
||||
|
@ -18,11 +18,13 @@ public class Label {
|
|||
this.marque = marque;
|
||||
this.cost = cost;
|
||||
this.parent = parent;
|
||||
listLabels = new ArrayList<Node>();
|
||||
listLabels.add(sommet);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Label arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Node getSommet() {
|
||||
return sommet;
|
||||
|
@ -36,5 +38,29 @@ public class Label {
|
|||
public Arc getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
public void setSommet(Node sommet) {
|
||||
this.sommet = sommet;
|
||||
}
|
||||
|
||||
|
||||
public void setMarque(boolean marque) {
|
||||
this.marque = marque;
|
||||
}
|
||||
|
||||
|
||||
public void setCost(double cost) {
|
||||
this.cost = cost;
|
||||
}
|
||||
|
||||
|
||||
public void setParent(Arc parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue