Added packages, Previous class and ASet class.

This commit is contained in:
antograb authored and Sylvain Rager (regar42) committed 2017-12-03 20:41:05 +01:00
1 parent f252db5e3d
commit acab098ea1
16 files changed
+99 -5

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
package dijkstra;
import java.util.ArrayList;
import java.util.Hashtable;
public class Previous implements PreviousInterface {
private Hashtable<VertexInterface, VertexInterface> hashPrevious = new Hashtable<VertexInterface, VertexInterface>() ;
private ArrayList<VertexInterface> shortestPath = new ArrayList<VertexInterface>() ;
public VertexInterface getPrevious(VertexInterface vertex) {
return hashPrevious.get(vertex) ;
}
public void setPrevious(VertexInterface father, VertexInterface son) {
hashPrevious.put(son, father) ;
}
public ArrayList<VertexInterface> getShortestPathTo(VertexInterface vertex) {
VertexInterface father = getPrevious(vertex) ;
shortestPath.add(father) ;
if (getPrevious(father) == null) return shortestPath ;
else {
return getShortestPathTo(father) ;
}
}
}