Added two separate folders for the src and the data. Added construction of maze from labyrinthe.txt. Added neighbourList generation for each box in the maze. Added writing into file the constructed maze.
This commit is contained in:
1 parent
6b92f5d725
commit
648dfc6b83
16 files changed
+502
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Dijkstra {
|
||||
|
||||
private PreviousInterface dijkstra(GraphInterface g, VertexInterface r, ASetInterface a, PiInterface pi, PreviousInterface previous) {
|
||||
|
||||
a.add(r) ; ;
|
||||
VertexInterface pivot = r ;
|
||||
pi.setPi(0, r) ;
|
||||
|
||||
ArrayList<VertexInterface> vertexList = g.getVertexes() ;
|
||||
|
||||
for (VertexInterface vertex: vertexList) {
|
||||
if (vertex != r) {
|
||||
pi.setPi(Integer.MAX_VALUE, vertex);
|
||||
}
|
||||
}
|
||||
|
||||
int n = g.getVertexNumber();
|
||||
for (int j = 0; j < n; j++) {
|
||||
for (VertexInterface vertex: vertexList) {
|
||||
if (! a.contains(vertex) && previous.getPrevious(vertex).compareTo(pivot)) {
|
||||
if (pi.getPi(pivot) + g.getCost(pivot, vertex) < pi.getPi(vertex)) {
|
||||
pi.setPi(pi.getPi(pivot) + g.getCost(pivot, vertex), vertex) ;
|
||||
previous.setPrevious(pivot, vertex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int piMax = Integer.MAX_VALUE ;
|
||||
for (VertexInterface vertex: vertexList) {
|
||||
if (! a.contains(vertex) && pi.getPi(vertex) < piMax) {
|
||||
pivot = vertex ;
|
||||
piMax = pi.getPi(vertex) ;
|
||||
}
|
||||
}
|
||||
a.add(pivot);
|
||||
}
|
||||
|
||||
return previous ;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user