Add UI to the project #29
No files matched your search
@@ -22,7 +22,7 @@ public class Dijkstra {
|
||||
int n = g.getVertexNumber();
|
||||
|
||||
for (int j = 0; j < n; j++) {
|
||||
for (VertexInterface vertex: g.generateNeighbours(pivot)) {
|
||||
for (VertexInterface vertex: pivot.generateNeighbours()) {
|
||||
if (!a.contains(vertex)) {
|
||||
if (pi.getPi(pivot) + g.getCost(pivot, vertex) < pi.getPi(vertex)) {
|
||||
pi.setPi(pi.getPi(pivot) + g.getCost(pivot, vertex), vertex) ;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package dijkstra;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* This describes a vertex as seen in graphs (see INF101 course).
|
||||
*
|
||||
@@ -10,5 +12,10 @@ public interface VertexInterface {
|
||||
* @return The label of the element.
|
||||
*/
|
||||
public String getLabel() ;
|
||||
|
||||
|
||||
/**
|
||||
* Updates the attribute of the element.
|
||||
* @return The neighbourList of the element.
|
||||
*/
|
||||
public ArrayList<VertexInterface> generateNeighbours();
|
||||
}
|
||||
+4
-4
@@ -22,7 +22,7 @@ public abstract class Box
|
||||
private int y ;
|
||||
private String label = null ;
|
||||
private Maze maze ;
|
||||
private ArrayList<Box> neighbourList = new ArrayList<Box>() ;
|
||||
private ArrayList<VertexInterface> neighbourList;
|
||||
|
||||
public Box (String label, int y , int x, Maze maze) { //y first because of graphical maze representation
|
||||
|
||||
@@ -33,9 +33,9 @@ public abstract class Box
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<VertexInterface> generateNeighbors() {
|
||||
public ArrayList<VertexInterface> generateNeighbours() {
|
||||
this.neighbourList = maze.generateNeighbours(this);
|
||||
return maze.generateNeighbours(this) ;
|
||||
|
||||
}
|
||||
|
||||
public boolean isWalkable() {
|
||||
@@ -50,7 +50,7 @@ public abstract class Box
|
||||
return false ;
|
||||
}
|
||||
|
||||
public ArrayList<Box> getNeighbourList() {
|
||||
public ArrayList<VertexInterface> getNeighbourList() {
|
||||
return neighbourList;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ public class Maze
|
||||
return neighbourList ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**Constructs the maze from a text file, according to each single character on each line.
|
||||
* @param filename
|
||||
* The path to the file containing the representation of the maze.
|
||||
|
||||
Reference in new issue
Block a user