Added documentation for modified interfaces.
This commit is contained in:
1 parent
d7368f7cda
commit
9d34134943
7 files changed
+39
-14
No files matched your search
@@ -2,6 +2,9 @@ package dijkstra;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the ASet class as described in the INF101 course of Telecom Paristech.
|
||||||
|
*/
|
||||||
public interface ASetInterface {
|
public interface ASetInterface {
|
||||||
|
|
||||||
/** Add a vertex to the ASet */
|
/** Add a vertex to the ASet */
|
||||||
@@ -9,7 +12,8 @@ public interface ASetInterface {
|
|||||||
|
|
||||||
/** Check if a vertex belongs to ASet */
|
/** Check if a vertex belongs to ASet */
|
||||||
public boolean contains(VertexInterface vertex) ;
|
public boolean contains(VertexInterface vertex) ;
|
||||||
|
|
||||||
|
/** Returns the HashSet which represents the ASet. */
|
||||||
public HashSet<VertexInterface> getVertexHashSet();
|
public HashSet<VertexInterface> getVertexHashSet();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class Dijkstra {
|
|||||||
if (!a.contains(vertex)) {
|
if (!a.contains(vertex)) {
|
||||||
if (pi.getPi(pivot) + g.getCost(pivot, vertex) < pi.getPi(vertex)) {
|
if (pi.getPi(pivot) + g.getCost(pivot, vertex) < pi.getPi(vertex)) {
|
||||||
pi.setPi(pi.getPi(pivot) + g.getCost(pivot, vertex), vertex) ;
|
pi.setPi(pi.getPi(pivot) + g.getCost(pivot, vertex), vertex) ;
|
||||||
previous.setPrevious(pivot, vertex);
|
previous.setPrevious(pivot, vertex) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ public class Dijkstra {
|
|||||||
piMax = pi.getPi(vertex) ;
|
piMax = pi.getPi(vertex) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a.add(pivot);
|
a.add(pivot) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return previous ;
|
return previous ;
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
package dijkstra;
|
package dijkstra;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the Graph class as described in the INF101 course of Telecom Paristech.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface GraphInterface {
|
public interface GraphInterface {
|
||||||
|
|
||||||
/** Returns the number of Vertexes **/
|
/** Returns the number of Vertexes. **/
|
||||||
public int getVertexNumber() ;
|
public int getVertexNumber() ;
|
||||||
|
|
||||||
/** Return the cost between two vertexes **/
|
/** Return the cost between two vertexes. **/
|
||||||
public int getCost(VertexInterface start, VertexInterface end) ;
|
public int getCost(VertexInterface start, VertexInterface end) ;
|
||||||
|
|
||||||
/** Returns an list of Vertexes **/
|
/** Returns an list of Vertexes. **/
|
||||||
public ArrayList<VertexInterface> getVertexes() ;
|
public ArrayList<VertexInterface> getVertexes() ;
|
||||||
|
|
||||||
/** Returns the neighbour list for a given box */
|
/** Returns the neighbour list for a given box. */
|
||||||
public ArrayList<VertexInterface> generateNeighbours(VertexInterface vertex) ;
|
public ArrayList<VertexInterface> generateNeighbours(VertexInterface vertex) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
package dijkstra;
|
package dijkstra;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the Pi class as described in the INF101 course of Telecom Paristech.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface PiInterface {
|
public interface PiInterface {
|
||||||
|
|
||||||
/** Returns the value of pi(v) */
|
/** Returns the value of pi(v) */
|
||||||
|
|||||||
@@ -2,9 +2,6 @@ package dijkstra;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import maze.Box;
|
|
||||||
|
|
||||||
public class Previous implements PreviousInterface {
|
public class Previous implements PreviousInterface {
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package dijkstra;
|
package dijkstra;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This describes a vertex as seen in graphs (see INF101 course).
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface VertexInterface {
|
public interface VertexInterface {
|
||||||
|
|
||||||
/** Compare a Vertex to another */
|
/** Compare a Vertex to another. */
|
||||||
public boolean compareTo(VertexInterface vertex) ;
|
public boolean compareTo(VertexInterface vertex) ;
|
||||||
|
|
||||||
|
/** Returns the Label of the vertex. */
|
||||||
public String getLabel() ;
|
public String getLabel() ;
|
||||||
}
|
}
|
||||||
+14
-2
@@ -8,6 +8,15 @@ import java.util.ArrayList;
|
|||||||
import dijkstra.GraphInterface;
|
import dijkstra.GraphInterface;
|
||||||
import dijkstra.VertexInterface;
|
import dijkstra.VertexInterface;
|
||||||
|
|
||||||
|
/** <h1> Maze class </h1>
|
||||||
|
* <p>
|
||||||
|
* This class describes the maze as a matrix of Boxes ({@link maze.Box}).
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Antonin Godard
|
||||||
|
* @author Sylvain Rager
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class Maze
|
public class Maze
|
||||||
implements GraphInterface {
|
implements GraphInterface {
|
||||||
|
|
||||||
@@ -81,16 +90,19 @@ public class Maze
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**Constructs the maze from a text file, according to each single character on each line.
|
||||||
|
* @param filename
|
||||||
|
*/
|
||||||
|
|
||||||
public final void initFromTextFile(String filename) {
|
public final void initFromTextFile(String filename) {
|
||||||
|
|
||||||
FileReader fr = null ;
|
FileReader fr = null ;
|
||||||
BufferedReader br = null ;
|
BufferedReader br = null ;
|
||||||
|
|
||||||
try { //Determines the height of the maze and stores it into lineCount
|
try {
|
||||||
fr = new FileReader(filename) ;
|
fr = new FileReader(filename) ;
|
||||||
br = new BufferedReader(fr) ;
|
br = new BufferedReader(fr) ;
|
||||||
while (br.readLine() != null) dimensionY++;
|
while (br.readLine() != null) dimensionY++;
|
||||||
//System.out.println("Line count :" + lineCount);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in new issue
Block a user